use of org.apache.hyracks.dataflow.common.comm.io.FrameTupleAccessor in project asterixdb by apache.
the class IndexSearchOperatorNodePushable method open.
@Override
public void open() throws HyracksDataException {
writer.open();
indexHelper.open();
index = indexHelper.getIndexInstance();
accessor = new FrameTupleAccessor(inputRecDesc);
if (retainMissing) {
int fieldCount = getFieldCount();
nonMatchTupleBuild = new ArrayTupleBuilder(fieldCount);
buildMissingTuple(fieldCount, nonMatchTupleBuild, nonMatchWriter);
} else {
nonMatchTupleBuild = null;
}
if (appendIndexFilter) {
int numIndexFilterFields = index.getNumOfFilterFields();
nonFilterTupleBuild = new ArrayTupleBuilder(numIndexFilterFields);
buildMissingTuple(numIndexFilterFields, nonFilterTupleBuild, nonMatchWriter);
}
try {
searchPred = createSearchPredicate();
tb = new ArrayTupleBuilder(recordDesc.getFieldCount());
dos = tb.getDataOutput();
appender = new FrameTupleAppender(new VSizeFrame(ctx), true);
ISearchOperationCallback searchCallback = searchCallbackFactory.createSearchOperationCallback(indexHelper.getResource().getId(), ctx, null);
indexAccessor = index.createAccessor(NoOpOperationCallback.INSTANCE, searchCallback);
cursor = createCursor();
if (retainInput) {
frameTuple = new FrameTupleReference();
}
} catch (Exception e) {
throw new HyracksDataException(e);
}
}
use of org.apache.hyracks.dataflow.common.comm.io.FrameTupleAccessor in project asterixdb by apache.
the class FramewriterTest method setUp.
@Before
public void setUp() throws Exception {
// Mock static methods
PowerMockito.mockStatic(BTreeUtils.class);
PowerMockito.when(BTreeUtils.getSearchMultiComparator(Matchers.any(), Matchers.any())).thenReturn(mockMultiComparator());
PowerMockito.mockStatic(FrameUtils.class);
// Custom implementation for FrameUtils that push to next frame immediately
PowerMockito.when(FrameUtils.appendToWriter(Matchers.any(IFrameWriter.class), Matchers.any(IFrameTupleAppender.class), Matchers.any(IFrameTupleAccessor.class), Matchers.anyInt(), Matchers.anyInt())).thenAnswer(new Answer<Integer>() {
@Override
public Integer answer(InvocationOnMock invocation) throws Throwable {
Object[] args = invocation.getArguments();
IFrameWriter writer = (IFrameWriter) args[0];
writer.nextFrame(EMPTY_BUFFER);
return BUFFER_SIZE;
}
});
// create global mock for FrameTupleAccessor, ArrayTupleBuilder
FrameTupleAccessor frameAccessor = Mockito.mock(FrameTupleAccessor.class);
Mockito.when(frameAccessor.getTupleCount()).thenReturn(RECORDS_PER_FRAME);
// Global custom implementations for FrameTupleAppender
// since we have two appenders, then we need to test each test twice
FrameTupleAppender[] appenders = mockAppenders();
// Mock all instances of a class <Note that you need to prepare the class calling this constructor as well>
PowerMockito.whenNew(FrameTupleAccessor.class).withAnyArguments().thenReturn(frameAccessor);
PowerMockito.whenNew(FrameTupleAppender.class).withAnyArguments().thenAnswer(new Answer<FrameTupleAppender>() {
@Override
public FrameTupleAppender answer(InvocationOnMock invocation) throws Throwable {
counter++;
if (counter % 2 == 1) {
return appenders[0];
}
return appenders[1];
}
});
}
use of org.apache.hyracks.dataflow.common.comm.io.FrameTupleAccessor in project asterixdb by apache.
the class InputHandlerTest method createInputHandler.
private FeedRuntimeInputHandler createInputHandler(IHyracksTaskContext ctx, IFrameWriter writer, FeedPolicyAccessor fpa, ConcurrentFramePool framePool) throws HyracksDataException {
FrameTupleAccessor fta = Mockito.mock(FrameTupleAccessor.class);
EntityId feedId = new EntityId(FeedUtils.FEED_EXTENSION_NAME, DATAVERSE, FEED);
FeedConnectionId connectionId = new FeedConnectionId(feedId, DATASET);
ActiveRuntimeId runtimeId = new ActiveRuntimeId(feedId, FeedRuntimeType.COLLECT.toString(), 0);
return new FeedRuntimeInputHandler(ctx, connectionId, runtimeId, writer, fpa, fta, framePool);
}
use of org.apache.hyracks.dataflow.common.comm.io.FrameTupleAccessor in project asterixdb by apache.
the class VariableFramesMemoryManagerTest method setUp.
@Before
public void setUp() throws Exception {
VariableFramePool framePool = new VariableFramePool(Common.commonFrameManager, BUDGET);
FrameFreeSlotLastFit policy = new FrameFreeSlotLastFit(NUM_MIN_FRAME);
framesMemoryManager = new VariableFrameMemoryManager(framePool, policy);
RecordDescriptor recordDescriptor = new RecordDescriptor(new ISerializerDeserializer[] { null });
fta = new FrameTupleAccessor(recordDescriptor);
random = new Random(System.currentTimeMillis());
frameList = new ArrayList<>();
}
use of org.apache.hyracks.dataflow.common.comm.io.FrameTupleAccessor in project asterixdb by apache.
the class LSMPrimaryUpsertOperatorNodePushable method open.
// we have the permutation which has [pk locations, record location, optional:filter-location]
// the index -> we don't need anymore data?
// we need to use the primary index opTracker and secondary indexes callbacks for insert/delete since the lock would
// have been obtained through searchForUpsert operation
@Override
public void open() throws HyracksDataException {
accessor = new FrameTupleAccessor(inputRecDesc);
writeBuffer = new VSizeFrame(ctx);
writer.open();
indexHelper.open();
index = indexHelper.getIndexInstance();
try {
if (ctx.getSharedObject() != null) {
PrimaryIndexLogMarkerCallback callback = new PrimaryIndexLogMarkerCallback((AbstractLSMIndex) index);
TaskUtil.putInSharedMap(ILogMarkerCallback.KEY_MARKER_CALLBACK, callback, ctx);
}
missingTupleBuilder = new ArrayTupleBuilder(1);
DataOutput out = missingTupleBuilder.getDataOutput();
try {
missingWriter.writeMissing(out);
} catch (IOException e) {
throw new HyracksDataException(e);
}
missingTupleBuilder.addFieldEndOffset();
searchPred = createSearchPredicate();
tb = new ArrayTupleBuilder(recordDesc.getFieldCount());
dos = tb.getDataOutput();
appender = new FrameTupleAppender(new VSizeFrame(ctx), true);
modCallback = modOpCallbackFactory.createModificationOperationCallback(indexHelper.getResource(), ctx, this);
abstractModCallback = (AbstractIndexModificationOperationCallback) modCallback;
searchCallback = (LockThenSearchOperationCallback) searchCallbackFactory.createSearchOperationCallback(indexHelper.getResource().getId(), ctx, this);
indexAccessor = index.createAccessor(abstractModCallback, searchCallback);
lsmAccessor = (LSMTreeIndexAccessor) indexAccessor;
cursor = indexAccessor.createSearchCursor(false);
frameTuple = new FrameTupleReference();
INcApplicationContext appCtx = (INcApplicationContext) ctx.getJobletContext().getServiceContext().getApplicationContext();
LSMIndexUtil.checkAndSetFirstLSN((AbstractLSMIndex) index, appCtx.getTransactionSubsystem().getLogManager());
frameOpCallback = new IFrameOperationCallback() {
IFrameOperationCallback callback = frameOpCallbackFactory.createFrameOperationCallback(ctx, (ILSMIndexAccessor) indexAccessor);
@Override
public void frameCompleted() throws HyracksDataException {
callback.frameCompleted();
appender.write(writer, true);
}
};
} catch (Exception e) {
indexHelper.close();
throw new HyracksDataException(e);
}
}
Aggregations