Skip to content

Commit 5b06b61

Browse files
committed
---
yaml --- r: 1655 b: refs/heads/master c: 3f39ab2 h: refs/heads/master i: 1653: af63142 1651: 7ede22d 1647: efa89f7
1 parent db7f6c3 commit 5b06b61

32 files changed

Lines changed: 1152 additions & 1555 deletions

File tree

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: cdec697470a3e55066936d7099a0f066ae5f3005
2+
refs/heads/master: 3f39ab2edf65cc2184baf0d2a964711ac98b02aa
33
refs/heads/travis: e21ee7b88a5edc3f3d8c71f90c3fc32abf7e8dd6
44
refs/heads/gh-pages: d1b373c30c176edc08692348167bec3a244bb823
55
refs/heads/bigquery: 762fa5830e6c398c0396177e3e7fd243bd62cfc3

trunk/README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,6 @@ Here is a code snippet showing a simple usage example from within Compute/App En
250250
import static java.nio.charset.StandardCharsets.UTF_8;
251251
252252
import com.google.gcloud.storage.Blob;
253-
import com.google.gcloud.storage.BlobInfo;
254253
import com.google.gcloud.storage.BlobId;
255254
import com.google.gcloud.storage.Storage;
256255
import com.google.gcloud.storage.StorageOptions;
@@ -260,7 +259,7 @@ import java.nio.channels.WritableByteChannel;
260259
261260
Storage storage = StorageOptions.defaultInstance().service();
262261
BlobId blobId = BlobId.of("bucket", "blob_name");
263-
Blob blob = storage.get(blobId);
262+
Blob blob = Blob.get(storage, blobId);
264263
if (blob == null) {
265264
BlobInfo blobInfo = BlobInfo.builder(blobId).contentType("text/plain").build();
266265
storage.create(blobInfo, "Hello, Cloud Storage!".getBytes(UTF_8));

trunk/gcloud-java-bigquery/pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?xml version="1.0"?>
22
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
33
<modelVersion>4.0.0</modelVersion>
4+
<groupId>com.google.gcloud</groupId>
45
<artifactId>gcloud-java-bigquery</artifactId>
56
<packaging>jar</packaging>
67
<name>GCloud Java bigquery</name>

trunk/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/Table.java

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -182,8 +182,7 @@ public boolean delete() {
182182
* @param rows rows to be inserted
183183
* @throws BigQueryException upon failure
184184
*/
185-
public InsertAllResponse insert(Iterable<InsertAllRequest.RowToInsert> rows)
186-
throws BigQueryException {
185+
InsertAllResponse insert(Iterable<InsertAllRequest.RowToInsert> rows) throws BigQueryException {
187186
return bigquery.insertAll(InsertAllRequest.of(tableId(), rows));
188187
}
189188

@@ -198,8 +197,8 @@ public InsertAllResponse insert(Iterable<InsertAllRequest.RowToInsert> rows)
198197
* to be invalid
199198
* @throws BigQueryException upon failure
200199
*/
201-
public InsertAllResponse insert(Iterable<InsertAllRequest.RowToInsert> rows,
202-
boolean skipInvalidRows, boolean ignoreUnknownValues) throws BigQueryException {
200+
InsertAllResponse insert(Iterable<InsertAllRequest.RowToInsert> rows, boolean skipInvalidRows,
201+
boolean ignoreUnknownValues) throws BigQueryException {
203202
InsertAllRequest request = InsertAllRequest.builder(tableId(), rows)
204203
.skipInvalidRows(skipInvalidRows)
205204
.ignoreUnknownValues(ignoreUnknownValues)
@@ -213,7 +212,7 @@ public InsertAllResponse insert(Iterable<InsertAllRequest.RowToInsert> rows,
213212
* @param options table data list options
214213
* @throws BigQueryException upon failure
215214
*/
216-
public Page<List<FieldValue>> list(BigQuery.TableDataListOption... options) throws BigQueryException {
215+
Page<List<FieldValue>> list(BigQuery.TableDataListOption... options) throws BigQueryException {
217216
return bigquery.listTableData(tableId(), options);
218217
}
219218

@@ -226,7 +225,7 @@ public Page<List<FieldValue>> list(BigQuery.TableDataListOption... options) thro
226225
* @param options job options
227226
* @throws BigQueryException upon failure
228227
*/
229-
public Job copy(String destinationDataset, String destinationTable, BigQuery.JobOption... options)
228+
Job copy(String destinationDataset, String destinationTable, BigQuery.JobOption... options)
230229
throws BigQueryException {
231230
return copy(TableId.of(destinationDataset, destinationTable), options);
232231
}
@@ -239,8 +238,7 @@ public Job copy(String destinationDataset, String destinationTable, BigQuery.Job
239238
* @param options job options
240239
* @throws BigQueryException upon failure
241240
*/
242-
public Job copy(TableId destinationTable, BigQuery.JobOption... options)
243-
throws BigQueryException {
241+
Job copy(TableId destinationTable, BigQuery.JobOption... options) throws BigQueryException {
244242
CopyJobConfiguration configuration = CopyJobConfiguration.of(destinationTable, tableId());
245243
return bigquery.create(JobInfo.of(configuration), options);
246244
}
@@ -255,7 +253,7 @@ public Job copy(TableId destinationTable, BigQuery.JobOption... options)
255253
* @param options job options
256254
* @throws BigQueryException upon failure
257255
*/
258-
public Job extract(String format, String destinationUri, BigQuery.JobOption... options)
256+
Job extract(String format, String destinationUri, BigQuery.JobOption... options)
259257
throws BigQueryException {
260258
return extract(format, ImmutableList.of(destinationUri), options);
261259
}
@@ -270,7 +268,7 @@ public Job extract(String format, String destinationUri, BigQuery.JobOption... o
270268
* @param options job options
271269
* @throws BigQueryException upon failure
272270
*/
273-
public Job extract(String format, List<String> destinationUris, BigQuery.JobOption... options)
271+
Job extract(String format, List<String> destinationUris, BigQuery.JobOption... options)
274272
throws BigQueryException {
275273
ExtractJobConfiguration extractConfiguration =
276274
ExtractJobConfiguration.of(tableId(), destinationUris, format);
@@ -287,7 +285,7 @@ public Job extract(String format, List<String> destinationUris, BigQuery.JobOpti
287285
* @param options job options
288286
* @throws BigQueryException upon failure
289287
*/
290-
public Job load(FormatOptions format, String sourceUri, BigQuery.JobOption... options)
288+
Job load(FormatOptions format, String sourceUri, BigQuery.JobOption... options)
291289
throws BigQueryException {
292290
return load(format, ImmutableList.of(sourceUri), options);
293291
}
@@ -302,7 +300,7 @@ public Job load(FormatOptions format, String sourceUri, BigQuery.JobOption... op
302300
* @param options job options
303301
* @throws BigQueryException upon failure
304302
*/
305-
public Job load(FormatOptions format, List<String> sourceUris, BigQuery.JobOption... options)
303+
Job load(FormatOptions format, List<String> sourceUris, BigQuery.JobOption... options)
306304
throws BigQueryException {
307305
LoadJobConfiguration loadConfig = LoadJobConfiguration.of(tableId(), sourceUris, format);
308306
return bigquery.create(JobInfo.of(loadConfig), options);

trunk/gcloud-java-bigquery/src/test/java/com/google/gcloud/bigquery/ITBigQueryTest.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -654,9 +654,10 @@ public void testQuery() throws InterruptedException {
654654
rowCount++;
655655
}
656656
assertEquals(2, rowCount);
657-
Job queryJob = bigquery.getJob(response.jobId());
658-
JobStatistics.QueryStatistics statistics = queryJob.statistics();
659-
assertNotNull(statistics.queryPlan());
657+
// todo(mziccard) uncomment as soon as #624 is closed
658+
// Job queryJob = bigquery.getJob(response.jobId());
659+
// JobStatistics.QueryStatistics statistics = queryJob.statistics();
660+
// assertNotNull(statistics.queryPlan());
660661
}
661662

662663
@Test
@@ -821,9 +822,10 @@ public void testQueryJob() throws InterruptedException {
821822
}
822823
assertEquals(2, rowCount);
823824
assertTrue(bigquery.delete(DATASET, tableName));
824-
Job queryJob = bigquery.getJob(remoteJob.jobId());
825-
JobStatistics.QueryStatistics statistics = queryJob.statistics();
826-
assertNotNull(statistics.queryPlan());
825+
// todo(mziccard) uncomment as soon as #624 is closed
826+
// Job queryJob = bigquery.getJob(remoteJob.jobId());
827+
// JobStatistics.QueryStatistics statistics = queryJob.statistics();
828+
// assertNotNull(statistics.queryPlan());
827829
}
828830

829831
@Test

trunk/gcloud-java-contrib/pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?xml version="1.0"?>
22
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
33
<modelVersion>4.0.0</modelVersion>
4+
<groupId>com.google.gcloud</groupId>
45
<artifactId>gcloud-java-contrib</artifactId>
56
<packaging>jar</packaging>
67
<name>GCloud Java contributions</name>

trunk/gcloud-java-core/pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?xml version="1.0"?>
22
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
33
<modelVersion>4.0.0</modelVersion>
4+
<groupId>com.google.gcloud</groupId>
45
<artifactId>gcloud-java-core</artifactId>
56
<packaging>jar</packaging>
67
<name>GCloud Java core</name>

trunk/gcloud-java-datastore/pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?xml version="1.0"?>
22
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
33
<modelVersion>4.0.0</modelVersion>
4+
<groupId>com.google.gcloud</groupId>
45
<artifactId>gcloud-java-datastore</artifactId>
56
<packaging>jar</packaging>
67
<name>GCloud Java datastore</name>

trunk/gcloud-java-examples/pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?xml version="1.0"?>
22
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
33
<modelVersion>4.0.0</modelVersion>
4+
<groupId>com.google.gcloud</groupId>
45
<artifactId>gcloud-java-examples</artifactId>
56
<packaging>jar</packaging>
67
<name>GCloud Java examples</name>

trunk/gcloud-java-examples/src/main/java/com/google/gcloud/examples/StorageExample.java

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import com.google.gcloud.storage.BlobId;
2626
import com.google.gcloud.storage.BlobInfo;
2727
import com.google.gcloud.storage.Bucket;
28+
import com.google.gcloud.storage.BucketInfo;
2829
import com.google.gcloud.storage.CopyWriter;
2930
import com.google.gcloud.storage.Storage;
3031
import com.google.gcloud.storage.Storage.ComposeRequest;
@@ -132,27 +133,27 @@ public void run(Storage storage, BlobId... blobIds) {
132133
if (blobIds.length == 1) {
133134
if (blobIds[0].name().isEmpty()) {
134135
// get Bucket
135-
Bucket bucket = storage.get(blobIds[0].bucket());
136+
Bucket bucket = Bucket.get(storage, blobIds[0].bucket());
136137
if (bucket == null) {
137138
System.out.println("No such bucket");
138139
return;
139140
}
140-
System.out.println("Bucket info: " + bucket);
141+
System.out.println("Bucket info: " + bucket.info());
141142
} else {
142143
// get Blob
143-
Blob blob = storage.get(blobIds[0]);
144+
Blob blob = Blob.get(storage, blobIds[0]);
144145
if (blob == null) {
145146
System.out.println("No such object");
146147
return;
147148
}
148-
System.out.println("Blob info: " + blob);
149+
System.out.println("Blob info: " + blob.info());
149150
}
150151
} else {
151152
// use batch to get multiple blobs.
152-
List<Blob> blobs = storage.get(blobIds);
153+
List<Blob> blobs = Blob.get(storage, Arrays.asList(blobIds));
153154
for (Blob blob : blobs) {
154155
if (blob != null) {
155-
System.out.println(blob);
156+
System.out.println(blob.info());
156157
}
157158
}
158159
}
@@ -183,7 +184,7 @@ private static class DeleteAction extends BlobsAction {
183184
@Override
184185
public void run(Storage storage, BlobId... blobIds) {
185186
// use batch operation
186-
List<Boolean> deleteResults = storage.delete(blobIds);
187+
List<Boolean> deleteResults = Blob.delete(storage, blobIds);
187188
int index = 0;
188189
for (Boolean deleted : deleteResults) {
189190
if (deleted) {
@@ -217,20 +218,20 @@ String parse(String... args) {
217218
public void run(Storage storage, String bucketName) {
218219
if (bucketName == null) {
219220
// list buckets
220-
Iterator<Bucket> bucketIterator = storage.list().iterateAll();
221-
while (bucketIterator.hasNext()) {
222-
System.out.println(bucketIterator.next());
221+
Iterator<BucketInfo> bucketInfoIterator = storage.list().iterateAll();
222+
while (bucketInfoIterator.hasNext()) {
223+
System.out.println(bucketInfoIterator.next());
223224
}
224225
} else {
225226
// list a bucket's blobs
226-
Bucket bucket = storage.get(bucketName);
227+
Bucket bucket = Bucket.get(storage, bucketName);
227228
if (bucket == null) {
228229
System.out.println("No such bucket");
229230
return;
230231
}
231232
Iterator<Blob> blobIterator = bucket.list().iterateAll();
232233
while (blobIterator.hasNext()) {
233-
System.out.println(blobIterator.next());
234+
System.out.println(blobIterator.next().info());
234235
}
235236
}
236237
}
@@ -256,7 +257,8 @@ private void run(Storage storage, Path uploadFrom, BlobInfo blobInfo) throws IOE
256257
if (Files.size(uploadFrom) > 1_000_000) {
257258
// When content is not available or large (1MB or more) it is recommended
258259
// to write it in chunks via the blob's channel writer.
259-
try (WriteChannel writer = storage.writer(blobInfo)) {
260+
Blob blob = new Blob(storage, blobInfo);
261+
try (WriteChannel writer = blob.writer()) {
260262
byte[] buffer = new byte[1024];
261263
try (InputStream input = Files.newInputStream(uploadFrom)) {
262264
int limit;
@@ -309,7 +311,7 @@ public void run(Storage storage, Tuple<BlobId, Path> tuple) throws IOException {
309311
}
310312

311313
private void run(Storage storage, BlobId blobId, Path downloadTo) throws IOException {
312-
Blob blob = storage.get(blobId);
314+
Blob blob = Blob.get(storage, blobId);
313315
if (blob == null) {
314316
System.out.println("No such object");
315317
return;
@@ -318,7 +320,7 @@ private void run(Storage storage, BlobId blobId, Path downloadTo) throws IOExcep
318320
if (downloadTo != null) {
319321
writeTo = new PrintStream(new FileOutputStream(downloadTo.toFile()));
320322
}
321-
if (blob.size() < 1_000_000) {
323+
if (blob.info().size() < 1_000_000) {
322324
// Blob is small read all its content in one request
323325
byte[] content = blob.content();
324326
writeTo.write(content);
@@ -436,13 +438,13 @@ public void run(Storage storage, Tuple<BlobId, Map<String, String>> tuple)
436438
}
437439

438440
private void run(Storage storage, BlobId blobId, Map<String, String> metadata) {
439-
Blob blob = storage.get(blobId);
441+
Blob blob = Blob.get(storage, blobId);
440442
if (blob == null) {
441443
System.out.println("No such object");
442444
return;
443445
}
444-
Blob updateBlob = blob.toBuilder().metadata(metadata).build().update();
445-
System.out.println("Updated " + updateBlob);
446+
Blob updateBlob = blob.update(blob.info().toBuilder().metadata(metadata).build());
447+
System.out.println("Updated " + updateBlob.info());
446448
}
447449

448450
@Override
@@ -486,8 +488,9 @@ public void run(Storage storage, Tuple<ServiceAccountAuthCredentials, BlobInfo>
486488
run(storage, tuple.x(), tuple.y());
487489
}
488490

489-
private void run(Storage storage, ServiceAccountAuthCredentials cred, BlobInfo blobInfo) {
490-
Blob blob = storage.get(blobInfo.blobId());
491+
private void run(Storage storage, ServiceAccountAuthCredentials cred, BlobInfo blobInfo)
492+
throws IOException {
493+
Blob blob = new Blob(storage, blobInfo);
491494
System.out.println("Signed URL: "
492495
+ blob.signUrl(1, TimeUnit.DAYS, SignUrlOption.serviceAccount(cred)));
493496
}

0 commit comments

Comments
 (0)