Search in sources :

Example 1 with PartitionLimit

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

the class TestPartitionLimitBatch method testPartitionLimitCommon.

/**
 * Common method used by all the tests for {@link PartitionLimitRecordBatch} below. It creates the MockRecordBatch
 * and {@link PartitionLimitRecordBatch} with the populated containers and outcomes list in the test. It also
 * verifies the expected outcomes list and record count populated by each test against each next() call to
 * {@link PartitionLimitRecordBatch}. For cases when the expected record count is >0 it verifies the actual output
 * returned by {@link PartitionLimitRecordBatch} with expected output rows.
 * @param start - Start offset for {@link PartitionLimit} PopConfig
 * @param end - End offset for {@link PartitionLimit} PopConfig
 */
private void testPartitionLimitCommon(Integer start, Integer end) {
    final MockRecordBatch mockInputBatch = new MockRecordBatch(operatorFixture.getFragmentContext(), opContext, inputContainer, inputOutcomes, inputContainerSv2, inputContainer.get(0).getSchema());
    final PartitionLimit limitConf = new PartitionLimit(null, start, end, PARTITION_COLUMN);
    limitBatch = new PartitionLimitRecordBatch(limitConf, operatorFixture.getFragmentContext(), mockInputBatch);
    int i = 0;
    int expectedRowSetIndex = 0;
    while (i < expectedOutcomes.size()) {
        try {
            assertTrue(expectedOutcomes.get(i) == limitBatch.next());
            assertTrue(expectedRecordCounts.get(i++) == limitBatch.getRecordCount());
            if (limitBatch.getRecordCount() > 0) {
                final RowSet actualRowSet = IndirectRowSet.fromSv2(limitBatch.getContainer(), limitBatch.getSelectionVector2());
                new RowSetComparison(expectedRowSets.get(expectedRowSetIndex++)).verify(actualRowSet);
            }
        } finally {
            limitBatch.getSelectionVector2().clear();
            limitBatch.getContainer().zeroVectors();
        }
    }
}
Also used : RowSetComparison(org.apache.drill.test.rowSet.RowSetComparison) PartitionLimit(org.apache.drill.exec.physical.config.PartitionLimit) IndirectRowSet(org.apache.drill.exec.physical.rowSet.IndirectRowSet) RowSet(org.apache.drill.exec.physical.rowSet.RowSet) MockRecordBatch(org.apache.drill.exec.physical.impl.MockRecordBatch) PartitionLimitRecordBatch(org.apache.drill.exec.physical.impl.limit.PartitionLimitRecordBatch)

Example 2 with PartitionLimit

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

the class LimitPrel method getPhysicalOperator.

@Override
public PhysicalOperator getPhysicalOperator(PhysicalPlanCreator creator) throws IOException {
    Prel child = (Prel) this.getInput();
    PhysicalOperator childPOP = child.getPhysicalOperator(creator);
    // First offset to include into results (inclusive). Null implies it is starting from offset 0
    int first = offset != null ? Math.max(0, RexLiteral.intValue(offset)) : 0;
    // Last offset to stop including into results (exclusive), translating fetch row counts into an offset.
    // Null value implies including entire remaining result set from first offset
    Integer last = fetch != null ? Math.max(0, RexLiteral.intValue(fetch)) + first : null;
    Limit limit;
    if (isPartitioned) {
        limit = new PartitionLimit(childPOP, first, last, DrillRelOptUtil.IMPLICIT_COLUMN);
    } else {
        limit = new Limit(childPOP, first, last);
    }
    return creator.addMetadata(this, limit);
}
Also used : PhysicalOperator(org.apache.drill.exec.physical.base.PhysicalOperator) PartitionLimit(org.apache.drill.exec.physical.config.PartitionLimit) Limit(org.apache.drill.exec.physical.config.Limit) PartitionLimit(org.apache.drill.exec.physical.config.PartitionLimit)

Aggregations

PartitionLimit (org.apache.drill.exec.physical.config.PartitionLimit)2 PhysicalOperator (org.apache.drill.exec.physical.base.PhysicalOperator)1 Limit (org.apache.drill.exec.physical.config.Limit)1 MockRecordBatch (org.apache.drill.exec.physical.impl.MockRecordBatch)1 PartitionLimitRecordBatch (org.apache.drill.exec.physical.impl.limit.PartitionLimitRecordBatch)1 IndirectRowSet (org.apache.drill.exec.physical.rowSet.IndirectRowSet)1 RowSet (org.apache.drill.exec.physical.rowSet.RowSet)1 RowSetComparison (org.apache.drill.test.rowSet.RowSetComparison)1