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();
}
}
}
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);
}
Aggregations