/** * Sets the column bit set for the column index, and returns the column's offset. * @param columnIndex the index of the column to get the position for and mark as set * @return the offset in rowAlloc for the column */ private int getPositionInRowAllocAndSetBitSet(int columnIndex) { columnsBitSet.set(columnIndex); return schema.getColumnOffset(columnIndex); }
/** * Get the specified column's byte * @param columnIndex Column index in the schema * @return a byte * @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 byte getByte(int columnIndex) { checkColumn(schema.getColumnByIndex(columnIndex), Type.INT8); checkValue(columnIndex); return rowAlloc[schema.getColumnOffset(columnIndex)]; }
/** * Get the specified column's boolean * @param columnIndex Column index in the schema * @return a boolean * @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 boolean getBoolean(int columnIndex) { checkColumn(schema.getColumnByIndex(columnIndex), Type.BOOL); checkValue(columnIndex); byte b = rowAlloc[schema.getColumnOffset(columnIndex)]; return b == 1; }
sb.append(Bytes.getBoolean(rowAlloc, schema.getColumnOffset(idx))); return; case INT8: sb.append(Bytes.getByte(rowAlloc, schema.getColumnOffset(idx))); return; case INT16: sb.append(Bytes.getShort(rowAlloc, schema.getColumnOffset(idx))); return; case INT32: sb.append(Bytes.getInt(rowAlloc, schema.getColumnOffset(idx))); return; case INT64: sb.append(Bytes.getLong(rowAlloc, schema.getColumnOffset(idx))); return; case UNIXTIME_MICROS: sb.append(TimestampUtil.timestampToString( Bytes.getLong(rowAlloc, schema.getColumnOffset(idx)))); return; case FLOAT: sb.append(Bytes.getFloat(rowAlloc, schema.getColumnOffset(idx))); return; case DOUBLE: sb.append(Bytes.getDouble(rowAlloc, schema.getColumnOffset(idx))); return; case DECIMAL: ColumnTypeAttributes typeAttributes = col.getTypeAttributes(); sb.append(Bytes.getDecimal(rowAlloc, schema.getColumnOffset(idx), typeAttributes.getPrecision(), typeAttributes.getScale())); return;
/** * Get the specified column's double * @param columnIndex Column index in the schema * @return a double * @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 double getDouble(int columnIndex) { checkColumn(schema.getColumnByIndex(columnIndex), Type.DOUBLE); checkValue(columnIndex); return Bytes.getDouble(rowAlloc, schema.getColumnOffset(columnIndex)); }
/** * Get the specified column's short * @param columnIndex Column index in the schema * @return a short * @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 short getShort(int columnIndex) { checkColumn(schema.getColumnByIndex(columnIndex), Type.INT16); checkValue(columnIndex); return Bytes.getShort(rowAlloc, schema.getColumnOffset(columnIndex)); }
/** * Get the specified column's integer * @param columnIndex Column index in the schema * @return an integer * @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 int getInt(int columnIndex) { checkColumn(schema.getColumnByIndex(columnIndex), Type.INT32); checkValue(columnIndex); return Bytes.getInt(rowAlloc, schema.getColumnOffset(columnIndex)); }
/** * Get the specified column's float * @param columnIndex Column index in the schema * @return a float * @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 float getFloat(int columnIndex) { checkColumn(schema.getColumnByIndex(columnIndex), Type.FLOAT); checkValue(columnIndex); return Bytes.getFloat(rowAlloc, schema.getColumnOffset(columnIndex)); }
/** * Encodes a single column of a row into the output buffer. * @param row the row being encoded * @param columnIdx the column index of the column to encode * @param isLast whether the column is the last component of the key */ private static void encodeColumn(PartialRow row, int columnIdx, boolean isLast, ByteVec buf) { final Schema schema = row.getSchema(); final ColumnSchema column = schema.getColumnByIndex(columnIdx); if (!row.isSet(columnIdx)) { throw new IllegalStateException(String.format("Primary key column %s is not set", column.getName())); } final Type type = column.getType(); if (type == Type.STRING || type == Type.BINARY) { encodeBinary(row.getVarLengthData().get(columnIdx), isLast, buf); } else { encodeSignedInt(row.getRowAlloc(), schema.getColumnOffset(columnIdx), column.getTypeSize(), buf); } }
/** * Get the specified column's long * * If this is a UNIXTIME_MICROS column, the long value corresponds to a number of microseconds * since midnight, January 1, 1970 UTC. * * @param columnIndex Column index in the schema * @return a long * @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 long getLong(int columnIndex) { checkColumn(schema.getColumnByIndex(columnIndex), Type.INT64, Type.UNIXTIME_MICROS); checkColumnExists(schema.getColumnByIndex(columnIndex)); checkValue(columnIndex); return Bytes.getLong(rowAlloc, schema.getColumnOffset(columnIndex)); }
int offset = a.getSchema().getColumnOffset(index);
/** * 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) { checkColumn(schema.getColumnByIndex(columnIndex), Type.UNIXTIME_MICROS); checkColumnExists(schema.getColumnByIndex(columnIndex)); checkValue(columnIndex); long micros = Bytes.getLong(rowAlloc, schema.getColumnOffset(columnIndex)); return TimestampUtil.microsToTimestamp(micros); }
int offset = lower.getSchema().getColumnOffset(index);
Type type = column.getType(); Preconditions.checkState(isSet(index)); int offset = schema.getColumnOffset(index); switch (type) { case BOOL: {
/** * Get the specified column's Decimal. * * @param columnIndex Column index in the schema * @return a BigDecimal * @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 BigDecimal getDecimal(int columnIndex) { checkColumn(schema.getColumnByIndex(columnIndex), Type.DECIMAL); checkColumnExists(schema.getColumnByIndex(columnIndex)); checkValue(columnIndex); ColumnSchema column = schema.getColumnByIndex(columnIndex); ColumnTypeAttributes typeAttributes = column.getTypeAttributes(); return Bytes.getDecimal(rowAlloc, schema.getColumnOffset(columnIndex), typeAttributes.getPrecision(), typeAttributes.getScale()); }