@Test public void testHeapTupleFromHeap() throws CloneNotSupportedException { MemoryRowBlock rowBlock = TestMemoryRowBlock.createRowBlock(1024); int length = rowBlock.getMemory().writerPosition(); ByteBuf heapBuffer = BufferPool.heapBuffer(length, length); heapBuffer.writeBytes(rowBlock.getMemory().getBuffer()); assertFalse(heapBuffer.isDirect()); ResizableMemoryBlock memoryBlock = new ResizableMemoryBlock(heapBuffer); assertFalse(memoryBlock.hasAddress()); RowBlockReader reader = new HeapRowBlockReader(memoryBlock, rowBlock.getDataTypes(), rowBlock.rows()); assertEquals(HeapRowBlockReader.class, reader.getClass()); HeapTuple heapTuple = new HeapTuple(); int i = 0; while (reader.next(heapTuple)) { TestMemoryRowBlock.validateTupleResult(i, heapTuple); TestMemoryRowBlock.validateTupleResult(i, heapTuple.clone()); i++; } assertEquals(rowBlock.rows(), i); rowBlock.release(); memoryBlock.release(); }
@Override public Tuple clone() throws CloneNotSupportedException { HeapTuple heapTuple = (HeapTuple) super.clone(); heapTuple.buffer = buffer.copy(getRelativePos(), getLength()); heapTuple.relativePos = 0; return heapTuple; }
HeapTuple extends ZeroCopyTuple implements Cloneable { @Override public Tuple clone() throws CloneNotSupportedException { HeapTuple heapTuple = (HeapTuple) super.clone(); heapTuple.buffer = buffer.copy(getRelativePos(), getLength()); heapTuple.relativePos = 0; return heapTuple; } }
HeapTuple extends ZeroCopyTuple implements Cloneable { @Override public Tuple clone() throws CloneNotSupportedException { HeapTuple heapTuple = (HeapTuple) super.clone(); heapTuple.buffer = buffer.copy(getRelativePos(), getLength()); heapTuple.relativePos = 0; return heapTuple; }  }
HeapTuple extends ZeroCopyTuple implements Cloneable { @Override public Tuple clone() throws CloneNotSupportedException { HeapTuple heapTuple = (HeapTuple) super.clone(); heapTuple.buffer = buffer.copy(getRelativePos(), getLength()); heapTuple.relativePos = 0; return heapTuple; }  @Override void set(MemoryBlock memoryBlock, int relativePos, DataType[] types); @Override int size(); @Override int getLength(); @Override TajoDataTypes.Type type(int fieldId); @Override int size(int fieldId); @Override void clearOffset(); @Override boolean contains(int fieldid); @Override boolean isBlank(int fieldid); @Override boolean isBlankOrNull(int fieldid); @Override void insertTuple(int fieldId, Tuple tuple); @Override void clear(); @Override void put(int fieldId, Datum value); @Override void put(Datum[] values); @Override Datum asDatum(int fieldId); @Override void setOffset(long offset); @Override long getOffset(); @Override boolean getBool(int fieldId); @Override byte getByte(int fieldId); @Override char getChar(int fieldId); @Override byte[] getBytes(int fieldId); @Override byte[] getTextBytes(int fieldId); @Override short getInt2(int fieldId); @Override int getInt4(int fieldId); @Override long getInt8(int fieldId); @Override float getFloat4(int fieldId); @Override double getFloat8(int fieldId); @Override String getText(int fieldId); @Override TimeMeta getTimeDate(int fieldId); IntervalDatum getInterval(int fieldId); @Override Datum getProtobufDatum(int fieldId); @Override char[] getUnicodeChars(int fieldId); @Override Datum[] getValues(); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object obj); @Override Tuple clone(); }
HeapTuple extends ZeroCopyTuple implements Cloneable { @Override public Tuple clone() throws CloneNotSupportedException { HeapTuple heapTuple = (HeapTuple) super.clone(); heapTuple.buffer = buffer.copy(getRelativePos(), getLength()); heapTuple.relativePos = 0; return heapTuple; }  @Override void set(MemoryBlock memoryBlock, int relativePos, DataType[] types); @Override int size(); @Override int getLength(); @Override TajoDataTypes.Type type(int fieldId); @Override int size(int fieldId); @Override void clearOffset(); @Override boolean contains(int fieldid); @Override boolean isBlank(int fieldid); @Override boolean isBlankOrNull(int fieldid); @Override void insertTuple(int fieldId, Tuple tuple); @Override void clear(); @Override void put(int fieldId, Datum value); @Override void put(Datum[] values); @Override Datum asDatum(int fieldId); @Override void setOffset(long offset); @Override long getOffset(); @Override boolean getBool(int fieldId); @Override byte getByte(int fieldId); @Override char getChar(int fieldId); @Override byte[] getBytes(int fieldId); @Override byte[] getTextBytes(int fieldId); @Override short getInt2(int fieldId); @Override int getInt4(int fieldId); @Override long getInt8(int fieldId); @Override float getFloat4(int fieldId); @Override double getFloat8(int fieldId); @Override String getText(int fieldId); @Override TimeMeta getTimeDate(int fieldId); IntervalDatum getInterval(int fieldId); @Override Datum getProtobufDatum(int fieldId); @Override char[] getUnicodeChars(int fieldId); @Override Datum[] getValues(); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object obj); @Override Tuple clone();  }