Search in sources :

Example 6 with FixedSizeFrame

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

the class TopKRunGeneratorTest method prepareSortedData.

private ByteBuffer prepareSortedData(Map<Integer, String> keyValuePair) throws HyracksDataException {
    ByteBuffer buffer = ByteBuffer.allocate(PAGE_SIZE * NUM_PAGES);
    IFrame inputFrame = new FixedSizeFrame(buffer);
    FrameTupleAppender appender = new FrameTupleAppender();
    appender.reset(inputFrame, true);
    ArrayTupleBuilder builder = new ArrayTupleBuilder(RecordDesc.getFieldCount());
    for (Map.Entry<Integer, String> entry : keyValuePair.entrySet()) {
        builder.reset();
        builder.addField(SerDers[0], entry.getKey());
        builder.addField(SerDers[1], entry.getValue());
        appender.append(builder.getFieldEndOffsets(), builder.getByteArray(), 0, builder.getSize());
    }
    return buffer;
}
Also used : IFrame(org.apache.hyracks.api.comm.IFrame) FixedSizeFrame(org.apache.hyracks.api.comm.FixedSizeFrame) FrameTupleAppender(org.apache.hyracks.dataflow.common.comm.io.FrameTupleAppender) ArrayTupleBuilder(org.apache.hyracks.dataflow.common.comm.io.ArrayTupleBuilder) ByteBuffer(java.nio.ByteBuffer) Map(java.util.Map) TreeMap(java.util.TreeMap)

Aggregations

ByteBuffer (java.nio.ByteBuffer)6 FixedSizeFrame (org.apache.hyracks.api.comm.FixedSizeFrame)6 FrameTupleAppender (org.apache.hyracks.dataflow.common.comm.io.FrameTupleAppender)6 HashMap (java.util.HashMap)5 IFrame (org.apache.hyracks.api.comm.IFrame)3 Map (java.util.Map)2 IFrameTupleAppender (org.apache.hyracks.api.comm.IFrameTupleAppender)2 TreeMap (java.util.TreeMap)1 ArrayTupleBuilder (org.apache.hyracks.dataflow.common.comm.io.ArrayTupleBuilder)1 TuplePointer (org.apache.hyracks.dataflow.std.structures.TuplePointer)1