Search in sources :

Example 96 with ResultSet

use of com.google.api.ads.admanager.axis.v202205.ResultSet 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());
}
Also used : SpannerStub(com.google.spanner.v1.SpannerGrpc.SpannerStub) PartialResultSet(com.google.spanner.v1.PartialResultSet) ResultSet(com.google.spanner.v1.ResultSet) ManagedChannel(io.grpc.ManagedChannel) GcpManagedChannel(com.google.grpc.gcp.GcpManagedChannel) Session(com.google.spanner.v1.Session) ReadRequest(com.google.spanner.v1.ReadRequest)

Example 97 with ResultSet

use of com.google.api.ads.admanager.axis.v202205.ResultSet in project grpc-gcp-java by GoogleCloudPlatform.

the class SpannerIntegrationTest method testExecuteSqlFuture.

@Test
public void testExecuteSqlFuture() throws Exception {
    SpannerFutureStub stub = getSpannerFutureStub();
    List<String> futureNames = createFutureSessions(stub);
    for (String futureName : futureNames) {
        ListenableFuture<ResultSet> responseFuture = stub.executeSql(ExecuteSqlRequest.newBuilder().setSession(futureName).setSql("select * FROM Users").build());
        // The ChannelRef which is bound with the current affinity key.
        GcpManagedChannel.ChannelRef currentChannel = gcpChannel.affinityKeyToChannelRef.get(futureName);
        // Verify the channel is in use.
        assertEquals(1, currentChannel.getActiveStreamsCount());
        ResultSet response = responseFuture.get();
        assertEquals(1, response.getRowsCount());
        assertEquals(USERNAME, response.getRows(0).getValuesList().get(1).getStringValue());
        assertEquals(0, currentChannel.getActiveStreamsCount());
    }
    deleteFutureSessions(stub, futureNames);
}
Also used : SpannerFutureStub(com.google.spanner.v1.SpannerGrpc.SpannerFutureStub) PartialResultSet(com.google.spanner.v1.PartialResultSet) ResultSet(com.google.spanner.v1.ResultSet) Test(org.junit.Test)

Example 98 with ResultSet

use of com.google.api.ads.admanager.axis.v202205.ResultSet in project cassandra by apache.

the class ListUsersStatement method formatResults.

@Override
protected ResultMessage formatResults(List<RoleResource> sortedRoles) {
    ResultSet.ResultMetadata resultMetadata = new ResultSet.ResultMetadata(metadata);
    ResultSet result = new ResultSet(resultMetadata);
    IRoleManager roleManager = DatabaseDescriptor.getRoleManager();
    INetworkAuthorizer networkAuthorizer = DatabaseDescriptor.getNetworkAuthorizer();
    for (RoleResource role : sortedRoles) {
        if (!roleManager.canLogin(role))
            continue;
        result.addColumnValue(UTF8Type.instance.decompose(role.getRoleName()));
        result.addColumnValue(BooleanType.instance.decompose(Roles.hasSuperuserStatus(role)));
        result.addColumnValue(UTF8Type.instance.decompose(networkAuthorizer.authorize(role).toString()));
    }
    return new ResultMessage.Rows(result);
}
Also used : ResultSet(org.apache.cassandra.cql3.ResultSet)

Example 99 with ResultSet

use of com.google.api.ads.admanager.axis.v202205.ResultSet in project cassandra by apache.

the class BurnTestUtil method generateRows.

public static ResultMessage.Rows generateRows(int idx, SizeCaps sizeCaps) {
    Random rnd = new Random(idx);
    List<ColumnSpecification> columns = new ArrayList<>();
    for (int i = 0; i < sizeCaps.columnCountCap; i++) {
        columns.add(new ColumnSpecification("ks", "cf", new ColumnIdentifier(bytes(rnd, 5, 10), BytesType.instance), BytesType.instance));
    }
    List<List<ByteBuffer>> rows = new ArrayList<>();
    int count = rnd.nextInt(sizeCaps.rowsCountCap);
    for (int i = 0; i < count; i++) {
        List<ByteBuffer> row = new ArrayList<>();
        for (int j = 0; j < sizeCaps.columnCountCap; j++) row.add(bytes(rnd, sizeCaps.valueMinSize, sizeCaps.valueMaxSize));
        rows.add(row);
    }
    ResultSet resultSet = new ResultSet(new ResultSet.ResultMetadata(columns), rows);
    return new ResultMessage.Rows(resultSet);
}
Also used : ColumnSpecification(org.apache.cassandra.cql3.ColumnSpecification) ArrayList(java.util.ArrayList) ByteBuffer(java.nio.ByteBuffer) Random(java.util.Random) ResultSet(org.apache.cassandra.cql3.ResultSet) ColumnIdentifier(org.apache.cassandra.cql3.ColumnIdentifier) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

Test (org.junit.Test)37 ResultSet (com.google.spanner.v1.ResultSet)21 PartialResultSet (com.google.spanner.v1.PartialResultSet)14 ResultSet (com.google.api.ads.admanager.axis.v202108.ResultSet)12 ResultSet (com.google.api.ads.admanager.axis.v202111.ResultSet)12 ResultSet (com.google.api.ads.admanager.axis.v202202.ResultSet)12 ResultSet (com.google.api.ads.admanager.axis.v202205.ResultSet)12 Function (com.google.common.base.Function)10 StatementBuilder (com.google.api.ads.admanager.axis.utils.v202108.StatementBuilder)8 StatementBuilder (com.google.api.ads.admanager.axis.utils.v202111.StatementBuilder)8 StatementBuilder (com.google.api.ads.admanager.axis.utils.v202202.StatementBuilder)8 StatementBuilder (com.google.api.ads.admanager.axis.utils.v202205.StatementBuilder)8 PublisherQueryLanguageServiceInterface (com.google.api.ads.admanager.axis.v202108.PublisherQueryLanguageServiceInterface)8 PublisherQueryLanguageServiceInterface (com.google.api.ads.admanager.axis.v202111.PublisherQueryLanguageServiceInterface)8 PublisherQueryLanguageServiceInterface (com.google.api.ads.admanager.axis.v202202.PublisherQueryLanguageServiceInterface)8 PublisherQueryLanguageServiceInterface (com.google.api.ads.admanager.axis.v202205.PublisherQueryLanguageServiceInterface)8 Session (com.google.spanner.v1.Session)8 DateTime (org.joda.time.DateTime)8 ListValue (com.google.protobuf.ListValue)5 ResultSet (org.apache.cassandra.cql3.ResultSet)5