Search in sources :

Example 6 with TuplePointer

use of org.apache.hyracks.dataflow.std.structures.TuplePointer in project asterixdb by apache.

the class VariableTupleMemoryManagerTest method testReOrganizeSpace.

@Test
public void testReOrganizeSpace() throws HyracksDataException {
    int iTuplePerFrame = 3;
    Map<Integer, Integer> mapPrepare = prepareFixedSizeTuples(iTuplePerFrame, EXTRA_BYTES_FOR_DELETABLE_FRAME, 0);
    Map<Integer, Integer> copyMap = new HashMap<>(mapPrepare);
    Map<TuplePointer, Integer> mapInserted = insertInFTAToBufferShouldAllSuccess();
    ByteBuffer buffer = deleteRandomSelectedTuples(mapPrepare, mapInserted, mapPrepare.size() / 2);
    inFTA.reset(buffer);
    //The deletable frame buffer will keep the deleted slot untouched, which will take more space.
    // the reason is to not reuse the same TuplePointer outside.
    Map<TuplePointer, Integer> mapInserted2 = insertInFTAToBufferMayNotAllSuccess();
    assertTrue(mapInserted2.size() > 0);
}
Also used : HashMap(java.util.HashMap) TuplePointer(org.apache.hyracks.dataflow.std.structures.TuplePointer) ByteBuffer(java.nio.ByteBuffer) Test(org.junit.Test)

Example 7 with TuplePointer

use of org.apache.hyracks.dataflow.std.structures.TuplePointer in project asterixdb by apache.

the class VariableTupleMemoryManagerTest method insertInFTAToBufferShouldAllSuccess.

private Map<TuplePointer, Integer> insertInFTAToBufferShouldAllSuccess() throws HyracksDataException {
    Map<TuplePointer, Integer> tuplePointerIntegerMap = new HashMap<>();
    for (int i = 0; i < inFTA.getTupleCount(); i++) {
        TuplePointer tuplePointer = new TuplePointer();
        assertTrue(tupleMemoryManager.insertTuple(inFTA, i, tuplePointer));
        tuplePointerIntegerMap.put(tuplePointer, IntSerDeUtils.getInt(inFTA.getBuffer().array(), inFTA.getAbsoluteFieldStartOffset(i, 0)));
    }
    return tuplePointerIntegerMap;
}
Also used : HashMap(java.util.HashMap) TuplePointer(org.apache.hyracks.dataflow.std.structures.TuplePointer)

Example 8 with TuplePointer

use of org.apache.hyracks.dataflow.std.structures.TuplePointer in project asterixdb by apache.

the class VariableTupleMemoryManagerTest method insertInFTAToBufferMayNotAllSuccess.

private Map<TuplePointer, Integer> insertInFTAToBufferMayNotAllSuccess() throws HyracksDataException {
    Map<TuplePointer, Integer> tuplePointerIntegerMap = new HashMap<>();
    for (int i = 0; i < inFTA.getTupleCount(); i++) {
        TuplePointer tuplePointer = new TuplePointer();
        if (!tupleMemoryManager.insertTuple(inFTA, i, tuplePointer)) {
            break;
        }
        tuplePointerIntegerMap.put(tuplePointer, IntSerDeUtils.getInt(inFTA.getBuffer().array(), inFTA.getAbsoluteFieldStartOffset(i, 0)));
    }
    return tuplePointerIntegerMap;
}
Also used : HashMap(java.util.HashMap) TuplePointer(org.apache.hyracks.dataflow.std.structures.TuplePointer)

Example 9 with TuplePointer

use of org.apache.hyracks.dataflow.std.structures.TuplePointer in project asterixdb by apache.

the class VariableTupleMemoryManagerTest method insertInFTAToBufferCouldFailForLargerTuples.

private Map<TuplePointer, Integer> insertInFTAToBufferCouldFailForLargerTuples(Map<Integer, Integer> map) throws HyracksDataException {
    Map<TuplePointer, Integer> tuplePointerIdMap = new HashMap<>();
    int i = 0;
    for (; i < inFTA.getTupleCount(); i++) {
        TuplePointer tuplePointer = new TuplePointer();
        if (!tupleMemoryManager.insertTuple(inFTA, i, tuplePointer)) {
            break;
        }
        tuplePointerIdMap.put(tuplePointer, IntSerDeUtils.getInt(inFTA.getBuffer().array(), inFTA.getAbsoluteFieldStartOffset(i, 0)));
    }
    for (; i < inFTA.getTupleCount(); i++) {
        map.remove(IntSerDeUtils.getInt(inFTA.getBuffer().array(), inFTA.getAbsoluteFieldStartOffset(i, 0)));
    }
    return tuplePointerIdMap;
}
Also used : HashMap(java.util.HashMap) TuplePointer(org.apache.hyracks.dataflow.std.structures.TuplePointer)

Aggregations

TuplePointer (org.apache.hyracks.dataflow.std.structures.TuplePointer)9 HashMap (java.util.HashMap)7 ByteBuffer (java.nio.ByteBuffer)3 IFrameTupleAccessor (org.apache.hyracks.api.comm.IFrameTupleAccessor)2 FrameTupleAppender (org.apache.hyracks.dataflow.common.comm.io.FrameTupleAppender)2 Test (org.junit.Test)2 BitSet (java.util.BitSet)1 Map (java.util.Map)1 FixedSizeFrame (org.apache.hyracks.api.comm.FixedSizeFrame)1 IFrameWriter (org.apache.hyracks.api.comm.IFrameWriter)1 VSizeFrame (org.apache.hyracks.api.comm.VSizeFrame)1 ITuplePartitionComputer (org.apache.hyracks.api.dataflow.value.ITuplePartitionComputer)1 HyracksDataException (org.apache.hyracks.api.exceptions.HyracksDataException)1 ArrayTupleBuilder (org.apache.hyracks.dataflow.common.comm.io.ArrayTupleBuilder)1 FrameTupleAccessor (org.apache.hyracks.dataflow.common.comm.io.FrameTupleAccessor)1 FieldHashPartitionComputerFamily (org.apache.hyracks.dataflow.common.data.partition.FieldHashPartitionComputerFamily)1 DeallocatableFramePool (org.apache.hyracks.dataflow.std.buffermanager.DeallocatableFramePool)1 FramePoolBackedFrameBufferManager (org.apache.hyracks.dataflow.std.buffermanager.FramePoolBackedFrameBufferManager)1 IDeallocatableFramePool (org.apache.hyracks.dataflow.std.buffermanager.IDeallocatableFramePool)1 IPartitionedTupleBufferManager (org.apache.hyracks.dataflow.std.buffermanager.IPartitionedTupleBufferManager)1