Skip to content

Commit 48dcb46

Browse files
committed
---
yaml --- r: 6711 b: refs/heads/tswast-patch-1 c: b1ff62b h: refs/heads/master i: 6709: 26755da 6707: 7f3485f 6703: c2fa923
1 parent 9fa60f3 commit 48dcb46

43 files changed

Lines changed: 2129 additions & 184 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
@@ -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: 13b1b0e5ab44cb19c0802fcac992baa0bac9c8f7
60+
refs/heads/tswast-patch-1: b1ff62bf6b117ded6090e7447e0c55e940e8ffcf
6161
refs/heads/pubsub-streaming-pull: 19262b752ee874eb2ca3b950eb2aef44d5a5267b

branches/tswast-patch-1/CONTRIBUTING.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,20 @@ Using maven for build/test
1515
After you cloned the repository use Maven for building and running the tests.
1616
Maven 3.0+ is required.
1717

18+
When downloading the source, we recommend you obtain service account credentials.
19+
These credentials will allow you to run integration tests using `mvn verify` in command line.
20+
Follow step 2 of the [authentication instructions](https://github.com/GoogleCloudPlatform/gcloud-java#authentication) to generate and use JSON service account credentials.
21+
22+
It's also important to test that changes don't break compatibility with App/Compute Engine and when running elsewhere.
23+
To run tests on different platforms, try deploying the apps available on the [gcloud-java-examples](https://github.com/GoogleCloudPlatform/gcloud-java-examples) repository.
24+
End-to-end tests should ensure that gcloud-java works when running on the
25+
26+
* App Engine production environment (see the docs for [uploading your app to production App Engine](https://cloud.google.com/appengine/docs/java/tools/maven#uploading_your_app_to_production_app_engine))
27+
* App Engine development server (see the docs for [testing your app with the development server](https://cloud.google.com/appengine/docs/java/tools/maven#testing_your_app_with_the_development_server))
28+
* Compute Engine (see the [Getting Started Guide](https://cloud.google.com/compute/docs/quickstart), and be sure to [enable the appropriate APIs](https://github.com/GoogleCloudPlatform/gcloud-common/tree/master/authentication#on-google-compute-engine))
29+
* Your desktop (using `mvn exec:java`, for example)
30+
31+
When changes are made to authentication and project ID-related code, authentication and project ID inference should be tested using all relevant methods detailed in the [authentication docs](https://github.com/GoogleCloudPlatform/gcloud-java#authentication) and [project ID docs](https://github.com/GoogleCloudPlatform/gcloud-java#specifying-a-project-id).
1832

1933
Adding Features
2034
---------------

branches/tswast-patch-1/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)
1516
- [Google Cloud Datastore] (#google-cloud-datastore)
16-
- [Google Cloud Storage] (#google-cloud-storage)
1717
- [Google Cloud Resource Manager] (#google-cloud-resource-manager)
18-
- [Google Cloud BigQuery] (#google-cloud-bigquery)
18+
- [Google Cloud Storage] (#google-cloud-storage)
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).
4547
- [`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
4648
- 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).
47-
- [`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
48-
- 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).
4949
- [`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
5050
- 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).
51+
- [`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
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/StorageExample.html).
5353

5454
Specifying a Project ID
5555
-----------------------
@@ -109,6 +109,51 @@ 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+
112157
Google Cloud Datastore
113158
----------------------
114159
@@ -149,45 +194,6 @@ if (entity == null) {
149194
}
150195
```
151196
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-
191197
Google Cloud Resource Manager
192198
----------------------
193199
@@ -219,48 +225,42 @@ while (projectIterator.hasNext()) {
219225
}
220226
```
221227
222-
Google Cloud BigQuery
228+
Google Cloud Storage
223229
----------------------
224230
225-
- [API Documentation][bigquery-api]
226-
- [Official Documentation][cloud-bigquery-docs]
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.*
227235
228236
#### Preview
229237
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.
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.
232239
233240
```java
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;
241+
import static java.nio.charset.StandardCharsets.UTF_8;
243242
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)));
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;
250+
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));
251257
} else {
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-
}
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();
264264
}
265265
```
266266

branches/tswast-patch-1/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;

0 commit comments

Comments
 (0)