use of org.apache.hyracks.api.comm.VSizeFrame in project asterixdb by apache.
the class TreeIndexStatsOperatorNodePushable method initialize.
@Override
public void initialize() throws HyracksDataException {
treeIndexHelper.open();
ITreeIndex treeIndex = (ITreeIndex) treeIndexHelper.getIndexInstance();
try {
writer.open();
IBufferCache bufferCache = storageManager.getBufferCache(ctx.getJobletContext().getServiceContext());
IFileMapProvider fileMapProvider = storageManager.getFileMapProvider(ctx.getJobletContext().getServiceContext());
LocalResource resource = treeIndexHelper.getResource();
IIOManager ioManager = ctx.getIoManager();
FileReference fileRef = ioManager.resolve(resource.getPath());
int indexFileId = fileMapProvider.lookupFileId(fileRef);
TreeIndexStatsGatherer statsGatherer = new TreeIndexStatsGatherer(bufferCache, treeIndex.getPageManager(), indexFileId, treeIndex.getRootPageId());
TreeIndexStats stats = statsGatherer.gatherStats(treeIndex.getLeafFrameFactory().createFrame(), treeIndex.getInteriorFrameFactory().createFrame(), treeIndex.getPageManager().createMetadataFrame());
// Write the stats output as a single string field.
FrameTupleAppender appender = new FrameTupleAppender(new VSizeFrame(ctx));
ArrayTupleBuilder tb = new ArrayTupleBuilder(1);
DataOutput dos = tb.getDataOutput();
tb.reset();
utf8SerDer.serialize(stats.toString(), dos);
tb.addFieldEndOffset();
if (!appender.append(tb.getFieldEndOffsets(), tb.getByteArray(), 0, tb.getSize())) {
throw new HyracksDataException("Record size (" + tb.getSize() + ") larger than frame size (" + appender.getBuffer().capacity() + ")");
}
appender.write(writer, false);
} catch (Exception e) {
writer.fail();
throw new HyracksDataException(e);
} finally {
try {
writer.close();
} finally {
treeIndexHelper.close();
}
}
}
use of org.apache.hyracks.api.comm.VSizeFrame in project asterixdb by apache.
the class IndexInsertUpdateDeleteOperatorNodePushable method open.
@Override
public void open() throws HyracksDataException {
accessor = new FrameTupleAccessor(inputRecDesc);
writeBuffer = new VSizeFrame(ctx);
indexHelper.open();
index = indexHelper.getIndexInstance();
try {
writer.open();
LocalResource resource = indexHelper.getResource();
modCallback = modOpCallbackFactory.createModificationOperationCallback(resource, ctx, this);
indexAccessor = index.createAccessor(modCallback, NoOpOperationCallback.INSTANCE);
if (tupleFilterFactory != null) {
tupleFilter = tupleFilterFactory.createTupleFilter(ctx);
frameTuple = new FrameTupleReference();
}
} catch (Exception e) {
throw new HyracksDataException(e);
}
}
use of org.apache.hyracks.api.comm.VSizeFrame in project asterixdb by apache.
the class SortMergeFrameReader method open.
@Override
public void open() throws HyracksDataException {
if (maxConcurrentMerges >= nSenders) {
List<IFrame> inFrames = new ArrayList<>(nSenders);
for (int i = 0; i < nSenders; ++i) {
inFrames.add(new VSizeFrame(ctx));
}
List<IFrameReader> batch = new ArrayList<IFrameReader>(nSenders);
pbm.getNextBatch(batch, nSenders);
merger = new RunMergingFrameReader(ctx, batch, inFrames, sortFields, comparators, nmkComputer, recordDescriptor);
} else {
// multi level merge.
throw new HyracksDataException("Not yet supported");
}
merger.open();
}
use of org.apache.hyracks.api.comm.VSizeFrame in project asterixdb by apache.
the class FrameFixedFieldTupleAppenderTest method createAppender.
@Before
public void createAppender() throws HyracksDataException {
appender = new FrameFixedFieldAppender(fields.length);
FrameManager manager = new FrameManager(TEST_FRAME_SIZE);
IFrame frame = new VSizeFrame(manager);
appender.reset(frame, true);
}
use of org.apache.hyracks.api.comm.VSizeFrame in project asterixdb by apache.
the class FrameFixedFieldTupleAppenderTest method prepareData.
private IFrameTupleAccessor prepareData(DATA_TYPE type) throws HyracksDataException {
IFrameTupleAccessor accessor = new FrameTupleAccessor(recordDescriptor);
IFrameTupleAppender appender = new FrameTupleAppender(new VSizeFrame(new FrameManager(INPUT_BUFFER_SIZE)), true);
int i = 0;
do {
switch(type) {
case NORMAL_RECORD:
makeATuple(tupleBuilder, i++);
break;
case ONE_FIELD_LONG:
makeASizeUpTuple(tupleBuilder, i++);
break;
case ONE_RECORD_LONG:
makeABigObjectTuple(tupleBuilder, i++);
break;
}
} while (appender.append(tupleBuilder.getFieldEndOffsets(), tupleBuilder.getByteArray(), 0, tupleBuilder.getSize()));
accessor.reset(appender.getBuffer());
return accessor;
}
Aggregations