use of org.apache.drill.exec.planner.cost.PrelCostEstimates in project drill by apache.
the class TestPartitionSender method testPartitionSenderCostToThreads.
@Test
public /**
* Main test to go over different scenarios
* @throws Exception
*/
void testPartitionSenderCostToThreads() throws Exception {
final VectorContainer container = new VectorContainer();
container.buildSchema(SelectionVectorMode.FOUR_BYTE);
final SelectionVector4 sv = Mockito.mock(SelectionVector4.class, "SelectionVector4");
Mockito.when(sv.getCount()).thenReturn(100);
Mockito.when(sv.getTotalCount()).thenReturn(100);
for (int i = 0; i < 100; i++) {
Mockito.when(sv.get(i)).thenReturn(i);
}
final TopNBatch.SimpleSV4RecordBatch incoming = new TopNBatch.SimpleSV4RecordBatch(container, sv, null);
updateTestCluster(DRILLBITS_COUNT, null);
test("ALTER SESSION SET `planner.slice_target`=1");
String plan = getPlanInString("EXPLAIN PLAN FOR " + groupByQuery, JSON_FORMAT);
final DrillbitContext drillbitContext = getDrillbitContext();
final PhysicalPlanReader planReader = drillbitContext.getPlanReader();
final PhysicalPlan physicalPlan = planReader.readPhysicalPlan(plan);
final Fragment rootFragment = PopUnitTestBase.getRootFragmentFromPlanString(planReader, plan);
final PlanningSet planningSet = new PlanningSet();
final FunctionImplementationRegistry registry = new FunctionImplementationRegistry(config);
// Create a planningSet to get the assignment of major fragment ids to fragments.
PARALLELIZER.initFragmentWrappers(rootFragment, planningSet);
final List<PhysicalOperator> operators = physicalPlan.getSortedOperators(false);
// get HashToRandomExchange physical operator
HashToRandomExchange hashToRandomExchange = null;
for (PhysicalOperator operator : operators) {
if (operator instanceof HashToRandomExchange) {
hashToRandomExchange = (HashToRandomExchange) operator;
break;
}
}
final OptionList options = new OptionList();
// try multiple scenarios with different set of options
options.add(OptionValue.create(OptionValue.AccessibleScopes.SESSION, "planner.slice_target", 1, OptionScope.SESSION));
testThreadsHelper(hashToRandomExchange, drillbitContext, options, incoming, registry, planReader, planningSet, rootFragment, 1);
options.clear();
options.add(OptionValue.create(AccessibleScopes.SESSION, "planner.slice_target", 1, OptionScope.SESSION));
options.add(OptionValue.create(OptionValue.AccessibleScopes.SESSION, "planner.partitioner_sender_max_threads", 10, OptionScope.SESSION));
hashToRandomExchange.setCost(new PrelCostEstimates(1000, 1000));
testThreadsHelper(hashToRandomExchange, drillbitContext, options, incoming, registry, planReader, planningSet, rootFragment, 10);
options.clear();
options.add(OptionValue.create(AccessibleScopes.SESSION, "planner.slice_target", 1000, OptionScope.SESSION));
options.add(OptionValue.create(AccessibleScopes.SESSION, "planner.partitioner_sender_threads_factor", 2, OptionScope.SESSION));
hashToRandomExchange.setCost(new PrelCostEstimates(14000, 14000));
testThreadsHelper(hashToRandomExchange, drillbitContext, options, incoming, registry, planReader, planningSet, rootFragment, 2);
}
use of org.apache.drill.exec.planner.cost.PrelCostEstimates in project drill by apache.
the class TestOpSerialization method setupPhysicalOperator.
private static PhysicalOperator setupPhysicalOperator(PhysicalOperator operator) {
operator.setOperatorId(1);
operator.setCost(new PrelCostEstimates(1.0, 1.0));
operator.setMaxAllocation(1000);
return operator;
}
use of org.apache.drill.exec.planner.cost.PrelCostEstimates in project drill by apache.
the class PhysicalPlanCreator method getPrelCostEstimates.
private PrelCostEstimates getPrelCostEstimates(Prel originalPrel, PhysicalOperator op) {
final RelMetadataQuery mq = originalPrel.getCluster().getMetadataQuery();
final double estimatedRowCount = originalPrel.estimateRowCount(mq);
final DrillCostBase costBase = (DrillCostBase) originalPrel.computeSelfCost(originalPrel.getCluster().getPlanner(), mq);
final PrelCostEstimates costEstimates;
if (!op.isBufferedOperator(context)) {
costEstimates = new PrelCostEstimates(context.getOptions().getLong(ExecConstants.OUTPUT_BATCH_SIZE), estimatedRowCount);
} else {
costEstimates = new PrelCostEstimates(costBase.getMemory(), estimatedRowCount);
}
return costEstimates;
}
Aggregations