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();
}
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();
}
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;
}
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);
}
}
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();
}
}
Aggregations