Skip to content

Commit 1317aa0

Browse files
committed
Fix LongDoubleConversion warnings
1 parent 500996f commit 1317aa0

19 files changed

Lines changed: 33 additions & 27 deletions

File tree

it/google-cloud-platform/src/test/java/org/apache/beam/it/gcp/bigquery/BigQueryIOLT.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ private void testRead() throws IOException {
341341
region,
342342
launchInfo.jobId(),
343343
getBeamMetricsName(PipelineMetricsType.COUNTER, READ_ELEMENT_METRIC_NAME));
344-
assertEquals(configuration.numRecords, numRecords, 0.5);
344+
assertEquals((double) configuration.numRecords, numRecords, 0.5);
345345

346346
// export metrics
347347
MetricsConfiguration metricsConfig =

it/google-cloud-platform/src/test/java/org/apache/beam/it/gcp/spanner/SpannerIOLT.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ public void testSpannerWriteAndRead() throws IOException {
156156
region,
157157
readInfo.jobId(),
158158
getBeamMetricsName(PipelineMetricsType.COUNTER, READ_ELEMENT_METRIC_NAME));
159-
assertEquals(configuration.numRecords, numRecords, 0.5);
159+
assertEquals((double) configuration.numRecords, numRecords, 0.5);
160160

161161
// export metrics
162162
MetricsConfiguration metricsConfig =

it/google-cloud-platform/src/test/java/org/apache/beam/it/gcp/storage/FileBasedIOLT.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ public void testTextIOWriteThenRead() throws IOException {
221221
readInfo.jobId(),
222222
getBeamMetricsName(PipelineMetricsType.COUNTER, READ_ELEMENT_METRIC_NAME));
223223

224-
assertEquals(configuration.numRecords, numRecords, 0.5);
224+
assertEquals((double) configuration.numRecords, numRecords, 0.5);
225225

226226
// export metrics
227227
MetricsConfiguration metricsConfig =

runners/direct-java/src/main/java/org/apache/beam/runners/direct/WriteWithShardingFactory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ private int calculateShards(long totalRecords) {
138138
return (int) totalRecords;
139139
}
140140
// 100mil records before >7 output files
141-
int floorLogRecs = (int) Math.log10(totalRecords);
141+
int floorLogRecs = (int) Math.log10((double) totalRecords);
142142
return Math.max(floorLogRecs, MIN_SHARDS_FOR_LOG) + extraShards;
143143
}
144144
}

runners/google-cloud-dataflow-java/worker/src/main/java/org/apache/beam/runners/dataflow/worker/WorkerCustomSources.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -661,7 +661,7 @@ public void close() throws IOException {
661661
@VisibleForTesting
662662
static @Nullable ReportedParallelism longToParallelism(long value) {
663663
if (value >= 0) {
664-
return new ReportedParallelism().setValue(Double.valueOf(value));
664+
return new ReportedParallelism().setValue(Double.valueOf((double) value));
665665
} else {
666666
return null;
667667
}

runners/google-cloud-dataflow-java/worker/src/main/java/org/apache/beam/runners/dataflow/worker/counters/CounterFactory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ public final CounterDistribution addValue(long value) {
226226
long count = this.getCount() + 1;
227227
long sum = this.getSum() + value;
228228
// TODO: Replace sum-of-squares with statistics for a better stddev algorithm.
229-
double sumOfSquares = this.getSumOfSquares() + Math.pow(value, 2);
229+
double sumOfSquares = this.getSumOfSquares() + Math.pow((double) value, 2);
230230

231231
int bucketIndex = calculateBucket(value);
232232
List<Long> buckets = incrementBucket(bucketIndex);

sdks/java/extensions/google-cloud-platform-core/src/main/java/org/apache/beam/sdk/extensions/gcp/util/LatencyRecordingHttpRequestInitializer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public LoggingInterceptor(Histogram requestLatencies) {
6363
@Override
6464
public void interceptResponse(HttpResponse response) throws IOException {
6565
long timeToResponse = System.currentTimeMillis() - startTime;
66-
requestLatencies.update(timeToResponse);
66+
requestLatencies.update((double) timeToResponse);
6767
}
6868

6969
@Override

sdks/java/extensions/sql/perf-tests/src/test/java/org/apache/beam/sdk/extensions/sql/meta/provider/bigquery/BigQueryIOPushDownIT.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ private Set<Function<MetricsReader, NamedTestResult>> getReadSuppliers(
199199
suppliers.add(
200200
reader -> {
201201
long fieldsRead = reader.getCounterMetric(FIELDS_READ_METRIC);
202-
return NamedTestResult.create(uuid, timestamp, FIELDS_READ_METRIC, fieldsRead);
202+
return NamedTestResult.create(uuid, timestamp, FIELDS_READ_METRIC, (double) fieldsRead);
203203
});
204204
return suppliers;
205205
}

sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigquery/BigQueryIO.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1003,7 +1003,8 @@ public void processElement(
10031003

10041004
private long getDesiredChunkSize(
10051005
PipelineOptions options, BigQueryStorageTableSource<T> output) throws Exception {
1006-
return Math.max(1 << 20, (long) (1000 * Math.sqrt(output.getEstimatedSizeBytes(options))));
1006+
return Math.max(
1007+
1 << 20, (long) (1000 * Math.sqrt((double) output.getEstimatedSizeBytes(options))));
10071008
}
10081009
}
10091010

@@ -1755,7 +1756,8 @@ private PCollection<T> expandForDirectRead(
17551756
desiredChunkSize = 64 << 20; // 64mb
17561757
} else {
17571758
// 1mb --> 1 shard; 1gb --> 32 shards; 1tb --> 1000 shards, 1pb --> 32k shards
1758-
desiredChunkSize = Math.max(1 << 20, (long) (1000 * Math.sqrt(estimatedSize)));
1759+
desiredChunkSize =
1760+
Math.max(1 << 20, (long) (1000 * Math.sqrt((double) estimatedSize)));
17591761
}
17601762
sources = source.split(desiredChunkSize, bqOptions);
17611763
} catch (Exception e) {

sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigquery/BigQuerySinkMetrics.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ private static void updateRpcLatencyMetric(@Nonnull Context<?> c, RpcMethod meth
139139
}
140140
long timeElapsed = java.time.Duration.between(operationStartTime, operationEndTime).toMillis();
141141
if (timeElapsed > 0) {
142-
BigQuerySinkMetrics.createRPCLatencyHistogram(method).update(timeElapsed);
142+
BigQuerySinkMetrics.createRPCLatencyHistogram(method).update((double) timeElapsed);
143143
}
144144
}
145145

0 commit comments

Comments
 (0)