Skip to content

Commit 454a8a6

Browse files
committed
---
yaml --- r: 6461 b: refs/heads/tswast-patch-1 c: f569bdd h: refs/heads/master i: 6459: 6d5a31d
1 parent 9e21b00 commit 454a8a6

10 files changed

Lines changed: 95 additions & 119 deletions

File tree

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,5 +57,5 @@ refs/tags/v0.18.0: 9d193c4c4b9d1c6f21515dd8e50836b9194ec9bb
5757
refs/tags/v0.19.0: e67b56e4d8dad5f9a7b38c9b2107c23c828f2ed5
5858
refs/tags/v0.20.0: 839f7fb7156535146aa1cb2c5aadd8d375d854e8
5959
refs/tags/v0.20.1: 370471f437f1f4f68a11e068df5cd6bf39edb1fa
60-
refs/heads/tswast-patch-1: e91f47b893db5a07b11c6d21299ae9a87165af7e
60+
refs/heads/tswast-patch-1: f569bddb8405cd485ce57206574af1f1eedc899b
6161
refs/heads/pubsub-streaming-pull: 19262b752ee874eb2ca3b950eb2aef44d5a5267b

branches/tswast-patch-1/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/BaseTableInfo.java

Lines changed: 0 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
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;
@@ -81,79 +80,6 @@ public enum Type {
8180
EXTERNAL
8281
}
8382

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

branches/tswast-patch-1/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/ExternalTableInfo.java

Lines changed: 5 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -26,27 +26,24 @@
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,28 +77,19 @@ 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;
10391
}
10492

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;
111-
}
112-
11393
/**
11494
* Returns a builder for the {@code ExternalTableInfo} object.
11595
*/
@@ -120,18 +100,13 @@ public Builder toBuilder() {
120100

121101
@Override
122102
ToStringHelper toStringHelper() {
123-
return super.toStringHelper()
124-
.add("configuration", configuration)
125-
.add("streamingBuffer", streamingBuffer);
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

branches/tswast-patch-1/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/QueryRequest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,15 @@
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
3030
* 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
31+
* query does not complete within the provided {@link Builder#maxWaitTime(Long)}, the response
3232
* returned by {@link BigQuery#query(QueryRequest)} will have {@link QueryResponse#jobComplete()}
3333
* set to {@code false} and {@link QueryResponse#result()} set to {@code null}. To obtain query
3434
* results you can use {@link BigQuery#getQueryResults(JobId, BigQuery.QueryResultsOption...)} until
3535
* {@link QueryResponse#jobComplete()} returns {@code true}.
3636
*
3737
* <p>Example usage of a query request:
3838
* <pre> {@code
39+
* // Substitute "field", "table" and "dataset" with real field, table and dataset identifiers
3940
* QueryRequest request = QueryRequest.builder("SELECT field FROM table")
4041
* .defaultDataset(DatasetId.of("dataset"))
4142
* .maxWaitTime(60000L)

branches/tswast-patch-1/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/TableInfo.java

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,15 @@
1616

1717
package com.google.gcloud.bigquery;
1818

19+
import com.google.api.services.bigquery.model.Streamingbuffer;
1920
import com.google.api.services.bigquery.model.Table;
21+
import com.google.common.base.MoreObjects;
2022
import com.google.common.base.MoreObjects.ToStringHelper;
2123

24+
import java.io.Serializable;
25+
import java.math.BigInteger;
26+
import java.util.Objects;
27+
2228
/**
2329
* A Google BigQuery Table information. A BigQuery table is a standard, two-dimensional table with
2430
* individual records organized in rows, and a data type assigned to each column (also called a
@@ -34,6 +40,79 @@ public class TableInfo extends BaseTableInfo {
3440
private final String location;
3541
private final StreamingBuffer streamingBuffer;
3642

43+
/**
44+
* Google BigQuery Table's Streaming Buffer information. This class contains information on a
45+
* table's streaming buffer as the estimated size in number of rows/bytes.
46+
*/
47+
public static class StreamingBuffer implements Serializable {
48+
49+
private static final long serialVersionUID = -6713971364725267597L;
50+
private final long estimatedRows;
51+
private final long estimatedBytes;
52+
private final long oldestEntryTime;
53+
54+
StreamingBuffer(long estimatedRows, long estimatedBytes, long oldestEntryTime) {
55+
this.estimatedRows = estimatedRows;
56+
this.estimatedBytes = estimatedBytes;
57+
this.oldestEntryTime = oldestEntryTime;
58+
}
59+
60+
/**
61+
* Returns a lower-bound estimate of the number of rows currently in the streaming buffer.
62+
*/
63+
public long estimatedRows() {
64+
return estimatedRows;
65+
}
66+
67+
/**
68+
* Returns a lower-bound estimate of the number of bytes currently in the streaming buffer.
69+
*/
70+
public long estimatedBytes() {
71+
return estimatedBytes;
72+
}
73+
74+
/**
75+
* Returns the timestamp of the oldest entry in the streaming buffer, in milliseconds since
76+
* epoch.
77+
*/
78+
public long oldestEntryTime() {
79+
return oldestEntryTime;
80+
}
81+
82+
@Override
83+
public String toString() {
84+
return MoreObjects.toStringHelper(this)
85+
.add("estimatedRows", estimatedRows)
86+
.add("estimatedBytes", estimatedBytes)
87+
.add("oldestEntryTime", oldestEntryTime)
88+
.toString();
89+
}
90+
91+
@Override
92+
public int hashCode() {
93+
return Objects.hash(estimatedRows, estimatedBytes, oldestEntryTime);
94+
}
95+
96+
@Override
97+
public boolean equals(Object obj) {
98+
return obj instanceof StreamingBuffer
99+
&& Objects.equals(toPb(), ((StreamingBuffer) obj).toPb());
100+
}
101+
102+
Streamingbuffer toPb() {
103+
return new Streamingbuffer()
104+
.setEstimatedBytes(BigInteger.valueOf(estimatedBytes))
105+
.setEstimatedRows(BigInteger.valueOf(estimatedRows))
106+
.setOldestEntryTime(BigInteger.valueOf(oldestEntryTime));
107+
}
108+
109+
static StreamingBuffer fromPb(Streamingbuffer streamingBufferPb) {
110+
return new StreamingBuffer(streamingBufferPb.getEstimatedRows().longValue(),
111+
streamingBufferPb.getEstimatedBytes().longValue(),
112+
streamingBufferPb.getOldestEntryTime().longValue());
113+
}
114+
}
115+
37116
public static final class Builder extends BaseTableInfo.Builder<TableInfo, Builder> {
38117

39118
private String location;

branches/tswast-patch-1/gcloud-java-bigquery/src/main/java/com/google/gcloud/spi/DefaultBigQueryRpc.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,8 @@ public Tuple<String, Iterable<Dataset>> listDatasets(Map<Option, ?> options)
122122
.execute();
123123
Iterable<DatasetList.Datasets> datasets = datasetsList.getDatasets();
124124
return Tuple.of(datasetsList.getNextPageToken(),
125-
Iterables.transform(datasets != null ? datasets :
126-
ImmutableList.<DatasetList.Datasets>of(),
125+
Iterables.transform(datasets != null ? datasets
126+
: ImmutableList.<DatasetList.Datasets>of(),
127127
new Function<DatasetList.Datasets, Dataset>() {
128128
@Override
129129
public Dataset apply(DatasetList.Datasets datasetPb) {

branches/tswast-patch-1/gcloud-java-bigquery/src/test/java/com/google/gcloud/bigquery/OptionTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public void testOption() {
3131
assertEquals("token", option.value());
3232
}
3333

34-
@Test(expected=NullPointerException.class)
34+
@Test(expected = NullPointerException.class)
3535
public void testNullRpcOption() {
3636
new Option(null, "token");
3737
}

branches/tswast-patch-1/gcloud-java-bigquery/src/test/java/com/google/gcloud/bigquery/QueryResultTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@
1616

1717
package com.google.gcloud.bigquery;
1818

19+
import static org.junit.Assert.assertEquals;
20+
1921
import com.google.common.collect.ImmutableList;
2022

2123
import org.junit.Test;
2224

2325
import java.util.List;
2426

25-
import static org.junit.Assert.assertEquals;
26-
2727
public class QueryResultTest {
2828

2929
private static final String CURSOR = "cursor";

branches/tswast-patch-1/gcloud-java-bigquery/src/test/java/com/google/gcloud/bigquery/SerializationTest.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import com.google.common.collect.ImmutableMap;
2424
import com.google.gcloud.AuthCredentials;
2525
import com.google.gcloud.RetryParams;
26+
import com.google.gcloud.bigquery.TableInfo.StreamingBuffer;
2627

2728
import org.junit.Test;
2829

@@ -94,8 +95,7 @@ public class SerializationTest {
9495
.description("FieldDescription3")
9596
.build();
9697
private static final Schema TABLE_SCHEMA = Schema.of(FIELD_SCHEMA1, FIELD_SCHEMA2, FIELD_SCHEMA3);
97-
private static final BaseTableInfo.StreamingBuffer STREAMING_BUFFER =
98-
new BaseTableInfo.StreamingBuffer(1L, 2L, 3L);
98+
private static final StreamingBuffer STREAMING_BUFFER = new StreamingBuffer(1L, 2L, 3L);
9999
private static final List<String> SOURCE_URIS = ImmutableList.of("uri1", "uri2");
100100
private static final ExternalDataConfiguration EXTERNAL_DATA_CONFIGURATION =
101101
ExternalDataConfiguration.builder(SOURCE_URIS, TABLE_SCHEMA, CSV_OPTIONS)
@@ -128,7 +128,6 @@ public class SerializationTest {
128128
.description(DESCRIPTION)
129129
.etag(ETAG)
130130
.id(ID)
131-
.streamingBuffer(STREAMING_BUFFER)
132131
.build();
133132
private static final JobStatistics JOB_STATISTICS = JobStatistics.builder()
134133
.creationTime(1L)

0 commit comments

Comments
 (0)