use of org.apache.asterix.external.indexing.ExternalFileIndexAccessor in project asterixdb by apache.
the class ExternalLookupOperatorDescriptor method createPushRuntime.
@Override
public IOperatorNodePushable createPushRuntime(final IHyracksTaskContext ctx, final IRecordDescriptorProvider recordDescProvider, final int partition, int nPartitions) throws HyracksDataException {
// Create a file index accessor to be used for files lookup operations
final ExternalFileIndexAccessor snapshotAccessor = new ExternalFileIndexAccessor(dataflowHelperFactory.create(ctx, partition), searchOpCallbackFactory, version);
return new AbstractUnaryInputUnaryOutputOperatorNodePushable() {
// The adapter that uses the file index along with the coming tuples to access files in HDFS
private LookupAdapter<?> adapter;
private boolean indexOpen = false;
@Override
public void open() throws HyracksDataException {
try {
adapter = adapterFactory.createAdapter(ctx, partition, recordDescProvider.getInputRecordDescriptor(getActivityId(), 0), snapshotAccessor, writer);
// Open the file index accessor here
snapshotAccessor.open();
indexOpen = true;
adapter.open();
} catch (Throwable th) {
throw new HyracksDataException(th);
}
}
@Override
public void close() throws HyracksDataException {
HyracksDataException hde = null;
if (indexOpen) {
try {
snapshotAccessor.close();
} catch (Throwable th) {
hde = new HyracksDataException(th);
}
try {
adapter.close();
} catch (Throwable th) {
if (hde == null) {
hde = new HyracksDataException(th);
} else {
hde.addSuppressed(th);
}
}
}
}
@Override
public void fail() throws HyracksDataException {
try {
adapter.fail();
} catch (Throwable th) {
throw new HyracksDataException(th);
}
}
@Override
public void nextFrame(ByteBuffer buffer) throws HyracksDataException {
try {
adapter.nextFrame(buffer);
} catch (Throwable th) {
throw new HyracksDataException(th);
}
}
@Override
public void flush() throws HyracksDataException {
adapter.flush();
}
};
}
Aggregations