Skip to content

Commit 19fab62

Browse files
committed
---
yaml --- r: 3231 b: refs/heads/master c: 106fae9 h: refs/heads/master i: 3229: d31efb2 3227: 3fef7dd 3223: aca7d65 3215: c8b95c2 3199: 8b489fe
1 parent 5fb9ce8 commit 19fab62

84 files changed

Lines changed: 1734 additions & 1503 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
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 43b2ef990fd27944823722aaf6caee902f9d429c
2+
refs/heads/master: 106fae97b0560d6cccfce335ac7338d55c7955b2
33
refs/heads/travis: e21ee7b88a5edc3f3d8c71f90c3fc32abf7e8dd6
44
refs/heads/gh-pages: 4e0561bb4504bf647db669a14417b2b2c87ba45d
55
refs/heads/pubsub-alpha: 1a0e970f265af871e02274085b9662b3fe29058b

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

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ static QueryStep fromPb(com.google.api.services.bigquery.model.ExplainQueryStep
137137

138138
private final double computeRatioAvg;
139139
private final double computeRatioMax;
140-
private final long id;
140+
private final long generatedId;
141141
private final String name;
142142
private final double readRatioAvg;
143143
private final double readRatioMax;
@@ -153,7 +153,7 @@ static final class Builder {
153153

154154
private double computeRatioAvg;
155155
private double computeRatioMax;
156-
private long id;
156+
private long generatedId;
157157
private String name;
158158
private double readRatioAvg;
159159
private double readRatioMax;
@@ -177,8 +177,8 @@ Builder computeRatioMax(double computeRatioMax) {
177177
return this;
178178
}
179179

180-
Builder id(long id) {
181-
this.id = id;
180+
Builder generatedId(long generatedId) {
181+
this.generatedId = generatedId;
182182
return this;
183183
}
184184

@@ -240,7 +240,7 @@ QueryStage build() {
240240
QueryStage(Builder builder) {
241241
computeRatioAvg = builder.computeRatioAvg;
242242
computeRatioMax = builder.computeRatioMax;
243-
id = builder.id;
243+
generatedId = builder.generatedId;
244244
name = builder.name;
245245
readRatioAvg = builder.readRatioAvg;
246246
readRatioMax = builder.readRatioMax;
@@ -270,10 +270,10 @@ public double computeRatioMax() {
270270
}
271271

272272
/**
273-
* Returns a unique ID for the stage within its plan.
273+
* Returns a unique, server-generated ID for the stage within its plan.
274274
*/
275-
public long id() {
276-
return id;
275+
public long generatedId() {
276+
return generatedId;
277277
}
278278

279279
/**
@@ -357,7 +357,7 @@ public String toString() {
357357
return MoreObjects.toStringHelper(this)
358358
.add("computeRatioAvg", computeRatioAvg)
359359
.add("computeRatioMax", computeRatioMax)
360-
.add("id", id)
360+
.add("generatedId", generatedId)
361361
.add("name", name)
362362
.add("readRatioAvg", readRatioAvg)
363363
.add("readRatioMax", readRatioMax)
@@ -373,7 +373,7 @@ public String toString() {
373373

374374
@Override
375375
public int hashCode() {
376-
return Objects.hash(computeRatioAvg, computeRatioMax, id, name, readRatioAvg, readRatioMax,
376+
return Objects.hash(computeRatioAvg, computeRatioMax, generatedId, name, readRatioAvg, readRatioMax,
377377
recordsRead, recordsWritten, steps, waitRatioAvg, waitRatioMax, writeRatioAvg);
378378
}
379379

@@ -383,7 +383,7 @@ public boolean equals(Object obj) {
383383
return false;
384384
}
385385
QueryStage other = (QueryStage) obj;
386-
return id == other.id
386+
return generatedId == other.generatedId
387387
&& computeRatioAvg == other.computeRatioAvg
388388
&& computeRatioMax == other.computeRatioMax
389389
&& readRatioAvg == other.readRatioAvg
@@ -406,7 +406,7 @@ ExplainQueryStage toPb() {
406406
ExplainQueryStage stagePb = new ExplainQueryStage()
407407
.setComputeRatioAvg(computeRatioAvg)
408408
.setComputeRatioMax(computeRatioMax)
409-
.setId(id)
409+
.setId(generatedId)
410410
.setName(name)
411411
.setReadRatioAvg(readRatioAvg)
412412
.setReadRatioMax(readRatioMax)
@@ -426,7 +426,7 @@ static QueryStage fromPb(com.google.api.services.bigquery.model.ExplainQueryStag
426426
Builder builder = new QueryStage.Builder();
427427
builder.computeRatioAvg(stagePb.getComputeRatioAvg());
428428
builder.computeRatioMax(stagePb.getComputeRatioMax());
429-
builder.id(stagePb.getId());
429+
builder.generatedId(stagePb.getId());
430430
builder.name(stagePb.getName());
431431
builder.readRatioAvg(stagePb.getReadRatioAvg());
432432
builder.readRatioMax(stagePb.getReadRatioMax());

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public class JobStatisticsTest {
7171
private static final QueryStage QUERY_STAGE = QueryStage.builder()
7272
.computeRatioAvg(1.1)
7373
.computeRatioMax(2.2)
74-
.id(42L)
74+
.generatedId(42L)
7575
.name("stage")
7676
.readRatioAvg(3.3)
7777
.readRatioMax(4.4)

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public class QueryStageTest {
4848
private static final QueryStage QUERY_STAGE = QueryStage.builder()
4949
.computeRatioAvg(COMPUTE_RATIO_AVG)
5050
.computeRatioMax(COMPUTE_RATIO_MAX)
51-
.id(ID)
51+
.generatedId(ID)
5252
.name(NAME)
5353
.readRatioAvg(READ_RATIO_AVG)
5454
.readRatioMax(READ_RATIO_MAX)
@@ -73,7 +73,7 @@ public void testQueryStepConstructor() {
7373
public void testBuilder() {
7474
assertEquals(COMPUTE_RATIO_AVG, QUERY_STAGE.computeRatioAvg(), 0);
7575
assertEquals(COMPUTE_RATIO_MAX, QUERY_STAGE.computeRatioMax(), 0);
76-
assertEquals(ID, QUERY_STAGE.id());
76+
assertEquals(ID, QUERY_STAGE.generatedId());
7777
assertEquals(NAME, QUERY_STAGE.name());
7878
assertEquals(READ_RATIO_AVG, QUERY_STAGE.readRatioAvg(), 0);
7979
assertEquals(READ_RATIO_MAX, QUERY_STAGE.readRatioMax(), 0);
@@ -108,7 +108,7 @@ private void compareQueryStage(QueryStage expected, QueryStage value) {
108108
assertEquals(expected, value);
109109
assertEquals(expected.computeRatioAvg(), value.computeRatioAvg(), 0);
110110
assertEquals(expected.computeRatioMax(), value.computeRatioMax(), 0);
111-
assertEquals(expected.id(), value.id());
111+
assertEquals(expected.generatedId(), value.generatedId());
112112
assertEquals(expected.name(), value.name());
113113
assertEquals(expected.readRatioAvg(), value.readRatioAvg(), 0);
114114
assertEquals(expected.readRatioMax(), value.readRatioMax(), 0);

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@
7171

7272
import org.junit.AfterClass;
7373
import org.junit.BeforeClass;
74+
import org.junit.Ignore;
7475
import org.junit.Rule;
7576
import org.junit.Test;
7677
import org.junit.rules.Timeout;
@@ -623,6 +624,7 @@ public void testInsertAllWithErrors() {
623624
assertTrue(bigquery.delete(TableId.of(DATASET, tableName)));
624625
}
625626

627+
@Ignore("Flaky test; see issue #836")
626628
@Test
627629
public void testListAllTableData() {
628630
Page<List<FieldValue>> rows = bigquery.listTableData(TABLE_ID);
@@ -906,6 +908,7 @@ public void testCancelNonExistingJob() {
906908
assertFalse(bigquery.cancel("test_cancel_non_existing_job"));
907909
}
908910

911+
@Ignore("Flaky test; see #836")
909912
@Test
910913
public void testInsertFromFile() throws InterruptedException {
911914
String destinationTableName = "test_insert_from_file_table";

trunk/gcloud-java-datastore/pom.xml

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,14 @@
2222
<version>${project.version}</version>
2323
</dependency>
2424
<dependency>
25-
<groupId>com.google.apis</groupId>
26-
<artifactId>google-api-services-datastore-protobuf</artifactId>
27-
<version>v1beta2-rev1-4.0.0</version>
28-
<scope>compile</scope>
29-
<exclusions>
30-
<exclusion>
31-
<groupId>com.google.api-client</groupId>
32-
<artifactId>google-api-client</artifactId>
33-
</exclusion>
34-
</exclusions>
25+
<groupId>com.google.cloud.datastore</groupId>
26+
<artifactId>datastore-v1beta3-protos</artifactId>
27+
<version>1.0.0-beta</version>
28+
</dependency>
29+
<dependency>
30+
<groupId>com.google.cloud.datastore</groupId>
31+
<artifactId>datastore-v1beta3-proto-client</artifactId>
32+
<version>1.0.0-beta</version>
3533
</dependency>
3634
<dependency>
3735
<groupId>${project.groupId}</groupId>

trunk/gcloud-java-datastore/src/main/java/com/google/gcloud/datastore/BaseDatastoreBatchWriter.java

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@
1616

1717
package com.google.gcloud.datastore;
1818

19-
import com.google.api.services.datastore.DatastoreV1;
2019
import com.google.common.base.Preconditions;
2120
import com.google.common.collect.Iterables;
2221
import com.google.common.collect.Lists;
2322

23+
import java.util.ArrayList;
2424
import java.util.Collections;
2525
import java.util.Iterator;
2626
import java.util.LinkedHashMap;
@@ -88,9 +88,7 @@ public final List<Entity> add(FullEntity<?>... entities) {
8888
for (FullEntity<?> entity : entities) {
8989
IncompleteKey key = entity.key();
9090
Preconditions.checkArgument(key != null, "Entity must have a key");
91-
if (key instanceof Key) {
92-
addInternal((FullEntity<Key>) entity);
93-
} else {
91+
if (!(key instanceof Key)) {
9492
incompleteKeys.add(key);
9593
}
9694
}
@@ -104,6 +102,7 @@ public final List<Entity> add(FullEntity<?>... entities) {
104102
List<Entity> answer = Lists.newArrayListWithExpectedSize(entities.length);
105103
for (FullEntity<?> entity : entities) {
106104
if (entity.key() instanceof Key) {
105+
addInternal((FullEntity<Key>) entity);
107106
answer.add(Entity.convert((FullEntity<Key>) entity));
108107
} else {
109108
Entity entityWithAllocatedId = Entity.builder(allocated.next(), entity).build();
@@ -199,24 +198,30 @@ protected DatastoreException newInvalidRequest(String msg, Object... params) {
199198
return DatastoreException.throwInvalidRequest(String.format(msg, params));
200199
}
201200

202-
DatastoreV1.Mutation.Builder toMutationPb() {
203-
DatastoreV1.Mutation.Builder mutationPb = DatastoreV1.Mutation.newBuilder();
201+
protected List<com.google.datastore.v1beta3.Mutation> toMutationPbList() {
202+
List<com.google.datastore.v1beta3.Mutation> mutationsPb =
203+
new ArrayList<>();
204204
for (FullEntity<IncompleteKey> entity : toAddAutoId()) {
205-
mutationPb.addInsertAutoId(entity.toPb());
205+
mutationsPb.add(
206+
com.google.datastore.v1beta3.Mutation.newBuilder().setInsert(entity.toPb()).build());
206207
}
207208
for (FullEntity<Key> entity : toAdd().values()) {
208-
mutationPb.addInsert(entity.toPb());
209+
mutationsPb.add(
210+
com.google.datastore.v1beta3.Mutation.newBuilder().setInsert(entity.toPb()).build());
209211
}
210212
for (FullEntity<Key> entity : toUpdate().values()) {
211-
mutationPb.addUpdate(entity.toPb());
213+
mutationsPb.add(
214+
com.google.datastore.v1beta3.Mutation.newBuilder().setUpdate(entity.toPb()).build());
212215
}
213216
for (FullEntity<Key> entity : toPut().values()) {
214-
mutationPb.addUpsert(entity.toPb());
217+
mutationsPb.add(
218+
com.google.datastore.v1beta3.Mutation.newBuilder().setUpsert(entity.toPb()).build());
215219
}
216220
for (Key key : toDelete()) {
217-
mutationPb.addDelete(key.toPb());
221+
mutationsPb.add(
222+
com.google.datastore.v1beta3.Mutation.newBuilder().setDelete(key.toPb()).build());
218223
}
219-
return mutationPb;
224+
return mutationsPb;
220225
}
221226

222227
protected abstract Datastore datastore();

trunk/gcloud-java-datastore/src/main/java/com/google/gcloud/datastore/BaseEntity.java

Lines changed: 54 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@
2222
import static com.google.gcloud.datastore.DoubleValue.of;
2323
import static com.google.gcloud.datastore.EntityValue.of;
2424
import static com.google.gcloud.datastore.KeyValue.of;
25+
import static com.google.gcloud.datastore.LatLngValue.of;
2526
import static com.google.gcloud.datastore.ListValue.of;
2627
import static com.google.gcloud.datastore.LongValue.of;
2728
import static com.google.gcloud.datastore.NullValue.of;
2829
import static com.google.gcloud.datastore.StringValue.of;
2930

30-
import com.google.api.services.datastore.DatastoreV1;
3131
import com.google.common.collect.ImmutableSortedMap;
3232
import com.google.common.collect.Maps;
3333
import com.google.protobuf.InvalidProtocolBufferException;
@@ -49,7 +49,8 @@
4949
* @see <a href="https://cloud.google.com/datastore/docs/concepts/entities">Google Cloud Datastore
5050
* Entities, Properties, and Keys</a>
5151
*/
52-
public abstract class BaseEntity<K extends IncompleteKey> extends Serializable<DatastoreV1.Entity> {
52+
public abstract class BaseEntity<K extends IncompleteKey>
53+
extends Serializable<com.google.datastore.v1beta3.Entity> {
5354

5455
private static final long serialVersionUID = 8175618724683792766L;
5556

@@ -91,10 +92,11 @@ private B self() {
9192
}
9293

9394
@SuppressWarnings("unchecked")
94-
B fill(DatastoreV1.Entity entityPb) {
95+
B fill(com.google.datastore.v1beta3.Entity entityPb) {
9596
Map<String, Value<?>> copiedProperties = Maps.newHashMap();
96-
for (DatastoreV1.Property property : entityPb.getPropertyList()) {
97-
copiedProperties.put(property.getName(), Value.fromPb(property.getValue()));
97+
for (Map.Entry<String, com.google.datastore.v1beta3.Value> entry :
98+
entityPb.getProperties().entrySet()) {
99+
copiedProperties.put(entry.getKey(), Value.fromPb(entry.getValue()));
98100
}
99101
properties(copiedProperties);
100102
if (entityPb.hasKey()) {
@@ -290,6 +292,36 @@ public B set(String name, DateTime first, DateTime second, DateTime... others) {
290292
return self();
291293
}
292294

295+
/**
296+
* Sets a property of type {@link LatLng}.
297+
*
298+
* @param name name of the property
299+
* @param value value associated with the property
300+
*/
301+
public B set(String name, LatLng value) {
302+
properties.put(name, of(value));
303+
return self();
304+
}
305+
306+
/**
307+
* Sets a list property containing elements of type {@link LatLng}.
308+
*
309+
* @param name name of the property
310+
* @param first the first {@link LatLng} in the list
311+
* @param second the second {@link LatLng} in the list
312+
* @param others other {@link LatLng}s in the list
313+
*/
314+
public B set(String name, LatLng first, LatLng second, LatLng... others) {
315+
List<LatLngValue> values = new LinkedList<>();
316+
values.add(of(first));
317+
values.add(of(second));
318+
for (LatLng other : others) {
319+
values.add(of(other));
320+
}
321+
properties.put(name, of(values));
322+
return self();
323+
}
324+
293325
/**
294326
* Sets a property of type {@link KeyValue}.
295327
*
@@ -545,6 +577,17 @@ public DateTime getDateTime(String name) {
545577
return ((Value<DateTime>) getValue(name)).get();
546578
}
547579

580+
/**
581+
* Returns the property value as a LatLng.
582+
*
583+
* @throws DatastoreException if not such property.
584+
* @throws ClassCastException if value is not a LatLng.
585+
*/
586+
@SuppressWarnings("unchecked")
587+
public LatLng getLatLng(String name) {
588+
return ((Value<LatLng>) getValue(name)).get();
589+
}
590+
548591
/**
549592
* Returns the property value as a Key.
550593
*
@@ -603,20 +646,19 @@ ImmutableSortedMap<String, Value<?>> properties() {
603646
@Override
604647
Object fromPb(byte[] bytesPb) throws InvalidProtocolBufferException {
605648
Builder<?, ?> builder = emptyBuilder();
606-
builder.fill(DatastoreV1.Entity.parseFrom(bytesPb));
649+
builder.fill(com.google.datastore.v1beta3.Entity.parseFrom(bytesPb));
607650
return builder.build();
608651
}
609652

610653
protected abstract Builder<?, ?> emptyBuilder();
611654

612655
@Override
613-
final DatastoreV1.Entity toPb() {
614-
DatastoreV1.Entity.Builder entityPb = DatastoreV1.Entity.newBuilder();
656+
final com.google.datastore.v1beta3.Entity toPb() {
657+
com.google.datastore.v1beta3.Entity.Builder entityPb =
658+
com.google.datastore.v1beta3.Entity.newBuilder();
659+
Map<String, com.google.datastore.v1beta3.Value> propertiesPb = entityPb.getMutableProperties();
615660
for (Map.Entry<String, Value<?>> entry : properties.entrySet()) {
616-
DatastoreV1.Property.Builder propertyPb = DatastoreV1.Property.newBuilder();
617-
propertyPb.setName(entry.getKey());
618-
propertyPb.setValue(entry.getValue().toPb());
619-
entityPb.addProperty(propertyPb.build());
661+
propertiesPb.put(entry.getKey(), entry.getValue().toPb());
620662
}
621663
if (key != null) {
622664
entityPb.setKey(key.toPb());

0 commit comments

Comments
 (0)