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
FieldsModifier and TypeFieldDescriptionstatic final intSize in bytes of the maximum length for a VoltDB tuple.static final StringString representation ofMAX_TUPLE_LENGTH. -
Method Summary
Modifier and TypeMethodDescriptionbooleanMakes the next row active so calls to getXXX() will return values from the current record.booleanadvanceToRow(int rowIndex) Advance to a specific row so calls to getXXX() will return values from the current record.abstract VoltTableRowcloneRow()Clone a row.final Objectget(int columnIndex) Retrieve the column of the current row atcolumnIndex.final ObjectRetrieve a value from the row by specifying the column index and thetype.final ObjectRetrieve a value from the row by specifying the column name and thetype.intGet the position in the table of this row instance, starting at zero for the first row.abstract intReturns the number of columns in the table schemaabstract intgetColumnIndex(String columnName) Return the index of the column with the specified column name.abstract VoltTypegetColumnType(int columnIndex) Return thetypeof the column with the specified index.final BigDecimalgetDecimalAsBigDecimal(int columnIndex) Retrieve theBigDecimalvalue stored in the column specified by the index.getDecimalAsBigDecimal(String columnName) Retrieve theBigDecimalvalue stored in the column specified by columnName.final doublegetDouble(int columnIndex) Retrieve thedoublevalue stored in the column specified by index.final doubleRetrieve thedoublevalue stored in the column specified by name.final GeographyPointValuegetGeographyPointValue(int columnIndex) Retrieve the GeographyPointValue value stored in the column specified by index.final GeographyPointValuegetGeographyPointValue(String columnName) Retrieve the GeographyPointValue value stored in the column specified by name.final GeographyValuegetGeographyValue(int columnIndex) Retrieve the GeographyValue value stored in the column specified by index.final GeographyValuegetGeographyValue(String columnName) Retrieve the GeographyValue value stored in the column specified by name.final longgetLong(int columnIndex) Retrieve thelongvalue stored in the column specified by index.final longRetrieve thelongvalue stored in the column specified by name.final intgetOffset(int index) final ByteBuffergetRow()final Object[]Retrieve the current row as an array of Objects.final StringgetString(int columnIndex) Retrieve theStringvalue stored in the column specified by index.final StringRetrieve theStringvalue stored in the column specified by name.final byte[]getStringAsBytes(int columnIndex) Retrieve thestringvalue stored in the column specified by index as an array of bytes.final byte[]getStringAsBytes(String columnName) Retrieve thestringvalue stored in the column specified by name as an array of bytes.final longgetTimestampAsLong(int columnIndex) Retrieve thelongtimestamp stored in the column specified by index.final longgetTimestampAsLong(String columnName) Retrieve thelongtimestamp value stored in the column specified by name.final TimestampgetTimestampAsSqlTimestamp(int columnIndex) Retrieve thejava.sql.Timestampequivalent to the value stored in the column specified by index.getTimestampAsSqlTimestamp(String columnName) Retrieve thejava.sql.Timestampequivalent to the value stored in the column specified by name.final TimestampTypegetTimestampAsTimestamp(int columnIndex) Retrieve theTimestampTypevalue stored in the column specified by index.final TimestampTypegetTimestampAsTimestamp(String columnName) Retrieve theTimestampTypevalue 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 intgetVarbinaryLen(int columnIndex) Retrieve the length of the varbinary value stored in the column specified by index.voidSets the active position indicator so that the next call toadvanceRow()will make the first record active.final booleanwasNull()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 thetypeof the column with the specified index.- Parameters:
columnIndex- Index of the column- Returns:
VoltTypeof 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
VoltTableRowinstance.
-
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 isnullthennullwill be returned andwasNull()will returntrue- Parameters:
columnIndex- Index of the column- Returns:
- The value or
nullif the value is not set. - Throws:
RuntimeException- if the current row is not valid
-
getLong
public final long getLong(int columnIndex) Retrieve thelongvalue 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:
longvalue stored in the specified column- See Also:
-
getLong
Retrieve thelongvalue 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:
longvalue 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 representsnullthe SQL notion ofnullin our system.- Returns:
trueif 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 thedoublevalue 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:
doublevalue stored in the specified column- See Also:
-
getDouble
Retrieve thedoublevalue 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:
doublevalue stored in the specified column- See Also:
-
getString
Retrieve theStringvalue 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 theStringobject. -
getString
Retrieve theStringvalue 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 theStringobject.- Parameters:
columnName- Name of the column- Returns:
Stringvalue stored in the specified column- See Also:
-
getStringAsBytes
public final byte[] getStringAsBytes(int columnIndex) Retrieve thestringvalue 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:
stringvalue stored in the specified column as abyte[]- See Also:
-
getStringAsBytes
Retrieve thestringvalue 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:
stringvalue 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
-1if 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 thelongtimestamp 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:
longtimestamp value stored in the specified column- See Also:
-
getTimestampAsLong
Retrieve thelongtimestamp 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:
longtimestamp value stored in the specified column- See Also:
-
getTimestampAsTimestamp
Retrieve theTimestampTypevalue 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:
TimestampTypevalue stored in the specified column- See Also:
-
getTimestampAsTimestamp
Retrieve theTimestampTypevalue 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:
TimestampTypevalue stored in the specified column- See Also:
-
getTimestampAsSqlTimestamp
Retrieve thejava.sql.Timestampequivalent 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.Timestampequivalent to the value stored in the specified column
-
getTimestampAsSqlTimestamp
Retrieve thejava.sql.Timestampequivalent 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.Timestampequivalent to the value stored in the specified column
-
getDecimalAsBigDecimal
Retrieve the
BigDecimalvalue 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 theBigDecimalvalue 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
-