use of org.apache.drill.exec.store.xml.XMLReader in project drill by apache.
the class HttpXMLBatchReader method open.
@Override
public boolean open(SchemaNegotiator negotiator) {
HttpUrl url = buildUrl();
// Result set loader setup
String tempDirPath = negotiator.drillConfig().getString(ExecConstants.DRILL_TMP_DIR);
// Create user-friendly error context
CustomErrorContext errorContext = new ChildErrorContext(negotiator.parentErrorContext()) {
@Override
public void addContext(UserException.Builder builder) {
super.addContext(builder);
builder.addContext("URL", url.toString());
}
};
negotiator.setErrorContext(errorContext);
// Http client setup
SimpleHttp http = SimpleHttp.builder().scanDefn(subScan).url(url).tempDir(new File(tempDirPath)).paginator(paginator).proxyConfig(proxySettings(negotiator.drillConfig(), url)).errorContext(errorContext).build();
// Get the input stream
inStream = http.getInputStream();
// Initialize the XMLReader the reader
try {
xmlReader = new XMLReader(inStream, dataLevel, maxRecords);
resultLoader = negotiator.build();
if (implicitColumnsAreProjected()) {
implicitColumns = new ImplicitColumns(resultLoader.writer());
buildImplicitColumns();
populateImplicitFieldMap(http);
}
RowSetLoader rootRowWriter = resultLoader.writer();
xmlReader.open(rootRowWriter, errorContext);
xmlReader.implicitFields(implicitColumns);
} catch (XMLStreamException e) {
throw UserException.dataReadError(e).message("Error opening XML stream: " + e.getMessage()).addContext(errorContext).build(logger);
}
return true;
}
Aggregations