@InterfaceAudience.Public @InterfaceStability.Evolving public class PartialRow extends Object
Values can be replaced as often as needed, but once the enclosing Operation
is applied
then they cannot be changed again. This means that a PartialRow cannot be reused.
Each PartialRow is backed by an byte array where all the cells (except strings and binary data) are written. The others are kept in a List.
This class isn't thread-safe.
Constructor and Description |
---|
PartialRow(Schema schema)
This is not a stable API, prefer using
Schema.newPartialRow()
to create a new partial row. |
Modifier and Type | Method and Description |
---|---|
void |
addBinary(int columnIndex,
byte[] val)
Add binary data with the specified value.
|
void |
addBinary(int columnIndex,
ByteBuffer value)
Add binary data with the specified value, from the current ByteBuffer's position to its limit.
|
void |
addBinary(String columnName,
byte[] val)
Add binary data with the specified value.
|
void |
addBinary(String columnName,
ByteBuffer value)
Add binary data with the specified value, from the current ByteBuffer's position to its limit.
|
void |
addBoolean(int columnIndex,
boolean val)
Add a boolean for the specified column.
|
void |
addBoolean(String columnName,
boolean val)
Add a boolean for the specified column.
|
void |
addByte(int columnIndex,
byte val)
Add a byte for the specified column.
|
void |
addByte(String columnName,
byte val)
Add a byte for the specified column.
|
void |
addDecimal(int columnIndex,
BigDecimal val)
Add a Decimal for the specified column.
|
void |
addDecimal(String columnName,
BigDecimal val)
Add a Decimal for the specified column.
|
void |
addDouble(int columnIndex,
double val)
Add an double for the specified column.
|
void |
addDouble(String columnName,
double val)
Add an double for the specified column.
|
void |
addFloat(int columnIndex,
float val)
Add an float for the specified column.
|
void |
addFloat(String columnName,
float val)
Add an float for the specified column.
|
void |
addInt(int columnIndex,
int val)
Add an int for the specified column.
|
void |
addInt(String columnName,
int val)
Add an int for the specified column.
|
void |
addLong(int columnIndex,
long val)
Add an long for the specified column.
|
void |
addLong(String columnName,
long val)
Add an long for the specified column.
|
void |
addShort(int columnIndex,
short val)
Add a short for the specified column.
|
void |
addShort(String columnName,
short val)
Add a short for the specified column.
|
void |
addString(int columnIndex,
String val)
Add a String for the specified column.
|
void |
addString(String columnName,
String val)
Add a String for the specified column.
|
void |
addStringUtf8(int columnIndex,
byte[] val)
Add a String for the specified value, encoded as UTF8.
|
void |
addStringUtf8(String columnName,
byte[] val)
Add a String for the specified value, encoded as UTF8.
|
void |
addTimestamp(int columnIndex,
Timestamp val)
Add a Timestamp for the specified column.
|
void |
addTimestamp(String columnName,
Timestamp val)
Add a Timestamp for the specified column.
|
byte[] |
encodePrimaryKey()
Returns the encoded primary key of the row.
|
ByteBuffer |
getBinary(int columnIndex)
Get the specified column's binary data.
|
ByteBuffer |
getBinary(String columnName)
Get the specified column's binary data.
|
byte[] |
getBinaryCopy(int columnIndex)
Get a copy of the specified column's binary data.
|
byte[] |
getBinaryCopy(String columnName)
Get a copy of the specified column's binary data.
|
boolean |
getBoolean(int columnIndex)
Get the specified column's boolean
|
boolean |
getBoolean(String columnName)
Get the specified column's boolean
|
byte |
getByte(int columnIndex)
Get the specified column's byte
|
byte |
getByte(String columnName)
Get the specified column's byte
|
BigDecimal |
getDecimal(int columnIndex)
Get the specified column's Decimal.
|
BigDecimal |
getDecimal(String columnName)
Get the specified column's BigDecimal
|
double |
getDouble(int columnIndex)
Get the specified column's double
|
double |
getDouble(String columnName)
Get the specified column's double
|
float |
getFloat(int columnIndex)
Get the specified column's float
|
float |
getFloat(String columnName)
Get the specified column's float
|
int |
getInt(int columnIndex)
Get the specified column's integer
|
int |
getInt(String columnName)
Get the specified column's integer
|
long |
getLong(int columnIndex)
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.
|
long |
getLong(String 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.
|
short |
getShort(int columnIndex)
Get the specified column's short
|
short |
getShort(String columnName)
Get the specified column's short
|
String |
getString(int columnIndex)
Get the specified column's string.
|
String |
getString(String columnName)
Get the specified column's string.
|
Timestamp |
getTimestamp(int columnIndex)
Get the specified column's Timestamp.
|
Timestamp |
getTimestamp(String columnName)
Get the specified column's Timestamp.
|
boolean |
isNull(int columnIndex)
Get if the specified column is NULL
|
boolean |
isNull(String columnName)
Get if the specified column is NULL
|
boolean |
isSet(int columnIndex)
Get if the specified column has been set
|
boolean |
isSet(String columnName)
Get if the specified column has been set
|
void |
setNull(int columnIndex)
Set the specified column to null
|
void |
setNull(String columnName)
Set the specified column to null
|
String |
stringifyRowKey()
Transforms the row key into a string representation where each column is in the format:
"type col_name=value".
|
String |
toString() |
public PartialRow(Schema schema)
Schema.newPartialRow()
to create a new partial row.schema
- the schema to use for this rowpublic void addBoolean(int columnIndex, boolean val)
columnIndex
- the column's index in the schemaval
- value to addIllegalArgumentException
- if the value doesn't match the column's typeIllegalStateException
- if the row was already appliedIndexOutOfBoundsException
- if the column doesn't existpublic void addBoolean(String columnName, boolean val)
columnName
- Name of the columnval
- value to addIllegalArgumentException
- if the column doesn't exist
or if the value doesn't match the column's typeIllegalStateException
- if the row was already appliedpublic boolean getBoolean(String columnName)
columnName
- name of the column to get data forIllegalArgumentException
- if the column doesn't exist,
is null, is unset, or the type doesn't match the column's typepublic boolean getBoolean(int columnIndex)
columnIndex
- Column index in the schemaIllegalArgumentException
- if the column is null, is unset,
or if the type doesn't match the column's typeIndexOutOfBoundsException
- if the column doesn't existpublic void addByte(int columnIndex, byte val)
columnIndex
- the column's index in the schemaval
- value to addIllegalArgumentException
- if the value doesn't match the column's typeIllegalStateException
- if the row was already appliedIndexOutOfBoundsException
- if the column doesn't existpublic void addByte(String columnName, byte val)
columnName
- Name of the columnval
- value to addIllegalArgumentException
- if the column doesn't exist
or if the value doesn't match the column's typeIllegalStateException
- if the row was already appliedpublic byte getByte(String columnName)
columnName
- name of the column to get data forIllegalArgumentException
- if the column doesn't exist,
is null, is unset, or the type doesn't match the column's typepublic byte getByte(int columnIndex)
columnIndex
- Column index in the schemaIllegalArgumentException
- if the column is null, is unset,
or if the type doesn't match the column's typeIndexOutOfBoundsException
- if the column doesn't existpublic void addShort(int columnIndex, short val)
columnIndex
- the column's index in the schemaval
- value to addIllegalArgumentException
- if the value doesn't match the column's typeIllegalStateException
- if the row was already appliedIndexOutOfBoundsException
- if the column doesn't existpublic void addShort(String columnName, short val)
columnName
- Name of the columnval
- value to addIllegalArgumentException
- if the column doesn't exist
or if the value doesn't match the column's typeIllegalStateException
- if the row was already appliedpublic short getShort(String columnName)
columnName
- name of the column to get data forIllegalArgumentException
- if the column doesn't exist,
is null, is unset, or the type doesn't match the column's typepublic short getShort(int columnIndex)
columnIndex
- Column index in the schemaIllegalArgumentException
- if the column is null, is unset,
or if the type doesn't match the column's typeIndexOutOfBoundsException
- if the column doesn't existpublic void addInt(int columnIndex, int val)
columnIndex
- the column's index in the schemaval
- value to addIllegalArgumentException
- if the value doesn't match the column's typeIllegalStateException
- if the row was already appliedIndexOutOfBoundsException
- if the column doesn't existpublic void addInt(String columnName, int val)
columnName
- Name of the columnval
- value to addIllegalArgumentException
- if the column doesn't exist
or if the value doesn't match the column's typeIllegalStateException
- if the row was already appliedpublic int getInt(String columnName)
columnName
- name of the column to get data forIllegalArgumentException
- if the column doesn't exist,
is null, is unset, or the type doesn't match the column's typepublic int getInt(int columnIndex)
columnIndex
- Column index in the schemaIllegalArgumentException
- if the column is null, is unset,
or if the type doesn't match the column's typeIndexOutOfBoundsException
- if the column doesn't existpublic void addLong(int columnIndex, long val)
columnIndex
- the column's index in the schemaval
- value to addIllegalArgumentException
- if the value doesn't match the column's typeIllegalStateException
- if the row was already appliedIndexOutOfBoundsException
- if the column doesn't existpublic void addLong(String columnName, long val)
columnName
- Name of the columnval
- value to addIllegalArgumentException
- if the column doesn't exist
or if the value doesn't match the column's typeIllegalStateException
- if the row was already appliedpublic long getLong(String columnName)
columnName
- name of the column to get data forIllegalArgumentException
- if the column doesn't exist,
is null, is unset, or the type doesn't match the column's typepublic long getLong(int columnIndex)
columnIndex
- Column index in the schemaIllegalArgumentException
- if the column is null, is unset,
or if the type doesn't match the column's typeIndexOutOfBoundsException
- if the column doesn't existpublic void addFloat(int columnIndex, float val)
columnIndex
- the column's index in the schemaval
- value to addIllegalArgumentException
- if the value doesn't match the column's typeIllegalStateException
- if the row was already appliedIndexOutOfBoundsException
- if the column doesn't existpublic void addFloat(String columnName, float val)
columnName
- Name of the columnval
- value to addIllegalArgumentException
- if the column doesn't exist
or if the value doesn't match the column's typeIllegalStateException
- if the row was already appliedpublic float getFloat(String columnName)
columnName
- name of the column to get data forIllegalArgumentException
- if the column doesn't exist,
is null, is unset, or the type doesn't match the column's typepublic float getFloat(int columnIndex)
columnIndex
- Column index in the schemaIllegalArgumentException
- if the column is null, is unset,
or if the type doesn't match the column's typeIndexOutOfBoundsException
- if the column doesn't existpublic void addDouble(int columnIndex, double val)
columnIndex
- the column's index in the schemaval
- value to addIllegalArgumentException
- if the value doesn't match the column's typeIllegalStateException
- if the row was already appliedIndexOutOfBoundsException
- if the column doesn't existpublic void addDouble(String columnName, double val)
columnName
- Name of the columnval
- value to addIllegalArgumentException
- if the column doesn't exist
or if the value doesn't match the column's typeIllegalStateException
- if the row was already appliedpublic double getDouble(String columnName)
columnName
- name of the column to get data forIllegalArgumentException
- if the column doesn't exist,
is null, is unset, or the type doesn't match the column's typepublic double getDouble(int columnIndex)
columnIndex
- Column index in the schemaIllegalArgumentException
- if the column is null, is unset,
or if the type doesn't match the column's typeIndexOutOfBoundsException
- if the column doesn't existpublic void addDecimal(int columnIndex, BigDecimal val)
columnIndex
- the column's index in the schemaval
- value to addIllegalArgumentException
- if the value doesn't match the column's typeIllegalStateException
- if the row was already appliedIndexOutOfBoundsException
- if the column doesn't existpublic void addDecimal(String columnName, BigDecimal val)
columnName
- Name of the columnval
- value to addIllegalArgumentException
- if the column doesn't exist
or if the value doesn't match the column's typeIllegalStateException
- if the row was already appliedpublic BigDecimal getDecimal(String columnName)
columnName
- name of the column to get data forIllegalArgumentException
- if the column doesn't exist,
is null, is unset, or the type doesn't match the column's typepublic BigDecimal getDecimal(int columnIndex)
columnIndex
- Column index in the schemaIllegalArgumentException
- if the column is null, is unset,
or if the type doesn't match the column's typeIndexOutOfBoundsException
- if the column doesn't existpublic void addTimestamp(int columnIndex, Timestamp val)
columnIndex
- the column's index in the schemaval
- value to addIllegalArgumentException
- if the value doesn't match the column's typeIllegalStateException
- if the row was already appliedIndexOutOfBoundsException
- if the column doesn't existpublic void addTimestamp(String columnName, Timestamp val)
columnName
- Name of the columnval
- value to addIllegalArgumentException
- if the column doesn't exist
or if the value doesn't match the column's typeIllegalStateException
- if the row was already appliedpublic Timestamp getTimestamp(String columnName)
columnName
- name of the column to get data forIllegalArgumentException
- if the column doesn't exist,
is null, is unset, or the type doesn't match the column's typepublic Timestamp getTimestamp(int columnIndex)
columnIndex
- Column index in the schemaIllegalArgumentException
- if the column is null, is unset,
or if the type doesn't match the column's typeIndexOutOfBoundsException
- if the column doesn't existpublic void addString(int columnIndex, String val)
columnIndex
- the column's index in the schemaval
- value to addIllegalArgumentException
- if the value doesn't match the column's typeIllegalStateException
- if the row was already appliedIndexOutOfBoundsException
- if the column doesn't existpublic void addString(String columnName, String val)
columnName
- Name of the columnval
- value to addIllegalArgumentException
- if the column doesn't exist
or if the value doesn't match the column's typeIllegalStateException
- if the row was already appliedpublic String getString(String columnName)
columnName
- name of the column to get data forIllegalArgumentException
- if the column doesn't exist,
is null, is unset, or the type doesn't match the column's typepublic String getString(int columnIndex)
columnIndex
- Column index in the schemaIllegalArgumentException
- if the column is null, is unset,
or if the type doesn't match the column's typeIndexOutOfBoundsException
- if the column doesn't existpublic void addStringUtf8(int columnIndex, byte[] val)
columnIndex
- the column's index in the schemaval
- value to addIllegalArgumentException
- if the value doesn't match the column's typeIllegalStateException
- if the row was already appliedIndexOutOfBoundsException
- if the column doesn't existpublic void addStringUtf8(String columnName, byte[] val)
columnName
- Name of the columnval
- value to addIllegalArgumentException
- if the column doesn't exist
or if the value doesn't match the column's typeIllegalStateException
- if the row was already appliedpublic void addBinary(int columnIndex, byte[] val)
columnIndex
- the column's index in the schemaval
- value to addIllegalArgumentException
- if the value doesn't match the column's typeIllegalStateException
- if the row was already appliedIndexOutOfBoundsException
- if the column doesn't existpublic void addBinary(int columnIndex, ByteBuffer value)
columnIndex
- the column's index in the schemavalue
- byte buffer to get the value fromIllegalArgumentException
- if the value doesn't match the column's typeIllegalStateException
- if the row was already appliedIndexOutOfBoundsException
- if the column doesn't existpublic void addBinary(String columnName, byte[] val)
columnName
- Name of the columnval
- value to addIllegalArgumentException
- if the column doesn't exist
or if the value doesn't match the column's typeIllegalStateException
- if the row was already appliedpublic void addBinary(String columnName, ByteBuffer value)
columnName
- Name of the columnvalue
- byte buffer to get the value fromIllegalArgumentException
- if the column doesn't exist
or if the value doesn't match the column's typeIllegalStateException
- if the row was already appliedpublic byte[] getBinaryCopy(String columnName)
columnName
- name of the column to get data forIllegalArgumentException
- if the column doesn't exist,
is null, is unset, or the type doesn't match the column's typepublic byte[] getBinaryCopy(int columnIndex)
columnIndex
- Column index in the schemaIllegalArgumentException
- if the column is null, is unset,
or if the type doesn't match the column's typeIndexOutOfBoundsException
- if the column doesn't existpublic ByteBuffer getBinary(String columnName)
columnName
- name of the column to get data forIllegalArgumentException
- if the column doesn't exist,
is null, is unset, or the type doesn't match the column's typepublic ByteBuffer getBinary(int columnIndex)
columnIndex
- Column index in the schemaIllegalArgumentException
- if the column is null, is unset,
or if the type doesn't match the column's typeIndexOutOfBoundsException
- if the column doesn't existpublic void setNull(int columnIndex)
columnIndex
- the column's index in the schemaIllegalArgumentException
- if the column doesn't exist or cannot be set to nullIllegalStateException
- if the row was already appliedpublic void setNull(String columnName)
columnName
- Name of the columnIllegalArgumentException
- if the column doesn't exist or cannot be set to nullIllegalStateException
- if the row was already appliedpublic boolean isNull(String columnName)
columnName
- name of the column in the schemaIllegalArgumentException
- if the column doesn't existpublic boolean isNull(int columnIndex)
columnIndex
- Column index in the schemaIndexOutOfBoundsException
- if the column doesn't existpublic boolean isSet(String columnName)
columnName
- name of the column in the schemaIllegalArgumentException
- if the column doesn't existpublic boolean isSet(int columnIndex)
columnIndex
- Column index in the schemaIndexOutOfBoundsException
- if the column doesn't existpublic byte[] encodePrimaryKey()
public String stringifyRowKey()
Copyright © 2018 The Apache Software Foundation. All rights reserved.