use of org.apache.drill.test.rowSet.RowSetWriter in project drill by axbaretto.
the class TestCopier method makeDataSet.
public static SingleRowSet makeDataSet(BatchSchema 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;
}
use of org.apache.drill.test.rowSet.RowSetWriter in project drill by axbaretto.
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);
}
BatchSchema schema = builder.build();
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();
VectorContainer dest = new VectorContainer();
SortImpl sort = makeSortImpl(fixture, Ordering.ORDER_ASC, Ordering.NULLS_UNSPECIFIED, dest);
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.test.rowSet.RowSetWriter in project drill by axbaretto.
the class TestBatchSerialization method makeRowSet.
public SingleRowSet makeRowSet(BatchSchema 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.test.rowSet.RowSetWriter in project drill by axbaretto.
the class RowSetTest method testTopFixedWidthArray.
/**
* Test an array of ints (as an example fixed-width type)
* at the top level of a schema.
*/
@Test
public void testTopFixedWidthArray() {
BatchSchema batchSchema = new SchemaBuilder().add("c", MinorType.INT).addArray("a", MinorType.INT).build();
ExtendableRowSet rs1 = fixture.rowSet(batchSchema);
RowSetWriter writer = rs1.writer();
writer.scalar(0).setInt(10);
ScalarWriter array = writer.array(1).scalar();
array.setInt(100);
array.setInt(110);
writer.save();
writer.scalar(0).setInt(20);
array.setInt(200);
array.setInt(120);
array.setInt(220);
writer.save();
writer.scalar(0).setInt(30);
writer.save();
SingleRowSet result = writer.done();
RowSetReader reader = result.reader();
assertTrue(reader.next());
assertEquals(10, reader.scalar(0).getInt());
ScalarElementReader arrayReader = reader.array(1).elements();
assertEquals(2, arrayReader.size());
assertEquals(100, arrayReader.getInt(0));
assertEquals(110, arrayReader.getInt(1));
assertTrue(reader.next());
assertEquals(20, reader.scalar(0).getInt());
assertEquals(3, arrayReader.size());
assertEquals(200, arrayReader.getInt(0));
assertEquals(120, arrayReader.getInt(1));
assertEquals(220, arrayReader.getInt(2));
assertTrue(reader.next());
assertEquals(30, reader.scalar(0).getInt());
assertEquals(0, arrayReader.size());
assertFalse(reader.next());
SingleRowSet rs2 = fixture.rowSetBuilder(batchSchema).addRow(10, intArray(100, 110)).addRow(20, intArray(200, 120, 220)).addRow(30, null).build();
new RowSetComparison(rs1).verifyAndClearAll(rs2);
}
use of org.apache.drill.test.rowSet.RowSetWriter in project drill by axbaretto.
the class RowSetTest method testRowBounds.
/**
* Test filling a row set up to the maximum number of rows.
* Values are small enough to prevent filling to the
* maximum buffer size.
*/
@Test
public void testRowBounds() {
BatchSchema batchSchema = new SchemaBuilder().add("a", MinorType.INT).build();
ExtendableRowSet rs = fixture.rowSet(batchSchema);
RowSetWriter writer = rs.writer();
int count = 0;
while (!writer.isFull()) {
writer.scalar(0).setInt(count++);
writer.save();
}
writer.done();
assertEquals(ValueVector.MAX_ROW_COUNT, count);
// The writer index points past the writable area.
// But, this is fine, the valid() method says we can't
// write at this location.
assertEquals(ValueVector.MAX_ROW_COUNT, writer.rowIndex());
assertEquals(ValueVector.MAX_ROW_COUNT, rs.rowCount());
rs.clear();
}
Aggregations