use of org.apache.drill.test.OperatorFixture in project drill by axbaretto.
the class TestSortImpl method testSingleBatch.
/**
* Degenerate case: two (unsorted) rows in single batch
* @throws Exception
*/
@Test
public void testSingleBatch() throws Exception {
try (OperatorFixture fixture = OperatorFixture.standardFixture()) {
BatchSchema schema = SortTestUtilities.nonNullSchema();
SortTestFixture sortTest = new SortTestFixture(fixture);
sortTest.addInput(fixture.rowSetBuilder(schema).addRow(2, "second").addRow(1, "first").build());
sortTest.addOutput(fixture.rowSetBuilder(schema).addRow(1, "first").addRow(2, "second").build());
sortTest.run();
}
}
use of org.apache.drill.test.OperatorFixture in project drill by axbaretto.
the class TestSortImpl method testTwoBatches.
/**
* Degenerate case, one row in each of two
* (unsorted) batches.
* @throws Exception
*/
@Test
public void testTwoBatches() throws Exception {
try (OperatorFixture fixture = OperatorFixture.standardFixture()) {
BatchSchema schema = SortTestUtilities.nonNullSchema();
SortTestFixture sortTest = new SortTestFixture(fixture);
sortTest.addInput(fixture.rowSetBuilder(schema).addRow(2, "second").build());
sortTest.addInput(fixture.rowSetBuilder(schema).addRow(1, "first").build());
sortTest.addOutput(fixture.rowSetBuilder(schema).addRow(1, "first").addRow(2, "second").build());
sortTest.run();
}
}
use of org.apache.drill.test.OperatorFixture in project drill by axbaretto.
the class TestSortImpl method testSpill.
/**
* Force the sorter to spill, and verify that the resulting data
* is correct. Uses a specific property of the sort to set the
* in-memory batch limit so that we don't have to fiddle with filling
* up memory. The point here is not to test the code that decides when
* to spill (that was already tested.) Nor to test the spilling
* mechanism itself (that has also already been tested.) Rather it is
* to ensure that, when those components are integrated into the
* sort implementation, that the whole assembly does the right thing.
*
* @throws Exception
*/
@Test
public void testSpill() throws Exception {
OperatorFixture.Builder builder = OperatorFixture.builder();
builder.configBuilder().put(ExecConstants.EXTERNAL_SORT_BATCH_LIMIT, 2);
try (OperatorFixture fixture = builder.build()) {
BatchSchema schema = SortTestUtilities.nonNullSchema();
SortTestFixture sortTest = new SortTestFixture(fixture) {
@Override
protected void validateSort(SortImpl sort) {
assertEquals(1, sort.getMetrics().getSpillCount());
assertEquals(0, sort.getMetrics().getMergeCount());
assertEquals(2, sort.getMetrics().getPeakBatchCount());
}
@Override
protected void validateFinalStats(SortImpl sort) {
assertTrue(sort.getMetrics().getWriteBytes() > 0);
}
};
sortTest.addInput(fixture.rowSetBuilder(schema).addRow(2, "second").build());
sortTest.addInput(fixture.rowSetBuilder(schema).addRow(3, "third").build());
sortTest.addInput(fixture.rowSetBuilder(schema).addRow(1, "first").build());
sortTest.addOutput(fixture.rowSetBuilder(schema).addRow(1, "first").addRow(2, "second").addRow(3, "third").build());
sortTest.run();
}
}
use of org.apache.drill.test.OperatorFixture in project drill by axbaretto.
the class TestSortImpl method testEmptyInput.
/**
* Test for an input with a schema, but only an empty input batch.
* @throws Exception
*/
@Test
public void testEmptyInput() throws Exception {
try (OperatorFixture fixture = OperatorFixture.standardFixture()) {
BatchSchema schema = SortTestUtilities.nonNullSchema();
SortTestFixture sortTest = new SortTestFixture(fixture);
sortTest.addInput(fixture.rowSetBuilder(schema).build());
sortTest.run();
}
}
use of org.apache.drill.test.OperatorFixture in project drill by axbaretto.
the class TestSortImpl method testSingleRow.
/**
* Degenerate case: single row in single batch.
* @throws Exception
*/
@Test
public void testSingleRow() throws Exception {
try (OperatorFixture fixture = OperatorFixture.standardFixture()) {
BatchSchema schema = SortTestUtilities.nonNullSchema();
SortTestFixture sortTest = new SortTestFixture(fixture);
sortTest.addInput(fixture.rowSetBuilder(schema).addRow(1, "first").build());
sortTest.addOutput(fixture.rowSetBuilder(schema).addRow(1, "first").build());
sortTest.run();
}
}
Aggregations