Skip to content

Commit 433c286

Browse files
committed
Merge pull request #482 from mziccard/bigquery
Make checkstyle happy, remove StreamingBuffer from external tables
2 parents 814264a + f569bdd commit 433c286

21 files changed

Lines changed: 184 additions & 171 deletions

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: 5 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@
2020
import static com.google.common.base.Preconditions.checkNotNull;
2121

2222
import com.google.api.client.util.Data;
23-
import com.google.api.services.bigquery.model.Streamingbuffer;
2423
import com.google.api.services.bigquery.model.Table;
2524
import com.google.common.base.Function;
2625
import com.google.common.base.MoreObjects;
26+
import com.google.common.base.MoreObjects.ToStringHelper;
2727

2828
import java.io.Serializable;
2929
import java.math.BigInteger;
@@ -63,12 +63,14 @@ public enum Type {
6363
* A normal BigQuery table.
6464
*/
6565
TABLE,
66+
6667
/**
6768
* A virtual table defined by a SQL query.
6869
*
6970
* @see <a href="https://cloud.google.com/bigquery/querying-data#views">Views</a>
7071
*/
7172
VIEW,
73+
7274
/**
7375
* A BigQuery table backed by external data.
7476
*
@@ -78,79 +80,6 @@ public enum Type {
7880
EXTERNAL
7981
}
8082

81-
/**
82-
* Google BigQuery Table's Streaming Buffer information. This class contains information on a
83-
* table's streaming buffer as the estimated size in number of rows/bytes.
84-
*/
85-
public static class StreamingBuffer implements Serializable {
86-
87-
private static final long serialVersionUID = -6713971364725267597L;
88-
private final long estimatedRows;
89-
private final long estimatedBytes;
90-
private final long oldestEntryTime;
91-
92-
StreamingBuffer(long estimatedRows, long estimatedBytes, long oldestEntryTime) {
93-
this.estimatedRows = estimatedRows;
94-
this.estimatedBytes = estimatedBytes;
95-
this.oldestEntryTime = oldestEntryTime;
96-
}
97-
98-
/**
99-
* Returns a lower-bound estimate of the number of rows currently in the streaming buffer.
100-
*/
101-
public long estimatedRows() {
102-
return estimatedRows;
103-
}
104-
105-
/**
106-
* Returns a lower-bound estimate of the number of bytes currently in the streaming buffer.
107-
*/
108-
public long estimatedBytes() {
109-
return estimatedBytes;
110-
}
111-
112-
/**
113-
* Returns the timestamp of the oldest entry in the streaming buffer, in milliseconds since
114-
* epoch.
115-
*/
116-
public long oldestEntryTime() {
117-
return oldestEntryTime;
118-
}
119-
120-
@Override
121-
public String toString() {
122-
return MoreObjects.toStringHelper(this)
123-
.add("estimatedRows", estimatedRows)
124-
.add("estimatedBytes", estimatedBytes)
125-
.add("oldestEntryTime", oldestEntryTime)
126-
.toString();
127-
}
128-
129-
@Override
130-
public int hashCode() {
131-
return Objects.hash(estimatedRows, estimatedBytes, oldestEntryTime);
132-
}
133-
134-
@Override
135-
public boolean equals(Object obj) {
136-
return obj instanceof StreamingBuffer
137-
&& Objects.equals(toPb(), ((StreamingBuffer) obj).toPb());
138-
}
139-
140-
public Streamingbuffer toPb() {
141-
return new Streamingbuffer()
142-
.setEstimatedBytes(BigInteger.valueOf(estimatedBytes))
143-
.setEstimatedRows(BigInteger.valueOf(estimatedRows))
144-
.setOldestEntryTime(BigInteger.valueOf(oldestEntryTime));
145-
}
146-
147-
static StreamingBuffer fromPb(Streamingbuffer streamingBufferPb) {
148-
return new StreamingBuffer(streamingBufferPb.getEstimatedRows().longValue(),
149-
streamingBufferPb.getEstimatedBytes().longValue(),
150-
streamingBufferPb.getOldestEntryTime().longValue());
151-
}
152-
}
153-
15483
private final String etag;
15584
private final String id;
15685
private final String selfLink;
@@ -165,7 +94,7 @@ static StreamingBuffer fromPb(Streamingbuffer streamingBufferPb) {
16594
private final Long expirationTime;
16695
private final Long lastModifiedTime;
16796

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

17099
private String etag;
171100
private String id;
@@ -429,7 +358,7 @@ public Long lastModifiedTime() {
429358
*/
430359
public abstract Builder toBuilder();
431360

432-
protected MoreObjects.ToStringHelper toStringHelper() {
361+
ToStringHelper toStringHelper() {
433362
return MoreObjects.toStringHelper(this)
434363
.add("tableId", tableId)
435364
.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: 7 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -19,34 +19,31 @@
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
2626
* reside outside of BigQuery but can be queried as normal BigQuery tables. External tables are
2727
* experimental and might be subject to change or removed.
2828
*
29-
* @see <a href="https://cloud.google.com/bigquery/federated-data-sources">Federated Data
30-
* Sources</a>
29+
* @see <a href="https://cloud.google.com/bigquery/federated-data-sources">Federated Data Sources
30+
* </a>
3131
*/
3232
public class ExternalTableInfo extends BaseTableInfo {
3333

3434
private static final long serialVersionUID = -5893406738246214865L;
3535

3636
private final ExternalDataConfiguration configuration;
37-
private final StreamingBuffer streamingBuffer;
3837

3938
public static final class Builder extends BaseTableInfo.Builder<ExternalTableInfo, Builder> {
4039

4140
private ExternalDataConfiguration configuration;
42-
private StreamingBuffer streamingBuffer;
4341

4442
private Builder() {}
4543

4644
private Builder(ExternalTableInfo tableInfo) {
4745
super(tableInfo);
4846
this.configuration = tableInfo.configuration;
49-
this.streamingBuffer = tableInfo.streamingBuffer;
5047
}
5148

5249
protected Builder(Table tablePb) {
@@ -55,9 +52,6 @@ protected Builder(Table tablePb) {
5552
this.configuration =
5653
ExternalDataConfiguration.fromPb(tablePb.getExternalDataConfiguration());
5754
}
58-
if (tablePb.getStreamingBuffer() != null) {
59-
this.streamingBuffer = StreamingBuffer.fromPb(tablePb.getStreamingBuffer());
60-
}
6155
}
6256

6357
/**
@@ -71,11 +65,6 @@ public Builder configuration(ExternalDataConfiguration configuration) {
7165
return self();
7266
}
7367

74-
Builder streamingBuffer(StreamingBuffer streamingBuffer) {
75-
this.streamingBuffer = streamingBuffer;
76-
return self();
77-
}
78-
7968
/**
8069
* Creates a {@code ExternalTableInfo} object.
8170
*/
@@ -88,26 +77,17 @@ public ExternalTableInfo build() {
8877
private ExternalTableInfo(Builder builder) {
8978
super(builder);
9079
this.configuration = builder.configuration;
91-
this.streamingBuffer = builder.streamingBuffer;
9280
}
9381

9482
/**
9583
* Returns the data format, location and other properties of a table stored outside of BigQuery.
9684
* This property is experimental and might be subject to change or removed.
9785
*
98-
* @see <a href="https://cloud.google.com/bigquery/federated-data-sources">Federated Data
99-
* Sources</a>
86+
* @see <a href="https://cloud.google.com/bigquery/federated-data-sources">Federated Data Sources
87+
* </a>
10088
*/
10189
public ExternalDataConfiguration configuration() {
10290
return configuration;
103-
};
104-
105-
/**
106-
* Returns information on the table's streaming buffer if any exists. Returns {@code null} if no
107-
* streaming buffer exists.
108-
*/
109-
public StreamingBuffer streamingBuffer() {
110-
return streamingBuffer;
11191
}
11292

11393
/**
@@ -119,19 +99,14 @@ public Builder toBuilder() {
11999
}
120100

121101
@Override
122-
protected MoreObjects.ToStringHelper toStringHelper() {
123-
return super.toStringHelper()
124-
.add("configuration", configuration)
125-
.add("streamingBuffer", streamingBuffer);
102+
ToStringHelper toStringHelper() {
103+
return super.toStringHelper().add("configuration", configuration);
126104
}
127105

128106
@Override
129107
Table toPb() {
130108
Table tablePb = super.toPb();
131109
tablePb.setExternalDataConfiguration(configuration.toPb());
132-
if (streamingBuffer != null) {
133-
tablePb.setStreamingBuffer(streamingBuffer.toPb());
134-
}
135110
return tablePb;
136111
}
137112

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

0 commit comments

Comments
 (0)