Module datarush.library
Class CompositeTokenSequence
- java.lang.Object
-
- com.pervasive.datarush.sequences.record.CompositeTokenSequence
-
- All Implemented Interfaces:
RecordTokenSequence,TokenSequence,RecordTyped,TokenTyped
public class CompositeTokenSequence extends Object
A record sequence comprised of scalar sequences for fields.There is no guarantee of immutability for these objects. While no mutators are provided on
CompositeTokenSequence, the underlying columns may refer to mutable objects.
-
-
Constructor Summary
Constructors Constructor Description CompositeTokenSequence(RecordTokenType type, ScalarTokenSequence[] columns)Create a new sequence backed with the specified scalar token sequences containing the field values for each record element.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intcolumns()Gets the number of columns in a record.intcompareElement(int index, TokenValued value)Compares the values of the specified row of tokens to the tokens at which the given port is positioned.intcompareElements(int lhsIndex, int rhsIndex)Compares the values of the tokens at the specified positions.booleancontainsNull(int index)Determines if any column in the specified row is null valued.ScalarTokenSequencegetColumn(int i)Gets theScalarTokenSequencecontaining the specified column data.ElementComparatorgetElementComparator(SortKey... sortKeys)Gets anElementComparatorfor the token array for the fields with the given names and the given token orders.ElementComparatorgetElementComparator(TokenOrder sortOrder)Gets an ElementComparator for the token array and given ordering.ElementComparatorgetElementComparator(TokenOrder... sortOrder)Gets an ElementComparator for the token array and given ordering.RecordValuedgetToken(int index)Gets the value at the specified position.RecordTokenTypegetType()Gets the type of data tokens handled by the implementor.inthashCode(int index)Gets the hash code for the token at the specified position.booleanisNull(int index)Indicates whether the specified token has a null value.RecordValuedIteratornewValueIterator()Creates an iterator over the non-null values of this sequence.intsize()Gets the length of the sequence.StringtoString()StringtoString(int index)Gets the string representation of the token at the specified position.
-
-
-
Constructor Detail
-
CompositeTokenSequence
public CompositeTokenSequence(RecordTokenType type, ScalarTokenSequence[] columns)
Create a new sequence backed with the specified scalar token sequences containing the field values for each record element. All sequences must be of the same length.- Parameters:
type- the record schemacolumns- theScalarTokenArrayobjects containing the column data.- Throws:
IllegalArgumentException- if not all columns are of the same length
-
-
Method Detail
-
columns
public final int columns()
Description copied from interface:RecordTokenSequenceGets the number of columns in a record.- Specified by:
columnsin interfaceRecordTokenSequence- Returns:
- the number of columns in a record.
-
getColumn
public ScalarTokenSequence getColumn(int i)
Description copied from interface:RecordTokenSequenceGets theScalarTokenSequencecontaining the specified column data.- Specified by:
getColumnin interfaceRecordTokenSequence- Parameters:
i- the column sequence to get. Indexes are zero-based and ordered identically to the fields in theRecordTokenTypefor this array.- Returns:
- a
ScalarTokenSequencecontaining the token values for the column.
-
size
public final int size()
Description copied from interface:TokenSequenceGets the length of the sequence.- Specified by:
sizein interfaceTokenSequence- Returns:
- the number of tokens in the sequence.
-
getType
public final RecordTokenType getType()
Description copied from interface:TokenTypedGets the type of data tokens handled by the implementor.- Specified by:
getTypein interfaceRecordTyped- Specified by:
getTypein interfaceTokenTyped- Returns:
- the type of tokens associated with the class.
-
isNull
public final boolean isNull(int index)
Description copied from interface:TokenSequenceIndicates whether the specified token has a null value.- Specified by:
isNullin interfaceTokenSequence- Parameters:
index- the index of the token- Returns:
trueif the element is null,falseotherwise
-
containsNull
public final boolean containsNull(int index)
Description copied from interface:RecordTokenSequenceDetermines if any column in the specified row is null valued.- Specified by:
containsNullin interfaceRecordTokenSequence- Parameters:
index- the row to check- Returns:
trueif at least one column is null valued,falseif none are
-
compareElement
public final int compareElement(int index, TokenValued value)Description copied from interface:RecordTokenSequenceCompares the values of the specified row of tokens to the tokens at which the given port is positioned. Tokens in a row are compared to the token of the subport in the same position as the token's column. Comparison starts with the first column and progresses until the tokens compare unequal or there are no more columns.The source sequence must be composite and have the same number of columns as this sequence. All columns must be of comparable types.
- Specified by:
compareElementin interfaceRecordTokenSequence- Specified by:
compareElementin interfaceTokenSequence- Parameters:
index- the index of the tokenvalue- the input port positioned at the token for comparison- Returns:
0if the values are equal,1if the sequence token value is greater,-1if the sequence token value is lesser. A null value is greater than any other non-null; two null values compare as equal.
-
compareElements
public final int compareElements(int lhsIndex, int rhsIndex)Description copied from interface:TokenSequenceCompares the values of the tokens at the specified positions.- Specified by:
compareElementsin interfaceRecordTokenSequence- Specified by:
compareElementsin interfaceTokenSequence- Parameters:
lhsIndex- the index of the left-hand elementrhsIndex- the index of the right-hand element- Returns:
0if the values are equal,1if the left hand value is greater,-1if the left hand value is lesser. A null value is greater than any other non-null; two null values compare as equal.
-
getElementComparator
public final ElementComparator getElementComparator(TokenOrder sortOrder)
Description copied from interface:RecordTokenSequenceGets an ElementComparator for the token array and given ordering. All columns will by sorted in the given order.- Specified by:
getElementComparatorin interfaceRecordTokenSequence- Specified by:
getElementComparatorin interfaceTokenSequence- Parameters:
sortOrder- the desired ordering- Returns:
- an ElementComparator on the CompositeTokenArray.
-
getElementComparator
public final ElementComparator getElementComparator(TokenOrder... sortOrder)
Description copied from interface:RecordTokenSequenceGets an ElementComparator for the token array and given ordering. Each column will be sorted by the order specified in the matching position in the ordering array. An ordering must be specified for each column.- Specified by:
getElementComparatorin interfaceRecordTokenSequence- Parameters:
sortOrder- the desired ordering- Returns:
- an
ElementComparatoron this sequence
-
getElementComparator
public final ElementComparator getElementComparator(SortKey... sortKeys)
Description copied from interface:RecordTokenSequenceGets anElementComparatorfor the token array for the fields with the given names and the given token orders.- Specified by:
getElementComparatorin interfaceRecordTokenSequence- Parameters:
sortKeys- list of key fields and sort order for each- Returns:
- an
ElementComparatoron this sequence
-
getToken
public final RecordValued getToken(int index)
Description copied from interface:TokenSequenceGets the value at the specified position.- Specified by:
getTokenin interfaceRecordTokenSequence- Specified by:
getTokenin interfaceTokenSequence- Parameters:
index- the index of the token- Returns:
- the value
-
hashCode
public final int hashCode(int index)
Description copied from interface:TokenSequenceGets the hash code for the token at the specified position.- Specified by:
hashCodein interfaceTokenSequence- Parameters:
index- the index of the token- Returns:
- the hash code for the token
-
toString
public final String toString(int index)
Description copied from interface:TokenSequenceGets the string representation of the token at the specified position.- Specified by:
toStringin interfaceTokenSequence- Parameters:
index- the index of the token- Returns:
- the string representation of the token
-
newValueIterator
public RecordValuedIterator newValueIterator()
Description copied from interface:TokenSequenceCreates an iterator over the non-null values of this sequence. The iterator will automatically be reset as modifications are made to the sequence.- Specified by:
newValueIteratorin interfaceRecordTokenSequence- Specified by:
newValueIteratorin interfaceTokenSequence- Returns:
- an newly-created iterator over the non-null values of this sequence.
-
-