Skip to content

Commit 4390015

Browse files
author
Ajay Kannan
committed
---
yaml --- r: 4747 b: refs/heads/logging-alpha c: 883c60e h: refs/heads/master i: 4745: bb2da23 4743: 3d22c8a
1 parent 51c9e1c commit 4390015

83 files changed

Lines changed: 1502 additions & 1729 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
@@ -12,7 +12,7 @@ refs/heads/compute-alpha: 969cba2627f1d53d352cc4a5ffe0879dacf65e6c
1212
refs/heads/dns-alpha: 2f90e7e338349287ace33375896907af0f032ca1
1313
refs/heads/dns-alpha-batch: 17442b07867021b85d0452f5f3eda29a3413288f
1414
refs/heads/gcs-nio: 283aeaf15efdcf3621eb6859f05e55ad7764375d
15-
refs/heads/logging-alpha: c70d9d7800aae74d81385b0c88d7d27e6cff6861
15+
refs/heads/logging-alpha: 883c60eff3f38413ca4187722233c599378e6de2
1616
refs/tags/v0.1.0: a615317f7424ed58621b1f65d5c4d8cbbe8a6ed8
1717
refs/tags/v0.1.1: 7a7f6985fe465e9dd6a075af55493f42b4933be0
1818
refs/tags/v0.1.2: 3eb3fe866ba22487686048f45d927b8c8638ea3f

branches/logging-alpha/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());

branches/logging-alpha/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)

branches/logging-alpha/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);

branches/logging-alpha/gcloud-java-datastore/pom.xml

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,16 @@
2222
<version>${project.version}</version>
2323
</dependency>
2424
<dependency>
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>
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>
3335
</dependency>
3436
<dependency>
3537
<groupId>${project.groupId}</groupId>

branches/logging-alpha/gcloud-java-datastore/src/main/java/com/google/gcloud/datastore/BaseDatastoreBatchWriter.java

Lines changed: 12 additions & 17 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;
1920
import com.google.common.base.Preconditions;
2021
import com.google.common.collect.Iterables;
2122
import com.google.common.collect.Lists;
2223

23-
import java.util.ArrayList;
2424
import java.util.Collections;
2525
import java.util.Iterator;
2626
import java.util.LinkedHashMap;
@@ -88,7 +88,9 @@ 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)) {
91+
if (key instanceof Key) {
92+
addInternal((FullEntity<Key>) entity);
93+
} else {
9294
incompleteKeys.add(key);
9395
}
9496
}
@@ -102,7 +104,6 @@ public final List<Entity> add(FullEntity<?>... entities) {
102104
List<Entity> answer = Lists.newArrayListWithExpectedSize(entities.length);
103105
for (FullEntity<?> entity : entities) {
104106
if (entity.key() instanceof Key) {
105-
addInternal((FullEntity<Key>) entity);
106107
answer.add(Entity.convert((FullEntity<Key>) entity));
107108
} else {
108109
Entity entityWithAllocatedId = Entity.builder(allocated.next(), entity).build();
@@ -198,30 +199,24 @@ protected DatastoreException newInvalidRequest(String msg, Object... params) {
198199
return DatastoreException.throwInvalidRequest(String.format(msg, params));
199200
}
200201

201-
protected List<com.google.datastore.v1beta3.Mutation> toMutationPbList() {
202-
List<com.google.datastore.v1beta3.Mutation> mutationsPb =
203-
new ArrayList<>();
202+
DatastoreV1.Mutation.Builder toMutationPb() {
203+
DatastoreV1.Mutation.Builder mutationPb = DatastoreV1.Mutation.newBuilder();
204204
for (FullEntity<IncompleteKey> entity : toAddAutoId()) {
205-
mutationsPb.add(
206-
com.google.datastore.v1beta3.Mutation.newBuilder().setInsert(entity.toPb()).build());
205+
mutationPb.addInsertAutoId(entity.toPb());
207206
}
208207
for (FullEntity<Key> entity : toAdd().values()) {
209-
mutationsPb.add(
210-
com.google.datastore.v1beta3.Mutation.newBuilder().setInsert(entity.toPb()).build());
208+
mutationPb.addInsert(entity.toPb());
211209
}
212210
for (FullEntity<Key> entity : toUpdate().values()) {
213-
mutationsPb.add(
214-
com.google.datastore.v1beta3.Mutation.newBuilder().setUpdate(entity.toPb()).build());
211+
mutationPb.addUpdate(entity.toPb());
215212
}
216213
for (FullEntity<Key> entity : toPut().values()) {
217-
mutationsPb.add(
218-
com.google.datastore.v1beta3.Mutation.newBuilder().setUpsert(entity.toPb()).build());
214+
mutationPb.addUpsert(entity.toPb());
219215
}
220216
for (Key key : toDelete()) {
221-
mutationsPb.add(
222-
com.google.datastore.v1beta3.Mutation.newBuilder().setDelete(key.toPb()).build());
217+
mutationPb.addDelete(key.toPb());
223218
}
224-
return mutationsPb;
219+
return mutationPb;
225220
}
226221

227222
protected abstract Datastore datastore();

branches/logging-alpha/gcloud-java-datastore/src/main/java/com/google/gcloud/datastore/BaseEntity.java

Lines changed: 12 additions & 54 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;
2625
import static com.google.gcloud.datastore.ListValue.of;
2726
import static com.google.gcloud.datastore.LongValue.of;
2827
import static com.google.gcloud.datastore.NullValue.of;
2928
import static com.google.gcloud.datastore.StringValue.of;
3029

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,8 +49,7 @@
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>
53-
extends Serializable<com.google.datastore.v1beta3.Entity> {
52+
public abstract class BaseEntity<K extends IncompleteKey> extends Serializable<DatastoreV1.Entity> {
5453

5554
private static final long serialVersionUID = 8175618724683792766L;
5655

@@ -92,11 +91,10 @@ private B self() {
9291
}
9392

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

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-
325293
/**
326294
* Sets a property of type {@link KeyValue}.
327295
*
@@ -577,17 +545,6 @@ public DateTime getDateTime(String name) {
577545
return ((Value<DateTime>) getValue(name)).get();
578546
}
579547

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-
591548
/**
592549
* Returns the property value as a Key.
593550
*
@@ -646,19 +603,20 @@ ImmutableSortedMap<String, Value<?>> properties() {
646603
@Override
647604
Object fromPb(byte[] bytesPb) throws InvalidProtocolBufferException {
648605
Builder<?, ?> builder = emptyBuilder();
649-
builder.fill(com.google.datastore.v1beta3.Entity.parseFrom(bytesPb));
606+
builder.fill(DatastoreV1.Entity.parseFrom(bytesPb));
650607
return builder.build();
651608
}
652609

653610
protected abstract Builder<?, ?> emptyBuilder();
654611

655612
@Override
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();
613+
final DatastoreV1.Entity toPb() {
614+
DatastoreV1.Entity.Builder entityPb = DatastoreV1.Entity.newBuilder();
660615
for (Map.Entry<String, Value<?>> entry : properties.entrySet()) {
661-
propertiesPb.put(entry.getKey(), entry.getValue().toPb());
616+
DatastoreV1.Property.Builder propertyPb = DatastoreV1.Property.newBuilder();
617+
propertyPb.setName(entry.getKey());
618+
propertyPb.setValue(entry.getValue().toPb());
619+
entityPb.addProperty(propertyPb.build());
662620
}
663621
if (key != null) {
664622
entityPb.setKey(key.toPb());

0 commit comments

Comments
 (0)