@java.lang.Override public Builder newBuilderForType() { return newBuilder(); }
result = result && getProjectId().equals(other.getProjectId()); result = result && (hasPartitionId() == other.hasPartitionId()); if (hasPartitionId()) { result = result && getPartitionId().equals(other.getPartitionId()); result = result && (hasReadOptions() == other.hasReadOptions()); if (hasReadOptions()) { result = result && getReadOptions().equals(other.getReadOptions()); result = result && getQueryTypeCase().equals(other.getQueryTypeCase()); if (!result) return false; switch (queryTypeCase_) { case 3: result = result && getQuery().equals(other.getQuery()); break; case 7: result = result && getGqlQuery().equals(other.getGqlQuery()); break; case 0:
@java.lang.Override public com.google.datastore.v1.RunQueryRequest buildPartial() { com.google.datastore.v1.RunQueryRequest result = new com.google.datastore.v1.RunQueryRequest(this); result.projectId_ = projectId_; if (partitionIdBuilder_ == null) {
/** * * * <pre> * The ID of the project against which to make the request. * </pre> * * <code>string project_id = 8;</code> */ public Builder clearProjectId() { projectId_ = getDefaultInstance().getProjectId(); onChanged(); return this; } /**
@java.lang.Override public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { if (readOptions_ != null) { output.writeMessage(1, getReadOptions()); } if (partitionId_ != null) { output.writeMessage(2, getPartitionId()); } if (queryTypeCase_ == 3) { output.writeMessage(3, (com.google.datastore.v1.Query) queryType_); } if (queryTypeCase_ == 7) { output.writeMessage(7, (com.google.datastore.v1.GqlQuery) queryType_); } if (!getProjectIdBytes().isEmpty()) { com.google.protobuf.GeneratedMessageV3.writeString(output, 8, projectId_); } unknownFields.writeTo(output); }
hash = (19 * hash) + getDescriptor().hashCode(); hash = (37 * hash) + PROJECT_ID_FIELD_NUMBER; hash = (53 * hash) + getProjectId().hashCode(); if (hasPartitionId()) { hash = (37 * hash) + PARTITION_ID_FIELD_NUMBER; hash = (53 * hash) + getPartitionId().hashCode(); if (hasReadOptions()) { hash = (37 * hash) + READ_OPTIONS_FIELD_NUMBER; hash = (53 * hash) + getReadOptions().hashCode(); hash = (53 * hash) + getQuery().hashCode(); break; case 7: hash = (37 * hash) + GQL_QUERY_FIELD_NUMBER; hash = (53 * hash) + getGqlQuery().hashCode(); break; case 0:
hash = (19 * hash) + getDescriptorForType().hashCode(); hash = (37 * hash) + PROJECT_ID_FIELD_NUMBER; hash = (53 * hash) + getProjectId().hashCode(); if (hasPartitionId()) { hash = (37 * hash) + PARTITION_ID_FIELD_NUMBER; hash = (53 * hash) + getPartitionId().hashCode(); if (hasReadOptions()) { hash = (37 * hash) + READ_OPTIONS_FIELD_NUMBER; hash = (53 * hash) + getReadOptions().hashCode(); hash = (53 * hash) + getQuery().hashCode(); break; case 7: hash = (37 * hash) + GQL_QUERY_FIELD_NUMBER; hash = (53 * hash) + getGqlQuery().hashCode(); break; case 0:
/** Helper function to run a test reading from a {@link ReadFn}. */ private void readFnTest(int numEntities) throws Exception { // An empty query to read entities. Query query = Query.newBuilder().setLimit(Int32Value.newBuilder().setValue(numEntities)).build(); // Use mockResponseForQuery to generate results. when(mockDatastore.runQuery(any(RunQueryRequest.class))) .thenAnswer( invocationOnMock -> { Query q = ((RunQueryRequest) invocationOnMock.getArguments()[0]).getQuery(); return mockResponseForQuery(q); }); ReadFn readFn = new ReadFn(V_1_OPTIONS, mockDatastoreFactory); DoFnTester<Query, Entity> doFnTester = DoFnTester.of(readFn); /** * Although Datastore client is marked transient in {@link ReadFn}, when injected through mock * factory using a when clause for unit testing purposes, it is not serializable because it * doesn't have a no-arg constructor. Thus disabling the cloning to prevent the test object from * being serialized. */ doFnTester.setCloningBehavior(CloningBehavior.DO_NOT_CLONE); List<Entity> entities = doFnTester.processBundle(query); int expectedNumCallsToRunQuery = (int) Math.ceil((double) numEntities / QUERY_BATCH_LIMIT); verify(mockDatastore, times(expectedNumCallsToRunQuery)).runQuery(any(RunQueryRequest.class)); // Validate the number of results. assertEquals(numEntities, entities.size()); }
@java.lang.Override public com.google.datastore.v1.RunQueryRequest getDefaultInstanceForType() { return com.google.datastore.v1.RunQueryRequest.getDefaultInstance(); }
/** * * * <pre> * Entities are partitioned into subsets, identified by a partition ID. * Queries are scoped to a single partition. * This partition ID is normalized with the standard default context * partition ID. * </pre> * * <code>.google.datastore.v1.PartitionId partition_id = 2;</code> */ public com.google.datastore.v1.PartitionIdOrBuilder getPartitionIdOrBuilder() { return getPartitionId(); }
hash = (19 * hash) + getDescriptor().hashCode(); hash = (37 * hash) + PROJECT_ID_FIELD_NUMBER; hash = (53 * hash) + getProjectId().hashCode(); if (hasPartitionId()) { hash = (37 * hash) + PARTITION_ID_FIELD_NUMBER; hash = (53 * hash) + getPartitionId().hashCode(); if (hasReadOptions()) { hash = (37 * hash) + READ_OPTIONS_FIELD_NUMBER; hash = (53 * hash) + getReadOptions().hashCode(); hash = (53 * hash) + getQuery().hashCode(); break; case 7: hash = (37 * hash) + GQL_QUERY_FIELD_NUMBER; hash = (53 * hash) + getGqlQuery().hashCode(); break; case 0:
@java.lang.Override public int getSerializedSize() { int size = memoizedSize; if (size != -1) return size; size = 0; if (readOptions_ != null) { size += com.google.protobuf.CodedOutputStream.computeMessageSize(1, getReadOptions()); } if (partitionId_ != null) { size += com.google.protobuf.CodedOutputStream.computeMessageSize(2, getPartitionId()); } if (queryTypeCase_ == 3) { size += com.google.protobuf.CodedOutputStream.computeMessageSize( 3, (com.google.datastore.v1.Query) queryType_); } if (queryTypeCase_ == 7) { size += com.google.protobuf.CodedOutputStream.computeMessageSize( 7, (com.google.datastore.v1.GqlQuery) queryType_); } if (!getProjectIdBytes().isEmpty()) { size += com.google.protobuf.GeneratedMessageV3.computeStringSize(8, projectId_); } size += unknownFields.getSerializedSize(); memoizedSize = size; return size; }
/** * <pre> * The ID of the project against which to make the request. * </pre> * * <code>optional string project_id = 8;</code> */ public Builder clearProjectId() { projectId_ = getDefaultInstance().getProjectId(); onChanged(); return this; } /**
/** Tests that {@link ReadFn} retries after an error. */ @Test public void testReadFnRetriesErrors() throws Exception { // An empty query to read entities. Query query = Query.newBuilder().setLimit(Int32Value.newBuilder().setValue(1)).build(); // Use mockResponseForQuery to generate results. when(mockDatastore.runQuery(any(RunQueryRequest.class))) .thenThrow(new DatastoreException("RunQuery", Code.DEADLINE_EXCEEDED, "", null)) .thenAnswer( invocationOnMock -> { Query q = ((RunQueryRequest) invocationOnMock.getArguments()[0]).getQuery(); return mockResponseForQuery(q); }); ReadFn readFn = new ReadFn(V_1_OPTIONS, mockDatastoreFactory); DoFnTester<Query, Entity> doFnTester = DoFnTester.of(readFn); doFnTester.setCloningBehavior(CloningBehavior.DO_NOT_CLONE); doFnTester.processBundle(query); }
@java.lang.Override public com.google.datastore.v1.RunQueryRequest getDefaultInstanceForType() { return com.google.datastore.v1.RunQueryRequest.getDefaultInstance(); }
/** * <pre> * Entities are partitioned into subsets, identified by a partition ID. * Queries are scoped to a single partition. * This partition ID is normalized with the standard default context * partition ID. * </pre> * * <code>optional .google.datastore.v1.PartitionId partition_id = 2;</code> */ public com.google.datastore.v1.PartitionIdOrBuilder getPartitionIdOrBuilder() { return getPartitionId(); }
public Builder mergeFrom(com.google.datastore.v1.RunQueryRequest other) { if (other == com.google.datastore.v1.RunQueryRequest.getDefaultInstance()) return this; if (!other.getProjectId().isEmpty()) { projectId_ = other.projectId_; onChanged(); if (other.hasPartitionId()) { mergePartitionId(other.getPartitionId()); if (other.hasReadOptions()) { mergeReadOptions(other.getReadOptions()); switch (other.getQueryTypeCase()) { case QUERY: mergeQuery(other.getQuery()); break; mergeGqlQuery(other.getGqlQuery()); break;
private void sendRequest() { com.google.datastore.v1.RunQueryRequest.Builder requestPb = com.google.datastore.v1.RunQueryRequest.newBuilder(); if (readOptionsPb != null) { requestPb.setReadOptions(readOptionsPb); } requestPb.setPartitionId(partitionIdPb); query.populatePb(requestPb); runQueryResponsePb = datastore.runQuery(requestPb.build()); mostRecentQueryPb = runQueryResponsePb.getQuery(); if (mostRecentQueryPb == null) { mostRecentQueryPb = requestPb.getQuery(); } lastBatch = runQueryResponsePb.getBatch().getMoreResults() != MoreResultsType.NOT_FINISHED; entityResultPbIter = runQueryResponsePb.getBatch().getEntityResultsList().iterator(); actualResultType = ResultType.fromPb(runQueryResponsePb.getBatch().getEntityResultType()); if (Objects.equals(queryResultType, ResultType.PROJECTION_ENTITY)) { // projection entity can represent all type of results actualResultType = ResultType.PROJECTION_ENTITY; } Preconditions.checkState( queryResultType.isAssignableFrom(actualResultType), "Unexpected result type " + actualResultType + " vs " + queryResultType); }
public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { if (readOptions_ != null) { output.writeMessage(1, getReadOptions()); } if (partitionId_ != null) { output.writeMessage(2, getPartitionId()); } if (queryTypeCase_ == 3) { output.writeMessage(3, (com.google.datastore.v1.Query) queryType_); } if (queryTypeCase_ == 7) { output.writeMessage(7, (com.google.datastore.v1.GqlQuery) queryType_); } if (!getProjectIdBytes().isEmpty()) { com.google.protobuf.GeneratedMessageV3.writeString(output, 8, projectId_); } }
/** * * * <pre> * The ID of the project against which to make the request. * </pre> * * <code>string project_id = 8;</code> */ public Builder clearProjectId() { projectId_ = getDefaultInstance().getProjectId(); onChanged(); return this; } /**