Skip to content

Commit e91f47b

Browse files
committed
Make checkstyle happy, fix minor issues, add better javadoc
1 parent d676636 commit e91f47b

17 files changed

Lines changed: 94 additions & 57 deletions

File tree

gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/Acl.java

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,12 @@ public enum Role {
4848
* Can read, query, copy or export tables in the dataset.
4949
*/
5050
READER,
51+
5152
/**
5253
* Same as {@link #READER} plus can edit or append data in the dataset.
5354
*/
5455
WRITER,
56+
5557
/**
5658
* Same as {@link #WRITER} plus can update and delete the dataset.
5759
*/
@@ -61,7 +63,7 @@ public enum Role {
6163
/**
6264
* Base class for BigQuery entities that can be grant access to the dataset.
6365
*/
64-
public static abstract class Entity implements Serializable {
66+
public abstract static class Entity implements Serializable {
6567

6668
private static final long serialVersionUID = 8111776788607959944L;
6769

@@ -132,14 +134,14 @@ public String domain() {
132134
}
133135

134136
@Override
135-
public boolean equals(Object o) {
136-
if (this == o) {
137+
public boolean equals(Object obj) {
138+
if (this == obj) {
137139
return true;
138140
}
139-
if (o == null || getClass() != o.getClass()) {
141+
if (obj == null || getClass() != obj.getClass()) {
140142
return false;
141143
}
142-
Domain domainEntity = (Domain) o;
144+
Domain domainEntity = (Domain) obj;
143145
return Objects.equals(type(), domainEntity.type())
144146
&& Objects.equals(domain, domainEntity.domain());
145147
}
@@ -196,14 +198,14 @@ public String identifier() {
196198
}
197199

198200
@Override
199-
public boolean equals(Object o) {
200-
if (this == o) {
201+
public boolean equals(Object obj) {
202+
if (this == obj) {
201203
return true;
202204
}
203-
if (o == null || getClass() != o.getClass()) {
205+
if (obj == null || getClass() != obj.getClass()) {
204206
return false;
205207
}
206-
Group group = (Group) o;
208+
Group group = (Group) obj;
207209
return Objects.equals(type(), group.type()) && Objects.equals(identifier, group.identifier);
208210
}
209211

@@ -288,14 +290,14 @@ public String email() {
288290
}
289291

290292
@Override
291-
public boolean equals(Object o) {
292-
if (this == o) {
293+
public boolean equals(Object obj) {
294+
if (this == obj) {
293295
return true;
294296
}
295-
if (o == null || getClass() != o.getClass()) {
297+
if (obj == null || getClass() != obj.getClass()) {
296298
return false;
297299
}
298-
User user = (User) o;
300+
User user = (User) obj;
299301
return Objects.equals(type(), user.type()) && Objects.equals(email, user.email);
300302
}
301303

@@ -341,14 +343,14 @@ public TableId id() {
341343
}
342344

343345
@Override
344-
public boolean equals(Object o) {
345-
if (this == o) {
346+
public boolean equals(Object obj) {
347+
if (this == obj) {
346348
return true;
347349
}
348-
if (o == null || getClass() != o.getClass()) {
350+
if (obj == null || getClass() != obj.getClass()) {
349351
return false;
350352
}
351-
View view = (View) o;
353+
View view = (View) obj;
352354
return Objects.equals(type(), view.type()) && Objects.equals(id, view.id);
353355
}
354356

gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/BaseTableInfo.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import com.google.api.services.bigquery.model.Table;
2525
import com.google.common.base.Function;
2626
import com.google.common.base.MoreObjects;
27+
import com.google.common.base.MoreObjects.ToStringHelper;
2728

2829
import java.io.Serializable;
2930
import java.math.BigInteger;
@@ -63,12 +64,14 @@ public enum Type {
6364
* A normal BigQuery table.
6465
*/
6566
TABLE,
67+
6668
/**
6769
* A virtual table defined by a SQL query.
6870
*
6971
* @see <a href="https://cloud.google.com/bigquery/querying-data#views">Views</a>
7072
*/
7173
VIEW,
74+
7275
/**
7376
* A BigQuery table backed by external data.
7477
*
@@ -137,7 +140,7 @@ public boolean equals(Object obj) {
137140
&& Objects.equals(toPb(), ((StreamingBuffer) obj).toPb());
138141
}
139142

140-
public Streamingbuffer toPb() {
143+
Streamingbuffer toPb() {
141144
return new Streamingbuffer()
142145
.setEstimatedBytes(BigInteger.valueOf(estimatedBytes))
143146
.setEstimatedRows(BigInteger.valueOf(estimatedRows))
@@ -165,7 +168,7 @@ static StreamingBuffer fromPb(Streamingbuffer streamingBufferPb) {
165168
private final Long expirationTime;
166169
private final Long lastModifiedTime;
167170

168-
public static abstract class Builder<T extends BaseTableInfo, B extends Builder<T, B>> {
171+
public abstract static class Builder<T extends BaseTableInfo, B extends Builder<T, B>> {
169172

170173
private String etag;
171174
private String id;
@@ -429,7 +432,7 @@ public Long lastModifiedTime() {
429432
*/
430433
public abstract Builder toBuilder();
431434

432-
protected MoreObjects.ToStringHelper toStringHelper() {
435+
ToStringHelper toStringHelper() {
433436
return MoreObjects.toStringHelper(this)
434437
.add("tableId", tableId)
435438
.add("type", type)

gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/CsvOptions.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,9 @@ public Integer skipLeadingRows() {
190190
return skipLeadingRows;
191191
}
192192

193+
/**
194+
* Returns a builder for the {@code CsvOptions} object.
195+
*/
193196
public Builder toBuilder() {
194197
return new Builder()
195198
.allowJaggedRows(allowJaggedRows)

gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/DatasetId.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public class DatasetId implements Serializable {
3434
private final String dataset;
3535

3636
/**
37-
* Returns project's user-defined id
37+
* Returns project's user-defined id.
3838
*/
3939
public String project() {
4040
return project;
@@ -81,11 +81,11 @@ public String toString() {
8181
return toPb().toString();
8282
}
8383

84-
public DatasetReference toPb() {
84+
DatasetReference toPb() {
8585
return new DatasetReference().setProjectId(project).setDatasetId(dataset);
8686
}
8787

88-
public static DatasetId fromPb(DatasetReference datasetRef) {
88+
static DatasetId fromPb(DatasetReference datasetRef) {
8989
return new DatasetId(
9090
datasetRef.getProjectId(),
9191
datasetRef.getDatasetId());

gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/DatasetInfo.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -384,8 +384,8 @@ static DatasetInfo fromPb(Dataset datasetPb) {
384384
builder.acl(Lists.transform(datasetPb.getAccess(),
385385
new Function<Dataset.Access, Acl>() {
386386
@Override
387-
public Acl apply(Dataset.Access f) {
388-
return Acl.fromPb(f);
387+
public Acl apply(Dataset.Access accessPb) {
388+
return Acl.fromPb(accessPb);
389389
}
390390
}));
391391
}

gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/ExternalTableInfo.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
import static com.google.common.base.Preconditions.checkNotNull;
2020

2121
import com.google.api.services.bigquery.model.Table;
22-
import com.google.common.base.MoreObjects;
22+
import com.google.common.base.MoreObjects.ToStringHelper;
2323

2424
/**
2525
* Google BigQuery External Table information. BigQuery's external tables are tables whose data
@@ -100,7 +100,7 @@ private ExternalTableInfo(Builder builder) {
100100
*/
101101
public ExternalDataConfiguration configuration() {
102102
return configuration;
103-
};
103+
}
104104

105105
/**
106106
* Returns information on the table's streaming buffer if any exists. Returns {@code null} if no
@@ -119,7 +119,7 @@ public Builder toBuilder() {
119119
}
120120

121121
@Override
122-
protected MoreObjects.ToStringHelper toStringHelper() {
122+
ToStringHelper toStringHelper() {
123123
return super.toStringHelper()
124124
.add("configuration", configuration)
125125
.add("streamingBuffer", streamingBuffer);

gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/Field.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@
3232
import java.util.Objects;
3333

3434
/**
35-
* Google BigQuery Table field. A table field has a name, a value, a mode and possibly a description.
36-
* Supported types are: {@link Type#integer()}, {@link Type#bool()}, {@link Type#string()},
37-
* {@link Type#floatingPoint()}, {@link Type#timestamp()} and {@link Type#record(Field...)}. One or
38-
* more fields form a table's schema.
35+
* Google BigQuery Table field. A table field has a name, a value, a mode and possibly a
36+
* description. Supported types are: {@link Type#integer()}, {@link Type#bool()},
37+
* {@link Type#string()}, {@link Type#floatingPoint()}, {@link Type#timestamp()} and
38+
* {@link Type#record(Field...)}. One or more fields form a table's schema.
3939
*/
4040
public class Field implements Serializable {
4141

gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/JobId.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@ public String job() {
4747
return job;
4848
}
4949

50-
private JobId(String project, String dataset) {
50+
private JobId(String project, String job) {
5151
this.project = project;
52-
this.job = dataset;
52+
this.job = job;
5353
}
5454

5555
/**

gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/JobInfo.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ public String userEmail() {
241241

242242
ToStringHelper toStringHelper() {
243243
return MoreObjects.toStringHelper(this)
244-
.add("jobId", jobId)
244+
.add("job", jobId)
245245
.add("status", status)
246246
.add("statistics", statistics)
247247
.add("userEmail", userEmail)

gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/QueryRequest.java

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,34 @@
2727
* Google Cloud BigQuery Query Request. This class can be used to run a BigQuery SQL query and
2828
* return results if the query completes within a specified timeout. The query results are saved to
2929
* a temporary table that is deleted approximately 24 hours after the query is run. The query is run
30-
* through a BigQuery Job whose identity can be accessed via {@link QueryResponse#jobId()}.
30+
* through a BigQuery Job whose identity can be accessed via {@link QueryResponse#jobId()}. If the
31+
* query does not complete within the provided {@link Builder#maxWaitTime(Long)} the response
32+
* returned by {@link BigQuery#query(QueryRequest)} will have {@link QueryResponse#jobComplete()}
33+
* set to {@code false} and {@link QueryResponse#result()} set to {@code null}. To obtain query
34+
* results you can use {@link BigQuery#getQueryResults(JobId, BigQuery.QueryResultsOption...)} until
35+
* {@link QueryResponse#jobComplete()} returns {@code true}.
36+
*
37+
* <p>Example usage of a query request:
38+
* <pre> {@code
39+
* QueryRequest request = QueryRequest.builder("SELECT field FROM table")
40+
* .defaultDataset(DatasetId.of("dataset"))
41+
* .maxWaitTime(60000L)
42+
* .maxResults(1000L)
43+
* .build();
44+
* QueryResponse response = bigquery.query(request);
45+
* while (!response.jobComplete()) {
46+
* Thread.sleep(1000);
47+
* response = bigquery.getQueryResults(response.jobId());
48+
* }
49+
* List<BigQueryError> executionErrors = response.executionErrors();
50+
* // look for errors in executionErrors
51+
* QueryResult result = response.result();
52+
* Iterator<List<FieldValue>> rowIterator = result.iterateAll();
53+
* while(rowIterator.hasNext()) {
54+
* List<FieldValue> row = rowIterator.next();
55+
* // do something with row
56+
* }
57+
* }</pre>
3158
*
3259
* @see <a href="https://cloud.google.com/bigquery/docs/reference/v2/jobs/query">Query</a>
3360
* @see <a href="https://cloud.google.com/bigquery/query-reference">Query Reference</a>

0 commit comments

Comments
 (0)