use of org.apache.hyracks.dataflow.std.sort.FrameSorterMergeSort in project asterixdb by apache.
the class InMemorySortRuntimeFactory method createOneOutputPushRuntime.
@Override
public AbstractOneInputOneOutputPushRuntime createOneOutputPushRuntime(final IHyracksTaskContext ctx) throws HyracksDataException {
return new AbstractOneInputOneOutputPushRuntime() {
FrameSorterMergeSort frameSorter = null;
@Override
public void open() throws HyracksDataException {
writer.open();
if (frameSorter == null) {
IFrameBufferManager manager = new VariableFrameMemoryManager(new VariableFramePool(ctx, VariableFramePool.UNLIMITED_MEMORY), FrameFreeSlotPolicyFactory.createFreeSlotPolicy(EnumFreeSlotPolicy.LAST_FIT));
frameSorter = new FrameSorterMergeSort(ctx, manager, sortFields, firstKeyNormalizerFactory, comparatorFactories, outputRecordDesc);
}
frameSorter.reset();
}
@Override
public void nextFrame(ByteBuffer buffer) throws HyracksDataException {
frameSorter.insertFrame(buffer);
}
@Override
public void fail() throws HyracksDataException {
writer.fail();
}
@Override
public void close() throws HyracksDataException {
try {
frameSorter.sort();
frameSorter.flush(writer);
} finally {
writer.close();
}
}
};
}
Aggregations