Search in sources :

Example 51 with ResultSet

use of com.google.spanner.v1.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)

Example 52 with ResultSet

use of com.google.spanner.v1.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 53 with ResultSet

use of com.google.spanner.v1.ResultSet in project googleads-java-lib by googleads.

the class PqlTest method testCombineResultSet.

@Test
public void testCombineResultSet() {
    Row row1 = new Row();
    row1.setValues(new Value[] { textValue1, booleanValue1, numberValue1 });
    Row row2 = new Row();
    row2.setValues(new Value[] { textValue2, booleanValue2, numberValue2 });
    Row row3 = new Row();
    row3.setValues(new Value[] { textValue3, booleanValue3, numberValue3 });
    ResultSet resultSet1 = new ResultSet();
    resultSet1.setColumnTypes(new ColumnType[] { column1, column2, column3 });
    resultSet1.setRows(new Row[] { row1, row2 });
    ResultSet resultSet2 = new ResultSet();
    resultSet2.setColumnTypes(new ColumnType[] { column1, column2, column3 });
    resultSet2.setRows(new Row[] { row3 });
    ResultSet combinedResultSet = Pql.combineResultSets(resultSet1, resultSet2);
    assertEquals(3, combinedResultSet.getRows().length);
    assertArrayEquals(new ColumnType[] { column1, column2, column3 }, combinedResultSet.getColumnTypes());
    assertArrayEquals(new Value[] { textValue1, booleanValue1, numberValue1 }, combinedResultSet.getRows()[0].getValues());
    assertArrayEquals(new Value[] { textValue2, booleanValue2, numberValue2 }, combinedResultSet.getRows()[1].getValues());
    assertArrayEquals(new Value[] { textValue3, booleanValue3, numberValue3 }, combinedResultSet.getRows()[2].getValues());
}
Also used : ResultSet(com.google.api.ads.admanager.axis.v202105.ResultSet) Row(com.google.api.ads.admanager.axis.v202105.Row) Test(org.junit.Test)

Example 54 with ResultSet

use of com.google.spanner.v1.ResultSet in project googleads-java-lib by googleads.

the class PqlTest method testCombineResultSet_badColumns.

@Test
public void testCombineResultSet_badColumns() {
    Row row1 = new Row();
    row1.setValues(new Value[] { textValue1, booleanValue1, numberValue1 });
    Row row2 = new Row();
    row2.setValues(new Value[] { textValue2, booleanValue2, numberValue2 });
    Row row3 = new Row();
    row3.setValues(new Value[] { textValue3, booleanValue3 });
    ResultSet resultSet1 = new ResultSet();
    resultSet1.setColumnTypes(new ColumnType[] { column1, column2, column3 });
    resultSet1.setRows(new Row[] { row1, row2 });
    ResultSet resultSet2 = new ResultSet();
    resultSet2.setColumnTypes(new ColumnType[] { column1, column2 });
    resultSet2.setRows(new Row[] { row3 });
    thrown.expect(IllegalArgumentException.class);
    Pql.combineResultSets(resultSet1, resultSet2);
}
Also used : ResultSet(com.google.api.ads.admanager.axis.v202105.ResultSet) Row(com.google.api.ads.admanager.axis.v202105.Row) Test(org.junit.Test)

Example 55 with ResultSet

use of com.google.spanner.v1.ResultSet in project googleads-java-lib by googleads.

the class PqlTest method testCombineResultSet.

@Test
public void testCombineResultSet() {
    Row row1 = new Row();
    row1.getValues().addAll(Lists.newArrayList(textValue1, booleanValue1, numberValue1));
    Row row2 = new Row();
    row2.getValues().addAll(Lists.newArrayList(textValue2, booleanValue2, numberValue2));
    Row row3 = new Row();
    row3.getValues().addAll(Lists.newArrayList(textValue3, booleanValue3, numberValue3));
    ResultSet resultSet1 = new ResultSet();
    resultSet1.getColumnTypes().addAll(Lists.newArrayList(column1, column2, column3));
    resultSet1.getRows().addAll(Lists.newArrayList(row1, row2));
    ResultSet resultSet2 = new ResultSet();
    resultSet2.getColumnTypes().addAll(Lists.newArrayList(column1, column2, column3));
    resultSet2.getRows().addAll(Lists.newArrayList(row3));
    ResultSet combinedResultSet = Pql.combineResultSets(resultSet1, resultSet2);
    assertEquals(3, combinedResultSet.getRows().size());
    assertEquals(Lists.newArrayList(column1, column2, column3), combinedResultSet.getColumnTypes());
    assertEquals(Lists.newArrayList(textValue1, booleanValue1, numberValue1), combinedResultSet.getRows().get(0).getValues());
    assertEquals(Lists.newArrayList(textValue2, booleanValue2, numberValue2), combinedResultSet.getRows().get(1).getValues());
    assertEquals(Lists.newArrayList(textValue3, booleanValue3, numberValue3), combinedResultSet.getRows().get(2).getValues());
}
Also used : ResultSet(com.google.api.ads.admanager.jaxws.v202105.ResultSet) Row(com.google.api.ads.admanager.jaxws.v202105.Row) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)37 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 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 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 Function (com.google.common.base.Function)8 ResultSetStats (com.google.spanner.v1.ResultSetStats)8 Statement (com.google.cloud.spanner.Statement)6 DateTime (org.joda.time.DateTime)6 PartialResultSet (com.google.spanner.v1.PartialResultSet)5 ResultSet (com.google.spanner.v1.ResultSet)5 ResultSet (com.google.api.ads.admanager.axis.v202105.ResultSet)4 Row (com.google.api.ads.admanager.axis.v202108.Row)4 Row (com.google.api.ads.admanager.axis.v202111.Row)4 Row (com.google.api.ads.admanager.axis.v202202.Row)4