use of org.apache.asterix.external.dataset.adapter.LookupAdapter in project asterixdb by apache.
the class LookupAdapterFactory method createAdapter.
public LookupAdapter<T> createAdapter(IHyracksTaskContext ctx, int partition, RecordDescriptor inRecDesc, ExternalFileIndexAccessor snapshotAccessor, IFrameWriter writer) throws HyracksDataException {
try {
IRecordDataParser<T> dataParser = dataParserFactory.createRecordParser(ctx);
ILookupRecordReader<? extends T> reader = readerFactory.createRecordReader(ctx, partition, snapshotAccessor);
reader.configure(configuration);
RecordIdReader ridReader = RecordIdReaderFactory.create(configuration, ridFields);
return new LookupAdapter<>(dataParser, reader, inRecDesc, ridReader, retainInput, retainMissing, isMissingWriterFactory, ctx, writer);
} catch (Exception e) {
throw new HyracksDataException(e);
}
}
use of org.apache.asterix.external.dataset.adapter.LookupAdapter 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