use of org.apache.drill.exec.physical.impl.scan.v3.ScanLifecycleBuilder in project drill by apache.
the class ReaderLifecycle method buildLoader.
public ResultSetLoader buildLoader() {
Preconditions.checkState(state == State.START);
ScanLifecycleBuilder scanOptions = scanOptions();
ResultSetOptionBuilder options = new ResultSetOptionBuilder().rowCountLimit(Math.min(schemaNegotiator.batchSize, scanOptions.scanBatchRecordLimit())).vectorCache(scanLifecycle.vectorCache()).batchSizeLimit(scanOptions.scanBatchByteLimit()).errorContext(errorContext()).projectionFilter(schemaTracker().projectionFilter(errorContext())).readerSchema(schemaNegotiator.readerSchema).limit(limit);
// Resolve the scan schema if possible.
applyEarlySchema();
// Create the table loader
tableLoader = new ResultSetLoaderImpl(scanLifecycle.allocator(), options.build());
state = State.DATA;
return tableLoader;
}
use of org.apache.drill.exec.physical.impl.scan.v3.ScanLifecycleBuilder in project drill by apache.
the class TestReaderErrors method testCtorUserError.
@Test
public void testCtorUserError() {
ScanLifecycleBuilder builder = new ScanLifecycleBuilder();
builder.errorContext(b -> b.addContext("Scan context"));
builder.readerFactory(new SingleReaderFactory() {
@Override
public ManagedReader next(SchemaNegotiator negotiator) {
return new FailingReader(negotiator, "ctor-u");
}
});
ScanLifecycle scan = buildScan(builder);
RowBatchReader reader = scan.nextReader();
try {
reader.open();
fail();
} catch (UserException e) {
String msg = e.getMessage();
assertTrue(msg.contains("Oops ctor"));
assertTrue(msg.contains("My custom context"));
assertTrue(msg.contains("Scan context"));
assertNull(e.getCause());
}
scan.close();
}
use of org.apache.drill.exec.physical.impl.scan.v3.ScanLifecycleBuilder in project drill by apache.
the class TestReaderErrors method testNextUserError.
@Test
public void testNextUserError() {
ScanLifecycleBuilder builder = new ScanLifecycleBuilder();
builder.errorContext(b -> b.addContext("Scan context"));
builder.readerFactory(new SingleReaderFactory() {
@Override
public ManagedReader next(SchemaNegotiator negotiator) {
return new FailingReader(negotiator, "next-u");
}
});
ScanLifecycle scan = buildScan(builder);
RowBatchReader reader = scan.nextReader();
assertTrue(reader.open());
try {
reader.next();
fail();
} catch (UserException e) {
String msg = e.getMessage();
assertTrue(msg.contains("Oops next"));
assertTrue(msg.contains("My custom context"));
assertTrue(msg.contains("Scan context"));
assertNull(e.getCause());
}
scan.close();
}
use of org.apache.drill.exec.physical.impl.scan.v3.ScanLifecycleBuilder in project drill by apache.
the class TestReaderErrors method testNextError.
@Test
public void testNextError() {
ScanLifecycleBuilder builder = new ScanLifecycleBuilder();
builder.errorContext(b -> b.addContext("Scan context"));
builder.readerFactory(new SingleReaderFactory() {
@Override
public ManagedReader next(SchemaNegotiator negotiator) {
return new FailingReader(negotiator, "next");
}
});
ScanLifecycle scan = buildScan(builder);
RowBatchReader reader = scan.nextReader();
assertTrue(reader.open());
try {
reader.next();
fail();
} catch (UserException e) {
String msg = e.getMessage();
assertTrue(msg.contains("Oops next"));
assertTrue(msg.contains("My custom context"));
assertTrue(msg.contains("Scan context"));
assertTrue(e.getCause() instanceof IllegalStateException);
}
scan.close();
}
use of org.apache.drill.exec.physical.impl.scan.v3.ScanLifecycleBuilder in project drill by apache.
the class TestReaderErrors method testCloseUserError.
@Test
public void testCloseUserError() {
ScanLifecycleBuilder builder = new ScanLifecycleBuilder();
builder.errorContext(b -> b.addContext("Scan context"));
builder.readerFactory(new SingleReaderFactory() {
@Override
public ManagedReader next(SchemaNegotiator negotiator) {
return new FailingReader(negotiator, "close-u");
}
});
ScanLifecycle scan = buildScan(builder);
RowBatchReader reader = scan.nextReader();
assertTrue(reader.open());
assertFalse(reader.next());
// to update an external system.
try {
reader.close();
fail();
} catch (UserException e) {
String msg = e.getMessage();
assertTrue(msg.contains("Oops close"));
assertTrue(msg.contains("My custom context"));
assertTrue(msg.contains("Scan context"));
assertNull(e.getCause());
}
scan.close();
}
Aggregations