Package com.apama.correlator.memstore
Class RowValueHelper
- java.lang.Object
-
- com.apama.correlator.memstore.RowValueHelper
-
public class RowValueHelper extends java.lang.Object
Helper class for more conveniently and efficiently dealing with RowValue objects for a given table schema.RowValueHelper is an immutable (and therefore thread-safe) object, which caches computed information about the schema during construction, so typical usage is to re-use a single instance of the helper as needed for all RowValue instances that have the same schema.
See
RowValue
Javadoc for example usage.
-
-
Constructor Summary
Constructors Constructor Description RowValueHelper(java.lang.String... schemaTypes)
Create a new RowValueHelper based on the specified schema type information.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description RowValue
createRowValue()
Create a new RowValue instance, with its data structured pre-allocated for the field types of this schema.java.lang.Iterable<java.lang.Object>
fieldValues(RowValue rv)
Use the schema to iterate over each field in the specified row value, returning a Java Object of the correct type for each field value.int
getTypedIndex(int fieldIndex)
Use the schema types to get the typedIndex (suitable for a RowValue.set/get call) from a fieldIndex.
-
-
-
Constructor Detail
-
RowValueHelper
public RowValueHelper(java.lang.String... schemaTypes)
Create a new RowValueHelper based on the specified schema type information.Do not create a new RowValueHelper for every RowValue, instead it is more efficient to reuse a single helper for many RowValue objects.
- Parameters:
schemaTypes
- A params array indicating the type and order of fields in this table's schema.
-
-
Method Detail
-
createRowValue
public RowValue createRowValue()
Create a new RowValue instance, with its data structured pre-allocated for the field types of this schema.- Returns:
- A new RowValue instance.
-
getTypedIndex
public int getTypedIndex(int fieldIndex)
Use the schema types to get the typedIndex (suitable for a RowValue.set/get call) from a fieldIndex.The correctness of this method is dependent on valid schema information being supplied - this method will return an out of range index if the schema and RowValue do not match, or if an invalid fieldIndex is specified (but it will not throw an exception).
- Parameters:
fieldIndex
- The field index, i.e. n where n is the nth field in the row.- Returns:
- The typed index for the type of this field, i.e. n where n is the nth field of the type (in the row).
-
fieldValues
public java.lang.Iterable<java.lang.Object> fieldValues(RowValue rv)
Use the schema to iterate over each field in the specified row value, returning a Java Object of the correct type for each field value.- Parameters:
rv
- The RowValue- Returns:
- An iterable that can be used as the target of a for-each loop.
-
-