Skip to content

Commit bb2da23

Browse files
author
Ajay Kannan
committed
---
yaml --- r: 4745 b: refs/heads/logging-alpha c: bf918e5 h: refs/heads/master i: 4743: 3d22c8a
1 parent 76c2b88 commit bb2da23

58 files changed

Lines changed: 801 additions & 540 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
@@ -12,7 +12,7 @@ refs/heads/compute-alpha: 969cba2627f1d53d352cc4a5ffe0879dacf65e6c
1212
refs/heads/dns-alpha: 2f90e7e338349287ace33375896907af0f032ca1
1313
refs/heads/dns-alpha-batch: 17442b07867021b85d0452f5f3eda29a3413288f
1414
refs/heads/gcs-nio: 283aeaf15efdcf3621eb6859f05e55ad7764375d
15-
refs/heads/logging-alpha: 98c69748247257eb24485542da9a3888a316efb2
15+
refs/heads/logging-alpha: bf918e5f0353f5eb54cb7b1d552e4e0972213cd7
1616
refs/tags/v0.1.0: a615317f7424ed58621b1f65d5c4d8cbbe8a6ed8
1717
refs/tags/v0.1.1: 7a7f6985fe465e9dd6a075af55493f42b4933be0
1818
refs/tags/v0.1.2: 3eb3fe866ba22487686048f45d927b8c8638ea3f

branches/logging-alpha/codacy-conf.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

branches/logging-alpha/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/BigQuery.java

Lines changed: 35 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,15 @@
1919
import static com.google.common.base.Preconditions.checkArgument;
2020

2121
import com.google.common.base.Function;
22-
import com.google.common.base.Joiner;
2322
import com.google.common.collect.ImmutableList;
2423
import com.google.common.collect.Lists;
25-
import com.google.common.collect.Sets;
24+
import com.google.gcloud.FieldSelector;
25+
import com.google.gcloud.FieldSelector.Helper;
2626
import com.google.gcloud.Page;
2727
import com.google.gcloud.Service;
2828
import com.google.gcloud.bigquery.spi.BigQueryRpc;
2929

3030
import java.util.List;
31-
import java.util.Set;
3231

3332
/**
3433
* An interface for Google Cloud BigQuery.
@@ -43,7 +42,7 @@ public interface BigQuery extends Service<BigQueryOptions> {
4342
* @see <a href="https://cloud.google.com/bigquery/docs/reference/v2/datasets#resource">Dataset
4443
* Resource</a>
4544
*/
46-
enum DatasetField {
45+
enum DatasetField implements FieldSelector {
4746
ACCESS("access"),
4847
CREATION_TIME("creationTime"),
4948
DATASET_REFERENCE("datasetReference"),
@@ -56,24 +55,19 @@ enum DatasetField {
5655
LOCATION("location"),
5756
SELF_LINK("selfLink");
5857

58+
static final List<? extends FieldSelector> REQUIRED_FIELDS =
59+
ImmutableList.of(DATASET_REFERENCE);
60+
5961
private final String selector;
6062

6163
DatasetField(String selector) {
6264
this.selector = selector;
6365
}
6466

67+
@Override
6568
public String selector() {
6669
return selector;
6770
}
68-
69-
static String selector(DatasetField... fields) {
70-
Set<String> fieldStrings = Sets.newHashSetWithExpectedSize(fields.length + 1);
71-
fieldStrings.add(DATASET_REFERENCE.selector());
72-
for (DatasetField field : fields) {
73-
fieldStrings.add(field.selector());
74-
}
75-
return Joiner.on(',').join(fieldStrings);
76-
}
7771
}
7872

7973
/**
@@ -82,7 +76,7 @@ static String selector(DatasetField... fields) {
8276
* @see <a href="https://cloud.google.com/bigquery/docs/reference/v2/tables#resource">Table
8377
* Resource</a>
8478
*/
85-
enum TableField {
79+
enum TableField implements FieldSelector {
8680
CREATION_TIME("creationTime"),
8781
DESCRIPTION("description"),
8882
ETAG("etag"),
@@ -101,25 +95,19 @@ enum TableField {
10195
TYPE("type"),
10296
VIEW("view");
10397

98+
static final List<? extends FieldSelector> REQUIRED_FIELDS =
99+
ImmutableList.of(TABLE_REFERENCE, TYPE);
100+
104101
private final String selector;
105102

106103
TableField(String selector) {
107104
this.selector = selector;
108105
}
109106

107+
@Override
110108
public String selector() {
111109
return selector;
112110
}
113-
114-
static String selector(TableField... fields) {
115-
Set<String> fieldStrings = Sets.newHashSetWithExpectedSize(fields.length + 2);
116-
fieldStrings.add(TABLE_REFERENCE.selector());
117-
fieldStrings.add(TYPE.selector());
118-
for (TableField field : fields) {
119-
fieldStrings.add(field.selector());
120-
}
121-
return Joiner.on(',').join(fieldStrings);
122-
}
123111
}
124112

125113
/**
@@ -128,7 +116,7 @@ static String selector(TableField... fields) {
128116
* @see <a href="https://cloud.google.com/bigquery/docs/reference/v2/jobs#resource">Job Resource
129117
* </a>
130118
*/
131-
enum JobField {
119+
enum JobField implements FieldSelector {
132120
CONFIGURATION("configuration"),
133121
ETAG("etag"),
134122
ID("id"),
@@ -138,25 +126,19 @@ enum JobField {
138126
STATUS("status"),
139127
USER_EMAIL("user_email");
140128

129+
static final List<? extends FieldSelector> REQUIRED_FIELDS =
130+
ImmutableList.of(JOB_REFERENCE, CONFIGURATION);
131+
141132
private final String selector;
142133

143134
JobField(String selector) {
144135
this.selector = selector;
145136
}
146137

138+
@Override
147139
public String selector() {
148140
return selector;
149141
}
150-
151-
static String selector(JobField... fields) {
152-
Set<String> fieldStrings = Sets.newHashSetWithExpectedSize(fields.length + 2);
153-
fieldStrings.add(JOB_REFERENCE.selector());
154-
fieldStrings.add(CONFIGURATION.selector());
155-
for (JobField field : fields) {
156-
fieldStrings.add(field.selector());
157-
}
158-
return Joiner.on(',').join(fieldStrings);
159-
}
160142
}
161143

162144
/**
@@ -210,7 +192,8 @@ private DatasetOption(BigQueryRpc.Option option, Object value) {
210192
* returned, even if not specified.
211193
*/
212194
public static DatasetOption fields(DatasetField... fields) {
213-
return new DatasetOption(BigQueryRpc.Option.FIELDS, DatasetField.selector(fields));
195+
return new DatasetOption(BigQueryRpc.Option.FIELDS,
196+
Helper.selector(DatasetField.REQUIRED_FIELDS, fields));
214197
}
215198
}
216199

@@ -279,7 +262,8 @@ private TableOption(BigQueryRpc.Option option, Object value) {
279262
* of {@link Table#definition()}) are always returned, even if not specified.
280263
*/
281264
public static TableOption fields(TableField... fields) {
282-
return new TableOption(BigQueryRpc.Option.FIELDS, TableField.selector(fields));
265+
return new TableOption(BigQueryRpc.Option.FIELDS,
266+
Helper.selector(TableField.REQUIRED_FIELDS, fields));
283267
}
284268
}
285269

@@ -376,10 +360,8 @@ public static JobListOption pageToken(String pageToken) {
376360
* listing jobs.
377361
*/
378362
public static JobListOption fields(JobField... fields) {
379-
String selector = JobField.selector(fields);
380-
StringBuilder builder = new StringBuilder();
381-
builder.append("etag,jobs(").append(selector).append(",state,errorResult),nextPageToken");
382-
return new JobListOption(BigQueryRpc.Option.FIELDS, builder.toString());
363+
return new JobListOption(BigQueryRpc.Option.FIELDS,
364+
Helper.listSelector("jobs", JobField.REQUIRED_FIELDS, fields, "state", "errorResult"));
383365
}
384366
}
385367

@@ -402,7 +384,8 @@ private JobOption(BigQueryRpc.Option option, Object value) {
402384
* returned, even if not specified.
403385
*/
404386
public static JobOption fields(JobField... fields) {
405-
return new JobOption(BigQueryRpc.Option.FIELDS, JobField.selector(fields));
387+
return new JobOption(BigQueryRpc.Option.FIELDS,
388+
Helper.selector(JobField.REQUIRED_FIELDS, fields));
406389
}
407390
}
408391

@@ -488,9 +471,10 @@ public static QueryResultsOption maxWaitTime(long maxWaitTime) {
488471
Dataset getDataset(DatasetId datasetId, DatasetOption... options);
489472

490473
/**
491-
* Lists the project's datasets. This method returns partial information on each dataset
492-
* ({@link Dataset#datasetId()}, {@link Dataset#friendlyName()} and {@link Dataset#id()}). To get
493-
* complete information use either {@link #getDataset(String, DatasetOption...)} or
474+
* Lists the project's datasets. This method returns partial information on each dataset:
475+
* ({@link Dataset#datasetId()}, {@link Dataset#friendlyName()} and
476+
* {@link Dataset#generatedId()}). To get complete information use either
477+
* {@link #getDataset(String, DatasetOption...)} or
494478
* {@link #getDataset(DatasetId, DatasetOption...)}.
495479
*
496480
* @throws BigQueryException upon failure
@@ -558,9 +542,9 @@ public static QueryResultsOption maxWaitTime(long maxWaitTime) {
558542
Table getTable(TableId tableId, TableOption... options);
559543

560544
/**
561-
* Lists the tables in the dataset. This method returns partial information on each table
562-
* ({@link Table#tableId()}, {@link Table#friendlyName()}, {@link Table#id()} and type, which
563-
* is part of {@link Table#definition()}). To get complete information use either
545+
* Lists the tables in the dataset. This method returns partial information on each table:
546+
* ({@link Table#tableId()}, {@link Table#friendlyName()}, {@link Table#generatedId()} and type,
547+
* which is part of {@link Table#definition()}). To get complete information use either
564548
* {@link #getTable(TableId, TableOption...)} or
565549
* {@link #getTable(String, String, TableOption...)}.
566550
*
@@ -569,9 +553,9 @@ public static QueryResultsOption maxWaitTime(long maxWaitTime) {
569553
Page<Table> listTables(String datasetId, TableListOption... options);
570554

571555
/**
572-
* Lists the tables in the dataset. This method returns partial information on each table
573-
* ({@link Table#tableId()}, {@link Table#friendlyName()}, {@link Table#id()} and type, which
574-
* is part of {@link Table#definition()}). To get complete information use either
556+
* Lists the tables in the dataset. This method returns partial information on each table:
557+
* ({@link Table#tableId()}, {@link Table#friendlyName()}, {@link Table#generatedId()} and type,
558+
* which is part of {@link Table#definition()}). To get complete information use either
575559
* {@link #getTable(TableId, TableOption...)} or
576560
* {@link #getTable(String, String, TableOption...)}.
577561
*

branches/logging-alpha/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/Dataset.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,8 @@ public Builder friendlyName(String friendlyName) {
103103
}
104104

105105
@Override
106-
Builder id(String id) {
107-
infoBuilder.id(id);
106+
Builder generatedId(String generatedId) {
107+
infoBuilder.generatedId(generatedId);
108108
return this;
109109
}
110110

branches/logging-alpha/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/DatasetInfo.java

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,7 @@ public Dataset apply(DatasetInfo datasetInfo) {
5555
return datasetInfo.toPb();
5656
}
5757
};
58-
59-
private static final long serialVersionUID = -6615133444520365839L;
58+
private static final long serialVersionUID = 8469473744160758489L;
6059

6160
private final DatasetId datasetId;
6261
private final List<Acl> acl;
@@ -65,7 +64,7 @@ public Dataset apply(DatasetInfo datasetInfo) {
6564
private final String description;
6665
private final String etag;
6766
private final String friendlyName;
68-
private final String id;
67+
private final String generatedId;
6968
private final Long lastModified;
7069
private final String location;
7170
private final String selfLink;
@@ -114,7 +113,7 @@ public abstract static class Builder {
114113
*/
115114
public abstract Builder friendlyName(String friendlyName);
116115

117-
abstract Builder id(String id);
116+
abstract Builder generatedId(String generatedId);
118117

119118
abstract Builder lastModified(Long lastModified);
120119

@@ -144,7 +143,7 @@ static final class BuilderImpl extends Builder {
144143
private String description;
145144
private String etag;
146145
private String friendlyName;
147-
private String id;
146+
private String generatedId;
148147
private Long lastModified;
149148
private String location;
150149
private String selfLink;
@@ -159,7 +158,7 @@ static final class BuilderImpl extends Builder {
159158
this.description = datasetInfo.description;
160159
this.etag = datasetInfo.etag;
161160
this.friendlyName = datasetInfo.friendlyName;
162-
this.id = datasetInfo.id;
161+
this.generatedId = datasetInfo.generatedId;
163162
this.lastModified = datasetInfo.lastModified;
164163
this.location = datasetInfo.location;
165164
this.selfLink = datasetInfo.selfLink;
@@ -182,7 +181,7 @@ public Acl apply(Dataset.Access accessPb) {
182181
this.description = datasetPb.getDescription();
183182
this.etag = datasetPb.getEtag();
184183
this.friendlyName = datasetPb.getFriendlyName();
185-
this.id = datasetPb.getId();
184+
this.generatedId = datasetPb.getId();
186185
this.lastModified = datasetPb.getLastModifiedTime();
187186
this.location = datasetPb.getLocation();
188187
this.selfLink = datasetPb.getSelfLink();
@@ -232,8 +231,8 @@ public Builder friendlyName(String friendlyName) {
232231
}
233232

234233
@Override
235-
Builder id(String id) {
236-
this.id = id;
234+
Builder generatedId(String generatedId) {
235+
this.generatedId = generatedId;
237236
return this;
238237
}
239238

@@ -269,7 +268,7 @@ public DatasetInfo build() {
269268
description = builder.description;
270269
etag = builder.etag;
271270
friendlyName = builder.friendlyName;
272-
id = builder.id;
271+
generatedId = builder.generatedId;
273272
lastModified = builder.lastModified;
274273
location = builder.location;
275274
selfLink = builder.selfLink;
@@ -333,10 +332,10 @@ public String friendlyName() {
333332
}
334333

335334
/**
336-
* Returns an opaque id for the dataset.
335+
* Returns the service-generated id for the dataset.
337336
*/
338-
public String id() {
339-
return id;
337+
public String generatedId() {
338+
return generatedId;
340339
}
341340

342341
/**
@@ -381,7 +380,7 @@ public String toString() {
381380
.add("description", description)
382381
.add("etag", etag)
383382
.add("friendlyName", friendlyName)
384-
.add("id", id)
383+
.add("generatedId", generatedId)
385384
.add("lastModified", lastModified)
386385
.add("location", location)
387386
.add("selfLink", selfLink)
@@ -431,7 +430,7 @@ Dataset toPb() {
431430
datasetPb.setDescription(description);
432431
datasetPb.setEtag(etag);
433432
datasetPb.setFriendlyName(friendlyName);
434-
datasetPb.setId(id);
433+
datasetPb.setId(generatedId);
435434
datasetPb.setLastModifiedTime(lastModified);
436435
datasetPb.setLocation(location);
437436
datasetPb.setSelfLink(selfLink);

branches/logging-alpha/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/Job.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ Builder etag(String etag) {
6363
}
6464

6565
@Override
66-
Builder id(String id) {
67-
infoBuilder.id(id);
66+
Builder generatedId(String generatedId) {
67+
infoBuilder.generatedId(generatedId);
6868
return this;
6969
}
7070

0 commit comments

Comments
 (0)