use of com.google.api.ads.admanager.axis.v202205.ResultSet in project grpc-gcp-java by GoogleCloudPlatform.
the class SpannerTestCases method testRead.
void testRead() throws InterruptedException {
System.out.println("\nTestRead");
ManagedChannel channel = getChannel();
SpannerBlockingStub stub = getBlockingStub(channel);
Session session = stub.createSession(CreateSessionRequest.newBuilder().setDatabase(database).build());
ReadRequest request = ReadRequest.newBuilder().setSession(session.getName()).setTable("small_table").setKeySet(KeySet.newBuilder().setAll(true).build()).addColumns("users").addColumns("firstname").addColumns("lastname").build();
BlockingCall<ReadRequest, ResultSet> blockingCall = (ReadRequest req) -> stub.read(req);
doTestBlocking(channel, request, blockingCall);
stub.deleteSession(DeleteSessionRequest.newBuilder().setName(session.getName()).build());
channel.shutdown().awaitTermination(5, TimeUnit.SECONDS);
}
use of com.google.api.ads.admanager.axis.v202205.ResultSet in project stargate by stargate.
the class DefaultQueryInterceptor method interceptQuery.
@Override
public ResultMessage interceptQuery(CQLStatement statement, QueryState state, QueryOptions options, Map<String, ByteBuffer> customPayload, long queryStartNanoTime) {
if (!isSystemLocalOrPeers(statement)) {
return null;
}
SelectStatement selectStatement = (SelectStatement) statement;
TableMetadata tableMetadata = StargateSystemKeyspace.Local;
if (isSystemPeers(selectStatement))
tableMetadata = StargateSystemKeyspace.Peers;
else if (isSystemPeersV2(selectStatement))
tableMetadata = StargateSystemKeyspace.PeersV2;
SelectStatement interceptStatement = new SelectStatement(tableMetadata, selectStatement.bindVariables, selectStatement.parameters, selectStatement.getSelection(), selectStatement.getRestrictions(), false, null, null, null, null);
ResultMessage.Rows rows = interceptStatement.execute(state, options, queryStartNanoTime);
return new ResultMessage.Rows(new ResultSet(selectStatement.getResultMetadata(), rows.result.rows));
}
use of com.google.api.ads.admanager.axis.v202205.ResultSet in project stargate by stargate.
the class ProxyProtocolQueryInterceptor method interceptQuery.
@Override
public Single<ResultMessage> interceptQuery(CQLStatement statement, QueryState state, QueryOptions options, Map<String, ByteBuffer> customPayload, long queryStartNanoTime) {
// see DseConnection
assert state.getClientState() instanceof StargateClientState;
StargateClientState clientState = (StargateClientState) state.getClientState();
if (!isSystemLocalOrPeers(statement) || !clientState.proxyDestinationAddress().isPresent()) {
return wrapped.map(i -> i.interceptQuery(statement, state, options, customPayload, queryStartNanoTime)).orElse(null);
}
InetSocketAddress destinationAddress = clientState.proxyDestinationAddress().get();
boolean isPrivateDestination = destinationAddress.getAddress().isSiteLocalAddress();
// If the destination is private, we want to use the "source" address of the PROXY header.
// We stored that in clientState.getRemoteAddress().
InetAddress systemLocalAddress = isPrivateDestination ? clientState.getRemoteAddress().getAddress() : destinationAddress.getAddress();
SelectStatement selectStatement = (SelectStatement) statement;
List<List<ByteBuffer>> rows;
String tableName = selectStatement.table();
boolean isPrivateLocal = systemLocalAddress.isSiteLocalAddress();
Set<InetAddress> peers = isPrivateLocal ? privatePeers : publicPeers;
if (tableName.equals(PeersSystemView.NAME)) {
rows = peers.isEmpty() ? Collections.emptyList() : Lists.newArrayListWithCapacity(peers.size() - 1);
for (InetAddress peer : peers) {
if (!peer.equals(systemLocalAddress)) {
rows.add(buildRow(selectStatement.getResultMetadata(), peer, peers));
}
}
} else {
assert tableName.equals(LocalNodeSystemView.NAME);
rows = Collections.singletonList(buildRow(selectStatement.getResultMetadata(), systemLocalAddress, peers));
}
ResultSet resultSet = new ResultSet(selectStatement.getResultMetadata(), rows);
return Single.just(new ResultMessage.Rows(resultSet));
}
use of com.google.api.ads.admanager.axis.v202205.ResultSet in project beam by apache.
the class SpannerChangeStreamErrorTest method mockTableExists.
private void mockTableExists() {
Statement tableExistsStatement = Statement.of("SELECT t.table_name FROM information_schema.tables AS t WHERE t.table_catalog = '' AND t.table_schema = '' AND t.table_name = 'my-metadata-table'");
ResultSetMetadata tableExistsResultSetMetadata = ResultSetMetadata.newBuilder().setRowType(StructType.newBuilder().addFields(Field.newBuilder().setName("table_name").setType(Type.newBuilder().setCode(TypeCode.STRING).build()).build()).build()).build();
ResultSet tableExistsResultSet = ResultSet.newBuilder().addRows(ListValue.newBuilder().addValues(Value.newBuilder().setStringValue(TEST_TABLE).build()).build()).setMetadata(tableExistsResultSetMetadata).build();
mockSpannerService.putStatementResult(StatementResult.query(tableExistsStatement, tableExistsResultSet));
}
use of com.google.api.ads.admanager.axis.v202205.ResultSet in project beam by apache.
the class SpannerChangeStreamErrorTest method mockGetParentPartition.
private ResultSet mockGetParentPartition(Timestamp startTimestamp, Timestamp after3Seconds) {
Statement getPartitionStatement = Statement.newBuilder("SELECT * FROM my-metadata-table WHERE PartitionToken = @partition").bind("partition").to("Parent0").build();
ResultSet getPartitionResultSet = ResultSet.newBuilder().addRows(ListValue.newBuilder().addValues(Value.newBuilder().setStringValue("Parent0")).addValues(Value.newBuilder().setListValue(ListValue.newBuilder().build())).addValues(Value.newBuilder().setStringValue(startTimestamp.toString())).addValues(Value.newBuilder().setStringValue(after3Seconds.toString())).addValues(Value.newBuilder().setStringValue("500")).addValues(Value.newBuilder().setStringValue(State.CREATED.name())).addValues(Value.newBuilder().setStringValue(startTimestamp.toString())).addValues(Value.newBuilder().setStringValue(startTimestamp.toString())).addValues(Value.newBuilder().setNullValue(NullValue.NULL_VALUE).build()).addValues(Value.newBuilder().setNullValue(NullValue.NULL_VALUE).build()).addValues(Value.newBuilder().setNullValue(NullValue.NULL_VALUE).build()).build()).setMetadata(PARTITION_METADATA_RESULT_SET_METADATA).build();
mockSpannerService.putStatementResult(StatementResult.query(getPartitionStatement, getPartitionResultSet));
return getPartitionResultSet;
}
Aggregations