Search in sources :

Example 96 with FragmentContextImpl

use of org.apache.drill.exec.ops.FragmentContextImpl in project drill by apache.

the class TestSimpleSort method sortTwoKeysOneAscendingOneDescending.

@Test
public void sortTwoKeysOneAscendingOneDescending() throws Throwable {
    final DrillbitContext bitContext = mockDrillbitContext();
    final UserClientConnection connection = Mockito.mock(UserClientConnection.class);
    final PhysicalPlanReader reader = PhysicalPlanReaderTestFactory.defaultPhysicalPlanReader(c);
    final PhysicalPlan plan = reader.readPhysicalPlan(Files.asCharSource(DrillFileUtils.getResourceAsFile("/sort/two_key_sort.json"), Charsets.UTF_8).read());
    final FunctionImplementationRegistry registry = new FunctionImplementationRegistry(c);
    final FragmentContextImpl context = new FragmentContextImpl(bitContext, PlanFragment.getDefaultInstance(), connection, registry);
    final SimpleRootExec exec = new SimpleRootExec(ImplCreator.getExec(context, (FragmentRoot) plan.getSortedOperators(false).iterator().next()));
    int previousInt = Integer.MIN_VALUE;
    long previousLong = Long.MAX_VALUE;
    int recordCount = 0;
    int batchCount = 0;
    while (exec.next()) {
        batchCount++;
        final IntVector c1 = exec.getValueVectorById(new SchemaPath("blue", ExpressionPosition.UNKNOWN), IntVector.class);
        final BigIntVector c2 = exec.getValueVectorById(new SchemaPath("alt", ExpressionPosition.UNKNOWN), BigIntVector.class);
        final IntVector.Accessor a1 = c1.getAccessor();
        final BigIntVector.Accessor a2 = c2.getAccessor();
        for (int i = 0; i < c1.getAccessor().getValueCount(); i++) {
            recordCount++;
            assertTrue(previousInt <= a1.get(i));
            if (previousInt != a1.get(i)) {
                previousLong = Long.MAX_VALUE;
                previousInt = a1.get(i);
            }
            assertTrue(previousLong >= a2.get(i));
        }
    }
    if (context.getExecutorState().getFailureCause() != null) {
        throw context.getExecutorState().getFailureCause();
    }
    assertTrue(!context.getExecutorState().isFailed());
}
Also used : DrillbitContext(org.apache.drill.exec.server.DrillbitContext) PhysicalPlan(org.apache.drill.exec.physical.PhysicalPlan) BigIntVector(org.apache.drill.exec.vector.BigIntVector) IntVector(org.apache.drill.exec.vector.IntVector) PhysicalPlanReader(org.apache.drill.exec.planner.PhysicalPlanReader) FragmentContextImpl(org.apache.drill.exec.ops.FragmentContextImpl) FragmentRoot(org.apache.drill.exec.physical.base.FragmentRoot) BigIntVector(org.apache.drill.exec.vector.BigIntVector) SimpleRootExec(org.apache.drill.exec.physical.impl.SimpleRootExec) SchemaPath(org.apache.drill.common.expression.SchemaPath) UserClientConnection(org.apache.drill.exec.rpc.UserClientConnection) FunctionImplementationRegistry(org.apache.drill.exec.expr.fn.FunctionImplementationRegistry) ExecTest(org.apache.drill.exec.ExecTest) OperatorTest(org.apache.drill.categories.OperatorTest) Test(org.junit.Test)

Example 97 with FragmentContextImpl

use of org.apache.drill.exec.ops.FragmentContextImpl in project drill by apache.

the class TestSimpleSort method sortOneKeyAscending.

@Test
public void sortOneKeyAscending() throws Throwable {
    final DrillbitContext bitContext = mockDrillbitContext();
    final UserClientConnection connection = Mockito.mock(UserClientConnection.class);
    final PhysicalPlanReader reader = PhysicalPlanReaderTestFactory.defaultPhysicalPlanReader(c);
    final PhysicalPlan plan = reader.readPhysicalPlan(Files.asCharSource(DrillFileUtils.getResourceAsFile("/sort/one_key_sort.json"), Charsets.UTF_8).read());
    final FunctionImplementationRegistry registry = new FunctionImplementationRegistry(c);
    final FragmentContextImpl context = new FragmentContextImpl(bitContext, PlanFragment.getDefaultInstance(), connection, registry);
    final SimpleRootExec exec = new SimpleRootExec(ImplCreator.getExec(context, (FragmentRoot) plan.getSortedOperators(false).iterator().next()));
    int previousInt = Integer.MIN_VALUE;
    int recordCount = 0;
    int batchCount = 0;
    while (exec.next()) {
        batchCount++;
        final IntVector c1 = exec.getValueVectorById(new SchemaPath("blue", ExpressionPosition.UNKNOWN), IntVector.class);
        final IntVector c2 = exec.getValueVectorById(new SchemaPath("green", ExpressionPosition.UNKNOWN), IntVector.class);
        final IntVector.Accessor a1 = c1.getAccessor();
        final IntVector.Accessor a2 = c2.getAccessor();
        for (int i = 0; i < c1.getAccessor().getValueCount(); i++) {
            recordCount++;
            assertTrue(previousInt <= a1.get(i));
            previousInt = a1.get(i);
            assertEquals(previousInt, a2.get(i));
        }
    }
    if (context.getExecutorState().getFailureCause() != null) {
        throw context.getExecutorState().getFailureCause();
    }
    assertTrue(!context.getExecutorState().isFailed());
}
Also used : DrillbitContext(org.apache.drill.exec.server.DrillbitContext) SimpleRootExec(org.apache.drill.exec.physical.impl.SimpleRootExec) PhysicalPlan(org.apache.drill.exec.physical.PhysicalPlan) BigIntVector(org.apache.drill.exec.vector.BigIntVector) IntVector(org.apache.drill.exec.vector.IntVector) SchemaPath(org.apache.drill.common.expression.SchemaPath) PhysicalPlanReader(org.apache.drill.exec.planner.PhysicalPlanReader) UserClientConnection(org.apache.drill.exec.rpc.UserClientConnection) FragmentContextImpl(org.apache.drill.exec.ops.FragmentContextImpl) FragmentRoot(org.apache.drill.exec.physical.base.FragmentRoot) FunctionImplementationRegistry(org.apache.drill.exec.expr.fn.FunctionImplementationRegistry) ExecTest(org.apache.drill.exec.ExecTest) OperatorTest(org.apache.drill.categories.OperatorTest) Test(org.junit.Test)

Example 98 with FragmentContextImpl

use of org.apache.drill.exec.ops.FragmentContextImpl in project drill by apache.

the class TestBitBitKerberos method setupFragmentContextAndManager.

private FragmentManager setupFragmentContextAndManager(BufferAllocator allocator) {
    final FragmentContextImpl fcontext = mock(FragmentContextImpl.class);
    when(fcontext.getAllocator()).thenReturn(allocator);
    return new MockFragmentManager(fcontext);
}
Also used : FragmentContextImpl(org.apache.drill.exec.ops.FragmentContextImpl)

Aggregations

FragmentContextImpl (org.apache.drill.exec.ops.FragmentContextImpl)98 FunctionImplementationRegistry (org.apache.drill.exec.expr.fn.FunctionImplementationRegistry)81 PhysicalPlan (org.apache.drill.exec.physical.PhysicalPlan)78 DrillbitContext (org.apache.drill.exec.server.DrillbitContext)77 FragmentRoot (org.apache.drill.exec.physical.base.FragmentRoot)74 UserClientConnection (org.apache.drill.exec.rpc.UserClientConnection)72 PhysicalPlanReader (org.apache.drill.exec.planner.PhysicalPlanReader)70 Test (org.junit.Test)66 SimpleRootExec (org.apache.drill.exec.physical.impl.SimpleRootExec)48 SchemaPath (org.apache.drill.common.expression.SchemaPath)32 OperatorTest (org.apache.drill.categories.OperatorTest)31 ExecTest (org.apache.drill.exec.ExecTest)31 ValueVector (org.apache.drill.exec.vector.ValueVector)16 BigIntVector (org.apache.drill.exec.vector.BigIntVector)12 IntVector (org.apache.drill.exec.vector.IntVector)12 Ignore (org.junit.Ignore)12 SlowTest (org.apache.drill.categories.SlowTest)10 DrillConfig (org.apache.drill.common.config.DrillConfig)8 StoragePluginRegistryImpl (org.apache.drill.exec.store.StoragePluginRegistryImpl)8 FragmentHandle (org.apache.drill.exec.proto.ExecProtos.FragmentHandle)7