@Test public void testLookupEventualConsistency() { ReadOptions readOption = ReadOptions.newBuilder().setReadConsistencyValue(ReadConsistency.EVENTUAL_VALUE).build(); com.google.datastore.v1.Key key = com.google.datastore.v1.Key.newBuilder() .setPartitionId(PartitionId.newBuilder().setProjectId(PROJECT_ID).build()) .addPath( com.google.datastore.v1.Key.PathElement.newBuilder() .setKind("kind1") .setName("name") .build()) .build(); LookupRequest lookupRequest = LookupRequest.newBuilder().setReadOptions(readOption).addKeys(key).build(); EasyMock.expect(rpcMock.lookup(lookupRequest)) .andReturn(LookupResponse.newBuilder().build()) .times(3); EasyMock.replay(rpcFactoryMock, rpcMock); Datastore datastore = rpcMockOptions.getService(); datastore.get(KEY1, ReadOption.eventualConsistency()); datastore.get(ImmutableList.of(KEY1), ReadOption.eventualConsistency()); datastore.fetch(ImmutableList.of(KEY1), ReadOption.eventualConsistency()); EasyMock.verify(rpcFactoryMock, rpcMock); }
Key.PathElement.newBuilder() .setKind("Trivia") .setName("hgtg"));
PartitionId partitionId = null; for (int pathIndex = 0; pathIndex < elements.length; pathIndex += 2) { PathElement.Builder pathElement = PathElement.newBuilder(); Object element = elements[pathIndex]; if (element instanceof Key) {
PartitionId partitionId = null; for (int pathIndex = 0; pathIndex < elements.length; pathIndex += 2) { PathElement.Builder pathElement = PathElement.newBuilder(); Object element = elements[pathIndex]; if (element instanceof Key) {
Key.newBuilder() .addPath( PathElement.newBuilder() .setKind(entityKind().get()) .setName(columnValue.toString()));
/** * Get key */ public Key getKey(String name) { Key.Builder keyBuilder = Key.newBuilder(); // Set namespace PartitionId partitionId = PartitionId.newBuilder() .setProjectId(projectId).setNamespaceId(namespace).build(); keyBuilder.setPartitionId(partitionId); // Set parent paths if (parents != null && parents.size() > 0) { for (String parentKey : parents.keySet()) { Key.PathElement.Builder parentPath = Key.PathElement.newBuilder().setKind(parentKey).setName(parents.get(parentKey)); keyBuilder.addPath(parentPath); } } // Set main kind Key.PathElement.Builder path = Key.PathElement.newBuilder().setKind(kind).setName(name); keyBuilder.addPath(path); return keyBuilder.build(); }
public Builder newBuilderForType() { return newBuilder(); } public static Builder newBuilder() {
/** * Add a path element of a given kind to this key. * * @param kind the path element kind. * @return this key builder. */ public Builder path(final String kind) { key.addPath(com.google.datastore.v1.Key.PathElement.newBuilder().setKind(kind)); return this; }
@java.lang.Override public Builder newBuilderForType() { return newBuilder(); }
/** * Add a path element of a given kind and name to this key. * * @param kind the path element kind. * @param name the path element name. * @return this key builder. */ public Builder path(final String kind, final String name) { key.addPath(com.google.datastore.v1.Key.PathElement.newBuilder().setKind(kind).setName(name)); return this; }
/** * Add a path element of a given kind and id to this key. * * @param kind the path element kind. * @param id the path element id. * @return this key builder. */ public Builder path(final String kind, final long id) { key.addPath(com.google.datastore.v1.Key.PathElement.newBuilder().setKind(kind).setId(id)); return this; }
com.google.datastore.v1.Key.PathElement toPb() { com.google.datastore.v1.Key.PathElement.Builder pathElementPb = com.google.datastore.v1.Key.PathElement.newBuilder(); pathElementPb.setKind(kind); if (id != null) { pathElementPb.setId(id); } else if (name != null) { pathElementPb.setName(name); } return pathElementPb.build(); }
@java.lang.Override public Builder newBuilderForType() { return newBuilder(); }
com.google.datastore.v1.Key.PathElement toPb() { com.google.datastore.v1.Key.PathElement.Builder pathElementPb = com.google.datastore.v1.Key.PathElement.newBuilder(); pathElementPb.setKind(kind); if (id != null) { pathElementPb.setId(id); } else if (name != null) { pathElementPb.setName(name); } return pathElementPb.build(); }
private Key.Builder buildPrimaryKey(String table, String key) { Key.Builder result = Key.newBuilder(); if (this.entityGroupingMode == EntityGroupingMode.MULTI_ENTITY_PER_GROUP) { // All entities are in side the same group when we are in this mode. result.addPath(Key.PathElement.newBuilder().setKind(table). setName(rootEntityName)); } return result.addPath(Key.PathElement.newBuilder().setKind(table) .setName(key)); }