Search in sources :

Example 56 with FragmentContext

use of org.apache.drill.exec.ops.FragmentContext in project drill by axbaretto.

the class TestExternalSortInternals method testConfigLimits.

/**
 * Some properties have hard-coded limits. Verify these limits.
 */
@Test
public void testConfigLimits() {
    OperatorFixture.Builder builder = new OperatorFixture.Builder();
    builder.configBuilder().put(ExecConstants.EXTERNAL_SORT_MERGE_LIMIT, SortConfig.MIN_MERGE_LIMIT - 1).put(ExecConstants.EXTERNAL_SORT_SPILL_FILE_SIZE, SortConfig.MIN_SPILL_FILE_SIZE - 1).put(ExecConstants.EXTERNAL_SORT_SPILL_BATCH_SIZE, SortConfig.MIN_SPILL_BATCH_SIZE - 1).put(ExecConstants.EXTERNAL_SORT_BATCH_LIMIT, 1).put(ExecConstants.EXTERNAL_SORT_MSORT_MAX_BATCHSIZE, 0).build();
    FragmentContext fragmentContext = builder.build().getFragmentContext();
    fragmentContext.getOptions().setLocalOption(ExecConstants.OUTPUT_BATCH_SIZE, SortConfig.MIN_MERGE_BATCH_SIZE - 1);
    SortConfig sortConfig = new SortConfig(fragmentContext.getConfig(), fragmentContext.getOptions());
    assertEquals(SortConfig.MIN_MERGE_LIMIT, sortConfig.mergeLimit());
    assertEquals(SortConfig.MIN_SPILL_FILE_SIZE, sortConfig.spillFileSize());
    assertEquals(SortConfig.MIN_SPILL_BATCH_SIZE, sortConfig.spillBatchSize());
    assertEquals(SortConfig.MIN_MERGE_BATCH_SIZE, sortConfig.mergeBatchSize());
    assertEquals(2, sortConfig.getBufferedBatchLimit());
    assertEquals(1, sortConfig.getMSortBatchSize());
}
Also used : FragmentContext(org.apache.drill.exec.ops.FragmentContext) OperatorFixture(org.apache.drill.test.OperatorFixture) OperatorTest(org.apache.drill.categories.OperatorTest) SubOperatorTest(org.apache.drill.test.SubOperatorTest) Test(org.junit.Test)

Example 57 with FragmentContext

use of org.apache.drill.exec.ops.FragmentContext in project drill by axbaretto.

the class TestOptiqPlans method doPhysicalTest.

private SimpleRootExec doPhysicalTest(final DrillbitContext bitContext, UserClientConnection connection, String file) throws Exception {
    mockDrillbitContext(bitContext);
    final StoragePluginRegistry reg = new StoragePluginRegistryImpl(bitContext);
    final PhysicalPlanReader reader = PhysicalPlanReaderTestFactory.defaultPhysicalPlanReader(config, reg);
    final PhysicalPlan plan = reader.readPhysicalPlan(Files.toString(DrillFileUtils.getResourceAsFile(file), Charsets.UTF_8));
    final FunctionImplementationRegistry registry = new FunctionImplementationRegistry(config);
    final FragmentContext context = new FragmentContext(bitContext, PlanFragment.getDefaultInstance(), connection, registry);
    final SimpleRootExec exec = new SimpleRootExec(ImplCreator.getExec(context, (FragmentRoot) plan.getSortedOperators(false).iterator().next()));
    return exec;
}
Also used : StoragePluginRegistry(org.apache.drill.exec.store.StoragePluginRegistry) PhysicalPlan(org.apache.drill.exec.physical.PhysicalPlan) FragmentContext(org.apache.drill.exec.ops.FragmentContext) PhysicalPlanReader(org.apache.drill.exec.planner.PhysicalPlanReader) StoragePluginRegistryImpl(org.apache.drill.exec.store.StoragePluginRegistryImpl) FragmentRoot(org.apache.drill.exec.physical.base.FragmentRoot) FunctionImplementationRegistry(org.apache.drill.exec.expr.fn.FunctionImplementationRegistry)

Example 58 with FragmentContext

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

the class TestExternalSortInternals method testConfigConstraints.

@Test
public void testConfigConstraints() {
    int memConstraint = 40 * ONE_MEG;
    int batchSizeConstraint = ONE_MEG / 2;
    int mergeSizeConstraint = ONE_MEG;
    OperatorFixture.Builder builder = new OperatorFixture.Builder(watcher);
    builder.configBuilder().put(ExecConstants.EXTERNAL_SORT_MAX_MEMORY, memConstraint).put(ExecConstants.EXTERNAL_SORT_SPILL_BATCH_SIZE, batchSizeConstraint).build();
    FragmentContext fragmentContext = builder.build().getFragmentContext();
    fragmentContext.getOptions().setLocalOption(ExecConstants.OUTPUT_BATCH_SIZE, mergeSizeConstraint);
    SortConfig sortConfig = new SortConfig(fragmentContext.getConfig(), fragmentContext.getOptions());
    long memoryLimit = 50 * ONE_MEG;
    SortMemoryManager memManager = new SortMemoryManager(sortConfig, memoryLimit);
    assertEquals(batchSizeConstraint, memManager.getPreferredSpillBatchSize());
    assertEquals(mergeSizeConstraint, memManager.getPreferredMergeBatchSize());
    assertEquals(memConstraint, memManager.getMemoryLimit());
    int rowWidth = 300;
    int rowCount = 10000;
    int batchSize = rowWidth * rowCount * 2;
    memManager.updateEstimates(batchSize, rowWidth, rowCount);
    verifyCalcs(sortConfig, memConstraint, memManager, batchSize, rowWidth, rowCount);
}
Also used : FragmentContext(org.apache.drill.exec.ops.FragmentContext) OperatorFixture(org.apache.drill.test.OperatorFixture) OperatorTest(org.apache.drill.categories.OperatorTest) SubOperatorTest(org.apache.drill.test.SubOperatorTest) Test(org.junit.Test)

Aggregations

FragmentContext (org.apache.drill.exec.ops.FragmentContext)58 Test (org.junit.Test)43 FunctionImplementationRegistry (org.apache.drill.exec.expr.fn.FunctionImplementationRegistry)40 PhysicalPlan (org.apache.drill.exec.physical.PhysicalPlan)39 FragmentRoot (org.apache.drill.exec.physical.base.FragmentRoot)39 PhysicalPlanReader (org.apache.drill.exec.planner.PhysicalPlanReader)35 SimpleRootExec (org.apache.drill.exec.physical.impl.SimpleRootExec)21 SchemaPath (org.apache.drill.common.expression.SchemaPath)16 ExecTest (org.apache.drill.exec.ExecTest)16 OperatorTest (org.apache.drill.categories.OperatorTest)10 OperatorFixture (org.apache.drill.test.OperatorFixture)10 SubOperatorTest (org.apache.drill.test.SubOperatorTest)10 ValueVector (org.apache.drill.exec.vector.ValueVector)7 IntVector (org.apache.drill.exec.vector.IntVector)6 Ignore (org.junit.Ignore)6 StoragePluginRegistryImpl (org.apache.drill.exec.store.StoragePluginRegistryImpl)5 BigIntVector (org.apache.drill.exec.vector.BigIntVector)5 NonStrictExpectations (mockit.NonStrictExpectations)4 BufferAllocator (org.apache.drill.exec.memory.BufferAllocator)4 DrillConfig (org.apache.drill.common.config.DrillConfig)3