Class VoltTableRow
- Direct Known Subclasses:
VoltTable
Represents the interface to a row in a VoltTable result set.
Accessing Row Fields
Row fields are acessed via methods of the form
get
<Type>(
col_index|
col_name)
.
Note: it is more performant to access rows by column index than by column name.
Advancing and Iterating through a Table
VoltTableRow represents both a row in a table and an iterator for all the
rows in the table. For a given table, each VoltTableRow instance has a position
value which represents the index represented in the table. To increment the
position, call advanceRow()
. To reset the position, call
resetRowPosition()
, which moves the position before the first row.
Note that before you can access fields after a call to resetRowPosition,
advanceRow must be called to move to the first row.
Example
VoltTableRow row = table.fetchRow(5);
System.out.println(row.getString("foo");
row.resetRowPosition();
while (row.advanceRow()) {
System.out.println(row.getLong(7));
}
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
Size in bytes of the maximum length for a VoltDB tuple.static final String
String representation ofMAX_TUPLE_LENGTH
. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Makes the next row active so calls to getXXX() will return values from the current record.boolean
advanceToRow
(int rowIndex) Advance to a specific row so calls to getXXX() will return values from the current record.abstract VoltTableRow
cloneRow()
Clone a row.final Object
get
(int columnIndex) Retrieve the column of the current row atcolumnIndex
.final Object
Retrieve a value from the row by specifying the column index and thetype
.final Object
Retrieve a value from the row by specifying the column name and thetype
.int
Get the position in the table of this row instance, starting at zero for the first row.abstract int
Returns the number of columns in the table schemaabstract int
getColumnIndex
(String columnName) Return the index of the column with the specified column name.abstract VoltType
getColumnType
(int columnIndex) Return thetype
of the column with the specified index.final BigDecimal
getDecimalAsBigDecimal
(int columnIndex) Retrieve theBigDecimal
value stored in the column specified by the index.getDecimalAsBigDecimal
(String columnName) Retrieve theBigDecimal
value stored in the column specified by columnName.final double
getDouble
(int columnIndex) Retrieve thedouble
value stored in the column specified by index.final double
Retrieve thedouble
value stored in the column specified by name.final GeographyPointValue
getGeographyPointValue
(int columnIndex) Retrieve the GeographyPointValue value stored in the column specified by index.final GeographyPointValue
getGeographyPointValue
(String columnName) Retrieve the GeographyPointValue value stored in the column specified by name.final GeographyValue
getGeographyValue
(int columnIndex) Retrieve the GeographyValue value stored in the column specified by index.final GeographyValue
getGeographyValue
(String columnName) Retrieve the GeographyValue value stored in the column specified by name.final long
getLong
(int columnIndex) Retrieve thelong
value stored in the column specified by index.final long
Retrieve thelong
value stored in the column specified by name.final int
getOffset
(int index) final ByteBuffer
getRow()
final Object[]
Retrieve the current row as an array of Objects.final String
getString
(int columnIndex) Retrieve theString
value stored in the column specified by index.final String
Retrieve theString
value stored in the column specified by name.final byte[]
getStringAsBytes
(int columnIndex) Retrieve thestring
value stored in the column specified by index as an array of bytes.final byte[]
getStringAsBytes
(String columnName) Retrieve thestring
value stored in the column specified by name as an array of bytes.final long
getTimestampAsLong
(int columnIndex) Retrieve thelong
timestamp stored in the column specified by index.final long
getTimestampAsLong
(String columnName) Retrieve thelong
timestamp value stored in the column specified by name.final Timestamp
getTimestampAsSqlTimestamp
(int columnIndex) Retrieve thejava.sql.Timestamp
equivalent to the value stored in the column specified by index.getTimestampAsSqlTimestamp
(String columnName) Retrieve thejava.sql.Timestamp
equivalent to the value stored in the column specified by name.final TimestampType
getTimestampAsTimestamp
(int columnIndex) Retrieve theTimestampType
value stored in the column specified by index.final TimestampType
getTimestampAsTimestamp
(String columnName) Retrieve theTimestampType
value stored in the column specified by name.final byte[]
getVarbinary
(int columnIndex) Retrieve the varbinary value stored in the column specified by index.final byte[]
getVarbinary
(String columnName) Retrieve the varbinary value stored in the column specified by name.final int
getVarbinaryLen
(int columnIndex) Retrieve the length of the varbinary value stored in the column specified by index.void
Sets the active position indicator so that the next call toadvanceRow()
will make the first record active.final boolean
wasNull()
Returns whether last retrieved value wasnull
.
-
Field Details
-
MAX_TUPLE_LENGTH
public static final int MAX_TUPLE_LENGTHSize in bytes of the maximum length for a VoltDB tuple. This is inclusive of the 4-byte row length prefix. 2 megs to allow a max size string/varbinary + length prefix + some other stuff- See Also:
-
MAX_TUPLE_LENGTH_STR
String representation ofMAX_TUPLE_LENGTH
.
-
-
Method Details
-
getColumnType
Return thetype
of the column with the specified index.- Parameters:
columnIndex
- Index of the column- Returns:
VoltType
of the column
-
getColumnIndex
Return the index of the column with the specified column name.- Parameters:
columnName
- Name of the column- Returns:
- Index of the column
-
getColumnCount
public abstract int getColumnCount()Returns the number of columns in the table schema- Returns:
- Number of columns in the table schema
-
cloneRow
Clone a row. The new instance returned will have an independent position from the original instance.- Returns:
- A deep copy of the current
VoltTableRow
instance.
-
getOffset
public final int getOffset(int index) -
resetRowPosition
public void resetRowPosition()Sets the active position indicator so that the next call toadvanceRow()
will make the first record active. This never needs to be called if the table is only going to be scanned once. After this callgetActiveRowIndex()
will return -1 untiladvanceRow()
is called. -
getActiveRowIndex
public int getActiveRowIndex()Get the position in the table of this row instance, starting at zero for the first row.- Returns:
- The index of the active row or -1 if none.
-
advanceRow
public boolean advanceRow()Makes the next row active so calls to getXXX() will return values from the current record. At initialization time, the active row index is -1, which is invalid. If advanced past the end of the resultset,resetRowPosition()
must be called to re-iterate through the rows.- Returns:
- True if a valid row became active. False otherwise.
-
advanceToRow
public boolean advanceToRow(int rowIndex) Advance to a specific row so calls to getXXX() will return values from the current record. At initialization time, the active row index is -1, which is invalid. If advanced past the end of the resultset,resetRowPosition()
must be called to re-iterate through the rows.- Parameters:
rowIndex
- The row to jump to.- Returns:
- True if a valid row became active. False otherwise.
-
get
Retrieve a value from the row by specifying the column index and thetype
. This method is slower then linking directly against the type specific getter. Prefer the type specific getter methods where viable. Looking at the return value is not a reliable way to check if the value isnull
. UsewasNull()
instead. -
get
Retrieve a value from the row by specifying the column name and thetype
. This method is slower then linking directly against the type specific getter. Prefer the type specific getter methods where viable. Looking at the return value is not a reliable way to check if the value isnull
. UsewasNull()
instead. -
getRowObjects
Retrieve the current row as an array of Objects. When this method is usedwasNull()
will not return a valid result since more than one value is being accessed.- Returns:
- The current row as an array of objects
- Throws:
RuntimeException
- if the current row is not valid
-
get
Retrieve the column of the current row atcolumnIndex
. If the value isnull
thennull
will be returned andwasNull()
will returntrue
- Parameters:
columnIndex
- Index of the column- Returns:
- The value or
null
if the value is not set. - Throws:
RuntimeException
- if the current row is not valid
-
getLong
public final long getLong(int columnIndex) Retrieve thelong
value stored in the column specified by index. Looking at the return value is not a reliable way to check if the value isnull
. UsewasNull()
instead.- Parameters:
columnIndex
- Index of the column- Returns:
long
value stored in the specified column- See Also:
-
getLong
Retrieve thelong
value stored in the column specified by name. Avoid retrieving via this method as it is slower than specifying the column by index. UsegetLong(int)
instead. Looking at the return value is not a reliable way to check if the value isnull
. UsewasNull()
instead.- Parameters:
columnName
- Name of the column- Returns:
long
value stored in the specified column- See Also:
-
wasNull
public final boolean wasNull()Returns whether last retrieved value wasnull
. Some special values that are NOT Java's NULL representsnull
the SQL notion ofnull
in our system.- Returns:
true
if the value wasnull
, false otherwise.
-
getRawRow
- Returns:
- A slice of the underlying buffer containing the raw data of a row in a format that can be blindly copied into a VoltDB with sufficient space and the exact same schema.
-
getDouble
public final double getDouble(int columnIndex) Retrieve thedouble
value stored in the column specified by index. Looking at the return value is not a reliable way to check if the value isnull
. UsewasNull()
instead.- Parameters:
columnIndex
- Index of the column- Returns:
double
value stored in the specified column- See Also:
-
getDouble
Retrieve thedouble
value stored in the column specified by name. Avoid retrieving via this method as it is slower than specifying the column by index. UsegetDouble(int)
instead. Looking at the return value is not a reliable way to check if the value isnull
. UsewasNull()
instead.- Parameters:
columnName
- Name of the column- Returns:
double
value stored in the specified column- See Also:
-
getString
Retrieve theString
value stored in the column specified by index. Looking at the return value is not a reliable way to check if the value isnull
. UsewasNull()
instead. If at all possible you should usegetStringAsBytes(int)
instead and avoid the overhead of constructing theString
object. -
getString
Retrieve theString
value stored in the column specified by name. Avoid retrieving via this method as it is slower than specifying the column by index. UsegetString(int)
instead. Looking at the return value is not a reliable way to check if the value isnull
. UsewasNull()
instead. If at all possible you should usegetStringAsBytes(int)
instead and avoid the overhead of constructing theString
object.- Parameters:
columnName
- Name of the column- Returns:
String
value stored in the specified column- See Also:
-
getStringAsBytes
public final byte[] getStringAsBytes(int columnIndex) Retrieve thestring
value stored in the column specified by index as an array of bytes. Assume UTF-8 encoding for all string values in VoltDB. Looking at the return value is not a reliable way to check if the value isnull
. UsewasNull()
instead.- Parameters:
columnIndex
- Index of the column- Returns:
string
value stored in the specified column as abyte[]
- See Also:
-
getStringAsBytes
Retrieve thestring
value stored in the column specified by name as an array of bytes. Assume UTF-8 encoding for all string values in VoltDB.Avoid retrieving via this method as it is slower than specifying the column by index. UsegetStringAsBytes(int)
instead. Looking at the return value is not a reliable way to check if the value isnull
. UsewasNull()
instead.- Parameters:
columnName
- Name of the column- Returns:
string
value stored in the specified column as abyte[]
- See Also:
-
getVarbinary
public final byte[] getVarbinary(int columnIndex) Retrieve the varbinary value stored in the column specified by index. Looking at the return value is not a reliable way to check if the value isnull
. UsewasNull()
instead.- Parameters:
columnIndex
- Index of the column- Returns:
- Varbinary value stored in the specified column
- See Also:
-
getVarbinaryLen
public final int getVarbinaryLen(int columnIndex) Retrieve the length of the varbinary value stored in the column specified by index.- Parameters:
columnIndex
- Index of the column- Returns:
- Length of the varbinary value stored in the specified column or
-1
if the value isnull
-
getVarbinary
Retrieve the varbinary value stored in the column specified by name. Avoid retrieving via this method as it is slower than specifying the column by index. UsegetVarbinary(int)
instead. Looking at the return value is not a reliable way to check if the value isnull
. UsewasNull()
instead.- Parameters:
columnName
- Name of the column- Returns:
- Varbinary value stored in the specified column
- See Also:
-
getGeographyPointValue
Retrieve the GeographyPointValue value stored in the column specified by index. Looking at the return value is not a reliable way to check if the value isnull
. UsewasNull()
instead.- Parameters:
columnIndex
- Index of the column- Returns:
- GeographyPointValue value stored in the specified column
- See Also:
-
getGeographyPointValue
Retrieve the GeographyPointValue value stored in the column specified by name. Avoid retrieving via this method as it is slower than specifying the column by index. UsegetGeographyPointValue(int)
instead. Looking at the return value is not a reliable way to check if the value isnull
. UsewasNull()
instead.- Parameters:
columnName
- Name of the column- Returns:
- GeographyPointValue value stored in the specified column
- See Also:
-
getGeographyValue
Retrieve the GeographyValue value stored in the column specified by index. Looking at the return value is not a reliable way to check if the value isnull
. UsewasNull()
instead.- Parameters:
columnIndex
- Index of the column- Returns:
- GeographyValue value stored in the specified column
- See Also:
-
getGeographyValue
Retrieve the GeographyValue value stored in the column specified by name. Avoid retrieving via this method as it is slower than specifying the column by index. UsegetGeographyValue(int)
instead. Looking at the return value is not a reliable way to check if the value isnull
. UsewasNull()
instead.- Parameters:
columnName
- Name of the column- Returns:
- GeographyValue value stored in the specified column
- See Also:
-
getTimestampAsLong
public final long getTimestampAsLong(int columnIndex) Retrieve thelong
timestamp stored in the column specified by index. Note that VoltDB uses GMT universally within its process space. Date objects sent over the wire from clients may seem to be different times because of this, but it is just a time zone offset. Timestamps represent microseconds from epoch.- Parameters:
columnIndex
- Index of the column- Returns:
long
timestamp value stored in the specified column- See Also:
-
getTimestampAsLong
Retrieve thelong
timestamp value stored in the column specified by name. Note that VoltDB uses GMT universally within its process space. Date objects sent over the wire from clients may seem to be different times because of this, but it is just a time zone offset. Avoid retrieving via this method as it is slower than specifying the column by index. UsegetTimestampAsLong(int)
instead.- Parameters:
columnName
- Name of the column- Returns:
long
timestamp value stored in the specified column- See Also:
-
getTimestampAsTimestamp
Retrieve theTimestampType
value stored in the column specified by index. Note that VoltDB uses GMT universally within its process space. Date objects sent over the wire from clients may seem to be different times because of this, but it is just a time zone offset.- Parameters:
columnIndex
- Index of the column- Returns:
TimestampType
value stored in the specified column- See Also:
-
getTimestampAsTimestamp
Retrieve theTimestampType
value stored in the column specified by name. Note that VoltDB uses GMT universally within its process space. Date objects sent over the wire from clients may seem to be different times because of this, but it is just a time zone offset. Avoid retrieving via this method as it is slower than specifying the column by index. UsegetTimestampAsTimestamp(int)
instead.- Parameters:
columnName
- Name of the column- Returns:
TimestampType
value stored in the specified column- See Also:
-
getTimestampAsSqlTimestamp
Retrieve thejava.sql.Timestamp
equivalent to the value stored in the column specified by index. Note that VoltDB uses GMT universally within its process space. Date objects sent over the wire from clients may seem to be different times because of this, but it is just a time zone offset. VoltDB Timestamps are stored as long integer microseconds from epoch. The resulting value is accurate to no finer than microsecond granularity.- Parameters:
columnIndex
- Index of the column- Returns:
- the
java.sql.Timestamp
equivalent to the value stored in the specified column
-
getTimestampAsSqlTimestamp
Retrieve thejava.sql.Timestamp
equivalent to the value stored in the column specified by name. Note that VoltDB uses GMT universally within its process space. Date objects sent over the wire from clients may seem to be different times because of this, but it is just a time zone offset. VoltDB Timestamps are stored as long integer microseconds from epoch. The resulting value is accurate to no finer than microsecond granularity. Avoid retrieving via this method as it is slower than specifying the column by index. UsegetTimestampAsSqlTimestamp(int)
instead.- Parameters:
columnName
- name of the column- Returns:
- the
java.sql.Timestamp
equivalent to the value stored in the specified column
-
getDecimalAsBigDecimal
Retrieve the
BigDecimal
value stored in the column specified by the index. All DECIMAL types have a fixed scale when represented as BigDecimals.- Parameters:
columnIndex
- Index of the column- Returns:
- BigDecimal representation.
- See Also:
-
getDecimalAsBigDecimal
Retrieve theBigDecimal
value stored in the column specified by columnName. All DECIMAL types have a fixed scale when represented as BigDecimals.- Parameters:
columnName
- Name of the column- Returns:
- BigDecimal representation.
- See Also:
-
getRow
-