Search in sources :

Example 1 with PrelCostEstimates

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);
}
Also used : DrillbitContext(org.apache.drill.exec.server.DrillbitContext) PhysicalPlan(org.apache.drill.exec.physical.PhysicalPlan) PhysicalPlanReader(org.apache.drill.exec.planner.PhysicalPlanReader) HashToRandomExchange(org.apache.drill.exec.physical.config.HashToRandomExchange) PlanFragment(org.apache.drill.exec.proto.BitControl.PlanFragment) Fragment(org.apache.drill.exec.planner.fragment.Fragment) MinorFragmentEndpoint(org.apache.drill.exec.physical.MinorFragmentEndpoint) VectorContainer(org.apache.drill.exec.record.VectorContainer) PrelCostEstimates(org.apache.drill.exec.planner.cost.PrelCostEstimates) PhysicalOperator(org.apache.drill.exec.physical.base.PhysicalOperator) TopNBatch(org.apache.drill.exec.physical.impl.TopN.TopNBatch) FunctionImplementationRegistry(org.apache.drill.exec.expr.fn.FunctionImplementationRegistry) PlanningSet(org.apache.drill.exec.planner.fragment.PlanningSet) OptionList(org.apache.drill.exec.server.options.OptionList) SelectionVector4(org.apache.drill.exec.record.selection.SelectionVector4) OperatorTest(org.apache.drill.categories.OperatorTest) Test(org.junit.Test)

Example 2 with PrelCostEstimates

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;
}
Also used : PrelCostEstimates(org.apache.drill.exec.planner.cost.PrelCostEstimates)

Example 3 with PrelCostEstimates

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;
}
Also used : RelMetadataQuery(org.apache.calcite.rel.metadata.RelMetadataQuery) PrelCostEstimates(org.apache.drill.exec.planner.cost.PrelCostEstimates) DrillCostBase(org.apache.drill.exec.planner.cost.DrillCostBase)

Aggregations

PrelCostEstimates (org.apache.drill.exec.planner.cost.PrelCostEstimates)3 RelMetadataQuery (org.apache.calcite.rel.metadata.RelMetadataQuery)1 OperatorTest (org.apache.drill.categories.OperatorTest)1 FunctionImplementationRegistry (org.apache.drill.exec.expr.fn.FunctionImplementationRegistry)1 MinorFragmentEndpoint (org.apache.drill.exec.physical.MinorFragmentEndpoint)1 PhysicalPlan (org.apache.drill.exec.physical.PhysicalPlan)1 PhysicalOperator (org.apache.drill.exec.physical.base.PhysicalOperator)1 HashToRandomExchange (org.apache.drill.exec.physical.config.HashToRandomExchange)1 TopNBatch (org.apache.drill.exec.physical.impl.TopN.TopNBatch)1 PhysicalPlanReader (org.apache.drill.exec.planner.PhysicalPlanReader)1 DrillCostBase (org.apache.drill.exec.planner.cost.DrillCostBase)1 Fragment (org.apache.drill.exec.planner.fragment.Fragment)1 PlanningSet (org.apache.drill.exec.planner.fragment.PlanningSet)1 PlanFragment (org.apache.drill.exec.proto.BitControl.PlanFragment)1 VectorContainer (org.apache.drill.exec.record.VectorContainer)1 SelectionVector4 (org.apache.drill.exec.record.selection.SelectionVector4)1 DrillbitContext (org.apache.drill.exec.server.DrillbitContext)1 OptionList (org.apache.drill.exec.server.options.OptionList)1 Test (org.junit.Test)1