/** * Get a copy of the specified column's binary data. * @param columnIndex Column index in the schema * @return a byte[] with the binary data. * @throws IllegalArgumentException if the column is null * or if the type doesn't match the column's type * @throws IndexOutOfBoundsException if the column doesn't exist */ public byte[] getBinaryCopy(int columnIndex) { checkValidColumn(columnIndex); checkNull(columnIndex); // C++ puts a Slice in rowData which is 16 bytes long for simplicity, // but we only support ints. long offset = getLong(columnIndex); long length = rowData.getLong(getCurrentRowDataOffsetForColumn(columnIndex) + 8); assert offset < Integer.MAX_VALUE; assert length < Integer.MAX_VALUE; byte[] ret = new byte[(int)length]; System.arraycopy(indirectData.getRawArray(), indirectData.getRawOffset() + (int) offset, ret, 0, (int) length); return ret; }
/** * Get the specified column's binary data. * * This doesn't copy the data and instead returns a ByteBuffer that wraps it. * * @param columnIndex Column index in the schema * @return a ByteBuffer with the binary data. * @throws IllegalArgumentException if the column is null * or if the type doesn't match the column's type * @throws IndexOutOfBoundsException if the column doesn't exist */ public ByteBuffer getBinary(int columnIndex) { checkValidColumn(columnIndex); checkNull(columnIndex); checkType(columnIndex, Type.BINARY); // C++ puts a Slice in rowData which is 16 bytes long for simplicity, // but we only support ints. long offset = getLong(columnIndex); long length = rowData.getLong(getCurrentRowDataOffsetForColumn(columnIndex) + 8); assert offset < Integer.MAX_VALUE; assert length < Integer.MAX_VALUE; return ByteBuffer.wrap(indirectData.getRawArray(), indirectData.getRawOffset() + (int) offset, (int) length); }
/** * Get the specified column's string. * @param columnIndex Column index in the schema * @return a string * @throws IllegalArgumentException if the column is null * or if the type doesn't match the column's type * @throws IndexOutOfBoundsException if the column doesn't exist */ public String getString(int columnIndex) { checkValidColumn(columnIndex); checkNull(columnIndex); checkType(columnIndex, Type.STRING); // C++ puts a Slice in rowData which is 16 bytes long for simplity, but we only support ints. long offset = getLong(columnIndex); long length = rowData.getLong(getCurrentRowDataOffsetForColumn(columnIndex) + 8); assert offset < Integer.MAX_VALUE; assert length < Integer.MAX_VALUE; return Bytes.getString(indirectData.getRawArray(), indirectData.getRawOffset() + (int)offset, (int)length); }