Search in sources :

Example 1 with FrameSorterMergeSort

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();
            }
        }
    };
}
Also used : VariableFramePool(org.apache.hyracks.dataflow.std.buffermanager.VariableFramePool) AbstractOneInputOneOutputPushRuntime(org.apache.hyracks.algebricks.runtime.operators.base.AbstractOneInputOneOutputPushRuntime) VariableFrameMemoryManager(org.apache.hyracks.dataflow.std.buffermanager.VariableFrameMemoryManager) FrameSorterMergeSort(org.apache.hyracks.dataflow.std.sort.FrameSorterMergeSort) IFrameBufferManager(org.apache.hyracks.dataflow.std.buffermanager.IFrameBufferManager) ByteBuffer(java.nio.ByteBuffer)

Aggregations

ByteBuffer (java.nio.ByteBuffer)1 AbstractOneInputOneOutputPushRuntime (org.apache.hyracks.algebricks.runtime.operators.base.AbstractOneInputOneOutputPushRuntime)1 IFrameBufferManager (org.apache.hyracks.dataflow.std.buffermanager.IFrameBufferManager)1 VariableFrameMemoryManager (org.apache.hyracks.dataflow.std.buffermanager.VariableFrameMemoryManager)1 VariableFramePool (org.apache.hyracks.dataflow.std.buffermanager.VariableFramePool)1 FrameSorterMergeSort (org.apache.hyracks.dataflow.std.sort.FrameSorterMergeSort)1