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);
}
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;
}
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;
}
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;
}
Aggregations