Search in sources :

Example 1 with IFrameTupleAppender

use of org.apache.hyracks.api.comm.IFrameTupleAppender in project asterixdb by apache.

the class VariableFramesMemoryManagerTest method prepareRandomTuples.

private HashMap<Integer, Integer> prepareRandomTuples() throws HyracksDataException {
    frameList.clear();
    HashMap<Integer, Integer> set = new HashMap<>(NUM_MIN_FRAME);
    int[] fieldSlot = { 0 };
    int id = 0;
    int size = 0;
    while (size < BUDGET) {
        int tupleLength = random.nextInt(BUDGET / 3) + 4;
        IFrame frame = new FixedSizeFrame(Common.commonFrameManager.allocateFrame(FrameHelper.calcAlignedFrameSizeToStore(1, tupleLength, MIN_FRAME_SIZE)));
        IFrameTupleAppender appender = new FrameTupleAppender();
        appender.reset(frame, true);
        //            System.out.println("id:" + id + ",frameSize:" + frame.getInitialFrameSize() / MIN_FRAME_SIZE);
        ByteBuffer buffer = ByteBuffer.allocate(tupleLength);
        buffer.putInt(0, id);
        assertTrue(appender.append(fieldSlot, buffer.array(), 0, buffer.capacity()));
        set.put(id++, tupleLength);
        size += frame.getFrameSize();
        frameList.add(frame);
    }
    return set;
}
Also used : HashMap(java.util.HashMap) IFrame(org.apache.hyracks.api.comm.IFrame) FixedSizeFrame(org.apache.hyracks.api.comm.FixedSizeFrame) FrameTupleAppender(org.apache.hyracks.dataflow.common.comm.io.FrameTupleAppender) IFrameTupleAppender(org.apache.hyracks.api.comm.IFrameTupleAppender) IFrameTupleAppender(org.apache.hyracks.api.comm.IFrameTupleAppender) ByteBuffer(java.nio.ByteBuffer)

Example 2 with IFrameTupleAppender

use of org.apache.hyracks.api.comm.IFrameTupleAppender in project asterixdb by apache.

the class VariableFramesMemoryManagerTest method prepareTuples.

private HashMap<Integer, Integer> prepareTuples() throws HyracksDataException {
    frameList.clear();
    HashMap<Integer, Integer> set = new HashMap<>(NUM_MIN_FRAME);
    for (int i = 0; i < NUM_MIN_FRAME; ++i) {
        IFrame frame = new FixedSizeFrame(Common.commonFrameManager.allocateFrame(MIN_FRAME_SIZE));
        IFrameTupleAppender appender = new FrameTupleAppender();
        appender.reset(frame, true);
        int[] fieldSlot = { 0 };
        ByteBuffer buffer = ByteBuffer.allocate(MIN_FRAME_SIZE / 2);
        buffer.putInt(0, i);
        appender.append(fieldSlot, buffer.array(), 0, buffer.capacity());
        set.put(i, buffer.capacity());
        frameList.add(frame);
    }
    return set;
}
Also used : HashMap(java.util.HashMap) IFrame(org.apache.hyracks.api.comm.IFrame) FixedSizeFrame(org.apache.hyracks.api.comm.FixedSizeFrame) FrameTupleAppender(org.apache.hyracks.dataflow.common.comm.io.FrameTupleAppender) IFrameTupleAppender(org.apache.hyracks.api.comm.IFrameTupleAppender) IFrameTupleAppender(org.apache.hyracks.api.comm.IFrameTupleAppender) ByteBuffer(java.nio.ByteBuffer)

Example 3 with IFrameTupleAppender

use of org.apache.hyracks.api.comm.IFrameTupleAppender 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;
}
Also used : IFrameTupleAccessor(org.apache.hyracks.api.comm.IFrameTupleAccessor) FrameTupleAppender(org.apache.hyracks.dataflow.common.comm.io.FrameTupleAppender) IFrameTupleAppender(org.apache.hyracks.api.comm.IFrameTupleAppender) FrameManager(org.apache.hyracks.control.nc.resources.memory.FrameManager) IFrameTupleAppender(org.apache.hyracks.api.comm.IFrameTupleAppender) VSizeFrame(org.apache.hyracks.api.comm.VSizeFrame) FrameTupleAccessor(org.apache.hyracks.dataflow.common.comm.io.FrameTupleAccessor) IFrameTupleAccessor(org.apache.hyracks.api.comm.IFrameTupleAccessor)

Aggregations

IFrameTupleAppender (org.apache.hyracks.api.comm.IFrameTupleAppender)3 FrameTupleAppender (org.apache.hyracks.dataflow.common.comm.io.FrameTupleAppender)3 ByteBuffer (java.nio.ByteBuffer)2 HashMap (java.util.HashMap)2 FixedSizeFrame (org.apache.hyracks.api.comm.FixedSizeFrame)2 IFrame (org.apache.hyracks.api.comm.IFrame)2 IFrameTupleAccessor (org.apache.hyracks.api.comm.IFrameTupleAccessor)1 VSizeFrame (org.apache.hyracks.api.comm.VSizeFrame)1 FrameManager (org.apache.hyracks.control.nc.resources.memory.FrameManager)1 FrameTupleAccessor (org.apache.hyracks.dataflow.common.comm.io.FrameTupleAccessor)1