Skip to content

Commit 2ae65ec

Browse files
committed
refactor(bigquery): type firstPageRows as Collection and simplify row count calculation
1 parent 4aca567 commit 2ae65ec

1 file changed

Lines changed: 5 additions & 12 deletions

File tree

  • java-bigquery/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery

java-bigquery/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/BigQueryImpl.java

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2047,7 +2047,7 @@ public TableDataList call() throws IOException {
20472047
}
20482048
}
20492049

2050-
private static Iterable<FieldValueList> transformTableData(
2050+
private static Collection<FieldValueList> transformTableData(
20512051
Iterable<TableRow> tableDataPb, final Schema schema, boolean useInt64Timestamps) {
20522052
return ImmutableList.copyOf(
20532053
Iterables.transform(
@@ -2317,7 +2317,7 @@ public com.google.api.services.bigquery.model.QueryResponse call()
23172317
return job;
23182318
}
23192319

2320-
Iterable<FieldValueList> firstPageRows;
2320+
Collection<FieldValueList> firstPageRows;
23212321
if (isArrow) {
23222322
if (results.getArrowRecordBatch() != null
23232323
&& results.getArrowRecordBatch().getSerializedRecordBatch() != null) {
@@ -2345,8 +2345,7 @@ public com.google.api.services.bigquery.model.QueryResponse call()
23452345

23462346
NextPageFetcher<FieldValueList> pageFetcher;
23472347
if (isArrow) {
2348-
long initialRowOffset =
2349-
firstPageRows instanceof Collection ? ((Collection<?>) firstPageRows).size() : 0L;
2348+
long initialRowOffset = firstPageRows.size();
23502349
pageFetcher =
23512350
new ArrowQueryPageFetcher(
23522351
jobId,
@@ -2370,10 +2369,7 @@ public com.google.api.services.bigquery.model.QueryResponse call()
23702369
.setJobId(jobId)
23712370
.setQueryId(results.getQueryId())
23722371
.setJobCreationReason(JobCreationReason.fromPb(results.getJobCreationReason()))
2373-
.setRowsInPage(
2374-
firstPageRows instanceof Collection
2375-
? (long) ((Collection<?>) firstPageRows).size()
2376-
: 0L)
2372+
.setRowsInPage((long) firstPageRows.size())
23772373
.build();
23782374
}
23792375
// only 1 page of result
@@ -2390,10 +2386,7 @@ public com.google.api.services.bigquery.model.QueryResponse call()
23902386
results.getJobReference() != null ? JobId.fromPb(results.getJobReference()) : null)
23912387
.setQueryId(results.getQueryId())
23922388
.setJobCreationReason(JobCreationReason.fromPb(results.getJobCreationReason()))
2393-
.setRowsInPage(
2394-
firstPageRows instanceof Collection
2395-
? (long) ((Collection<?>) firstPageRows).size()
2396-
: 0L)
2389+
.setRowsInPage((long) firstPageRows.size())
23972390
.build();
23982391
}
23992392

0 commit comments

Comments
 (0)