Skip to content

Commit 828bd37

Browse files
---
yaml --- r: 5483 b: refs/heads/master c: e2edc3c h: refs/heads/master i: 5481: 702604a 5479: aa98d8c
1 parent 4a187e7 commit 828bd37

127 files changed

Lines changed: 579 additions & 550 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 3e705980677c8da2fadbfd46c7813cd6bb5850e7
2+
refs/heads/master: e2edc3ccb88413c8d84e5d1e6fe9349af3550626
33
refs/heads/travis: dae77e558b884bc1b165155482d76c8e40b0fca4
44
refs/heads/gh-pages: 4936f6d1c43be1ab76229d2743bae07f4b4124b3
55
refs/tags/0.0.9: 22f1839238f66c39e67ed4dfdcd273b1ae2e8444

trunk/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/BigQuery.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
import com.google.cloud.FieldSelector.Helper;
2323
import com.google.cloud.Page;
2424
import com.google.cloud.Service;
25-
import com.google.cloud.bigquery.spi.BigQueryRpc;
25+
import com.google.cloud.bigquery.spi.v2.BigQueryRpc;
2626
import com.google.common.base.Function;
2727
import com.google.common.collect.ImmutableList;
2828
import com.google.common.collect.Lists;

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
import com.google.cloud.PageImpl.NextPageFetcher;
3030
import com.google.cloud.RetryHelper;
3131
import com.google.cloud.bigquery.InsertAllRequest.RowToInsert;
32-
import com.google.cloud.bigquery.spi.BigQueryRpc;
32+
import com.google.cloud.bigquery.spi.v2.BigQueryRpc;
3333
import com.google.common.base.Function;
3434
import com.google.common.collect.ImmutableList;
3535
import com.google.common.collect.ImmutableMap;
@@ -156,7 +156,7 @@ public QueryResult getNextPage() {
156156

157157
BigQueryImpl(BigQueryOptions options) {
158158
super(options);
159-
bigQueryRpc = options.getRpc();
159+
bigQueryRpc = options.getBigQueryRpcV2();
160160
}
161161

162162
@Override
@@ -256,7 +256,7 @@ private static Page<Dataset> listDatasets(final String projectId,
256256
@Override
257257
public BigQueryRpc.Tuple<String,
258258
Iterable<com.google.api.services.bigquery.model.Dataset>> call() {
259-
return serviceOptions.getRpc().listDatasets(projectId, optionsMap);
259+
return serviceOptions.getBigQueryRpcV2().listDatasets(projectId, optionsMap);
260260
}
261261
}, serviceOptions.getRetryParams(), EXCEPTION_HANDLER, serviceOptions.getClock());
262262
String cursor = result.x();
@@ -397,7 +397,7 @@ private static Page<Table> listTables(final DatasetId datasetId,
397397
@Override
398398
public BigQueryRpc.Tuple<String, Iterable<com.google.api.services.bigquery.model.Table>>
399399
call() {
400-
return serviceOptions.getRpc().listTables(
400+
return serviceOptions.getBigQueryRpcV2().listTables(
401401
datasetId.getProject(), datasetId.getDataset(), optionsMap);
402402
}
403403
}, serviceOptions.getRetryParams(), EXCEPTION_HANDLER, serviceOptions.getClock());
@@ -454,7 +454,7 @@ private static Page<List<FieldValue>> listTableData(final TableId tableId,
454454
runWithRetries(new Callable<BigQueryRpc.Tuple<String, Iterable<TableRow>>>() {
455455
@Override
456456
public BigQueryRpc.Tuple<String, Iterable<TableRow>> call() {
457-
return serviceOptions.getRpc()
457+
return serviceOptions.getBigQueryRpcV2()
458458
.listTableData(completeTableId.getProject(), completeTableId.getDataset(),
459459
completeTableId.getTable(), optionsMap);
460460
}
@@ -515,7 +515,7 @@ private static Page<Job> listJobs(final BigQueryOptions serviceOptions,
515515
@Override
516516
public BigQueryRpc.Tuple<String, Iterable<com.google.api.services.bigquery.model.Job>>
517517
call() {
518-
return serviceOptions.getRpc().listJobs(serviceOptions.getProjectId(), optionsMap);
518+
return serviceOptions.getBigQueryRpcV2().listJobs(serviceOptions.getProjectId(), optionsMap);
519519
}
520520
}, serviceOptions.getRetryParams(), EXCEPTION_HANDLER, serviceOptions.getClock());
521521
String cursor = result.x();
@@ -602,7 +602,7 @@ private static QueryResponse getQueryResults(JobId jobId,
602602
runWithRetries(new Callable<GetQueryResultsResponse>() {
603603
@Override
604604
public GetQueryResultsResponse call() {
605-
return serviceOptions.getRpc().getQueryResults(
605+
return serviceOptions.getBigQueryRpcV2().getQueryResults(
606606
completeJobId.getProject(), completeJobId.getJob(), optionsMap);
607607
}
608608
}, serviceOptions.getRetryParams(), EXCEPTION_HANDLER, serviceOptions.getClock());

trunk/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/BigQueryOptions.java

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,17 @@
1818

1919
import com.google.cloud.HttpTransportOptions;
2020
import com.google.cloud.ServiceDefaults;
21-
import com.google.cloud.ServiceFactory;
2221
import com.google.cloud.ServiceOptions;
22+
import com.google.cloud.ServiceRpc;
2323
import com.google.cloud.TransportOptions;
24-
import com.google.cloud.bigquery.spi.BigQueryRpc;
24+
import com.google.cloud.bigquery.spi.v2.BigQueryRpc;
2525
import com.google.cloud.bigquery.spi.BigQueryRpcFactory;
26-
import com.google.cloud.bigquery.spi.DefaultBigQueryRpc;
27-
import com.google.cloud.spi.ServiceRpcFactory;
26+
import com.google.cloud.bigquery.spi.v2.HttpBigQueryRpc;
2827
import com.google.common.collect.ImmutableSet;
2928

3029
import java.util.Set;
3130

32-
public class BigQueryOptions extends ServiceOptions<BigQuery, BigQueryRpc, BigQueryOptions> {
31+
public class BigQueryOptions extends ServiceOptions<BigQuery, BigQueryOptions> {
3332

3433
private static final String API_SHORT_NAME = "BigQuery";
3534
private static final String BIGQUERY_SCOPE = "https://www.googleapis.com/auth/bigquery";
@@ -51,13 +50,13 @@ public static class DefaultBigQueryRpcFactory implements BigQueryRpcFactory {
5150
private static final BigQueryRpcFactory INSTANCE = new DefaultBigQueryRpcFactory();
5251

5352
@Override
54-
public BigQueryRpc create(BigQueryOptions options) {
55-
return new DefaultBigQueryRpc(options);
53+
public ServiceRpc create(BigQueryOptions options) {
54+
return new HttpBigQueryRpc(options);
5655
}
5756
}
5857

5958
public static class Builder extends
60-
ServiceOptions.Builder<BigQuery, BigQueryRpc, BigQueryOptions, Builder> {
59+
ServiceOptions.Builder<BigQuery, BigQueryOptions, Builder> {
6160

6261
private Builder() {
6362
}
@@ -86,7 +85,7 @@ private BigQueryOptions(Builder builder) {
8685
}
8786

8887
private static class BigQueryDefaults implements
89-
ServiceDefaults<BigQuery, BigQueryRpc, BigQueryOptions> {
88+
ServiceDefaults<BigQuery, BigQueryOptions> {
9089

9190
@Override
9291
public BigQueryFactory getDefaultServiceFactory() {
@@ -113,6 +112,10 @@ protected Set<String> getScopes() {
113112
return SCOPES;
114113
}
115114

115+
protected BigQueryRpc getBigQueryRpcV2() {
116+
return (BigQueryRpc) getRpc();
117+
}
118+
116119
@SuppressWarnings("unchecked")
117120
@Override
118121
public Builder toBuilder() {

trunk/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/Option.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
import static com.google.common.base.Preconditions.checkNotNull;
2020

21-
import com.google.cloud.bigquery.spi.BigQueryRpc;
21+
import com.google.cloud.bigquery.spi.v2.BigQueryRpc;
2222
import com.google.common.base.MoreObjects;
2323

2424
import java.io.Serializable;

trunk/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/TableDataWriteChannel.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ protected void flushBuffer(final int length, final boolean last) {
5454
new Callable<com.google.api.services.bigquery.model.Job>() {
5555
@Override
5656
public com.google.api.services.bigquery.model.Job call() {
57-
return getOptions().getRpc().write(
57+
return getOptions().getBigQueryRpcV2().write(
5858
getUploadId(), getBuffer(), 0, getPosition(), length, last);
5959
}
6060
}, getOptions().getRetryParams(), BigQueryImpl.EXCEPTION_HANDLER, getOptions().getClock());
@@ -75,7 +75,7 @@ private static String open(final BigQueryOptions options,
7575
return runWithRetries(new Callable<String>() {
7676
@Override
7777
public String call() {
78-
return options.getRpc().open(writeChannelConfiguration.toPb());
78+
return options.getBigQueryRpcV2().open(writeChannelConfiguration.toPb());
7979
}
8080
}, options.getRetryParams(), BigQueryImpl.EXCEPTION_HANDLER, options.getClock());
8181
} catch (RetryHelper.RetryHelperException e) {

trunk/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/spi/BigQueryRpcFactory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,5 @@
2323
* An interface for BigQuery RPC factory.
2424
* Implementation will be loaded via {@link java.util.ServiceLoader}.
2525
*/
26-
public interface BigQueryRpcFactory extends ServiceRpcFactory<BigQueryRpc, BigQueryOptions> {
26+
public interface BigQueryRpcFactory extends ServiceRpcFactory<BigQueryOptions> {
2727
}

trunk/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/spi/BigQueryRpc.java renamed to trunk/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/spi/v2/BigQueryRpc.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package com.google.cloud.bigquery.spi;
17+
package com.google.cloud.bigquery.spi.v2;
1818

1919
import com.google.api.services.bigquery.model.Dataset;
2020
import com.google.api.services.bigquery.model.GetQueryResultsResponse;
@@ -26,11 +26,12 @@
2626
import com.google.api.services.bigquery.model.TableDataInsertAllRequest;
2727
import com.google.api.services.bigquery.model.TableDataInsertAllResponse;
2828
import com.google.api.services.bigquery.model.TableRow;
29+
import com.google.cloud.ServiceRpc;
2930
import com.google.cloud.bigquery.BigQueryException;
3031

3132
import java.util.Map;
3233

33-
public interface BigQueryRpc {
34+
public interface BigQueryRpc extends ServiceRpc {
3435

3536
// These options are part of the Google Cloud BigQuery query parameters
3637
enum Option {

trunk/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/spi/DefaultBigQueryRpc.java renamed to trunk/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/spi/v2/HttpBigQueryRpc.java

Lines changed: 32 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,8 @@
1414
* limitations under the License.
1515
*/
1616

17-
package com.google.cloud.bigquery.spi;
17+
package com.google.cloud.bigquery.spi.v2;
1818

19-
import static com.google.cloud.bigquery.spi.BigQueryRpc.Option.ALL_DATASETS;
20-
import static com.google.cloud.bigquery.spi.BigQueryRpc.Option.ALL_USERS;
21-
import static com.google.cloud.bigquery.spi.BigQueryRpc.Option.DELETE_CONTENTS;
22-
import static com.google.cloud.bigquery.spi.BigQueryRpc.Option.FIELDS;
23-
import static com.google.cloud.bigquery.spi.BigQueryRpc.Option.MAX_RESULTS;
24-
import static com.google.cloud.bigquery.spi.BigQueryRpc.Option.PAGE_TOKEN;
25-
import static com.google.cloud.bigquery.spi.BigQueryRpc.Option.START_INDEX;
26-
import static com.google.cloud.bigquery.spi.BigQueryRpc.Option.STATE_FILTER;
27-
import static com.google.cloud.bigquery.spi.BigQueryRpc.Option.TIMEOUT;
2819
import static java.net.HttpURLConnection.HTTP_CREATED;
2920
import static java.net.HttpURLConnection.HTTP_NOT_FOUND;
3021
import static java.net.HttpURLConnection.HTTP_OK;
@@ -69,7 +60,7 @@
6960
import java.util.List;
7061
import java.util.Map;
7162

72-
public class DefaultBigQueryRpc implements BigQueryRpc {
63+
public class HttpBigQueryRpc implements BigQueryRpc {
7364

7465
public static final String DEFAULT_PROJECTION = "full";
7566
private static final String BASE_RESUMABLE_URI =
@@ -79,7 +70,7 @@ public class DefaultBigQueryRpc implements BigQueryRpc {
7970
private final BigQueryOptions options;
8071
private final Bigquery bigquery;
8172

82-
public DefaultBigQueryRpc(BigQueryOptions options) {
73+
public HttpBigQueryRpc(BigQueryOptions options) {
8374
HttpTransportOptions transportOptions = (HttpTransportOptions) options.getTransportOptions();
8475
HttpTransport transport = transportOptions.getHttpTransportFactory().create();
8576
HttpRequestInitializer initializer = transportOptions.getHttpRequestInitializer(options);
@@ -99,7 +90,7 @@ public Dataset getDataset(String projectId, String datasetId, Map<Option, ?> opt
9990
try {
10091
return bigquery.datasets()
10192
.get(projectId, datasetId)
102-
.setFields(FIELDS.getString(options))
93+
.setFields(Option.FIELDS.getString(options))
10394
.execute();
10495
} catch (IOException ex) {
10596
BigQueryException serviceException = translate(ex);
@@ -115,10 +106,10 @@ public Tuple<String, Iterable<Dataset>> listDatasets(String projectId, Map<Optio
115106
try {
116107
DatasetList datasetsList = bigquery.datasets()
117108
.list(projectId)
118-
.setAll(ALL_DATASETS.getBoolean(options))
119-
.setMaxResults(MAX_RESULTS.getLong(options))
120-
.setPageToken(PAGE_TOKEN.getString(options))
121-
.setPageToken(PAGE_TOKEN.getString(options))
109+
.setAll(Option.ALL_DATASETS.getBoolean(options))
110+
.setMaxResults(Option.MAX_RESULTS.getLong(options))
111+
.setPageToken(Option.PAGE_TOKEN.getString(options))
112+
.setPageToken(Option.PAGE_TOKEN.getString(options))
122113
.execute();
123114
Iterable<DatasetList.Datasets> datasets = datasetsList.getDatasets();
124115
return Tuple.of(datasetsList.getNextPageToken(),
@@ -143,7 +134,7 @@ public Dataset apply(DatasetList.Datasets datasetPb) {
143134
public Dataset create(Dataset dataset, Map<Option, ?> options) {
144135
try {
145136
return bigquery.datasets().insert(dataset.getDatasetReference().getProjectId(), dataset)
146-
.setFields(FIELDS.getString(options))
137+
.setFields(Option.FIELDS.getString(options))
147138
.execute();
148139
} catch (IOException ex) {
149140
throw translate(ex);
@@ -158,7 +149,7 @@ public Table create(Table table, Map<Option, ?> options) {
158149
TableReference reference = table.getTableReference();
159150
return bigquery.tables()
160151
.insert(reference.getProjectId(), reference.getDatasetId(), table)
161-
.setFields(FIELDS.getString(options))
152+
.setFields(Option.FIELDS.getString(options))
162153
.execute();
163154
} catch (IOException ex) {
164155
throw translate(ex);
@@ -172,7 +163,7 @@ public Job create(Job job, Map<Option, ?> options) {
172163
? job.getJobReference().getProjectId() : this.options.getProjectId();
173164
return bigquery.jobs()
174165
.insert(projectId, job)
175-
.setFields(FIELDS.getString(options))
166+
.setFields(Option.FIELDS.getString(options))
176167
.execute();
177168
} catch (IOException ex) {
178169
throw translate(ex);
@@ -183,7 +174,7 @@ public Job create(Job job, Map<Option, ?> options) {
183174
public boolean deleteDataset(String projectId, String datasetId, Map<Option, ?> options) {
184175
try {
185176
bigquery.datasets().delete(projectId, datasetId)
186-
.setDeleteContents(DELETE_CONTENTS.getBoolean(options))
177+
.setDeleteContents(Option.DELETE_CONTENTS.getBoolean(options))
187178
.execute();
188179
return true;
189180
} catch (IOException ex) {
@@ -201,7 +192,7 @@ public Dataset patch(Dataset dataset, Map<Option, ?> options) {
201192
DatasetReference reference = dataset.getDatasetReference();
202193
return bigquery.datasets()
203194
.patch(reference.getProjectId(), reference.getDatasetId(), dataset)
204-
.setFields(FIELDS.getString(options))
195+
.setFields(Option.FIELDS.getString(options))
205196
.execute();
206197
} catch (IOException ex) {
207198
throw translate(ex);
@@ -216,7 +207,7 @@ public Table patch(Table table, Map<Option, ?> options) {
216207
TableReference reference = table.getTableReference();
217208
return bigquery.tables()
218209
.patch(reference.getProjectId(), reference.getDatasetId(), reference.getTableId(), table)
219-
.setFields(FIELDS.getString(options))
210+
.setFields(Option.FIELDS.getString(options))
220211
.execute();
221212
} catch (IOException ex) {
222213
throw translate(ex);
@@ -229,7 +220,7 @@ public Table getTable(String projectId, String datasetId, String tableId,
229220
try {
230221
return bigquery.tables()
231222
.get(projectId, datasetId, tableId)
232-
.setFields(FIELDS.getString(options))
223+
.setFields(Option.FIELDS.getString(options))
233224
.execute();
234225
} catch (IOException ex) {
235226
BigQueryException serviceException = translate(ex);
@@ -246,8 +237,8 @@ public Tuple<String, Iterable<Table>> listTables(String projectId, String datase
246237
try {
247238
TableList tableList = bigquery.tables()
248239
.list(projectId, datasetId)
249-
.setMaxResults(MAX_RESULTS.getLong(options))
250-
.setPageToken(PAGE_TOKEN.getString(options))
240+
.setMaxResults(Option.MAX_RESULTS.getLong(options))
241+
.setPageToken(Option.PAGE_TOKEN.getString(options))
251242
.execute();
252243
Iterable<TableList.Tables> tables = tableList.getTables();
253244
return Tuple.of(tableList.getNextPageToken(),
@@ -298,10 +289,10 @@ public Tuple<String, Iterable<TableRow>> listTableData(String projectId, String
298289
try {
299290
TableDataList tableDataList = bigquery.tabledata()
300291
.list(projectId, datasetId, tableId)
301-
.setMaxResults(MAX_RESULTS.getLong(options))
302-
.setPageToken(PAGE_TOKEN.getString(options))
303-
.setStartIndex(START_INDEX.getLong(options) != null
304-
? BigInteger.valueOf(START_INDEX.getLong(options)) : null)
292+
.setMaxResults(Option.MAX_RESULTS.getLong(options))
293+
.setPageToken(Option.PAGE_TOKEN.getString(options))
294+
.setStartIndex(Option.START_INDEX.getLong(options) != null
295+
? BigInteger.valueOf(Option.START_INDEX.getLong(options)) : null)
305296
.execute();
306297
return Tuple.<String, Iterable<TableRow>>of(tableDataList.getPageToken(),
307298
tableDataList.getRows());
@@ -315,7 +306,7 @@ public Job getJob(String projectId, String jobId, Map<Option, ?> options) {
315306
try {
316307
return bigquery.jobs()
317308
.get(projectId, jobId)
318-
.setFields(FIELDS.getString(options))
309+
.setFields(Option.FIELDS.getString(options))
319310
.execute();
320311
} catch (IOException ex) {
321312
BigQueryException serviceException = translate(ex);
@@ -331,11 +322,11 @@ public Tuple<String, Iterable<Job>> listJobs(String projectId, Map<Option, ?> op
331322
try {
332323
JobList jobsList = bigquery.jobs()
333324
.list(projectId)
334-
.setAllUsers(ALL_USERS.getBoolean(options))
335-
.setFields(FIELDS.getString(options))
336-
.setStateFilter(STATE_FILTER.<List<String>>get(options))
337-
.setMaxResults(MAX_RESULTS.getLong(options))
338-
.setPageToken(PAGE_TOKEN.getString(options))
325+
.setAllUsers(Option.ALL_USERS.getBoolean(options))
326+
.setFields(Option.FIELDS.getString(options))
327+
.setStateFilter(Option.STATE_FILTER.<List<String>>get(options))
328+
.setMaxResults(Option.MAX_RESULTS.getLong(options))
329+
.setPageToken(Option.PAGE_TOKEN.getString(options))
339330
.setProjection(DEFAULT_PROJECTION)
340331
.execute();
341332
Iterable<JobList.Jobs> jobs = jobsList.getJobs();
@@ -386,11 +377,11 @@ public GetQueryResultsResponse getQueryResults(String projectId, String jobId,
386377
Map<Option, ?> options) {
387378
try {
388379
return bigquery.jobs().getQueryResults(projectId, jobId)
389-
.setMaxResults(MAX_RESULTS.getLong(options))
390-
.setPageToken(PAGE_TOKEN.getString(options))
391-
.setStartIndex(START_INDEX.getLong(options) != null
392-
? BigInteger.valueOf(START_INDEX.getLong(options)) : null)
393-
.setTimeoutMs(TIMEOUT.getLong(options))
380+
.setMaxResults(Option.MAX_RESULTS.getLong(options))
381+
.setPageToken(Option.PAGE_TOKEN.getString(options))
382+
.setStartIndex(Option.START_INDEX.getLong(options) != null
383+
? BigInteger.valueOf(Option.START_INDEX.getLong(options)) : null)
384+
.setTimeoutMs(Option.TIMEOUT.getLong(options))
394385
.execute();
395386
} catch (IOException ex) {
396387
BigQueryException serviceException = translate(ex);

trunk/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/BigQueryImplTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@
3636
import com.google.cloud.RetryParams;
3737
import com.google.cloud.WriteChannel;
3838
import com.google.cloud.bigquery.InsertAllRequest.RowToInsert;
39-
import com.google.cloud.bigquery.spi.BigQueryRpc;
40-
import com.google.cloud.bigquery.spi.BigQueryRpc.Tuple;
39+
import com.google.cloud.bigquery.spi.v2.BigQueryRpc;
40+
import com.google.cloud.bigquery.spi.v2.BigQueryRpc.Tuple;
4141
import com.google.cloud.bigquery.spi.BigQueryRpcFactory;
4242
import com.google.common.base.Function;
4343
import com.google.common.collect.ImmutableList;

0 commit comments

Comments
 (0)