/** * Get the specified column's short * @param columnIndex Column index in the schema * @return a short * @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 short getShort(int columnIndex) { checkValidColumn(columnIndex); checkNull(columnIndex); checkType(columnIndex, Type.INT16); return Bytes.getShort(this.rowData.getRawArray(), this.rowData.getRawOffset() + getCurrentRowDataOffsetForColumn(columnIndex)); }
/** * Get the specified column's boolean * @param columnIndex Column index in the schema * @return a boolean * @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 boolean getBoolean(int columnIndex) { checkValidColumn(columnIndex); checkNull(columnIndex); checkType(columnIndex, Type.BOOL); byte b = Bytes.getByte(this.rowData.getRawArray(), this.rowData.getRawOffset() + getCurrentRowDataOffsetForColumn(columnIndex)); return b == 1; }
/** * Get the specified column's float * @param columnIndex Column index in the schema * @return a float * @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 float getFloat(int columnIndex) { checkValidColumn(columnIndex); checkNull(columnIndex); checkType(columnIndex, Type.FLOAT); return Bytes.getFloat(this.rowData.getRawArray(), this.rowData.getRawOffset() + getCurrentRowDataOffsetForColumn(columnIndex)); }
/** * Get the specified column's integer * @param columnIndex Column index in the schema * @return an integer * @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 int getInt(int columnIndex) { checkValidColumn(columnIndex); checkNull(columnIndex); checkType(columnIndex, Type.INT32); return Bytes.getInt(this.rowData.getRawArray(), this.rowData.getRawOffset() + getCurrentRowDataOffsetForColumn(columnIndex)); }
/** * Get the specified column's byte * @param columnIndex Column index in the schema * @return a byte * @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 getByte(int columnIndex) { checkValidColumn(columnIndex); checkNull(columnIndex); checkType(columnIndex, Type.INT8); return Bytes.getByte(this.rowData.getRawArray(), this.rowData.getRawOffset() + getCurrentRowDataOffsetForColumn(columnIndex)); }
/** * Get the specified column's double * @param columnIndex Column index in the schema * @return a double * @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 double getDouble(int columnIndex) { checkValidColumn(columnIndex); checkNull(columnIndex); checkType(columnIndex, Type.DOUBLE); return Bytes.getDouble(this.rowData.getRawArray(), this.rowData.getRawOffset() + getCurrentRowDataOffsetForColumn(columnIndex)); }
/** * 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 Timestamp. * * @param columnIndex Column index in the schema * @return a Timestamp * @throws IllegalArgumentException if the column is null, is unset, * or if the type doesn't match the column's type * @throws IndexOutOfBoundsException if the column doesn't exist */ public Timestamp getTimestamp(int columnIndex) { checkValidColumn(columnIndex); checkNull(columnIndex); checkType(columnIndex, Type.UNIXTIME_MICROS); ColumnSchema column = schema.getColumnByIndex(columnIndex); long micros = Bytes.getLong(this.rowData.getRawArray(), this.rowData.getRawOffset() + getCurrentRowDataOffsetForColumn(columnIndex)); return TimestampUtil.microsToTimestamp(micros); }
/** * 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); }
/** * Get the specified column's Decimal. * * @param columnIndex Column index in the schema * @return a BigDecimal. * @throws IllegalArgumentException if the column is null * @throws IndexOutOfBoundsException if the column doesn't exist */ public BigDecimal getDecimal(int columnIndex) { checkValidColumn(columnIndex); checkNull(columnIndex); checkType(columnIndex, Type.DECIMAL); ColumnSchema column = schema.getColumnByIndex(columnIndex); ColumnTypeAttributes typeAttributes = column.getTypeAttributes(); return Bytes.getDecimal(this.rowData.getRawArray(), this.rowData.getRawOffset() + getCurrentRowDataOffsetForColumn(columnIndex), typeAttributes.getPrecision(), typeAttributes.getScale()); }