Skip to content

Commit 28f95ab

Browse files
author
Ajay Kannan
committed
---
yaml --- r: 2671 b: refs/heads/update-datastore c: ce9b5c1 h: refs/heads/master i: 2669: 6fbac3d 2667: 2490ce2 2663: 5253e21 2655: f0d5938
1 parent f2712d5 commit 28f95ab

47 files changed

Lines changed: 227 additions & 1043 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
@@ -5,7 +5,7 @@ refs/heads/gh-pages: 4e0561bb4504bf647db669a14417b2b2c87ba45d
55
refs/heads/bigquery: 762fa5830e6c398c0396177e3e7fd243bd62cfc3
66
refs/heads/pubsub-alpha: 1a0e970f265af871e02274085b9662b3fe29058b
77
refs/heads/resource-manager: ebf4adc5ee835cd2086c4ac5b4e78d01a5a005a7
8-
refs/heads/update-datastore: f1a5cecd5da83bef5268f21e1b99517daef2a80d
8+
refs/heads/update-datastore: ce9b5c1d3676bca7a4687b91c8d348d30c7eccda
99
refs/tags/0.0.9: 22f1839238f66c39e67ed4dfdcd273b1ae2e8444
1010
refs/tags/v0.0.10: 207ebd2a3472fddee69fe1298eb90429e3306efd
1111
refs/tags/v0.0.11: ffbfba48a6426ff63c08ff2117e58681f251fbf2

branches/update-datastore/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/BaseTableInfo.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,8 @@ public enum Type {
9797
/**
9898
* Base builder for tables.
9999
*
100-
* @param <T> the table type
101-
* @param <B> the table builder
100+
* @param <T> the table type.
101+
* @param <B> the table builder.
102102
*/
103103
public abstract static class Builder<T extends BaseTableInfo, B extends Builder<T, B>> {
104104

branches/update-datastore/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/BigQuery.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -500,31 +500,31 @@ public static QueryResultsOption maxWaitTime(long maxWaitTime) {
500500
/**
501501
* Deletes the requested dataset.
502502
*
503-
* @return {@code true} if dataset was deleted, {@code false} if it was not found
503+
* @return {@code true} if dataset was deleted, {@code false} if it was not found.
504504
* @throws BigQueryException upon failure
505505
*/
506506
boolean delete(String datasetId, DatasetDeleteOption... options) throws BigQueryException;
507507

508508
/**
509509
* Deletes the requested dataset.
510510
*
511-
* @return {@code true} if dataset was deleted, {@code false} if it was not found
511+
* @return {@code true} if dataset was deleted, {@code false} if it was not found.
512512
* @throws BigQueryException upon failure
513513
*/
514514
boolean delete(DatasetId datasetId, DatasetDeleteOption... options) throws BigQueryException;
515515

516516
/**
517517
* Deletes the requested table.
518518
*
519-
* @return {@code true} if table was deleted, {@code false} if it was not found
519+
* @return {@code true} if table was deleted, {@code false} if it was not found.
520520
* @throws BigQueryException upon failure
521521
*/
522522
boolean delete(String datasetId, String tableId) throws BigQueryException;
523523

524524
/**
525525
* Deletes the requested table.
526526
*
527-
* @return {@code true} if table was deleted, {@code false} if it was not found
527+
* @return {@code true} if table was deleted, {@code false} if it was not found.
528528
* @throws BigQueryException upon failure
529529
*/
530530
boolean delete(TableId tableId) throws BigQueryException;

branches/update-datastore/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/BigQueryError.java

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,8 @@
88
import java.util.Objects;
99

1010
/**
11-
* Google Cloud BigQuery Error. Objects of this class represent errors encountered by the BigQuery
12-
* service while executing a request. A BigQuery Job that terminated with an error has a non-null
13-
* {@link JobStatus#error()}. A job can also encounter errors during its execution that do not cause
14-
* the whole job to fail (see {@link JobStatus#executionErrors()}). Similarly, queries and insert
15-
* all requests can cause BigQuery errors that do not mean the whole operation failed (see
16-
* {@link QueryResponse#executionErrors()} and {@link InsertAllResponse#insertErrors()}). When a
17-
* {@link BigQueryException} is thrown the BigQuery Error that caused it, if any, can be accessed
18-
* with {@link BigQueryException#error()}.
11+
* Google Cloud BigQuery Job Error. Objects of this class represent errors occurred during the
12+
* execution of a BigQuery Job.
1913
*/
2014
public class BigQueryError implements Serializable {
2115

@@ -40,14 +34,14 @@ public ErrorProto apply(BigQueryError error) {
4034
private final String debugInfo;
4135
private final String message;
4236

43-
public BigQueryError(String reason, String location, String message, String debugInfo) {
37+
BigQueryError(String reason, String location, String message, String debugInfo) {
4438
this.reason = reason;
4539
this.location = location;
4640
this.debugInfo = debugInfo;
4741
this.message = message;
4842
}
4943

50-
public BigQueryError(String reason, String location, String message) {
44+
BigQueryError(String reason, String location, String message) {
5145
this.reason = reason;
5246
this.location = location;
5347
this.message = message;

branches/update-datastore/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/BigQueryException.java

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -31,23 +31,8 @@ public class BigQueryException extends BaseServiceException {
3131
private static final long serialVersionUID = -5504832700512784654L;
3232
public static final int UNKNOWN_CODE = -1;
3333

34-
private final BigQueryError error;
35-
3634
public BigQueryException(int code, String message, boolean retryable) {
37-
this(code, message, retryable, null);
38-
}
39-
40-
public BigQueryException(int code, String message, boolean retryable, BigQueryError error) {
4135
super(code, message, retryable);
42-
this.error = error;
43-
}
44-
45-
/**
46-
* Returns the {@link BigQueryError} that caused this exception. Returns {@code null} if none
47-
* exists.
48-
*/
49-
public BigQueryError error() {
50-
return error;
5136
}
5237

5338
/**

branches/update-datastore/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/BigQueryImpl.java

Lines changed: 37 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
import com.google.gcloud.ExceptionHandler.Interceptor;
3939
import com.google.gcloud.Page;
4040
import com.google.gcloud.PageImpl;
41+
import com.google.gcloud.PageImpl.NextPageFetcher;
4142
import com.google.gcloud.RetryHelper;
4243
import com.google.gcloud.bigquery.InsertAllRequest.RowToInsert;
4344
import com.google.gcloud.spi.BigQueryRpc;
@@ -69,36 +70,17 @@ public RetryResult beforeEval(Exception exception) {
6970
static final ExceptionHandler EXCEPTION_HANDLER = ExceptionHandler.builder()
7071
.abortOn(RuntimeException.class).interceptor(EXCEPTION_HANDLER_INTERCEPTOR).build();
7172

72-
private abstract static class BasePageFetcher<T> implements PageImpl.NextPageFetcher<T> {
73+
private static class DatasetPageFetcher implements NextPageFetcher<DatasetInfo> {
7374

74-
private static final long serialVersionUID = -338124488600215401L;
75-
76-
protected final Map<BigQueryRpc.Option, ?> requestOptions;
77-
protected final BigQueryOptions serviceOptions;
78-
79-
BasePageFetcher(BigQueryOptions serviceOptions, String cursor,
80-
Map<BigQueryRpc.Option, ?> optionMap) {
81-
this.serviceOptions = serviceOptions;
82-
ImmutableMap.Builder<BigQueryRpc.Option, Object> builder = ImmutableMap.builder();
83-
if (cursor != null) {
84-
builder.put(BigQueryRpc.Option.PAGE_TOKEN, cursor);
85-
}
86-
for (Map.Entry<BigQueryRpc.Option, ?> option : optionMap.entrySet()) {
87-
if (option.getKey() != BigQueryRpc.Option.PAGE_TOKEN) {
88-
builder.put(option.getKey(), option.getValue());
89-
}
90-
}
91-
this.requestOptions = builder.build();
92-
}
93-
}
94-
95-
private static class DatasetPageFetcher extends BasePageFetcher<DatasetInfo> {
96-
97-
private static final long serialVersionUID = 3030824397616608646L;
75+
private static final long serialVersionUID = -3057564042439021278L;
76+
private final Map<BigQueryRpc.Option, ?> requestOptions;
77+
private final BigQueryOptions serviceOptions;
9878

9979
DatasetPageFetcher(BigQueryOptions serviceOptions, String cursor,
10080
Map<BigQueryRpc.Option, ?> optionMap) {
101-
super(serviceOptions, cursor, optionMap);
81+
this.requestOptions =
82+
PageImpl.nextRequestOptions(BigQueryRpc.Option.PAGE_TOKEN, cursor, optionMap);
83+
this.serviceOptions = serviceOptions;
10284
}
10385

10486
@Override
@@ -107,14 +89,18 @@ public Page<DatasetInfo> nextPage() {
10789
}
10890
}
10991

110-
private static class TablePageFetcher extends BasePageFetcher<BaseTableInfo> {
92+
private static class TablePageFetcher implements NextPageFetcher<BaseTableInfo> {
11193

112-
private static final long serialVersionUID = 5908129355985236115L;
94+
private static final long serialVersionUID = 8611248840504201187L;
95+
private final Map<BigQueryRpc.Option, ?> requestOptions;
96+
private final BigQueryOptions serviceOptions;
11397
private final String dataset;
11498

11599
TablePageFetcher(String dataset, BigQueryOptions serviceOptions, String cursor,
116100
Map<BigQueryRpc.Option, ?> optionMap) {
117-
super(serviceOptions, cursor, optionMap);
101+
this.requestOptions =
102+
PageImpl.nextRequestOptions(BigQueryRpc.Option.PAGE_TOKEN, cursor, optionMap);
103+
this.serviceOptions = serviceOptions;
118104
this.dataset = dataset;
119105
}
120106

@@ -124,13 +110,17 @@ public Page<BaseTableInfo> nextPage() {
124110
}
125111
}
126112

127-
private static class JobPageFetcher extends BasePageFetcher<JobInfo> {
113+
private static class JobPageFetcher implements NextPageFetcher<JobInfo> {
128114

129-
private static final long serialVersionUID = -4984845360519279880L;
115+
private static final long serialVersionUID = 8536533282558245472L;
116+
private final Map<BigQueryRpc.Option, ?> requestOptions;
117+
private final BigQueryOptions serviceOptions;
130118

131119
JobPageFetcher(BigQueryOptions serviceOptions, String cursor,
132120
Map<BigQueryRpc.Option, ?> optionMap) {
133-
super(serviceOptions, cursor, optionMap);
121+
this.requestOptions =
122+
PageImpl.nextRequestOptions(BigQueryRpc.Option.PAGE_TOKEN, cursor, optionMap);
123+
this.serviceOptions = serviceOptions;
134124
}
135125

136126
@Override
@@ -139,14 +129,18 @@ public Page<JobInfo> nextPage() {
139129
}
140130
}
141131

142-
private static class TableDataPageFetcher extends BasePageFetcher<List<FieldValue>> {
132+
private static class TableDataPageFetcher implements NextPageFetcher<List<FieldValue>> {
143133

144-
private static final long serialVersionUID = 1281938239570262432L;
134+
private static final long serialVersionUID = -8501991114794410114L;
135+
private final Map<BigQueryRpc.Option, ?> requestOptions;
136+
private final BigQueryOptions serviceOptions;
145137
private final TableId table;
146138

147139
TableDataPageFetcher(TableId table, BigQueryOptions serviceOptions, String cursor,
148140
Map<BigQueryRpc.Option, ?> optionMap) {
149-
super(serviceOptions, cursor, optionMap);
141+
this.requestOptions =
142+
PageImpl.nextRequestOptions(BigQueryRpc.Option.PAGE_TOKEN, cursor, optionMap);
143+
this.serviceOptions = serviceOptions;
150144
this.table = table;
151145
}
152146

@@ -156,15 +150,19 @@ public Page<List<FieldValue>> nextPage() {
156150
}
157151
}
158152

159-
private static class QueryResultsPageFetcherImpl extends BasePageFetcher<List<FieldValue>>
160-
implements QueryResult.QueryResultsPageFetcher {
153+
private static class QueryResultsPageFetcherImpl
154+
implements NextPageFetcher<List<FieldValue>>, QueryResult.QueryResultsPageFetcher {
161155

162-
private static final long serialVersionUID = 6713948754731557486L;
156+
private static final long serialVersionUID = -9198905840550459803L;
157+
private final Map<BigQueryRpc.Option, ?> requestOptions;
158+
private final BigQueryOptions serviceOptions;
163159
private final JobId job;
164160

165161
QueryResultsPageFetcherImpl(JobId job, BigQueryOptions serviceOptions, String cursor,
166162
Map<BigQueryRpc.Option, ?> optionMap) {
167-
super(serviceOptions, cursor, optionMap);
163+
this.requestOptions =
164+
PageImpl.nextRequestOptions(BigQueryRpc.Option.PAGE_TOKEN, cursor, optionMap);
165+
this.serviceOptions = serviceOptions;
168166
this.job = job;
169167
}
170168

branches/update-datastore/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/Dataset.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ public Dataset update(DatasetInfo datasetInfo, BigQuery.DatasetOption... options
184184
/**
185185
* Deletes this dataset.
186186
*
187-
* @return {@code true} if dataset was deleted, {@code false} if it was not found
187+
* @return {@code true} if dataset was deleted, {@code false} if it was not found.
188188
* @throws BigQueryException upon failure
189189
*/
190190
public boolean delete() {

branches/update-datastore/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/ExtractJobInfo.java

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -263,23 +263,6 @@ public static ExtractJobInfo of(TableId sourceTable, List<String> destinationUri
263263
return builder(sourceTable, destinationUris).build();
264264
}
265265

266-
/**
267-
* Returns a BigQuery Extract Job for the given source table, format and destination URI. Job's id
268-
* is chosen by the service.
269-
*/
270-
public static ExtractJobInfo of(TableId sourceTable, String format, String destinationUri) {
271-
return builder(sourceTable, destinationUri).format(format).build();
272-
}
273-
274-
/**
275-
* Returns a BigQuery Extract Job for the given source table, format and destination URIs. Job's
276-
* id is chosen by the service.
277-
*/
278-
public static ExtractJobInfo of(TableId sourceTable, String format,
279-
List<String> destinationUris) {
280-
return builder(sourceTable, destinationUris).format(format).build();
281-
}
282-
283266
/**
284267
* Returns a BigQuery Extract Job for the given source table and destination URI. Job's id is set
285268
* to the provided value.
@@ -296,24 +279,6 @@ public static ExtractJobInfo of(JobId jobId, TableId sourceTable, List<String> d
296279
return builder(sourceTable, destinationUris).jobId(jobId).build();
297280
}
298281

299-
/**
300-
* Returns a BigQuery Extract Job for the given source table, format and destination URI. Job's id
301-
* is set to the provided value.
302-
*/
303-
public static ExtractJobInfo of(JobId jobId, TableId sourceTable, String format,
304-
String destinationUri) {
305-
return builder(sourceTable, destinationUri).format(format).jobId(jobId).build();
306-
}
307-
308-
/**
309-
* Returns a BigQuery Extract Job for the given source table, format and destination URIs. Job's
310-
* id is set to the provided value.
311-
*/
312-
public static ExtractJobInfo of(JobId jobId, TableId sourceTable, String format,
313-
List<String> destinationUris) {
314-
return builder(sourceTable, destinationUris).format(format).jobId(jobId).build();
315-
}
316-
317282
@SuppressWarnings("unchecked")
318283
static ExtractJobInfo fromPb(Job jobPb) {
319284
return new Builder(jobPb).build();

branches/update-datastore/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/JobInfo.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
*
3434
* @see <a href="https://cloud.google.com/bigquery/docs/reference/v2/jobs">Jobs</a>
3535
*
36-
* @param <S> the statistics type
36+
* @param <S> the statistics type.
3737
*/
3838
public abstract class JobInfo<S extends JobStatistics> implements Serializable {
3939

@@ -92,9 +92,9 @@ public enum WriteDisposition {
9292
/**
9393
* Base builder for jobs.
9494
*
95-
* @param <T> the job type
96-
* @param <S> the job statistics type
97-
* @param <B> the job builder
95+
* @param <T> the job type.
96+
* @param <S> the job statistics type.
97+
* @param <B> the job builder.
9898
*/
9999
public abstract static class Builder<T extends JobInfo, S extends JobStatistics,
100100
B extends Builder<T, S, B>> {

0 commit comments

Comments
 (0)