@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); }
public Builder mergeFrom(com.google.datastore.v1.Key.PathElement other) { if (other == com.google.datastore.v1.Key.PathElement.getDefaultInstance()) return this; if (!other.getKind().isEmpty()) { kind_ = other.kind_; onChanged(); } switch (other.getIdTypeCase()) { case ID: { setId(other.getId()); break; } case NAME: { idTypeCase_ = 3; idType_ = other.idType_; onChanged(); break; } case IDTYPE_NOT_SET: { break; } } this.mergeUnknownFields(other.unknownFields); onChanged(); return this; }
@java.lang.Override public boolean equals(final java.lang.Object obj) { if (obj == this) { return true; } if (!(obj instanceof com.google.datastore.v1.Key.PathElement)) { return super.equals(obj); } com.google.datastore.v1.Key.PathElement other = (com.google.datastore.v1.Key.PathElement) obj; boolean result = true; result = result && getKind().equals(other.getKind()); result = result && getIdTypeCase().equals(other.getIdTypeCase()); if (!result) return false; switch (idTypeCase_) { case 2: result = result && (getId() == other.getId()); break; case 3: result = result && getName().equals(other.getName()); break; case 0: default: } result = result && unknownFields.equals(other.unknownFields); return result; }
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()));
public Builder mergeFrom(com.google.datastore.v1.Key.PathElement other) { if (other == com.google.datastore.v1.Key.PathElement.getDefaultInstance()) return this; if (!other.getKind().isEmpty()) { kind_ = other.kind_; onChanged(); } switch (other.getIdTypeCase()) { case ID: { setId(other.getId()); break; } case NAME: { idTypeCase_ = 3; idType_ = other.idType_; onChanged(); break; } case IDTYPE_NOT_SET: { break; } } this.mergeUnknownFields(other.unknownFields); onChanged(); return this; }
@java.lang.Override public int hashCode() { if (memoizedHashCode != 0) { return memoizedHashCode; } int hash = 41; hash = (19 * hash) + getDescriptorForType().hashCode(); hash = (37 * hash) + KIND_FIELD_NUMBER; hash = (53 * hash) + getKind().hashCode(); switch (idTypeCase_) { case 2: hash = (37 * hash) + ID_FIELD_NUMBER; hash = (53 * hash) + com.google.protobuf.Internal.hashLong( getId()); break; case 3: hash = (37 * hash) + NAME_FIELD_NUMBER; hash = (53 * hash) + getName().hashCode(); break; case 0: default: } hash = (29 * hash) + unknownFields.hashCode(); memoizedHashCode = hash; return hash; }
@java.lang.Override public boolean equals(final java.lang.Object obj) { if (obj == this) { return true; } if (!(obj instanceof com.google.datastore.v1.Key.PathElement)) { return super.equals(obj); } com.google.datastore.v1.Key.PathElement other = (com.google.datastore.v1.Key.PathElement) obj; boolean result = true; result = result && getKind() .equals(other.getKind()); result = result && getIdTypeCase().equals( other.getIdTypeCase()); if (!result) return false; switch (idTypeCase_) { case 2: result = result && (getId() == other.getId()); break; case 3: result = result && getName() .equals(other.getName()); break; case 0: default: } return result; }
public Builder mergeFrom(com.google.datastore.v1.Key.PathElement other) { if (other == com.google.datastore.v1.Key.PathElement.getDefaultInstance()) return this; if (!other.getKind().isEmpty()) { kind_ = other.kind_; onChanged(); } switch (other.getIdTypeCase()) { case ID: { setId(other.getId()); break; } case NAME: { idTypeCase_ = 3; idType_ = other.idType_; onChanged(); break; } case IDTYPE_NOT_SET: { break; } } onChanged(); return this; }
@java.lang.Override public int hashCode() { if (memoizedHashCode != 0) { return memoizedHashCode; } int hash = 41; hash = (19 * hash) + getDescriptor().hashCode(); hash = (37 * hash) + KIND_FIELD_NUMBER; hash = (53 * hash) + getKind().hashCode(); switch (idTypeCase_) { case 2: hash = (37 * hash) + ID_FIELD_NUMBER; hash = (53 * hash) + com.google.protobuf.Internal.hashLong(getId()); break; case 3: hash = (37 * hash) + NAME_FIELD_NUMBER; hash = (53 * hash) + getName().hashCode(); break; case 0: default: } hash = (29 * hash) + unknownFields.hashCode(); memoizedHashCode = hash; return hash; }
/** * 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(); }
@java.lang.Override public boolean equals(final java.lang.Object obj) { if (obj == this) { return true; } if (!(obj instanceof com.google.datastore.v1.Key.PathElement)) { return super.equals(obj); } com.google.datastore.v1.Key.PathElement other = (com.google.datastore.v1.Key.PathElement) obj; boolean result = true; result = result && getKind().equals(other.getKind()); result = result && getIdTypeCase().equals(other.getIdTypeCase()); if (!result) return false; switch (idTypeCase_) { case 2: result = result && (getId() == other.getId()); break; case 3: result = result && getName().equals(other.getName()); break; case 0: default: } result = result && unknownFields.equals(other.unknownFields); return result; }
/** * * * <pre> * The kind of the entity. * A kind matching regex `__.*__` is reserved/read-only. * A kind must not contain more than 1500 bytes when UTF-8 encoded. * Cannot be `""`. * </pre> * * <code>string kind = 1;</code> */ public Builder clearKind() { kind_ = getDefaultInstance().getKind(); onChanged(); return this; } /**
/** * <pre> * The kind of the entity. * A kind matching regex `__.*__` is reserved/read-only. * A kind must not contain more than 1500 bytes when UTF-8 encoded. * Cannot be `""`. * </pre> * * <code>optional string kind = 1;</code> */ public Builder clearKind() { kind_ = getDefaultInstance().getKind(); onChanged(); return this; } /**
private int comparePathElement(PathElement thisElement, PathElement otherElement) { int result = thisElement.getKind().compareTo(otherElement.getKind()); if (result != 0) { return result; } if (thisElement.getIdTypeCase() == IdTypeCase.ID) { if (otherElement.getIdTypeCase() != IdTypeCase.ID) { return -1; } return Long.valueOf(thisElement.getId()).compareTo(otherElement.getId()); } if (otherElement.getIdTypeCase() == IdTypeCase.ID) { return 1; } return thisElement.getName().compareTo(otherElement.getName()); }
/** * Return element kind of key, or null if not set. * * This is a shortcut for {@code Key.getPath().get(Key.getPath().size() - 1).getKind()} * * @return the element kind. */ public String getKind() { final com.google.datastore.v1.Key.PathElement element = Iterables.getLast(key.getPathList(), null); if (element == null) { return null; } return element.getKind(); }
private static boolean isId(final com.google.datastore.v1.Key.PathElement element) { return element.getIdTypeCase() == com.google.datastore.v1.Key.PathElement.IdTypeCase.ID; }
private int comparePathElement(PathElement thisElement, PathElement otherElement) { int result = thisElement.getKind().compareTo(otherElement.getKind()); if (result != 0) { return result; } if (thisElement.getIdTypeCase() == IdTypeCase.ID) { if (otherElement.getIdTypeCase() != IdTypeCase.ID) { return -1; } return Long.valueOf(thisElement.getId()).compareTo(otherElement.getId()); } if (otherElement.getIdTypeCase() == IdTypeCase.ID) { return 1; } return thisElement.getName().compareTo(otherElement.getName()); }