OffHeapRowBlock extends OffHeapMemory implements Deallocatable { public RowWriter getWriter() { return builder; } private  OffHeapRowBlock(ByteBuffer buffer, Schema schema, ResizableLimitSpec limitSpec);  OffHeapRowBlock(Schema schema, ResizableLimitSpec limitSpec); @VisibleForTesting  OffHeapRowBlock(Schema schema, int bytes); @VisibleForTesting  OffHeapRowBlock(Schema schema, ByteBuffer buffer); void position(int pos); void clear(); @Override ByteBuffer nioBuffer(); int position(); long usedMem(); void ensureSize(int size); long remain(); int maxRowNum(); int rows(); void setRows(int rowNum); boolean copyFromChannel(FileChannel channel, TableStats stats); RowWriter getWriter(); OffHeapRowBlockReader getReader(); static final int NULL_FIELD_OFFSET; }
@Test public void testPutAndReadValidation() { int rowNum = 1000; long allocStart = System.currentTimeMillis(); OffHeapRowBlock rowBlock = new OffHeapRowBlock(schema, 1024); long allocEnd = System.currentTimeMillis(); explainRowBlockAllocation(rowBlock, allocStart, allocEnd); OffHeapRowBlockReader reader = new OffHeapRowBlockReader(rowBlock); ZeroCopyTuple tuple = new ZeroCopyTuple(); long writeStart = System.currentTimeMillis(); for (int i = 0; i < rowNum; i++) { fillRow(i, rowBlock.getWriter()); reader.reset(); int j = 0; while(reader.next(tuple)) { validateTupleResult(j, tuple); j++; } } long writeEnd = System.currentTimeMillis(); LOG.info("writing and validating take " + (writeEnd - writeStart) + " msec"); long readStart = System.currentTimeMillis(); tuple = new ZeroCopyTuple(); int j = 0; reader.reset(); while(reader.next(tuple)) { validateTupleResult(j, tuple); j++; } long readEnd = System.currentTimeMillis(); LOG.info("reading takes " + (readEnd - readStart) + " msec"); rowBlock.release(); }
@Test public void testNullityValidation() { int rowNum = 1000; long allocStart = System.currentTimeMillis(); OffHeapRowBlock rowBlock = new OffHeapRowBlock(schema, 1024); long allocEnd = System.currentTimeMillis(); explainRowBlockAllocation(rowBlock, allocStart, allocEnd); OffHeapRowBlockReader reader = new OffHeapRowBlockReader(rowBlock); ZeroCopyTuple tuple = new ZeroCopyTuple(); long writeStart = System.currentTimeMillis(); for (int i = 0; i < rowNum; i++) { fillRowBlockWithNull(i, rowBlock.getWriter()); reader.reset(); int j = 0; while(reader.next(tuple)) { validateNullity(j, tuple); j++; } } long writeEnd = System.currentTimeMillis(); LOG.info("writing and nullity validating take " + (writeEnd - writeStart) +" msec"); long readStart = System.currentTimeMillis(); tuple = new ZeroCopyTuple(); int j = 0; reader.reset(); while(reader.next(tuple)) { validateNullity(j, tuple); j++; } long readEnd = System.currentTimeMillis(); LOG.info("reading takes " + (readEnd - readStart) + " msec"); rowBlock.release(); }
@Test public void testVTuplePutAndGetBenchmarkViaDirectRowEncoder() { int rowNum = 1000; OffHeapRowBlock rowBlock = new OffHeapRowBlock(schema, StorageUnit.MB * 100); long writeStart = System.currentTimeMillis(); VTuple tuple = new VTuple(schema.size()); for (int i = 0; i < rowNum; i++) { fillVTuple(i, tuple); RowStoreUtil.convert(tuple, rowBlock.getWriter()); } long writeEnd = System.currentTimeMillis(); LOG.info("Writing takes " + (writeEnd - writeStart) + " msec"); validateResults(rowBlock); rowBlock.release(); }