use of org.apache.drill.exec.physical.rowSet.RowSetWriter in project drill by apache.
the class TestBatchSerialization method makeRowSet.
public SingleRowSet makeRowSet(TupleMetadata schema, int rowCount) {
ExtendableRowSet rowSet = fixture.rowSet(schema);
RowSetWriter writer = rowSet.writer(rowCount);
for (int i = 0; i < rowCount; i++) {
RowSetUtilities.setFromInt(writer, 0, i);
writer.save();
}
writer.done();
return rowSet;
}
use of org.apache.drill.exec.physical.rowSet.RowSetWriter in project drill by apache.
the class TestBatchSerialization method makeNullableRowSet.
public SingleRowSet makeNullableRowSet(TupleMetadata schema, int rowCount) {
ExtendableRowSet rowSet = fixture.rowSet(schema);
RowSetWriter writer = rowSet.writer(rowCount);
for (int i = 0; i < rowCount; i++) {
if (i % 2 == 0) {
RowSetUtilities.setFromInt(writer, 0, i);
} else {
writer.scalar(0).setNull();
}
writer.save();
}
writer.done();
return rowSet;
}
use of org.apache.drill.exec.physical.rowSet.RowSetWriter in project drill by apache.
the class TestColumnConverter method testScalarConverter.
/**
* Test doing type conversion using (ad-hoc) properties on the
* column metadata to drive conversion. Verifies that the properties
* are available to the converter.
*/
@Test
public void testScalarConverter() {
// Defined schema for scan output
TupleMetadata outputSchema = new SchemaBuilder().add("a", MinorType.INT).addArray("b", MinorType.INT).buildSchema();
// Writer
RowSetWriter writer = makeWriter(outputSchema);
// Row and column formats
TupleNameSpace<MockConverter> rowFormat = new TupleNameSpace<>();
rowFormat.add(writer.column(0).schema().name(), new MockIntConverter(writer.column(0)));
rowFormat.add(writer.column(1).schema().name(), new MockArrayConverter(writer.column(1)));
// Write data as both a string as an integer
MockSource source = new MockSource();
for (int i = 0; i < 2; i++) {
// Simulate a row
source.rowNo = i + 1;
for (int j = 0; j < rowFormat.count(); j++) {
rowFormat.get(j).setColumn(source);
}
writer.save();
}
// Verify
final SingleRowSet expected = fixture.rowSetBuilder(outputSchema).addRow(10, intArray(101, 102, 103)).addRow(20, intArray(201, 202, 203)).build();
RowSetUtilities.verify(expected, writer.done());
}
use of org.apache.drill.exec.physical.rowSet.RowSetWriter in project drill by apache.
the class TestSortImpl method runWideRowsTest.
/**
* Run a test using wide rows. This stresses the "copier" portion of the sort
* and allows us to test the original generated copier and the revised "generic"
* copier.
*
* @param fixture operator test fixture
* @param colCount number of data (non-key) columns
* @param rowCount number of rows to generate
*/
public void runWideRowsTest(OperatorFixture fixture, int colCount, int rowCount) {
SchemaBuilder builder = new SchemaBuilder().add("key", MinorType.INT);
for (int i = 0; i < colCount; i++) {
builder.add("col" + (i + 1), MinorType.INT);
}
TupleMetadata schema = builder.buildSchema();
ExtendableRowSet rowSet = fixture.rowSet(schema);
RowSetWriter writer = rowSet.writer(rowCount);
for (int i = 0; i < rowCount; i++) {
writer.set(0, i);
for (int j = 0; j < colCount; j++) {
writer.set(j + 1, i * 100_000 + j);
}
writer.save();
}
writer.done();
SortImpl sort = makeSortImpl(fixture, Ordering.ORDER_ASC, Ordering.NULLS_UNSPECIFIED);
sort.setSchema(rowSet.container().getSchema());
sort.addBatch(rowSet.vectorAccessible());
SortResults results = sort.startMerge();
if (results.getContainer() != dest) {
dest.clear();
dest = results.getContainer();
}
assertTrue(results.next());
assertFalse(results.next());
results.close();
dest.clear();
sort.close();
sort.opContext().close();
}
use of org.apache.drill.exec.physical.rowSet.RowSetWriter in project drill by apache.
the class TestCopier method makeDataSet.
public static SingleRowSet makeDataSet(TupleMetadata schema, int first, int step, int count) {
ExtendableRowSet rowSet = fixture.rowSet(schema);
RowSetWriter writer = rowSet.writer(count);
int value = first;
for (int i = 0; i < count; i++, value += step) {
RowSetUtilities.setFromInt(writer, 0, value);
writer.scalar(1).setString(Integer.toString(value));
writer.save();
}
writer.done();
return rowSet;
}
Aggregations