Search in sources :

Example 6 with SimpleParallelizer

use of org.apache.drill.exec.planner.fragment.SimpleParallelizer in project drill by apache.

the class TestMemoryCalculator method TestSingleMajorFragmentWithProjectAndScan.

@Test
public void TestSingleMajorFragmentWithProjectAndScan() throws Exception {
    List<DrillbitEndpoint> activeEndpoints = getEndpoints(2, new HashSet<>());
    Map<DrillbitEndpoint, NodeResource> resources = activeEndpoints.stream().collect(Collectors.toMap(x -> x, x -> NodeResource.create()));
    String sql = "SELECT * from cp.`tpch/nation.parquet`";
    SimpleParallelizer parallelizer = new QueueQueryParallelizer(false, queryContext);
    PlanningSet planningSet = preparePlanningSet(activeEndpoints, DEFAULT_SLICE_TARGET, resources, sql, parallelizer);
    parallelizer.adjustMemory(planningSet, createSet(planningSet.getRootWrapper()), activeEndpoints);
    assertTrue("memory requirement is different", Iterables.all(resources.entrySet(), (e) -> e.getValue().getMemory() == 30));
}
Also used : NodeResource(org.apache.drill.exec.planner.cost.NodeResource) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) DrillbitEndpoint(org.apache.drill.exec.proto.CoordinationProtos.DrillbitEndpoint) QueueQueryParallelizer(org.apache.drill.exec.planner.fragment.QueueQueryParallelizer) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) PopUnitTestBase(org.apache.drill.exec.pop.PopUnitTestBase) HashSet(java.util.HashSet) DrillbitContext(org.apache.drill.exec.server.DrillbitContext) Iterables(org.apache.drill.shaded.guava.com.google.common.collect.Iterables) Map(java.util.Map) NodeResource(org.apache.drill.exec.planner.cost.NodeResource) SimpleParallelizer(org.apache.drill.exec.planner.fragment.SimpleParallelizer) ClientFixture(org.apache.drill.test.ClientFixture) QueryContext(org.apache.drill.exec.ops.QueryContext) AfterClass(org.junit.AfterClass) PlanTestBase(org.apache.drill.PlanTestBase) Iterator(java.util.Iterator) ClusterFixture(org.apache.drill.test.ClusterFixture) EmbeddedQueryQueue(org.apache.drill.exec.work.foreman.rm.EmbeddedQueryQueue) Set(java.util.Set) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) Mockito.when(org.mockito.Mockito.when) Collectors(java.util.stream.Collectors) PlanningSet(org.apache.drill.exec.planner.fragment.PlanningSet) List(java.util.List) Wrapper(org.apache.drill.exec.planner.fragment.Wrapper) PhysicalPlanReader(org.apache.drill.exec.planner.PhysicalPlanReader) Fragment(org.apache.drill.exec.planner.fragment.Fragment) UserBitShared(org.apache.drill.exec.proto.UserBitShared) UserProtos(org.apache.drill.exec.proto.UserProtos) ExecConstants(org.apache.drill.exec.ExecConstants) ClusterFixtureBuilder(org.apache.drill.test.ClusterFixtureBuilder) UserSession(org.apache.drill.exec.rpc.user.UserSession) Mockito.mock(org.mockito.Mockito.mock) DrillbitEndpoint(org.apache.drill.exec.proto.CoordinationProtos.DrillbitEndpoint) SimpleParallelizer(org.apache.drill.exec.planner.fragment.SimpleParallelizer) QueueQueryParallelizer(org.apache.drill.exec.planner.fragment.QueueQueryParallelizer) PlanningSet(org.apache.drill.exec.planner.fragment.PlanningSet) Test(org.junit.Test)

Example 7 with SimpleParallelizer

use of org.apache.drill.exec.planner.fragment.SimpleParallelizer in project drill by apache.

the class TestMemoryCalculator method TestTwoMajorFragmentWithSortyProjectAndScan.

@Test
public void TestTwoMajorFragmentWithSortyProjectAndScan() throws Exception {
    List<DrillbitEndpoint> activeEndpoints = getEndpoints(2, new HashSet<>());
    Map<DrillbitEndpoint, NodeResource> resources = activeEndpoints.stream().collect(Collectors.toMap(x -> x, x -> NodeResource.create()));
    String sql = "SELECT * from cp.`tpch/lineitem.parquet` order by dept_id";
    SimpleParallelizer parallelizer = new QueueQueryParallelizer(false, queryContext);
    PlanningSet planningSet = preparePlanningSet(activeEndpoints, 2, resources, sql, parallelizer);
    parallelizer.adjustMemory(planningSet, createSet(planningSet.getRootWrapper()), activeEndpoints);
    assertTrue("memory requirement is different", Iterables.all(resources.entrySet(), (e) -> e.getValue().getMemory() == 481490));
}
Also used : NodeResource(org.apache.drill.exec.planner.cost.NodeResource) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) DrillbitEndpoint(org.apache.drill.exec.proto.CoordinationProtos.DrillbitEndpoint) QueueQueryParallelizer(org.apache.drill.exec.planner.fragment.QueueQueryParallelizer) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) PopUnitTestBase(org.apache.drill.exec.pop.PopUnitTestBase) HashSet(java.util.HashSet) DrillbitContext(org.apache.drill.exec.server.DrillbitContext) Iterables(org.apache.drill.shaded.guava.com.google.common.collect.Iterables) Map(java.util.Map) NodeResource(org.apache.drill.exec.planner.cost.NodeResource) SimpleParallelizer(org.apache.drill.exec.planner.fragment.SimpleParallelizer) ClientFixture(org.apache.drill.test.ClientFixture) QueryContext(org.apache.drill.exec.ops.QueryContext) AfterClass(org.junit.AfterClass) PlanTestBase(org.apache.drill.PlanTestBase) Iterator(java.util.Iterator) ClusterFixture(org.apache.drill.test.ClusterFixture) EmbeddedQueryQueue(org.apache.drill.exec.work.foreman.rm.EmbeddedQueryQueue) Set(java.util.Set) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) Mockito.when(org.mockito.Mockito.when) Collectors(java.util.stream.Collectors) PlanningSet(org.apache.drill.exec.planner.fragment.PlanningSet) List(java.util.List) Wrapper(org.apache.drill.exec.planner.fragment.Wrapper) PhysicalPlanReader(org.apache.drill.exec.planner.PhysicalPlanReader) Fragment(org.apache.drill.exec.planner.fragment.Fragment) UserBitShared(org.apache.drill.exec.proto.UserBitShared) UserProtos(org.apache.drill.exec.proto.UserProtos) ExecConstants(org.apache.drill.exec.ExecConstants) ClusterFixtureBuilder(org.apache.drill.test.ClusterFixtureBuilder) UserSession(org.apache.drill.exec.rpc.user.UserSession) Mockito.mock(org.mockito.Mockito.mock) DrillbitEndpoint(org.apache.drill.exec.proto.CoordinationProtos.DrillbitEndpoint) SimpleParallelizer(org.apache.drill.exec.planner.fragment.SimpleParallelizer) QueueQueryParallelizer(org.apache.drill.exec.planner.fragment.QueueQueryParallelizer) PlanningSet(org.apache.drill.exec.planner.fragment.PlanningSet) Test(org.junit.Test)

Example 8 with SimpleParallelizer

use of org.apache.drill.exec.planner.fragment.SimpleParallelizer in project drill by apache.

the class TestMemoryCalculator method TestSingleMajorFragmentWithGroupByProjectAndScan.

@Test
public void TestSingleMajorFragmentWithGroupByProjectAndScan() throws Exception {
    List<DrillbitEndpoint> activeEndpoints = getEndpoints(2, new HashSet<>());
    Map<DrillbitEndpoint, NodeResource> resources = activeEndpoints.stream().collect(Collectors.toMap(x -> x, x -> NodeResource.create()));
    String sql = "SELECT dept_id, count(*) from cp.`tpch/lineitem.parquet` group by dept_id";
    SimpleParallelizer parallelizer = new QueueQueryParallelizer(false, queryContext);
    PlanningSet planningSet = preparePlanningSet(activeEndpoints, DEFAULT_SLICE_TARGET, resources, sql, parallelizer);
    parallelizer.adjustMemory(planningSet, createSet(planningSet.getRootWrapper()), activeEndpoints);
    assertTrue("memory requirement is different", Iterables.all(resources.entrySet(), (e) -> e.getValue().getMemory() == 529570));
}
Also used : NodeResource(org.apache.drill.exec.planner.cost.NodeResource) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) DrillbitEndpoint(org.apache.drill.exec.proto.CoordinationProtos.DrillbitEndpoint) QueueQueryParallelizer(org.apache.drill.exec.planner.fragment.QueueQueryParallelizer) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) PopUnitTestBase(org.apache.drill.exec.pop.PopUnitTestBase) HashSet(java.util.HashSet) DrillbitContext(org.apache.drill.exec.server.DrillbitContext) Iterables(org.apache.drill.shaded.guava.com.google.common.collect.Iterables) Map(java.util.Map) NodeResource(org.apache.drill.exec.planner.cost.NodeResource) SimpleParallelizer(org.apache.drill.exec.planner.fragment.SimpleParallelizer) ClientFixture(org.apache.drill.test.ClientFixture) QueryContext(org.apache.drill.exec.ops.QueryContext) AfterClass(org.junit.AfterClass) PlanTestBase(org.apache.drill.PlanTestBase) Iterator(java.util.Iterator) ClusterFixture(org.apache.drill.test.ClusterFixture) EmbeddedQueryQueue(org.apache.drill.exec.work.foreman.rm.EmbeddedQueryQueue) Set(java.util.Set) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) Mockito.when(org.mockito.Mockito.when) Collectors(java.util.stream.Collectors) PlanningSet(org.apache.drill.exec.planner.fragment.PlanningSet) List(java.util.List) Wrapper(org.apache.drill.exec.planner.fragment.Wrapper) PhysicalPlanReader(org.apache.drill.exec.planner.PhysicalPlanReader) Fragment(org.apache.drill.exec.planner.fragment.Fragment) UserBitShared(org.apache.drill.exec.proto.UserBitShared) UserProtos(org.apache.drill.exec.proto.UserProtos) ExecConstants(org.apache.drill.exec.ExecConstants) ClusterFixtureBuilder(org.apache.drill.test.ClusterFixtureBuilder) UserSession(org.apache.drill.exec.rpc.user.UserSession) Mockito.mock(org.mockito.Mockito.mock) DrillbitEndpoint(org.apache.drill.exec.proto.CoordinationProtos.DrillbitEndpoint) SimpleParallelizer(org.apache.drill.exec.planner.fragment.SimpleParallelizer) QueueQueryParallelizer(org.apache.drill.exec.planner.fragment.QueueQueryParallelizer) PlanningSet(org.apache.drill.exec.planner.fragment.PlanningSet) Test(org.junit.Test)

Example 9 with SimpleParallelizer

use of org.apache.drill.exec.planner.fragment.SimpleParallelizer in project drill by apache.

the class TestFragmentChecker method print.

private void print(String fragmentFile, int bitCount, int expectedFragmentCount) throws Exception {
    PhysicalPlanReader ppr = PhysicalPlanReaderTestFactory.defaultPhysicalPlanReader(CONFIG);
    Fragment fragmentRoot = getRootFragment(ppr, fragmentFile);
    SimpleParallelizer par = new DefaultQueryParallelizer(true, 1000 * 1000, 5, 10, 1.2);
    List<DrillbitEndpoint> endpoints = Lists.newArrayList();
    DrillbitEndpoint localBit = null;
    for (int i = 0; i < bitCount; i++) {
        DrillbitEndpoint b1 = DrillbitEndpoint.newBuilder().setAddress("localhost").setControlPort(1234 + i).build();
        if (i == 0) {
            localBit = b1;
        }
        endpoints.add(b1);
    }
    final QueryContextInformation queryContextInfo = Utilities.createQueryContextInfo("dummySchemaName", "938ea2d9-7cb9-4baf-9414-a5a0b7777e8e");
    QueryWorkUnit qwu = par.generateWorkUnit(new OptionList(), localBit, QueryId.getDefaultInstance(), endpoints, fragmentRoot, UserSession.Builder.newBuilder().withCredentials(UserBitShared.UserCredentials.newBuilder().setUserName("foo").build()).build(), queryContextInfo);
    qwu.applyPlan(ppr);
    assertEquals(expectedFragmentCount, qwu.getFragments().size() + 1);
}
Also used : DrillbitEndpoint(org.apache.drill.exec.proto.CoordinationProtos.DrillbitEndpoint) PhysicalPlanReader(org.apache.drill.exec.planner.PhysicalPlanReader) QueryWorkUnit(org.apache.drill.exec.work.QueryWorkUnit) SimpleParallelizer(org.apache.drill.exec.planner.fragment.SimpleParallelizer) Fragment(org.apache.drill.exec.planner.fragment.Fragment) DefaultQueryParallelizer(org.apache.drill.exec.planner.fragment.DefaultQueryParallelizer) DrillbitEndpoint(org.apache.drill.exec.proto.CoordinationProtos.DrillbitEndpoint) QueryContextInformation(org.apache.drill.exec.proto.BitControl.QueryContextInformation) OptionList(org.apache.drill.exec.server.options.OptionList)

Aggregations

Fragment (org.apache.drill.exec.planner.fragment.Fragment)9 SimpleParallelizer (org.apache.drill.exec.planner.fragment.SimpleParallelizer)9 DrillbitEndpoint (org.apache.drill.exec.proto.CoordinationProtos.DrillbitEndpoint)6 PhysicalPlanReader (org.apache.drill.exec.planner.PhysicalPlanReader)5 PlanFragment (org.apache.drill.exec.proto.BitControl.PlanFragment)5 QueryWorkUnit (org.apache.drill.exec.work.QueryWorkUnit)5 PhysicalOperator (org.apache.drill.exec.physical.base.PhysicalOperator)4 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 HashSet (java.util.HashSet)3 Iterator (java.util.Iterator)3 List (java.util.List)3 Map (java.util.Map)3 Set (java.util.Set)3 Collectors (java.util.stream.Collectors)3 PlanTestBase (org.apache.drill.PlanTestBase)3 ExecConstants (org.apache.drill.exec.ExecConstants)3 QueryContext (org.apache.drill.exec.ops.QueryContext)3 NodeResource (org.apache.drill.exec.planner.cost.NodeResource)3 PlanningSet (org.apache.drill.exec.planner.fragment.PlanningSet)3