|
19 | 19 | import static com.google.cloud.RetryHelper.runWithRetries; |
20 | 20 | import static com.google.common.base.Preconditions.checkArgument; |
21 | 21 |
|
| 22 | +import com.google.api.gax.paging.Page; |
22 | 23 | import com.google.api.services.bigquery.model.GetQueryResultsResponse; |
23 | 24 | import com.google.api.services.bigquery.model.TableDataInsertAllRequest; |
24 | 25 | import com.google.api.services.bigquery.model.TableDataInsertAllRequest.Rows; |
25 | 26 | import com.google.api.services.bigquery.model.TableRow; |
26 | 27 | import com.google.cloud.BaseService; |
27 | | -import com.google.api.gax.paging.Page; |
28 | 28 | import com.google.cloud.PageImpl; |
29 | 29 | import com.google.cloud.PageImpl.NextPageFetcher; |
30 | 30 | import com.google.cloud.RetryHelper; |
| 31 | +import com.google.cloud.Tuple; |
31 | 32 | import com.google.cloud.bigquery.InsertAllRequest.RowToInsert; |
32 | 33 | import com.google.cloud.bigquery.spi.v2.BigQueryRpc; |
33 | 34 | import com.google.common.base.Function; |
|
36 | 37 | import com.google.common.collect.Iterables; |
37 | 38 | import com.google.common.collect.Lists; |
38 | 39 | import com.google.common.collect.Maps; |
39 | | - |
40 | 40 | import java.util.List; |
41 | 41 | import java.util.Map; |
42 | 42 | import java.util.concurrent.Callable; |
@@ -247,21 +247,30 @@ public Page<Dataset> listDatasets(String projectId, DatasetListOption... options |
247 | 247 | return listDatasets(projectId, getOptions(), optionMap(options)); |
248 | 248 | } |
249 | 249 |
|
250 | | - private static Page<Dataset> listDatasets(final String projectId, |
251 | | - final BigQueryOptions serviceOptions, final Map<BigQueryRpc.Option, ?> optionsMap) { |
| 250 | + private static Page<Dataset> listDatasets( |
| 251 | + final String projectId, |
| 252 | + final BigQueryOptions serviceOptions, |
| 253 | + final Map<BigQueryRpc.Option, ?> optionsMap) { |
252 | 254 | try { |
253 | | - BigQueryRpc.Tuple<String, Iterable<com.google.api.services.bigquery.model.Dataset>> result = |
254 | | - runWithRetries(new Callable<BigQueryRpc.Tuple<String, |
255 | | - Iterable<com.google.api.services.bigquery.model.Dataset>>>() { |
| 255 | + Tuple<String, Iterable<com.google.api.services.bigquery.model.Dataset>> result = |
| 256 | + runWithRetries( |
| 257 | + new Callable< |
| 258 | + Tuple<String, Iterable<com.google.api.services.bigquery.model.Dataset>>>() { |
256 | 259 | @Override |
257 | | - public BigQueryRpc.Tuple<String, |
258 | | - Iterable<com.google.api.services.bigquery.model.Dataset>> call() { |
| 260 | + public Tuple<String, Iterable<com.google.api.services.bigquery.model.Dataset>> |
| 261 | + call() { |
259 | 262 | return serviceOptions.getBigQueryRpcV2().listDatasets(projectId, optionsMap); |
260 | 263 | } |
261 | | - }, serviceOptions.getRetrySettings(), EXCEPTION_HANDLER, serviceOptions.getClock()); |
| 264 | + }, |
| 265 | + serviceOptions.getRetrySettings(), |
| 266 | + EXCEPTION_HANDLER, |
| 267 | + serviceOptions.getClock()); |
262 | 268 | String cursor = result.x(); |
263 | | - return new PageImpl<>(new DatasetPageFetcher(projectId, serviceOptions, cursor, optionsMap), |
264 | | - cursor, Iterables.transform(result.y(), |
| 269 | + return new PageImpl<>( |
| 270 | + new DatasetPageFetcher(projectId, serviceOptions, cursor, optionsMap), |
| 271 | + cursor, |
| 272 | + Iterables.transform( |
| 273 | + result.y(), |
265 | 274 | new Function<com.google.api.services.bigquery.model.Dataset, Dataset>() { |
266 | 275 | @Override |
267 | 276 | public Dataset apply(com.google.api.services.bigquery.model.Dataset dataset) { |
@@ -391,11 +400,11 @@ public Page<Table> listTables(DatasetId datasetId, TableListOption... options) { |
391 | 400 | private static Page<Table> listTables(final DatasetId datasetId, |
392 | 401 | final BigQueryOptions serviceOptions, final Map<BigQueryRpc.Option, ?> optionsMap) { |
393 | 402 | try { |
394 | | - BigQueryRpc.Tuple<String, Iterable<com.google.api.services.bigquery.model.Table>> result = |
395 | | - runWithRetries(new Callable<BigQueryRpc.Tuple<String, |
| 403 | + Tuple<String, Iterable<com.google.api.services.bigquery.model.Table>> result = |
| 404 | + runWithRetries(new Callable<Tuple<String, |
396 | 405 | Iterable<com.google.api.services.bigquery.model.Table>>>() { |
397 | 406 | @Override |
398 | | - public BigQueryRpc.Tuple<String, Iterable<com.google.api.services.bigquery.model.Table>> |
| 407 | + public Tuple<String, Iterable<com.google.api.services.bigquery.model.Table>> |
399 | 408 | call() { |
400 | 409 | return serviceOptions.getBigQueryRpcV2().listTables( |
401 | 410 | datasetId.getProject(), datasetId.getDataset(), optionsMap); |
@@ -450,10 +459,10 @@ private static Page<List<FieldValue>> listTableData(final TableId tableId, |
450 | 459 | final BigQueryOptions serviceOptions, final Map<BigQueryRpc.Option, ?> optionsMap) { |
451 | 460 | try { |
452 | 461 | final TableId completeTableId = tableId.setProjectId(serviceOptions.getProjectId()); |
453 | | - BigQueryRpc.Tuple<String, Iterable<TableRow>> result = |
454 | | - runWithRetries(new Callable<BigQueryRpc.Tuple<String, Iterable<TableRow>>>() { |
| 462 | + Tuple<String, Iterable<TableRow>> result = |
| 463 | + runWithRetries(new Callable<Tuple<String, Iterable<TableRow>>>() { |
455 | 464 | @Override |
456 | | - public BigQueryRpc.Tuple<String, Iterable<TableRow>> call() { |
| 465 | + public Tuple<String, Iterable<TableRow>> call() { |
457 | 466 | return serviceOptions.getBigQueryRpcV2() |
458 | 467 | .listTableData(completeTableId.getProject(), completeTableId.getDataset(), |
459 | 468 | completeTableId.getTable(), optionsMap); |
@@ -509,11 +518,11 @@ public Page<Job> listJobs(JobListOption... options) { |
509 | 518 |
|
510 | 519 | private static Page<Job> listJobs(final BigQueryOptions serviceOptions, |
511 | 520 | final Map<BigQueryRpc.Option, ?> optionsMap) { |
512 | | - BigQueryRpc.Tuple<String, Iterable<com.google.api.services.bigquery.model.Job>> result = |
513 | | - runWithRetries(new Callable<BigQueryRpc.Tuple<String, |
| 521 | + Tuple<String, Iterable<com.google.api.services.bigquery.model.Job>> result = |
| 522 | + runWithRetries(new Callable<Tuple<String, |
514 | 523 | Iterable<com.google.api.services.bigquery.model.Job>>>() { |
515 | 524 | @Override |
516 | | - public BigQueryRpc.Tuple<String, Iterable<com.google.api.services.bigquery.model.Job>> |
| 525 | + public Tuple<String, Iterable<com.google.api.services.bigquery.model.Job>> |
517 | 526 | call() { |
518 | 527 | return serviceOptions.getBigQueryRpcV2().listJobs(serviceOptions.getProjectId(), optionsMap); |
519 | 528 | } |
|
0 commit comments