final ITreeNodeIdProvider nodeIdProvider = new TreeNodeIdProvider(partitionId, dataSourceId, totalDataSources);
final String nodeId = ctx.getJobletContext().getApplicationContext().getNodeId();
final DynamicContext dCtx = (DynamicContext) ctx.getJobletContext().getGlobalJobData();
final String collectionName = collectionPartitions[partition % collectionPartitions.length];
final XMLParser parser = new XMLParser(false, nodeIdProvider, nodeId, frame, appender, childSeq,
dCtx.getStaticContext());
return new AbstractUnaryInputUnaryOutputOperatorNodePushable() {
@Override
public void open() throws HyracksDataException {
appender.reset(frame, true);
writer.open();
}
@Override
public void nextFrame(ByteBuffer buffer) throws HyracksDataException {
fta.reset(buffer);
String collectionModifiedName = collectionName.replace("${nodeId}", nodeId);
File collectionDirectory = new File(collectionModifiedName);
// Go through each tuple.
if (collectionDirectory.isDirectory()) {
for (int tupleIndex = 0; tupleIndex < fta.getTupleCount(); ++tupleIndex) {
@SuppressWarnings("unchecked")
Iterator<File> it = FileUtils.iterateFiles(collectionDirectory, new VXQueryIOFileFilter(),
TrueFileFilter.INSTANCE);
while (it.hasNext()) {
File xmlDocument = it.next();
if (LOGGER.isLoggable(Level.FINE)) {
LOGGER.fine("Starting to read XML document: " + xmlDocument.getAbsolutePath());
}
parser.parseElements(xmlDocument, writer, fta, tupleIndex);
}
}
} else {
throw new HyracksDataException("Invalid directory parameter (" + nodeId + ":"
+ collectionDirectory.getAbsolutePath() + ") passed to collection.");