use of org.apache.drill.exec.ops.FragmentContextImpl in project drill by apache.
the class TestHashJoin method testHJMockScanCommon.
private void testHJMockScanCommon(String physicalPlan, int expectedRows) 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(physicalPlan), 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 totalRecordCount = 0;
while (exec.next()) {
totalRecordCount += exec.getRecordCount();
}
exec.close();
assertEquals(expectedRows, totalRecordCount);
if (context.getExecutorState().getFailureCause() != null) {
throw context.getExecutorState().getFailureCause();
}
assertTrue(!context.getExecutorState().isFailed());
}
use of org.apache.drill.exec.ops.FragmentContextImpl in project drill by apache.
the class TestMergeJoin method simpleEqualityJoin.
@Test
// this doesn't have a sort. it also causes an infinite loop. these may or may not be related.
@Ignore
public void simpleEqualityJoin() 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("/join/merge_join.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 totalRecordCount = 0;
final StringBuilder sb = new StringBuilder();
while (exec.next()) {
totalRecordCount += exec.getRecordCount();
for (final ValueVector v : exec) {
sb.append("[" + v.getField().getName() + "] ");
}
sb.append("\n\n");
for (int valueIdx = 0; valueIdx < exec.getRecordCount(); valueIdx++) {
final List<Object> row = new ArrayList<>();
for (final ValueVector v : exec) {
row.add(v.getAccessor().getObject(valueIdx));
}
for (final Object cell : row) {
if (cell == null) {
sb.append("<null> ");
continue;
}
final int len = cell.toString().length();
sb.append(cell);
for (int i = 0; i < (14 - len); ++i) {
sb.append(" ");
}
}
sb.append("\n");
}
sb.append("\n");
}
logger.info(sb.toString());
assertEquals(100, totalRecordCount);
if (context.getExecutorState().getFailureCause() != null) {
throw context.getExecutorState().getFailureCause();
}
assertTrue(!context.getExecutorState().isFailed());
}
use of org.apache.drill.exec.ops.FragmentContextImpl in project drill by apache.
the class TestMergeJoin method testJoinBatchSize.
@Test
public void testJoinBatchSize() 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("/join/join_batchsize.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()));
// skip schema batch
exec.next();
while (exec.next()) {
assertEquals(100, exec.getRecordCount());
}
if (context.getExecutorState().getFailureCause() != null) {
throw context.getExecutorState().getFailureCause();
}
assertTrue(!context.getExecutorState().isFailed());
}
use of org.apache.drill.exec.ops.FragmentContextImpl in project drill by apache.
the class TestMergeJoin method orderedEqualityInnerJoin.
@Test
@Ignore
public void orderedEqualityInnerJoin() throws Throwable {
final DrillbitContext bitContext = mockDrillbitContext();
final UserClientConnection connection = Mockito.mock(UserClientConnection.class);
final PhysicalPlanReader reader = PhysicalPlanReaderTestFactory.defaultPhysicalPlanReader(c, new StoragePluginRegistryImpl(bitContext));
final PhysicalPlan plan = reader.readPhysicalPlan(Files.asCharSource(DrillFileUtils.getResourceAsFile("/join/merge_inner_single_batch.json"), Charsets.UTF_8).read().replace("#{LEFT_FILE}", DrillFileUtils.getResourceAsFile("/join/merge_single_batch.left.json").toURI().toString()).replace("#{RIGHT_FILE}", DrillFileUtils.getResourceAsFile("/join/merge_single_batch.right.json").toURI().toString()));
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 totalRecordCount = 0;
final StringBuilder sb = new StringBuilder();
while (exec.next()) {
totalRecordCount += exec.getRecordCount();
sb.append(String.format("got next with record count: %d (total: %d):\n", exec.getRecordCount(), totalRecordCount));
sb.append(" t1 t2\n");
for (int valueIdx = 0; valueIdx < exec.getRecordCount(); valueIdx++) {
final List<Object> row = Lists.newArrayList();
for (final ValueVector v : exec) {
row.add(v.getField().getName() + ":" + v.getAccessor().getObject(valueIdx));
}
for (final Object cell : row) {
if (cell == null) {
sb.append("<null> ");
continue;
}
final int len = cell.toString().length();
sb.append(cell + " ");
for (int i = 0; i < (10 - len); ++i) {
sb.append(" ");
}
}
sb.append('\n');
}
}
assertEquals(23, totalRecordCount);
if (context.getExecutorState().getFailureCause() != null) {
throw context.getExecutorState().getFailureCause();
}
assertTrue(!context.getExecutorState().isFailed());
}
use of org.apache.drill.exec.ops.FragmentContextImpl in project drill by apache.
the class TestMergeJoin method orderedEqualityMultiBatchJoin.
@Test
@Ignore
public void orderedEqualityMultiBatchJoin() throws Throwable {
final DrillbitContext bitContext = mockDrillbitContext();
final UserClientConnection connection = Mockito.mock(UserClientConnection.class);
final PhysicalPlanReader reader = PhysicalPlanReaderTestFactory.defaultPhysicalPlanReader(c, new StoragePluginRegistryImpl(bitContext));
final PhysicalPlan plan = reader.readPhysicalPlan(Files.asCharSource(DrillFileUtils.getResourceAsFile("/join/merge_multi_batch.json"), Charsets.UTF_8).read().replace("#{LEFT_FILE}", DrillFileUtils.getResourceAsFile("/join/merge_multi_batch.left.json").toURI().toString()).replace("#{RIGHT_FILE}", DrillFileUtils.getResourceAsFile("/join/merge_multi_batch.right.json").toURI().toString()));
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 totalRecordCount = 0;
final StringBuilder sb = new StringBuilder();
while (exec.next()) {
totalRecordCount += exec.getRecordCount();
sb.append(String.format("got next with record count: %d (total: %d):\n", exec.getRecordCount(), totalRecordCount));
for (int valueIdx = 0; valueIdx < exec.getRecordCount(); valueIdx++) {
final List<Object> row = Lists.newArrayList();
for (final ValueVector v : exec) {
row.add(v.getField().getName() + ":" + v.getAccessor().getObject(valueIdx));
}
for (final Object cell : row) {
if (cell == null) {
sb.append("<null> ");
continue;
}
int len = cell.toString().length();
sb.append(cell + " ");
for (int i = 0; i < (10 - len); ++i) {
sb.append(" ");
}
}
sb.append('\n');
}
}
assertEquals(25, totalRecordCount);
if (context.getExecutorState().getFailureCause() != null) {
throw context.getExecutorState().getFailureCause();
}
assertTrue(!context.getExecutorState().isFailed());
}
Aggregations