@java.lang.Override public int hashCode() { if (memoizedHashCode != 0) { return memoizedHashCode; } int hash = 41; hash = (19 * hash) + getDescriptor().hashCode(); if (getFoundCount() > 0) { hash = (37 * hash) + FOUND_FIELD_NUMBER; hash = (53 * hash) + getFoundList().hashCode(); } if (getMissingCount() > 0) { hash = (37 * hash) + MISSING_FIELD_NUMBER; hash = (53 * hash) + getMissingList().hashCode(); } if (getDeferredCount() > 0) { hash = (37 * hash) + DEFERRED_FIELD_NUMBER; hash = (53 * hash) + getDeferredList().hashCode(); } hash = (29 * hash) + unknownFields.hashCode(); memoizedHashCode = hash; return hash; }
@java.lang.Override public Builder newBuilderForType() { return newBuilder(); }
@java.lang.Override public com.google.datastore.v1.LookupResponse buildPartial() { com.google.datastore.v1.LookupResponse result = new com.google.datastore.v1.LookupResponse(this); int from_bitField0_ = bitField0_; if (foundBuilder_ == null) {
@java.lang.Override public boolean equals(final java.lang.Object obj) { if (obj == this) { return true; } if (!(obj instanceof com.google.datastore.v1.LookupResponse)) { return super.equals(obj); } com.google.datastore.v1.LookupResponse other = (com.google.datastore.v1.LookupResponse) obj; boolean result = true; result = result && getFoundList().equals(other.getFoundList()); result = result && getMissingList().equals(other.getMissingList()); result = result && getDeferredList().equals(other.getDeferredList()); result = result && unknownFields.equals(other.unknownFields); return result; }
private void loadResults() { com.google.datastore.v1.LookupResponse responsePb = lookup(requestPb.build()); iter = responsePb.getFoundList().iterator(); requestPb.clearKeys(); if (responsePb.getDeferredCount() > 0) { requestPb.addAllKeys(responsePb.getDeferredList()); } }
@java.lang.Override public int hashCode() { if (memoizedHashCode != 0) { return memoizedHashCode; } int hash = 41; hash = (19 * hash) + getDescriptorForType().hashCode(); if (getFoundCount() > 0) { hash = (37 * hash) + FOUND_FIELD_NUMBER; hash = (53 * hash) + getFoundList().hashCode(); } if (getMissingCount() > 0) { hash = (37 * hash) + MISSING_FIELD_NUMBER; hash = (53 * hash) + getMissingList().hashCode(); } if (getDeferredCount() > 0) { hash = (37 * hash) + DEFERRED_FIELD_NUMBER; hash = (53 * hash) + getDeferredList().hashCode(); } hash = (29 * hash) + unknownFields.hashCode(); memoizedHashCode = hash; return hash; }
if (response.getFoundCount() == 0) { return new Status("ERROR-404", "Not Found, key is: " + key); } else if (response.getFoundCount() > 1) { Entity entity = response.getFound(0).getEntity(); logger.debug("Read entity: " + entity.toString());
static QueryResult build(final com.google.datastore.v1.LookupResponse response) { return new QueryResult(ImmutableList.copyOf( response.getFoundList().stream() .map(entity -> Entity.builder(entity.getEntity()).build()) .collect(Collectors.toList()))); }
@java.lang.Override public com.google.datastore.v1.LookupResponse getDefaultInstanceForType() { return com.google.datastore.v1.LookupResponse.getDefaultInstance(); }
@java.lang.Override public boolean equals(final java.lang.Object obj) { if (obj == this) { return true; } if (!(obj instanceof com.google.datastore.v1.LookupResponse)) { return super.equals(obj); } com.google.datastore.v1.LookupResponse other = (com.google.datastore.v1.LookupResponse) obj; boolean result = true; result = result && getFoundList().equals(other.getFoundList()); result = result && getMissingList().equals(other.getMissingList()); result = result && getDeferredList().equals(other.getDeferredList()); result = result && unknownFields.equals(other.unknownFields); return result; }
private void loadResults() { com.google.datastore.v1.LookupResponse responsePb = lookup(requestPb.build()); iter = responsePb.getFoundList().iterator(); requestPb.clearKeys(); if (responsePb.getDeferredCount() > 0) { requestPb.addAllKeys(responsePb.getDeferredList()); } }
// Create an RPC request to begin a new transaction. BeginTransactionRequest.Builder treq = BeginTransactionRequest.newBuilder(); // Execute the RPC synchronously. BeginTransactionResponse tres = datastore.beginTransaction(treq.build()); // Get the transaction handle from the response. ByteString tx = tres.getTransaction(); // Create an RPC request to get entities by key. LookupRequest.Builder lreq = LookupRequest.newBuilder(); // Set the entity key with only one `path_element`: no parent. Key.Builder key = Key.newBuilder().addPathElement( Key.PathElement.newBuilder() .setKind("Trivia") .setName("hgtg")); // Add one key to the lookup request. lreq.addKey(key); // Set the transaction, so we get a consistent snapshot of the // entity at the time the transaction started. lreq.getReadOptionsBuilder().setTransaction(tx); // Execute the RPC and get the response. LookupResponse lresp = datastore.lookup(lreq.build()); // Create an RPC request to commit the transaction. CommitRequest.Builder creq = CommitRequest.newBuilder(); // Set the transaction to commit. creq.setTransaction(tx); Entity entity; if (lresp.getFoundCount() > 0) { entity = lresp.getFound(0).getEntity(); }
public Builder mergeFrom(com.google.datastore.v1.LookupResponse other) { if (other == com.google.datastore.v1.LookupResponse.getDefaultInstance()) return this; if (foundBuilder_ == null) { if (!other.found_.isEmpty()) {
@java.lang.Override public int hashCode() { if (memoizedHashCode != 0) { return memoizedHashCode; } int hash = 41; hash = (19 * hash) + getDescriptor().hashCode(); if (getFoundCount() > 0) { hash = (37 * hash) + FOUND_FIELD_NUMBER; hash = (53 * hash) + getFoundList().hashCode(); } if (getMissingCount() > 0) { hash = (37 * hash) + MISSING_FIELD_NUMBER; hash = (53 * hash) + getMissingList().hashCode(); } if (getDeferredCount() > 0) { hash = (37 * hash) + DEFERRED_FIELD_NUMBER; hash = (53 * hash) + getDeferredList().hashCode(); } 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.LookupResponse)) { return super.equals(obj); } com.google.datastore.v1.LookupResponse other = (com.google.datastore.v1.LookupResponse) obj; boolean result = true; result = result && getFoundList() .equals(other.getFoundList()); result = result && getMissingList() .equals(other.getMissingList()); result = result && getDeferredList() .equals(other.getDeferredList()); return result; }
if (lresp.getFoundCount() > 0) { entity = lresp.getFound(0).getEntity(); } else {
List<LookupResponse> lookupResponses = new ArrayList<>(); lookupResponses.add( LookupResponse.newBuilder() .addFound(EntityResult.newBuilder().setEntity(ENTITY1.toPb())) .addFound(EntityResult.newBuilder().setEntity(entity4.toPb())) .build()); lookupResponses.add( LookupResponse.newBuilder() .addFound(EntityResult.newBuilder().setEntity(ENTITY2.toPb())) .addFound(EntityResult.newBuilder().setEntity(ENTITY3.toPb())) .build()); lookupResponses.add( LookupResponse.newBuilder() .addFound(EntityResult.newBuilder().setEntity(entity5.toPb())) .build());
@java.lang.Override public com.google.datastore.v1.LookupResponse getDefaultInstanceForType() { return com.google.datastore.v1.LookupResponse.getDefaultInstance(); }
public com.google.datastore.v1.LookupResponse buildPartial() { com.google.datastore.v1.LookupResponse result = new com.google.datastore.v1.LookupResponse(this); int from_bitField0_ = bitField0_; if (foundBuilder_ == null) {
@Test public void testRetryableException() throws Exception { LookupRequest requestPb = LookupRequest.newBuilder().addKeys(KEY1.toPb()).build(); LookupResponse responsePb = LookupResponse.newBuilder() .addFound(EntityResult.newBuilder().setEntity(ENTITY1.toPb())) .build(); EasyMock.expect(rpcMock.lookup(requestPb)) .andThrow(new DatastoreException(14, "UNAVAILABLE", "UNAVAILABLE", null)) .andReturn(responsePb); EasyMock.replay(rpcFactoryMock, rpcMock); Datastore datastore = rpcMockOptions.getService(); Entity entity = datastore.get(KEY1); assertEquals(ENTITY1, entity); EasyMock.verify(rpcFactoryMock, rpcMock); }