use of com.google.spanner.v1.ReadRequest in project java-spanner by googleapis.
the class DatabaseClientImplTest method testExecuteReadWithPriority.
@Test
public void testExecuteReadWithPriority() {
DatabaseClient client = spanner.getDatabaseClient(DatabaseId.of(TEST_PROJECT, TEST_INSTANCE, TEST_DATABASE));
try (ResultSet resultSet = client.singleUse().read(READ_TABLE_NAME, KeySet.singleKey(Key.of(1L)), READ_COLUMN_NAMES, Options.priority(RpcPriority.HIGH))) {
while (resultSet.next()) {
}
}
List<ReadRequest> requests = mockSpanner.getRequestsOfType(ReadRequest.class);
assertThat(requests).hasSize(1);
ReadRequest request = requests.get(0);
assertNotNull(request.getRequestOptions());
assertEquals(Priority.PRIORITY_HIGH, request.getRequestOptions().getPriority());
}
use of com.google.spanner.v1.ReadRequest in project grpc-gcp-java by GoogleCloudPlatform.
the class SpannerClientV1TestCases method testRead.
void testRead() throws InterruptedException {
System.out.println("\nTestRead");
SpannerClient client = getClient();
Session session = client.createSession(CreateSessionRequest.newBuilder().setDatabase(database).build());
ReadRequest request = ReadRequest.newBuilder().setSession(session.getName()).setTable(TABLE).setKeySet(KeySet.newBuilder().setAll(true).build()).addColumns("users").addColumns("firstname").addColumns("lastname").build();
RpcCall<ReadRequest, ResultSet> rpcCall = (ReadRequest req) -> client.read(req);
doTestBlocking(request, rpcCall);
cleanUpClient(client, session.getName());
}
use of com.google.spanner.v1.ReadRequest in project grpc-gcp-java by GoogleCloudPlatform.
the class SpannerTestCases method testReadAsync.
void testReadAsync() throws InterruptedException {
System.out.println("\nTestReadAsync");
ManagedChannel channel = getChannel();
SpannerStub stub = getStub(channel);
AsyncResponseObserver<Session> sessionObs = new AsyncResponseObserver<>();
stub.createSession(CreateSessionRequest.newBuilder().setDatabase(database).build(), sessionObs);
ReadRequest request = ReadRequest.newBuilder().setSession(sessionObs.get().getName()).setTable("small_table").setKeySet(KeySet.newBuilder().setAll(true).build()).addColumns("users").addColumns("firstname").addColumns("lastname").build();
AsyncCall<ReadRequest, ResultSet> asyncCall = (ReadRequest req, AsyncResponseObserver<ResultSet> resp) -> stub.read(req, resp);
doTestAsync(channel, request, asyncCall);
deleteAndCloseAsync(stub, channel, sessionObs.get().getName());
}
Aggregations