Skip to content

Commit ae9c35b

Browse files
author
Ajay Kannan
committed
---
yaml --- r: 2641 b: refs/heads/update-datastore c: edfb470 h: refs/heads/master i: 2639: d80ea15
1 parent 29734eb commit ae9c35b

27 files changed

Lines changed: 234 additions & 328 deletions

File tree

[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: 823f0de985d9217d9c3fe81af7e6054d9d6da18c
8+
refs/heads/update-datastore: edfb4707e6ae51b8bc15f4afb9dc1d44708dd08b
99
refs/tags/0.0.9: 22f1839238f66c39e67ed4dfdcd273b1ae2e8444
1010
refs/tags/v0.0.10: 207ebd2a3472fddee69fe1298eb90429e3306efd
1111
refs/tags/v0.0.11: ffbfba48a6426ff63c08ff2117e58681f251fbf2

branches/update-datastore/README.md

Lines changed: 78 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ Java idiomatic client for [Google Cloud Platform][cloud-platform] services.
1212

1313
This client supports the following Google Cloud Platform services:
1414

15-
- [Google Cloud BigQuery] (#google-cloud-bigquery)
1615
- [Google Cloud Datastore] (#google-cloud-datastore)
17-
- [Google Cloud Resource Manager] (#google-cloud-resource-manager)
1816
- [Google Cloud Storage] (#google-cloud-storage)
17+
- [Google Cloud Resource Manager] (#google-cloud-resource-manager)
18+
- [Google Cloud BigQuery] (#google-cloud-bigquery)
1919

2020
> Note: This client is a work-in-progress, and may occasionally
2121
> make backwards-incompatible changes.
@@ -42,14 +42,14 @@ libraryDependencies += "com.google.gcloud" % "gcloud-java" % "0.1.1"
4242
Example Applications
4343
--------------------
4444

45-
- [`BigQueryExample`](https://github.com/GoogleCloudPlatform/gcloud-java/blob/master/gcloud-java-examples/src/main/java/com/google/gcloud/examples/BigQueryExample.java) - A simple command line interface providing some of Cloud BigQuery's functionality
46-
- Read more about using this application on the [`gcloud-java-examples` docs page](http://googlecloudplatform.github.io/gcloud-java/apidocs/?com/google/gcloud/examples/BigQueryExample.html).
4745
- [`DatastoreExample`](https://github.com/GoogleCloudPlatform/gcloud-java/blob/master/gcloud-java-examples/src/main/java/com/google/gcloud/examples/DatastoreExample.java) - A simple command line interface for the Cloud Datastore
4846
- Read more about using this application on the [`gcloud-java-examples` docs page](http://googlecloudplatform.github.io/gcloud-java/apidocs/?com/google/gcloud/examples/DatastoreExample.html).
49-
- [`ResourceManagerExample`](https://github.com/GoogleCloudPlatform/gcloud-java/blob/master/gcloud-java-examples/src/main/java/com/google/gcloud/examples/ResourceManagerExample.java) - A simple command line interface providing some of Cloud Resource Manager's functionality
50-
- Read more about using this application on the [`gcloud-java-examples` docs page](http://googlecloudplatform.github.io/gcloud-java/apidocs/?com/google/gcloud/examples/ResourceManagerExample.html).
5147
- [`StorageExample`](https://github.com/GoogleCloudPlatform/gcloud-java/blob/master/gcloud-java-examples/src/main/java/com/google/gcloud/examples/StorageExample.java) - A simple command line interface providing some of Cloud Storage's functionality
5248
- Read more about using this application on the [`gcloud-java-examples` docs page](http://googlecloudplatform.github.io/gcloud-java/apidocs/?com/google/gcloud/examples/StorageExample.html).
49+
- [`ResourceManagerExample`](https://github.com/GoogleCloudPlatform/gcloud-java/blob/master/gcloud-java-examples/src/main/java/com/google/gcloud/examples/ResourceManagerExample.java) - A simple command line interface providing some of Cloud Resource Manager's functionality
50+
- Read more about using this application on the [`gcloud-java-examples` docs page](http://googlecloudplatform.github.io/gcloud-java/apidocs/?com/google/gcloud/examples/ResourceManagerExample.html).
51+
- [`BigQueryExample`](https://github.com/GoogleCloudPlatform/gcloud-java/blob/master/gcloud-java-examples/src/main/java/com/google/gcloud/examples/BigQueryExample.java) - A simple command line interface providing some of Cloud BigQuery's functionality
52+
- Read more about using this application on the [`gcloud-java-examples` docs page](http://googlecloudplatform.github.io/gcloud-java/apidocs/?com/google/gcloud/examples/BigQueryExample.html).
5353

5454
Specifying a Project ID
5555
-----------------------
@@ -109,51 +109,6 @@ Next, choose a method for authenticating API requests from within your project:
109109
4. Google Cloud SDK credentials
110110
5. Compute Engine credentials
111111
112-
Google Cloud BigQuery
113-
----------------------
114-
115-
- [API Documentation][bigquery-api]
116-
- [Official Documentation][cloud-bigquery-docs]
117-
118-
#### Preview
119-
120-
Here is a code snippet showing a simple usage example from within Compute/App Engine. Note that you
121-
must [supply credentials](#authentication) and a project ID if running this snippet elsewhere.
122-
123-
```java
124-
import com.google.gcloud.bigquery.BaseTableInfo;
125-
import com.google.gcloud.bigquery.BigQuery;
126-
import com.google.gcloud.bigquery.BigQueryOptions;
127-
import com.google.gcloud.bigquery.Field;
128-
import com.google.gcloud.bigquery.JobStatus;
129-
import com.google.gcloud.bigquery.LoadJobInfo;
130-
import com.google.gcloud.bigquery.Schema;
131-
import com.google.gcloud.bigquery.TableId;
132-
import com.google.gcloud.bigquery.TableInfo;
133-
134-
BigQuery bigquery = BigQueryOptions.defaultInstance().service();
135-
TableId tableId = TableId.of("dataset", "table");
136-
BaseTableInfo info = bigquery.getTable(tableId);
137-
if (info == null) {
138-
System.out.println("Creating table " + tableId);
139-
Field integerField = Field.of("fieldName", Field.Type.integer());
140-
bigquery.create(TableInfo.of(tableId, Schema.of(integerField)));
141-
} else {
142-
System.out.println("Loading data into table " + tableId);
143-
LoadJobInfo loadJob = LoadJobInfo.of(tableId, "gs://bucket/path");
144-
loadJob = bigquery.create(loadJob);
145-
while (loadJob.status().state() != JobStatus.State.DONE) {
146-
Thread.sleep(1000L);
147-
loadJob = bigquery.getJob(loadJob.jobId());
148-
}
149-
if (loadJob.status().error() != null) {
150-
System.out.println("Job completed with errors");
151-
} else {
152-
System.out.println("Job succeeded");
153-
}
154-
}
155-
```
156-
157112
Google Cloud Datastore
158113
----------------------
159114
@@ -194,6 +149,45 @@ if (entity == null) {
194149
}
195150
```
196151
152+
Google Cloud Storage
153+
----------------------
154+
155+
- [API Documentation][storage-api]
156+
- [Official Documentation][cloud-storage-docs]
157+
158+
*Follow the [activation instructions][cloud-storage-activation] to use the Google Cloud Storage API with your project.*
159+
160+
#### Preview
161+
162+
Here is a code snippet showing a simple usage example from within Compute/App Engine. Note that you must [supply credentials](#authentication) and a project ID if running this snippet elsewhere.
163+
164+
```java
165+
import static java.nio.charset.StandardCharsets.UTF_8;
166+
167+
import com.google.gcloud.storage.Blob;
168+
import com.google.gcloud.storage.BlobId;
169+
import com.google.gcloud.storage.Storage;
170+
import com.google.gcloud.storage.StorageOptions;
171+
172+
import java.nio.ByteBuffer;
173+
import java.nio.channels.WritableByteChannel;
174+
175+
Storage storage = StorageOptions.defaultInstance().service();
176+
BlobId blobId = BlobId.of("bucket", "blob_name");
177+
Blob blob = Blob.load(storage, blobId);
178+
if (blob == null) {
179+
BlobInfo blobInfo = BlobInfo.builder(blobId).contentType("text/plain").build();
180+
storage.create(blobInfo, "Hello, Cloud Storage!".getBytes(UTF_8));
181+
} else {
182+
System.out.println("Updating content for " + blobId.name());
183+
byte[] prevContent = blob.content();
184+
System.out.println(new String(prevContent, UTF_8));
185+
WritableByteChannel channel = blob.writer();
186+
channel.write(ByteBuffer.wrap("Updated content".getBytes(UTF_8)));
187+
channel.close();
188+
}
189+
```
190+
197191
Google Cloud Resource Manager
198192
----------------------
199193
@@ -225,42 +219,48 @@ while (projectIterator.hasNext()) {
225219
}
226220
```
227221
228-
Google Cloud Storage
222+
Google Cloud BigQuery
229223
----------------------
230224
231-
- [API Documentation][storage-api]
232-
- [Official Documentation][cloud-storage-docs]
233-
234-
*Follow the [activation instructions][cloud-storage-activation] to use the Google Cloud Storage API with your project.*
225+
- [API Documentation][bigquery-api]
226+
- [Official Documentation][cloud-bigquery-docs]
235227
236228
#### Preview
237229
238-
Here is a code snippet showing a simple usage example from within Compute/App Engine. Note that you must [supply credentials](#authentication) and a project ID if running this snippet elsewhere.
230+
Here is a code snippet showing a simple usage example from within Compute/App Engine. Note that you
231+
must [supply credentials](#authentication) and a project ID if running this snippet elsewhere.
239232
240233
```java
241-
import static java.nio.charset.StandardCharsets.UTF_8;
242-
243-
import com.google.gcloud.storage.Blob;
244-
import com.google.gcloud.storage.BlobId;
245-
import com.google.gcloud.storage.Storage;
246-
import com.google.gcloud.storage.StorageOptions;
247-
248-
import java.nio.ByteBuffer;
249-
import java.nio.channels.WritableByteChannel;
234+
import com.google.gcloud.bigquery.BaseTableInfo;
235+
import com.google.gcloud.bigquery.BigQuery;
236+
import com.google.gcloud.bigquery.BigQueryOptions;
237+
import com.google.gcloud.bigquery.Field;
238+
import com.google.gcloud.bigquery.JobStatus;
239+
import com.google.gcloud.bigquery.LoadJobInfo;
240+
import com.google.gcloud.bigquery.Schema;
241+
import com.google.gcloud.bigquery.TableId;
242+
import com.google.gcloud.bigquery.TableInfo;
250243
251-
Storage storage = StorageOptions.defaultInstance().service();
252-
BlobId blobId = BlobId.of("bucket", "blob_name");
253-
Blob blob = Blob.load(storage, blobId);
254-
if (blob == null) {
255-
BlobInfo blobInfo = BlobInfo.builder(blobId).contentType("text/plain").build();
256-
storage.create(blobInfo, "Hello, Cloud Storage!".getBytes(UTF_8));
244+
BigQuery bigquery = BigQueryOptions.defaultInstance().service();
245+
TableId tableId = TableId.of("dataset", "table");
246+
BaseTableInfo info = bigquery.getTable(tableId);
247+
if (info == null) {
248+
System.out.println("Creating table " + tableId);
249+
Field integerField = Field.of("fieldName", Field.Type.integer());
250+
bigquery.create(TableInfo.of(tableId, Schema.of(integerField)));
257251
} else {
258-
System.out.println("Updating content for " + blobId.name());
259-
byte[] prevContent = blob.content();
260-
System.out.println(new String(prevContent, UTF_8));
261-
WritableByteChannel channel = blob.writer();
262-
channel.write(ByteBuffer.wrap("Updated content".getBytes(UTF_8)));
263-
channel.close();
252+
System.out.println("Loading data into table " + tableId);
253+
LoadJobInfo loadJob = LoadJobInfo.of(tableId, "gs://bucket/path");
254+
loadJob = bigquery.create(loadJob);
255+
while (loadJob.status().state() != JobStatus.State.DONE) {
256+
Thread.sleep(1000L);
257+
loadJob = bigquery.getJob(loadJob.jobId());
258+
}
259+
if (loadJob.status().error() != null) {
260+
System.out.println("Job completed with errors");
261+
} else {
262+
System.out.println("Job succeeded");
263+
}
264264
}
265265
```
266266

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,12 @@ public enum Type {
9494
private final Long expirationTime;
9595
private final Long lastModifiedTime;
9696

97+
/**
98+
* Base builder for tables.
99+
*
100+
* @param <T> the table type.
101+
* @param <B> the table builder.
102+
*/
97103
public abstract static class Builder<T extends BaseTableInfo, B extends Builder<T, B>> {
98104

99105
private String etag;

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,6 @@ public InsertAllResponse insertAll(InsertAllRequest request) throws BigQueryExce
412412
final TableDataInsertAllRequest requestPb = new TableDataInsertAllRequest();
413413
requestPb.setIgnoreUnknownValues(request.ignoreUnknownValues());
414414
requestPb.setSkipInvalidRows(request.skipInvalidRows());
415-
requestPb.setTemplateSuffix(request.templateSuffix());
416415
List<Rows> rowsPb = Lists.transform(request.rows(), new Function<RowToInsert, Rows>() {
417416
@Override
418417
public Rows apply(RowToInsert rowToInsert) {

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616

1717
package com.google.gcloud.bigquery;
1818

19-
import static com.google.common.base.Preconditions.checkNotNull;
20-
2119
import com.google.common.base.MoreObjects;
2220

2321
import java.io.Serializable;
@@ -87,7 +85,7 @@ public static FormatOptions datastoreBackup() {
8785
* Default options for the provided format.
8886
*/
8987
public static FormatOptions of(String format) {
90-
if (checkNotNull(format).equals(CSV)) {
88+
if (format.equals(CSV)) {
9189
return csv();
9290
}
9391
return new FormatOptions(format);

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

Lines changed: 2 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ public class InsertAllRequest implements Serializable {
4545
private final List<RowToInsert> rows;
4646
private final Boolean skipInvalidRows;
4747
private final Boolean ignoreUnknownValues;
48-
private final String templateSuffix;
4948

5049
/**
5150
* A Google Big Query row to be inserted into a table. Each {@code RowToInsert} has an associated
@@ -141,7 +140,6 @@ public static final class Builder {
141140
private List<RowToInsert> rows;
142141
private Boolean skipInvalidRows;
143142
private Boolean ignoreUnknownValues;
144-
private String templateSuffix;
145143

146144
private Builder() {}
147145

@@ -233,20 +231,6 @@ public Builder ignoreUnknownValues(boolean ignoreUnknownValues) {
233231
return this;
234232
}
235233

236-
/**
237-
* If specified, the destination table is treated as a base template. Rows are inserted into an
238-
* instance table named "{destination}{templateSuffix}". BigQuery will manage the creation of
239-
* the instance table, using the schema of the base template table.
240-
*
241-
* @see <a
242-
* href="https://cloud.google.com/bigquery/streaming-data-into-bigquery#template-tables">
243-
* Template Tables</a>
244-
*/
245-
public Builder templateSuffix(String templateSuffix) {
246-
this.templateSuffix = templateSuffix;
247-
return this;
248-
}
249-
250234
public InsertAllRequest build() {
251235
return new InsertAllRequest(this);
252236
}
@@ -257,7 +241,6 @@ private InsertAllRequest(Builder builder) {
257241
this.rows = ImmutableList.copyOf(checkNotNull(builder.rows));
258242
this.ignoreUnknownValues = builder.ignoreUnknownValues;
259243
this.skipInvalidRows = builder.skipInvalidRows;
260-
this.templateSuffix = builder.templateSuffix;
261244
}
262245

263246
/**
@@ -290,19 +273,6 @@ public Boolean skipInvalidRows() {
290273
return skipInvalidRows;
291274
}
292275

293-
/**
294-
* If specified, the destination table is treated as a base template. Rows are inserted into an
295-
* instance table named "{destination}{templateSuffix}". BigQuery will manage the creation of the
296-
* instance table, using the schema of the base template table.
297-
*
298-
* @see <a
299-
* href="https://cloud.google.com/bigquery/streaming-data-into-bigquery#template-tables">
300-
* Template Tables</a>
301-
*/
302-
public String templateSuffix() {
303-
return templateSuffix;
304-
}
305-
306276
/**
307277
* Returns a builder for an {@code InsertAllRequest} object given the destination table.
308278
*/
@@ -414,13 +384,12 @@ public String toString() {
414384
.add("rows", rows)
415385
.add("ignoreUnknownValues", ignoreUnknownValues)
416386
.add("skipInvalidRows", skipInvalidRows)
417-
.add("templateSuffix", templateSuffix)
418387
.toString();
419388
}
420389

421390
@Override
422391
public int hashCode() {
423-
return Objects.hash(table, rows, ignoreUnknownValues, skipInvalidRows, templateSuffix);
392+
return Objects.hash(table, rows, ignoreUnknownValues, skipInvalidRows);
424393
}
425394

426395
@Override
@@ -432,7 +401,6 @@ public boolean equals(Object obj) {
432401
return Objects.equals(table, other.table)
433402
&& Objects.equals(rows, other.rows)
434403
&& Objects.equals(ignoreUnknownValues, other.ignoreUnknownValues)
435-
&& Objects.equals(skipInvalidRows, other.skipInvalidRows)
436-
&& Objects.equals(templateSuffix, other.templateSuffix);
404+
&& Objects.equals(skipInvalidRows, other.skipInvalidRows);
437405
}
438406
}

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
* a table. Use {@link QueryJobInfo} for a job that runs a query.
3333
*
3434
* @see <a href="https://cloud.google.com/bigquery/docs/reference/v2/jobs">Jobs</a>
35+
*
36+
* @param <S> the statistics type.
3537
*/
3638
public abstract class JobInfo<S extends JobStatistics> implements Serializable {
3739

@@ -87,6 +89,13 @@ public enum WriteDisposition {
8789
private final S statistics;
8890
private final String userEmail;
8991

92+
/**
93+
* Base builder for jobs.
94+
*
95+
* @param <T> the job type.
96+
* @param <S> the job statistics type.
97+
* @param <B> the job builder.
98+
*/
9099
public abstract static class Builder<T extends JobInfo, S extends JobStatistics,
91100
B extends Builder<T, S, B>> {
92101

branches/update-datastore/gcloud-java-bigquery/src/test/java/com/google/gcloud/bigquery/BigQueryImplTest.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -614,7 +614,6 @@ public void testInsertAll() {
614614
.rows(rows)
615615
.skipInvalidRows(false)
616616
.ignoreUnknownValues(true)
617-
.templateSuffix("suffix")
618617
.build();
619618
TableDataInsertAllRequest requestPb = new TableDataInsertAllRequest().setRows(
620619
Lists.transform(rows, new Function<RowToInsert, TableDataInsertAllRequest.Rows>() {
@@ -624,7 +623,7 @@ public TableDataInsertAllRequest.Rows apply(RowToInsert rowToInsert) {
624623
.setJson(rowToInsert.content());
625624
}
626625
})
627-
).setSkipInvalidRows(false).setIgnoreUnknownValues(true).setTemplateSuffix("suffix");
626+
).setSkipInvalidRows(false).setIgnoreUnknownValues(true);
628627
TableDataInsertAllResponse responsePb = new TableDataInsertAllResponse().setInsertErrors(
629628
ImmutableList.of(new TableDataInsertAllResponse.InsertErrors().setIndex(0L).setErrors(
630629
ImmutableList.of(new ErrorProto().setMessage("ErrorMessage")))));

0 commit comments

Comments
 (0)