use of org.apache.hyracks.storage.am.lsm.invertedindex.ondisk.FixedSizeFrameTupleAppender in project asterixdb by apache.
the class FixedSizeFrameTupleTest method singleFieldTest.
/**
* This test verifies the correct behavior of the FixedSizeFrameTuple class.
* Frames containing FixedSizeFrameTuple's require neither tuple slots nor
* field slots. The tests inserts generated data into a frame until the
* frame is full, and then verifies the frame's contents.
*
*/
@Test
public void singleFieldTest() throws Exception {
ByteBuffer buffer = ByteBuffer.allocate(FRAME_SIZE);
ITypeTraits[] fields = new ITypeTraits[1];
fields[0] = IntegerPointable.TYPE_TRAITS;
FixedSizeFrameTupleAppender ftapp = new FixedSizeFrameTupleAppender(FRAME_SIZE, fields);
FixedSizeFrameTupleAccessor ftacc = new FixedSizeFrameTupleAccessor(FRAME_SIZE, fields);
boolean frameHasSpace = true;
ArrayList<Integer> check = new ArrayList<Integer>();
ftapp.reset(buffer, true);
while (frameHasSpace) {
int val = rnd.nextInt();
frameHasSpace = ftapp.append(val);
if (frameHasSpace) {
check.add(val);
ftapp.incrementTupleCount(1);
}
}
ftacc.reset(buffer);
for (int i = 0; i < ftacc.getTupleCount(); i++) {
int val = IntegerPointable.getInteger(ftacc.getBuffer().array(), ftacc.getTupleStartOffset(i));
Assert.assertEquals(check.get(i).intValue(), val);
}
}
Aggregations