Search in sources :

Example 11 with RowSetReader

use of org.apache.drill.test.rowSet.RowSet.RowSetReader in project drill by apache.

the class QueryBuilder method singletonLong.

/**
   * Run the query that is expected to return (at least) one row
   * with the only (or first) column returning a long value.
   * The long value cannot be null.
   *
   * @return the value of the first column of the first row
   * @throws RpcException if anything goes wrong
   */
public long singletonLong() throws RpcException {
    RowSet rowSet = rowSet();
    if (rowSet == null) {
        throw new IllegalStateException("No rows returned");
    }
    RowSetReader reader = rowSet.reader();
    reader.next();
    long value = reader.column(0).getLong();
    rowSet.clear();
    return value;
}
Also used : DirectRowSet(org.apache.drill.test.rowSet.DirectRowSet) RowSet(org.apache.drill.test.rowSet.RowSet) RowSetReader(org.apache.drill.test.rowSet.RowSet.RowSetReader)

Example 12 with RowSetReader

use of org.apache.drill.test.rowSet.RowSet.RowSetReader in project drill by apache.

the class RowSetTest method testTinyIntRW.

private void testTinyIntRW() {
    BatchSchema batchSchema = new SchemaBuilder().add("col", MinorType.TINYINT).build();
    SingleRowSet rs = fixture.rowSetBuilder(batchSchema).add(0).add(Byte.MAX_VALUE).add(Byte.MIN_VALUE).build();
    RowSetReader reader = rs.reader();
    assertTrue(reader.next());
    assertEquals(0, reader.column(0).getInt());
    assertTrue(reader.next());
    assertEquals(Byte.MAX_VALUE, reader.column(0).getInt());
    assertTrue(reader.next());
    assertEquals(Byte.MIN_VALUE, reader.column(0).getInt());
    assertFalse(reader.next());
    rs.clear();
}
Also used : SingleRowSet(org.apache.drill.test.rowSet.RowSet.SingleRowSet) BatchSchema(org.apache.drill.exec.record.BatchSchema) SchemaBuilder(org.apache.drill.test.rowSet.SchemaBuilder) RowSetReader(org.apache.drill.test.rowSet.RowSet.RowSetReader)

Example 13 with RowSetReader

use of org.apache.drill.test.rowSet.RowSet.RowSetReader in project drill by apache.

the class RowSetTest method testFloatRW.

private void testFloatRW() {
    BatchSchema batchSchema = new SchemaBuilder().add("col", MinorType.FLOAT4).build();
    SingleRowSet rs = fixture.rowSetBuilder(batchSchema).add(0F).add(Float.MAX_VALUE).add(Float.MIN_VALUE).build();
    RowSetReader reader = rs.reader();
    assertTrue(reader.next());
    assertEquals(0, reader.column(0).getDouble(), 0.000001);
    assertTrue(reader.next());
    assertEquals(Float.MAX_VALUE, reader.column(0).getDouble(), 0.000001);
    assertTrue(reader.next());
    assertEquals(Float.MIN_VALUE, reader.column(0).getDouble(), 0.000001);
    assertFalse(reader.next());
    rs.clear();
}
Also used : SingleRowSet(org.apache.drill.test.rowSet.RowSet.SingleRowSet) BatchSchema(org.apache.drill.exec.record.BatchSchema) SchemaBuilder(org.apache.drill.test.rowSet.SchemaBuilder) RowSetReader(org.apache.drill.test.rowSet.RowSet.RowSetReader)

Aggregations

RowSetReader (org.apache.drill.test.rowSet.RowSet.RowSetReader)13 BatchSchema (org.apache.drill.exec.record.BatchSchema)8 SingleRowSet (org.apache.drill.test.rowSet.RowSet.SingleRowSet)8 SchemaBuilder (org.apache.drill.test.rowSet.SchemaBuilder)8 DirectRowSet (org.apache.drill.test.rowSet.DirectRowSet)3 RowSet (org.apache.drill.test.rowSet.RowSet)3 Test (org.junit.Test)2 SelectionVectorMode (org.apache.drill.exec.record.BatchSchema.SelectionVectorMode)1 ArrayReader (org.apache.drill.exec.vector.accessor.ArrayReader)1 ArrayWriter (org.apache.drill.exec.vector.accessor.ArrayWriter)1 ExtendableRowSet (org.apache.drill.test.rowSet.RowSet.ExtendableRowSet)1 RowSetWriter (org.apache.drill.test.rowSet.RowSet.RowSetWriter)1 RowSetComparison (org.apache.drill.test.rowSet.RowSetComparison)1