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());
}
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;
}
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);
}
Aggregations