private int getColumnIndex(Schema columns, String colName) { try { return columns.getColumnIndex(colName); } catch (Exception ex) { return -1; } } }
/** * Get the column associated with the specified name * @param columnName column's name * @return the column */ public ColumnSchema getColumn(String columnName) { return columnsByIndex.get(getColumnIndex(columnName)); }
/** * Get the specified column's integer * @param columnName name of the column to get data for * @return an integer * @throws IllegalArgumentException if the column doesn't exist, * is null, is unset, or the type doesn't match the column's type */ public int getInt(String columnName) { return getInt(this.schema.getColumnIndex(columnName)); }
/** * Add an float for the specified column. * @param columnName Name of the column * @param val value to add * @throws IllegalArgumentException if the column doesn't exist * or if the value doesn't match the column's type * @throws IllegalStateException if the row was already applied */ public void addFloat(String columnName, float val) { addFloat(schema.getColumnIndex(columnName), val); }
/** * Get the specified column's Timestamp. * * @param columnName name of the column to get data for * @return a Timestamp * @throws IllegalArgumentException if the column doesn't exist, * is null, is unset, or the type doesn't match the column's type */ public Timestamp getTimestamp(String columnName) { return getTimestamp(this.schema.getColumnIndex(columnName)); }
/** * Get if the specified column has been set * @param columnName name of the column in the schema * @return true if the column has been set * @throws IllegalArgumentException if the column doesn't exist */ public boolean isSet(String columnName) { return isSet(this.schema.getColumnIndex(columnName)); }
/** * Get the specified column's byte * @param columnName name of the column to get data for * @return a byte * @throws IllegalArgumentException if the column doesn't exist, is null, * or if the type doesn't match the column's type */ public byte getByte(String columnName) { return getByte(this.schema.getColumnIndex(columnName)); }
/** * Add a byte for the specified column. * @param columnName Name of the column * @param val value to add * @throws IllegalArgumentException if the column doesn't exist * or if the value doesn't match the column's type * @throws IllegalStateException if the row was already applied */ public void addByte(String columnName, byte val) { addByte(schema.getColumnIndex(columnName), val); }
/** * Get the specified column's integer * @param columnName name of the column to get data for * @return an integer * @throws IllegalArgumentException if the column doesn't exist, is null, * or if the type doesn't match the column's type */ public int getInt(String columnName) { return getInt(this.schema.getColumnIndex(columnName)); }
/** * Get the specified column's short * @param columnName name of the column to get data for * @return a short * @throws IllegalArgumentException if the column doesn't exist, is null, * or if the type doesn't match the column's type */ public short getShort(String columnName) { return getShort(this.schema.getColumnIndex(columnName)); }
/** * Add a boolean for the specified column. * @param columnName Name of the column * @param val value to add * @throws IllegalArgumentException if the column doesn't exist * or if the value doesn't match the column's type * @throws IllegalStateException if the row was already applied */ public void addBoolean(String columnName, boolean val) { addBoolean(schema.getColumnIndex(columnName), val); }
/** * Add a Decimal for the specified column. * * @param columnName Name of the column * @param val value to add * @throws IllegalArgumentException if the column doesn't exist * or if the value doesn't match the column's type * @throws IllegalStateException if the row was already applied */ public void addDecimal(String columnName, BigDecimal val) { addDecimal(schema.getColumnIndex(columnName), val); }
/** * Get a copy of the specified column's binary data. * @param columnName name of the column to get data for * @return a byte[] with the binary data. * @throws IllegalArgumentException if the column doesn't exist, * is null, is unset, or the type doesn't match the column's type */ public byte[] getBinaryCopy(String columnName) { return getBinaryCopy(this.schema.getColumnIndex(columnName)); }
/** * Get the specified column's float * @param columnName name of the column to get data for * @return a float * @throws IllegalArgumentException if the column doesn't exist, is null, * or if the type doesn't match the column's type */ public float getFloat(String columnName) { return getFloat(this.schema.getColumnIndex(columnName)); }
/** * 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 columnName name of the column to get data for * @return a positive long * @throws IllegalArgumentException if the column doesn't exist or is null */ public long getLong(String columnName) { return getLong(this.schema.getColumnIndex(columnName)); }
/** * Add a String for the specified value, encoded as UTF8. * Note that the provided value must not be mutated after this. * @param columnName Name of the column * @param val value to add * @throws IllegalArgumentException if the column doesn't exist * or if the value doesn't match the column's type * @throws IllegalStateException if the row was already applied * */ public void addStringUtf8(String columnName, byte[] val) { addStringUtf8(schema.getColumnIndex(columnName), val); }
/** * Get the specified column's binary data. * * This doesn't copy the data and instead returns a ByteBuffer that wraps it. * * @param columnName name of the column to get data for * @return a ByteBuffer with the binary data. * @throws IllegalArgumentException if the column doesn't exist, * is null, is unset, or the type doesn't match the column's type */ public ByteBuffer getBinary(String columnName) { return getBinary(this.schema.getColumnIndex(columnName)); }
/** * Add binary data with the specified value. * Note that the provided value must not be mutated after this. * @param columnName Name of the column * @param val value to add * @throws IllegalArgumentException if the column doesn't exist * or if the value doesn't match the column's type * @throws IllegalStateException if the row was already applied */ public void addBinary(String columnName, byte[] val) { addBinary(schema.getColumnIndex(columnName), val); }
/** * Get the specified column's Decimal. * * @param columnName name of the column to get data for * @return a BigDecimal * @throws IllegalArgumentException if the column doesn't exist or is null */ public BigDecimal getDecimal(String columnName) { return getDecimal(this.schema.getColumnIndex(columnName)); }
/** * Get the specified column's Timestamp. * * @param columnName name of the column to get data for * @return a Timestamp * @throws IllegalArgumentException if the column doesn't exist, * is null, is unset, or the type doesn't match the column's type */ public Timestamp getTimestamp(String columnName) { return getTimestamp(this.schema.getColumnIndex(columnName)); }