use of org.apache.hyracks.storage.am.lsm.btree.impls.ExternalBTree.LSMTwoPCBTreeBulkLoader in project asterixdb by apache.
the class ExternalFilesIndexModificationOperatorDescriptor method createPushRuntime.
@Override
public IOperatorNodePushable createPushRuntime(IHyracksTaskContext ctx, IRecordDescriptorProvider recordDescProvider, int partition, int nPartitions) throws HyracksDataException {
return new AbstractOperatorNodePushable() {
@Override
public void initialize() throws HyracksDataException {
final IIndexDataflowHelper indexHelper = dataflowHelperFactory.create(ctx, partition);
FileIndexTupleTranslator filesTupleTranslator = new FileIndexTupleTranslator();
// Open and get
indexHelper.open();
IIndex index = indexHelper.getIndexInstance();
LSMTwoPCBTreeBulkLoader bulkLoader = null;
try {
bulkLoader = (LSMTwoPCBTreeBulkLoader) ((ExternalBTree) index).createTransactionBulkLoader(BTree.DEFAULT_FILL_FACTOR, false, files.size());
// The files must be ordered according to their numbers
for (ExternalFile file : files) {
switch(file.getPendingOp()) {
case ADD_OP:
case APPEND_OP:
bulkLoader.add(filesTupleTranslator.getTupleFromFile(file));
break;
case DROP_OP:
bulkLoader.delete(filesTupleTranslator.getTupleFromFile(file));
break;
case NO_OP:
break;
default:
throw HyracksDataException.create(ErrorCode.UNKNOWN_EXTERNAL_FILE_PENDING_OP, file.getPendingOp());
}
}
bulkLoader.end();
} catch (Exception e) {
if (bulkLoader != null) {
bulkLoader.abort();
}
throw HyracksDataException.create(e);
} finally {
indexHelper.close();
}
}
@Override
public void deinitialize() throws HyracksDataException {
}
@Override
public int getInputArity() {
return 0;
}
@Override
public void setOutputFrameWriter(int index, IFrameWriter writer, RecordDescriptor recordDesc) throws HyracksDataException {
}
@Override
public IFrameWriter getInputFrameWriter(int index) {
return null;
}
};
}
Aggregations