public abstract class VoltTableRow
extends java.lang.Object
Represents the interface to a row in a VoltTable result set.
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.
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.
VoltTableRow row = table.fetchRow(5);
System.out.println(row.getString("foo");
row.resetRowPosition();
while (row.advanceRow()) {
System.out.println(row.getLong(7));
}
Modifier and Type | Field and Description |
---|---|
static int |
MAX_TUPLE_LENGTH
Size in bytes of the maximum length for a VoltDB tuple.
|
static java.lang.String |
MAX_TUPLE_LENGTH_STR
String representation of
MAX_TUPLE_LENGTH . |
Modifier and Type | Method and Description |
---|---|
boolean |
advanceRow()
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.
|
java.lang.Object |
get(int columnIndex)
Retrieve the column of the current row at
columnIndex . |
java.lang.Object |
get(int columnIndex,
VoltType type)
Retrieve a value from the row by specifying the column index and the
type . |
java.lang.Object |
get(java.lang.String columnName,
VoltType type)
Retrieve a value from the row by specifying the column name and the
type . |
int |
getActiveRowIndex()
Get the position in the table of this row instance, starting
at zero for the first row.
|
abstract int |
getColumnCount()
Returns the number of columns in the table schema
|
abstract int |
getColumnIndex(java.lang.String columnName)
Return the index of the column with the specified column name.
|
abstract VoltType |
getColumnType(int columnIndex)
Return the
type of the column with the specified index. |
java.math.BigDecimal |
getDecimalAsBigDecimal(int columnIndex)
Retrieve the
BigDecimal value stored in the column
specified by the index. |
java.math.BigDecimal |
getDecimalAsBigDecimal(java.lang.String columnName)
Retrieve the
BigDecimal value stored in the column
specified by columnName. |
double |
getDouble(int columnIndex)
Retrieve the double value stored in the column specified by index.
|
double |
getDouble(java.lang.String columnName)
Retrieve the double value stored in the column
specified by name.
|
GeographyPointValue |
getGeographyPointValue(int columnIndex)
Retrieve the GeographyPointValue value stored in the column specified by index.
|
GeographyPointValue |
getGeographyPointValue(java.lang.String columnName)
Retrieve the GeographyPointValue value stored in the column specified by name.
|
GeographyValue |
getGeographyValue(int columnIndex)
Retrieve the GeographyValue value stored in the column specified by index.
|
GeographyValue |
getGeographyValue(java.lang.String columnName)
Retrieve the GeographyValue value stored in the column specified by name.
|
long |
getLong(int columnIndex)
Retrieve the long value stored in the column specified by index.
|
long |
getLong(java.lang.String columnName)
Retrieve the long value stored in the column
specified by name.
|
int |
getOffset(int index) |
java.nio.ByteBuffer |
getRawRow() |
java.lang.String |
getRow() |
java.lang.Object[] |
getRowObjects()
Retrieve the current row as an array of Objects.
|
java.lang.String |
getString(int columnIndex)
Retrieve the
String value stored in the column specified by index. |
java.lang.String |
getString(java.lang.String columnName)
Retrieve the
String value stored in the column
specified by name. |
byte[] |
getStringAsBytes(int columnIndex)
Retrieve the string value stored in the column specified by index as
an array of bytes.
|
byte[] |
getStringAsBytes(java.lang.String columnName)
Retrieve the string value stored in the column
specified by name as an array of bytes.
|
long |
getTimestampAsLong(int columnIndex)
Retrieve the long timestamp stored in the column specified by index.
|
long |
getTimestampAsLong(java.lang.String columnName)
Retrieve the long timestamp value stored in the column
specified by name.
|
java.sql.Timestamp |
getTimestampAsSqlTimestamp(int columnIndex)
Retrieve the java.sql.Timestamp equivalent to the value stored in the column specified by index.
|
java.sql.Timestamp |
getTimestampAsSqlTimestamp(java.lang.String columnName)
Retrieve the java.sql.Timestamp equivalent to the value stored in the column specified by name.
|
TimestampType |
getTimestampAsTimestamp(int columnIndex)
Retrieve the
TimestampType
value stored in the column specified by index. |
TimestampType |
getTimestampAsTimestamp(java.lang.String columnName)
Retrieve the
TimestampType value stored in the column
specified by name. |
byte[] |
getVarbinary(int columnIndex)
Retrieve the varbinary value stored in the column specified by index.
|
byte[] |
getVarbinary(java.lang.String columnName)
Retrieve the varbinary value stored in the column
specified by name.
|
int |
getVarbinaryLen(int columnIndex)
Retrieve the length of the varbinary value stored in the column specified by index.
|
void |
resetRowPosition()
Sets the active position indicator so that the next call
to
advanceRow() will make the first record active. |
boolean |
wasNull()
Returns whether last retrieved value was null.
|
public static final int MAX_TUPLE_LENGTH
public static final java.lang.String MAX_TUPLE_LENGTH_STR
MAX_TUPLE_LENGTH
.public abstract VoltType getColumnType(int columnIndex)
type
of the column with the specified index.columnIndex
- Index of the columnVoltType
of the columnpublic abstract int getColumnIndex(java.lang.String columnName)
columnName
- Name of the columnpublic abstract int getColumnCount()
public abstract VoltTableRow cloneRow()
public final int getOffset(int index)
public void resetRowPosition()
advanceRow()
will make the first record active.
This never needs to be called if the table is only going to
be scanned once. After this call getActiveRowIndex()
will return -1 until advanceRow()
is called.public int getActiveRowIndex()
public boolean advanceRow()
resetRowPosition()
must be
called to re-iterate through the rows.public boolean advanceToRow(int rowIndex)
resetRowPosition()
must be called to re-iterate through the
rows.rowIndex
- The row to jump to.public final java.lang.Object get(int columnIndex, VoltType type)
type
.
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 is null. Use wasNull()
instead.public final java.lang.Object get(java.lang.String columnName, VoltType type)
type
. 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 is null. Use wasNull()
instead.public final java.lang.Object[] getRowObjects()
wasNull()
will not return a
valid result since more than one value is being accessed.java.lang.RuntimeException
- if the current row is not validpublic final java.lang.Object get(int columnIndex)
columnIndex
. If the value is null
then null
will be returned and wasNull()
will return true
columnIndex
- Index of the columnnull
if the value is not set.java.lang.RuntimeException
- if the current row is not validpublic final long getLong(int columnIndex)
wasNull()
instead.columnIndex
- Index of the columnwasNull()
public final long getLong(java.lang.String columnName)
getLong(int)
instead.
Looking at the return value is not a reliable way to check if the value
is null. Use wasNull()
instead.columnName
- Name of the columnwasNull()
,
getLong(int)
public final boolean wasNull()
public final java.nio.ByteBuffer getRawRow()
public final double getDouble(int columnIndex)
wasNull()
instead.columnIndex
- Index of the columnwasNull()
public final double getDouble(java.lang.String columnName)
getDouble(int)
instead.
Looking at the return value is not a reliable way to check if the value
is null. Use wasNull()
instead.columnName
- Name of the columnwasNull()
,
getDouble(int)
public final java.lang.String getString(int columnIndex)
String
value stored in the column specified by index.
Looking at the return value is not a reliable way to check if the value
is null. Use wasNull()
instead. If at all possible you should use getStringAsBytes(int)
instead
and avoid the overhead of constructing the String
object.columnIndex
- Index of the columnString
value stored in the specified columnwasNull()
public final java.lang.String getString(java.lang.String columnName)
String
value stored in the column
specified by name. Avoid retrieving via this method as it is slower than specifying the
column by index. Use getString(int)
instead.
Looking at the return value is not a reliable way to check if the value
is null. Use wasNull()
instead. If at all possible you should use getStringAsBytes(int)
instead
and avoid the overhead of constructing the String
object.columnName
- Name of the columnString
value stored in the specified columnwasNull()
,
getString(int)
public final byte[] getStringAsBytes(int columnIndex)
wasNull()
instead.columnIndex
- Index of the columnwasNull()
public final byte[] getStringAsBytes(java.lang.String columnName)
getStringAsBytes(int)
instead.
Looking at the return value is not a reliable way to check if the value
is null. Use wasNull()
instead.columnName
- Name of the columnwasNull()
,
getStringAsBytes(int)
public final byte[] getVarbinary(int columnIndex)
wasNull()
instead.columnIndex
- Index of the columnwasNull()
public final int getVarbinaryLen(int columnIndex)
columnIndex
- Index of the column-1
if the value is null
public final byte[] getVarbinary(java.lang.String columnName)
getVarbinary(int)
instead.
Looking at the return value is not a reliable way to check if the value
is null. Use wasNull()
instead.columnName
- Name of the columnwasNull()
,
getVarbinary(int)
public final GeographyPointValue getGeographyPointValue(int columnIndex)
wasNull()
instead.columnIndex
- Index of the columnwasNull()
public final GeographyPointValue getGeographyPointValue(java.lang.String columnName)
getGeographyPointValue(int)
instead.
Looking at the return value is not a reliable way to check if the value
is null. Use wasNull()
instead.columnName
- Name of the columnwasNull()
,
getGeographyPointValue(int)
public final GeographyValue getGeographyValue(int columnIndex)
wasNull()
instead.columnIndex
- Index of the columnwasNull()
public final GeographyValue getGeographyValue(java.lang.String columnName)
getGeographyValue(int)
instead.
Looking at the return value is not a reliable way to check if the value
is null. Use wasNull()
instead.columnName
- Name of the columnwasNull()
,
getGeographyPointValue(int)
public final long getTimestampAsLong(int columnIndex)
columnIndex
- Index of the columnwasNull()
,
getTimestampAsTimestamp(int)
public final long getTimestampAsLong(java.lang.String columnName)
getTimestampAsLong(int)
instead.columnName
- Name of the columnwasNull()
,
getTimestampAsLong(int)
,
getTimestampAsTimestamp(String)
public final TimestampType getTimestampAsTimestamp(int columnIndex)
TimestampType
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.columnIndex
- Index of the columnTimestampType
value stored in the specified columnwasNull()
public final TimestampType getTimestampAsTimestamp(java.lang.String columnName)
TimestampType
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. Use getTimestampAsTimestamp(int)
instead.columnName
- Name of the columnTimestampType
value stored in the specified columnwasNull()
,
getTimestampAsTimestamp(int)
public final java.sql.Timestamp getTimestampAsSqlTimestamp(int columnIndex)
columnIndex
- Index of the columnpublic java.sql.Timestamp getTimestampAsSqlTimestamp(java.lang.String columnName)
getTimestampAsSqlTimestamp(int)
instead.columnName
- name of the columnpublic final java.math.BigDecimal getDecimalAsBigDecimal(int columnIndex)
Retrieve the BigDecimal
value stored in the column
specified by the index. All DECIMAL types have a fixed
scale when represented as BigDecimals.
columnIndex
- Index of the columnwasNull()
public java.math.BigDecimal getDecimalAsBigDecimal(java.lang.String columnName)
BigDecimal
value stored in the column
specified by columnName. All DECIMAL types have a
fixed scale when represented as BigDecimals.columnName
- Name of the columnwasNull()
,
getDecimalAsBigDecimal(int)
public java.lang.String getRow()