Search in sources :

Example 11 with Sort

use of org.apache.drill.exec.physical.config.Sort in project drill by apache.

the class TestCopier method testEmptyInput.

@Test
public void testEmptyInput() {
    TupleMetadata schema = SortTestUtilities.nonNullSchema();
    List<BatchGroup> batches = new ArrayList<>();
    Sort popConfig = SortTestUtilities.makeCopierConfig(Ordering.ORDER_ASC, Ordering.NULLS_UNSPECIFIED);
    OperatorContext opContext = fixture.newOperatorContext(popConfig);
    PriorityQueueCopierWrapper copier = new PriorityQueueCopierWrapper(opContext);
    VectorContainer dest = new VectorContainer();
    try {
        // TODO: Create a vector allocator to pass as last parameter so
        // that the test uses the same vector allocator as the production
        // code. Only nuisance is that we don't have the required metadata
        // readily at hand here...
        copier.startMerge(new BatchSchema(BatchSchema.SelectionVectorMode.NONE, schema.toFieldList()), batches, dest, 10, null);
        fail();
    } catch (AssertionError e) {
    // Expected
    } finally {
        opContext.close();
    }
}
Also used : BatchSchema(org.apache.drill.exec.record.BatchSchema) TupleMetadata(org.apache.drill.exec.record.metadata.TupleMetadata) OperatorContext(org.apache.drill.exec.ops.OperatorContext) ArrayList(java.util.ArrayList) Sort(org.apache.drill.exec.physical.config.Sort) VectorContainer(org.apache.drill.exec.record.VectorContainer) OperatorTest(org.apache.drill.categories.OperatorTest) SubOperatorTest(org.apache.drill.test.SubOperatorTest) Test(org.junit.Test)

Example 12 with Sort

use of org.apache.drill.exec.physical.config.Sort in project drill by apache.

the class TestSorter method makeSortConfig.

public static Sort makeSortConfig(String key, String sortOrder, String nullOrder) {
    FieldReference expr = FieldReference.getWithQuotedRef(key);
    Ordering ordering = new Ordering(sortOrder, expr, nullOrder);
    return new Sort(null, Lists.newArrayList(ordering), false);
}
Also used : FieldReference(org.apache.drill.common.expression.FieldReference) Ordering(org.apache.drill.common.logical.data.Order.Ordering) Sort(org.apache.drill.exec.physical.config.Sort)

Example 13 with Sort

use of org.apache.drill.exec.physical.config.Sort in project drill by apache.

the class TestSorter method testMapKey.

@Test
@Ignore("DRILL-5384")
public void testMapKey() throws Exception {
    TupleMetadata schema = new SchemaBuilder().addMap("map").add("key", MinorType.INT).add("value", MinorType.VARCHAR).resumeSchema().buildSchema();
    SingleRowSet input = fixture.rowSetBuilder(schema).addRow(3, "third").addRow(1, "first").addRow(2, "second").withSv2().build();
    SingleRowSet output = fixture.rowSetBuilder(schema).addRow(1, "first").addRow(2, "second").addRow(3, "third").build();
    Sort popConfig = makeSortConfig("map.key", Ordering.ORDER_ASC, Ordering.NULLS_LAST);
    runSorterTest(popConfig, input, output);
}
Also used : SingleRowSet(org.apache.drill.exec.physical.rowSet.RowSet.SingleRowSet) TupleMetadata(org.apache.drill.exec.record.metadata.TupleMetadata) SchemaBuilder(org.apache.drill.exec.record.metadata.SchemaBuilder) Sort(org.apache.drill.exec.physical.config.Sort) Ignore(org.junit.Ignore) DrillTest(org.apache.drill.test.DrillTest) OperatorTest(org.apache.drill.categories.OperatorTest) Test(org.junit.Test)

Example 14 with Sort

use of org.apache.drill.exec.physical.config.Sort in project drill by apache.

the class SortTestUtilities method makeCopierConfig.

public static Sort makeCopierConfig(String sortOrder, String nullOrder) {
    FieldReference expr = FieldReference.getWithQuotedRef("key");
    Ordering ordering = new Ordering(sortOrder, expr, nullOrder);
    return new Sort(null, Lists.newArrayList(ordering), false);
}
Also used : FieldReference(org.apache.drill.common.expression.FieldReference) Ordering(org.apache.drill.common.logical.data.Order.Ordering) Sort(org.apache.drill.exec.physical.config.Sort)

Aggregations

Sort (org.apache.drill.exec.physical.config.Sort)14 Ordering (org.apache.drill.common.logical.data.Order.Ordering)8 FieldReference (org.apache.drill.common.expression.FieldReference)6 OperatorTest (org.apache.drill.categories.OperatorTest)4 OperatorContext (org.apache.drill.exec.ops.OperatorContext)4 Test (org.junit.Test)4 BatchSchema (org.apache.drill.exec.record.BatchSchema)3 VectorContainer (org.apache.drill.exec.record.VectorContainer)3 JConditional (com.sun.codemodel.JConditional)2 ArrayList (java.util.ArrayList)2 ErrorCollector (org.apache.drill.common.expression.ErrorCollector)2 ErrorCollectorImpl (org.apache.drill.common.expression.ErrorCollectorImpl)2 LogicalExpression (org.apache.drill.common.expression.LogicalExpression)2 SchemaChangeException (org.apache.drill.exec.exception.SchemaChangeException)2 HoldingContainer (org.apache.drill.exec.expr.ClassGenerator.HoldingContainer)2 RecordBatchData (org.apache.drill.exec.physical.impl.sort.RecordBatchData)2 SortRecordBatchBuilder (org.apache.drill.exec.physical.impl.sort.SortRecordBatchBuilder)2 SpillSet (org.apache.drill.exec.physical.impl.spill.SpillSet)2 FragmentHandle (org.apache.drill.exec.proto.ExecProtos.FragmentHandle)2 QueryId (org.apache.drill.exec.proto.UserBitShared.QueryId)2