use of org.apache.drill.exec.physical.config.ExternalSort in project drill by apache.
the class BasicPhysicalOpUnitTest method externalSortLowMemoryHelper.
private void externalSortLowMemoryHelper(int batchSize, int numberOfBatches, long initReservation, long maxAllocation) {
ExternalSort sortConf = new ExternalSort(null, Lists.newArrayList(ordering("b", RelFieldCollation.Direction.ASCENDING, RelFieldCollation.NullDirection.FIRST)), false);
List<String> inputJsonBatches = Lists.newArrayList();
StringBuilder batchString = new StringBuilder();
for (int j = 0; j < numberOfBatches; j++) {
batchString.append("[");
for (int i = 0; i < batchSize; i++) {
batchString.append("{\"a\": 5, \"b\" : 5},{\"a\": 3, \"b\" : 8},");
}
batchString.append("{\"a\": 5, \"b\" : 1 }");
batchString.append("]");
inputJsonBatches.add(batchString.toString());
}
LegacyOperatorTestBuilder opTestBuilder = legacyOpTestBuilder().initReservation(initReservation).maxAllocation(maxAllocation).physicalOperator(sortConf).inputDataStreamJson(inputJsonBatches).baselineColumns("a", "b");
for (int i = 0; i < numberOfBatches; i++) {
opTestBuilder.baselineValues(5l, 1l);
}
for (int i = 0; i < batchSize * numberOfBatches; i++) {
opTestBuilder.baselineValues(5l, 5l);
}
for (int i = 0; i < batchSize * numberOfBatches; i++) {
opTestBuilder.baselineValues(3l, 8l);
}
opTestBuilder.go();
}
use of org.apache.drill.exec.physical.config.ExternalSort in project drill by apache.
the class BasicPhysicalOpUnitTest method testExternalSort.
@Test
public void testExternalSort() {
ExternalSort sortConf = new ExternalSort(null, Lists.newArrayList(ordering("b", RelFieldCollation.Direction.ASCENDING, RelFieldCollation.NullDirection.FIRST)), false);
List<String> inputJsonBatches = Lists.newArrayList("[{\"a\": 5, \"b\" : 1 }]", "[{\"a\": 5, \"b\" : 5},{\"a\": 3, \"b\" : 8}]", "[{\"a\": 40, \"b\" : 3},{\"a\": 13, \"b\" : 100}]");
legacyOpTestBuilder().physicalOperator(sortConf).maxAllocation(15_000_000L).inputDataStreamJson(inputJsonBatches).baselineColumns("a", "b").baselineValues(5l, 1l).baselineValues(40l, 3l).baselineValues(5l, 5l).baselineValues(3l, 8l).baselineValues(13l, 100l).go();
}
use of org.apache.drill.exec.physical.config.ExternalSort in project drill by axbaretto.
the class TestNullInputMiniPlan method testSortEmpty.
@Test
public void testSortEmpty() throws Exception {
final PhysicalOperator sort = new ExternalSort(null, Lists.newArrayList(ordering("b", RelFieldCollation.Direction.ASCENDING, RelFieldCollation.NullDirection.FIRST)), false);
testSingleInputNullBatchHandling(sort);
}
use of org.apache.drill.exec.physical.config.ExternalSort in project drill by axbaretto.
the class TestExternalSortExec method testSortSpec.
@Test
public void testSortSpec() {
FieldReference expr = FieldReference.getWithQuotedRef("foo");
Ordering ordering = new Ordering(Ordering.ORDER_ASC, expr, Ordering.NULLS_FIRST);
// Basics
ExternalSort popConfig = new ExternalSort(null, Lists.newArrayList(ordering), false);
assertSame(ordering, popConfig.getOrderings().get(0));
assertFalse(popConfig.getReverse());
assertEquals(SelectionVectorMode.FOUR_BYTE, popConfig.getSVMode());
assertEquals(CoreOperatorType.EXTERNAL_SORT_VALUE, popConfig.getOperatorType());
assertEquals(ExternalSort.DEFAULT_SORT_ALLOCATION, popConfig.getInitialAllocation());
assertEquals(AbstractBase.MAX_ALLOCATION, popConfig.getMaxAllocation());
assertTrue(popConfig.isExecutable());
// Non-default settings
popConfig = new ExternalSort(null, Lists.newArrayList(ordering), true);
assertTrue(popConfig.getReverse());
long maxAlloc = 50_000_000;
popConfig.setMaxAllocation(maxAlloc);
assertEquals(ExternalSort.DEFAULT_SORT_ALLOCATION, popConfig.getInitialAllocation());
assertEquals(maxAlloc, popConfig.getMaxAllocation());
}
use of org.apache.drill.exec.physical.config.ExternalSort in project drill by axbaretto.
the class SortPrel method getPhysicalOperator.
@Override
public PhysicalOperator getPhysicalOperator(PhysicalPlanCreator creator) throws IOException {
Prel child = (Prel) this.getInput();
PhysicalOperator childPOP = child.getPhysicalOperator(creator);
org.apache.drill.exec.physical.config.Sort g = new ExternalSort(childPOP, PrelUtil.getOrdering(this.collation, getInput().getRowType()), false);
return creator.addMetadata(this, g);
}
Aggregations