Search in sources :

Example 1 with AbstractOneInputOneOutputPushRuntime

use of org.apache.hyracks.algebricks.runtime.operators.base.AbstractOneInputOneOutputPushRuntime 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)

Example 2 with AbstractOneInputOneOutputPushRuntime

use of org.apache.hyracks.algebricks.runtime.operators.base.AbstractOneInputOneOutputPushRuntime in project asterixdb by apache.

the class MicroPreClusteredGroupRuntimeFactory method createOneOutputPushRuntime.

@Override
public AbstractOneInputOneOutputPushRuntime createOneOutputPushRuntime(final IHyracksTaskContext ctx) throws HyracksDataException {
    final IBinaryComparator[] comparators = new IBinaryComparator[comparatorFactories.length];
    for (int i = 0; i < comparatorFactories.length; ++i) {
        comparators[i] = comparatorFactories[i].createBinaryComparator();
    }
    return new AbstractOneInputOneOutputPushRuntime() {

        private PreclusteredGroupWriter pgw;

        @Override
        public void open() throws HyracksDataException {
            pgw = new PreclusteredGroupWriter(ctx, groupFields, comparators, aggregatorFactory, inRecordDesc, outRecordDesc, writer);
            pgw.open();
        }

        @Override
        public void nextFrame(ByteBuffer buffer) throws HyracksDataException {
            pgw.nextFrame(buffer);
        }

        @Override
        public void fail() throws HyracksDataException {
            pgw.fail();
        }

        @Override
        public void close() throws HyracksDataException {
            pgw.close();
        }

        @Override
        public void flush() throws HyracksDataException {
            pgw.flush();
        }
    };
}
Also used : AbstractOneInputOneOutputPushRuntime(org.apache.hyracks.algebricks.runtime.operators.base.AbstractOneInputOneOutputPushRuntime) PreclusteredGroupWriter(org.apache.hyracks.dataflow.std.group.preclustered.PreclusteredGroupWriter) IBinaryComparator(org.apache.hyracks.api.dataflow.value.IBinaryComparator) ByteBuffer(java.nio.ByteBuffer)

Aggregations

ByteBuffer (java.nio.ByteBuffer)2 AbstractOneInputOneOutputPushRuntime (org.apache.hyracks.algebricks.runtime.operators.base.AbstractOneInputOneOutputPushRuntime)2 IBinaryComparator (org.apache.hyracks.api.dataflow.value.IBinaryComparator)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 PreclusteredGroupWriter (org.apache.hyracks.dataflow.std.group.preclustered.PreclusteredGroupWriter)1 FrameSorterMergeSort (org.apache.hyracks.dataflow.std.sort.FrameSorterMergeSort)1