Search in sources :

Example 6 with RowSetReader

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

the class RowSetTest method testLongRW.

private void testLongRW() {
    BatchSchema batchSchema = new SchemaBuilder().add("col", MinorType.BIGINT).build();
    SingleRowSet rs = fixture.rowSetBuilder(batchSchema).add(0L).add(Long.MAX_VALUE).add(Long.MIN_VALUE).build();
    RowSetReader reader = rs.reader();
    assertTrue(reader.next());
    assertEquals(0, reader.column(0).getLong());
    assertTrue(reader.next());
    assertEquals(Long.MAX_VALUE, reader.column(0).getLong());
    assertTrue(reader.next());
    assertEquals(Long.MIN_VALUE, reader.column(0).getLong());
    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 7 with RowSetReader

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

the class RowSetTest method testSmallIntRW.

private void testSmallIntRW() {
    BatchSchema batchSchema = new SchemaBuilder().add("col", MinorType.SMALLINT).build();
    SingleRowSet rs = fixture.rowSetBuilder(batchSchema).add(0).add(Short.MAX_VALUE).add(Short.MIN_VALUE).build();
    RowSetReader reader = rs.reader();
    assertTrue(reader.next());
    assertEquals(0, reader.column(0).getInt());
    assertTrue(reader.next());
    assertEquals(Short.MAX_VALUE, reader.column(0).getInt());
    assertTrue(reader.next());
    assertEquals(Short.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 8 with RowSetReader

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

the class QueryBuilder method singletonInt.

/**
   * Run the query that is expected to return (at least) one row
   * with the only (or first) column returning a int value.
   * The int value cannot be null.
   *
   * @return the value of the first column of the first row
   * @throws RpcException if anything goes wrong
   */
public int singletonInt() throws RpcException {
    RowSet rowSet = rowSet();
    if (rowSet == null) {
        throw new IllegalStateException("No rows returned");
    }
    RowSetReader reader = rowSet.reader();
    reader.next();
    int value = reader.column(0).getInt();
    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 9 with RowSetReader

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

the class RowSetComparison method verify.

/**
   * Verify the actual rows using the rules defined in this builder
   * @param actual the actual results to verify
   */
public void verify(RowSet actual) {
    int testLength = expected.rowCount() - offset;
    if (span > -1) {
        testLength = span;
    }
    int dataLength = offset + testLength;
    assertTrue("Missing expected rows", expected.rowCount() >= dataLength);
    assertTrue("Missing actual rows", actual.rowCount() >= dataLength);
    RowSetReader er = expected.reader();
    RowSetReader ar = actual.reader();
    for (int i = 0; i < offset; i++) {
        er.next();
        ar.next();
    }
    for (int i = 0; i < testLength; i++) {
        er.next();
        ar.next();
        verifyRow(er, ar);
    }
}
Also used : RowSetReader(org.apache.drill.test.rowSet.RowSet.RowSetReader)

Example 10 with RowSetReader

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

the class RowSetPrinter method print.

public void print(PrintStream out) {
    SelectionVectorMode selectionMode = rowSet.indirectionType();
    RowSetReader reader = rowSet.reader();
    int colCount = reader.schema().count();
    printSchema(out, selectionMode);
    while (reader.next()) {
        printHeader(out, reader, selectionMode);
        for (int i = 0; i < colCount; i++) {
            if (i > 0) {
                out.print(", ");
            }
            out.print(reader.getAsString(i));
        }
        out.println();
    }
}
Also used : RowSetReader(org.apache.drill.test.rowSet.RowSet.RowSetReader) SelectionVectorMode(org.apache.drill.exec.record.BatchSchema.SelectionVectorMode)

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