Search in sources :

Example 6 with ExternalSort

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();
}
Also used : LegacyOperatorTestBuilder(org.apache.drill.test.LegacyOperatorTestBuilder) ExternalSort(org.apache.drill.exec.physical.config.ExternalSort) MinorFragmentEndpoint(org.apache.drill.exec.physical.MinorFragmentEndpoint)

Example 7 with ExternalSort

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();
}
Also used : ExternalSort(org.apache.drill.exec.physical.config.ExternalSort) Test(org.junit.Test)

Example 8 with ExternalSort

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);
}
Also used : PhysicalOperator(org.apache.drill.exec.physical.base.PhysicalOperator) ExternalSort(org.apache.drill.exec.physical.config.ExternalSort) Test(org.junit.Test)

Example 9 with ExternalSort

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());
}
Also used : FieldReference(org.apache.drill.common.expression.FieldReference) ExternalSort(org.apache.drill.exec.physical.config.ExternalSort) Ordering(org.apache.drill.common.logical.data.Order.Ordering) OperatorTest(org.apache.drill.categories.OperatorTest) Test(org.junit.Test) DrillTest(org.apache.drill.test.DrillTest)

Example 10 with ExternalSort

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);
}
Also used : PhysicalOperator(org.apache.drill.exec.physical.base.PhysicalOperator) ExternalSort(org.apache.drill.exec.physical.config.ExternalSort)

Aggregations

ExternalSort (org.apache.drill.exec.physical.config.ExternalSort)12 Test (org.junit.Test)6 PhysicalOperator (org.apache.drill.exec.physical.base.PhysicalOperator)5 FieldReference (org.apache.drill.common.expression.FieldReference)3 OperatorTest (org.apache.drill.categories.OperatorTest)2 Ordering (org.apache.drill.common.logical.data.Order.Ordering)2 MinorFragmentEndpoint (org.apache.drill.exec.physical.MinorFragmentEndpoint)2 DrillTest (org.apache.drill.test.DrillTest)2 LinkedList (java.util.LinkedList)1 Order (org.apache.drill.common.logical.data.Order)1 OptionManager (org.apache.drill.exec.server.options.OptionManager)1 LegacyOperatorTestBuilder (org.apache.drill.test.LegacyOperatorTestBuilder)1 BeforeClass (org.junit.BeforeClass)1