- java.lang.Object
-
- com.pervasive.datarush.sequences.record.RecordTokenList
-
- All Implemented Interfaces:
MutableTokenSequence
,RecordTokenAppendable
,RecordTokenSequence
,MutableRecordTokenSequence
,TokenAppendable
,TokenSequence
,RecordTyped
,TokenTyped
public final class RecordTokenList extends Object implements MutableRecordTokenSequence
Primary implementation ofMutableRecordTokenSequence
.
-
-
Constructor Summary
Constructors Constructor Description RecordTokenList(MutableScalarTokenSequence... columns)
Create a new array backed with the specified scalar token arrays containing the field values for each record element.RecordTokenList(RecordTokenType type, int capacity)
Create an empty array with the specified type.RecordTokenList(RecordTokenType type, MutableScalarTokenSequence[] columns)
Create a new array backed with the specified scalar token arrays containing the field values for each record element.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
append(TokenSequence data)
Appends all tokens in the specified sequence to this sequence.void
append(TokenSequence data, int start, int length)
Appends a subsequence of tokens in the specified sequence to this sequence.void
append(TokenValued value)
Appends the specified token value to this sequence.void
append(TokenValued value, long count)
Appends the specified token value to this sequence multiple times.void
appendNull()
Appends a null value to all sequences comprising this composite sequence.void
appendNull(int count)
Appends the specified number of null values to all sequences comprising this composite sequence.void
appendZero()
Appends a zero value to this sequence.void
appendZero(int count)
Appends the specified number of zero values to this sequence.int
columns()
Gets the number of columns in a record.int
compareElement(int index, TokenValued value)
Compares the values of the specified row of tokens to the tokens at which the given port is positioned.int
compareElements(int lhsIndex, int rhsIndex)
Compares the values of the tokens at the specified positions.boolean
containsNull(int index)
Determines if any column in the specified row is null valued.void
fillValue(int startIndex, int count, TokenValued value)
Sets the tokens in the specified subsequence to the given value.ScalarTokenSequence
getColumn(int i)
Gets theScalarTokenSequence
containing the specified column data.ElementComparator
getElementComparator(SortKey... sortKeys)
Gets anElementComparator
for the token array for the fields with the given names and the given token orders.ElementComparator
getElementComparator(TokenOrder sortOrder)
Gets an ElementComparator for the token array and given ordering.ElementComparator
getElementComparator(TokenOrder... sortOrder)
Gets an ElementComparator for the token array and given ordering.RecordValued
getToken(int index)
Gets the value at the specified position.RecordSettable
getTokenSetter(int index)
Returns a mutator for the given index.RecordTokenType
getType()
Gets the type of data tokens handled by the implementor.int
hashCode(int index)
Gets the hash code for the token at the specified position.boolean
isNull(int index)
Indicates whether the specified token has a null value.RecordValuedIterator
newValueIterator()
Creates an iterator over the non-null values of this sequence.void
reset()
Removes all elements from the sequence.void
setNull(int index)
Sets the token at the specified position to be null valued.void
setNull(int startIndex, int count)
Sets the tokens in the specified subsequence to be null valued.void
setValue(int index, TokenValued value)
Sets the token at the specified position to the given value.void
setValues(int index, TokenSequence values, int offset, int length)
Sets the tokens in the specified subsequence of the array to the corresponding values from a subsequence of the given source sequence.void
setZero(int index)
Sets the token at the specified position to be zero valued.void
setZero(int start, int length)
Sets the tokens in the specified subsequence to be zero valued.int
size()
Gets the length of the sequence.void
sort(SortKey... sortKeys)
Sort the list using the specified ordering.String
toString()
String
toString(int index)
Gets the string representation of the token at the specified position.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.pervasive.datarush.sequences.record.RecordTokenSequence
columns, compareElement, compareElements, containsNull, getElementComparator, getElementComparator, getElementComparator, getToken, newValueIterator
-
Methods inherited from interface com.pervasive.datarush.types.RecordTyped
getType
-
Methods inherited from interface com.pervasive.datarush.sequences.TokenSequence
hashCode, isNull, size, toString
-
-
-
-
Constructor Detail
-
RecordTokenList
public RecordTokenList(RecordTokenType type, int capacity)
Create an empty array with the specified type.- Parameters:
type
- the record schemacapacity
- the initial capacity.
-
RecordTokenList
public RecordTokenList(MutableScalarTokenSequence... columns)
Create a new array backed with the specified scalar token arrays containing the field values for each record element.- Parameters:
columns
- theScalarTokenArray
objects containing the column data.- Throws:
IllegalArgumentException
- if not all columns are of the same length
-
RecordTokenList
public RecordTokenList(RecordTokenType type, MutableScalarTokenSequence[] columns)
Create a new array backed with the specified scalar token arrays containing the field values for each record element.- Parameters:
type
- the record schemacolumns
- theScalarTokenArray
objects containing the column data.- Throws:
IllegalArgumentException
- if not all columns are of the same length
-
-
Method Detail
-
getColumn
public ScalarTokenSequence getColumn(int i)
Description copied from interface:RecordTokenSequence
Gets theScalarTokenSequence
containing the specified column data.- Specified by:
getColumn
in interfaceRecordTokenSequence
- Parameters:
i
- the column sequence to get. Indexes are zero-based and ordered identically to the fields in theRecordTokenType
for this array.- Returns:
- a
ScalarTokenSequence
containing the token values for the column.
-
setNull
public void setNull(int index)
Description copied from interface:MutableTokenSequence
Sets the token at the specified position to be null valued.- Specified by:
setNull
in interfaceMutableTokenSequence
- Parameters:
index
- the position of the token in the array
-
setNull
public void setNull(int startIndex, int count)
Description copied from interface:MutableTokenSequence
Sets the tokens in the specified subsequence to be null valued.- Specified by:
setNull
in interfaceMutableTokenSequence
- Parameters:
startIndex
- the starting index of the subsequence in the arraycount
- the length of the subsequence
-
setZero
public void setZero(int index)
Description copied from interface:MutableTokenSequence
Sets the token at the specified position to be zero valued.- Specified by:
setZero
in interfaceMutableTokenSequence
- Parameters:
index
- the position of the token in the array
-
setZero
public void setZero(int start, int length)
Description copied from interface:MutableTokenSequence
Sets the tokens in the specified subsequence to be zero valued.- Specified by:
setZero
in interfaceMutableTokenSequence
- Parameters:
start
- the starting index of the subsequence in the arraylength
- the length of the subsequence
-
setValues
public void setValues(int index, TokenSequence values, int offset, int length)
Description copied from interface:MutableTokenSequence
Sets the tokens in the specified subsequence of the array to the corresponding values from a subsequence of the given source sequence.- Specified by:
setValues
in interfaceMutableTokenSequence
- Parameters:
index
- the starting index of the subsequence in the arrayvalues
- the source sequence. This sequence must be of an appropriate type for the array.offset
- the starting index in the source sequence. Corresponding values will be taken relative to this position. That is, the value of the token at positionoffset
invalues
will be assigned to the token at positionstart
, and so on.length
- the number of tokens to copy
-
setValue
public void setValue(int index, TokenValued value)
Description copied from interface:MutableTokenSequence
Sets the token at the specified position to the given value.- Specified by:
setValue
in interfaceMutableTokenSequence
- Parameters:
index
- the position of the token in the arrayvalue
- the value to which to set the token. This value must be of an appropriate type for the array.
-
fillValue
public void fillValue(int startIndex, int count, TokenValued value)
Description copied from interface:MutableTokenSequence
Sets the tokens in the specified subsequence to the given value.- Specified by:
fillValue
in interfaceMutableTokenSequence
- Parameters:
startIndex
- the starting index of the subsequence in the arraycount
- the length of the subsequencevalue
- the value to which to set the tokens. This value must be of an appropriate type for the array
-
reset
public void reset()
Description copied from interface:MutableTokenSequence
Removes all elements from the sequence.- Specified by:
reset
in interfaceMutableTokenSequence
-
appendNull
public void appendNull()
Appends a null value to all sequences comprising this composite sequence.- Specified by:
appendNull
in interfaceMutableTokenSequence
-
appendNull
public void appendNull(int count)
Appends the specified number of null values to all sequences comprising this composite sequence.- Specified by:
appendNull
in interfaceMutableTokenSequence
- Parameters:
count
- the number of null values to append
-
appendZero
public void appendZero()
Description copied from interface:MutableTokenSequence
Appends a zero value to this sequence.- Specified by:
appendZero
in interfaceMutableTokenSequence
-
appendZero
public void appendZero(int count)
Description copied from interface:MutableTokenSequence
Appends the specified number of zero values to this sequence.- Specified by:
appendZero
in interfaceMutableTokenSequence
- Parameters:
count
- the number of zero values to append
-
append
public void append(TokenValued value)
Appends the specified token value to this sequence.The source value must be
RecordValued
and have a number of fields equal to the number of columns in the sequence. Values are appended to the sequence by position, not name. The token types of fields must be compatible. If the types are not identical, appropriate coercion will be performed.- Specified by:
append
in interfaceTokenAppendable
- Parameters:
value
- the token value to append
-
append
public void append(TokenValued value, long count)
Appends the specified token value to this sequence multiple times.The source value must be
RecordValued
and have a number of fields equal to the number of columns in the sequence. Values are appended to the sequence by position, not name. The token types of fields must be compatible. If the types are not identical, appropriate coercion will be performed.- Specified by:
append
in interfaceTokenAppendable
- Parameters:
value
- the token value to appendcount
- the number of copies to append
-
append
public void append(TokenSequence data)
Appends all tokens in the specified sequence to this sequence. Columns are appended to the target column in the same position as the source.The source sequence must be composite and have the same number of columns as this sequence. The data types of the sequences must be compatible. If not identical, appropriate coercion will be performed, if possible.
- Specified by:
append
in interfaceTokenAppendable
- Parameters:
data
- the sequence to append
-
append
public void append(TokenSequence data, int start, int length)
Appends a subsequence of tokens in the specified sequence to this sequence. Columns are appended to the target column in the same position as the source.The source sequence must be composite and have the same number of columns as this sequence. The data types of the sequences must be compatible. If not identical, appropriate coercion will be performed, if possible.
- Specified by:
append
in interfaceTokenAppendable
- Parameters:
data
- the sequence containing tokens to appendstart
- the starting index of the subsequence in the sourcelength
- the length of the subsequence
-
sort
public void sort(SortKey... sortKeys)
Sort the list using the specified ordering.- Parameters:
sortKeys
- the fields and ordering by which to sort
-
getTokenSetter
public RecordSettable getTokenSetter(int index)
Description copied from interface:MutableTokenSequence
Returns a mutator for the given index.- Specified by:
getTokenSetter
in interfaceMutableRecordTokenSequence
- Specified by:
getTokenSetter
in interfaceMutableTokenSequence
- Parameters:
index
- the position- Returns:
- a mutator for the given index.
-
columns
public final int columns()
Description copied from interface:RecordTokenSequence
Gets the number of columns in a record.- Specified by:
columns
in interfaceRecordTokenSequence
- Returns:
- the number of columns in a record.
-
size
public final int size()
Description copied from interface:TokenSequence
Gets the length of the sequence.- Specified by:
size
in interfaceTokenSequence
- Returns:
- the number of tokens in the sequence.
-
getType
public final RecordTokenType getType()
Description copied from interface:TokenTyped
Gets the type of data tokens handled by the implementor.- Specified by:
getType
in interfaceRecordTyped
- Specified by:
getType
in interfaceTokenTyped
- Returns:
- the type of tokens associated with the class.
-
isNull
public final boolean isNull(int index)
Description copied from interface:TokenSequence
Indicates whether the specified token has a null value.- Specified by:
isNull
in interfaceTokenSequence
- Parameters:
index
- the index of the token- Returns:
true
if the element is null,false
otherwise
-
containsNull
public final boolean containsNull(int index)
Description copied from interface:RecordTokenSequence
Determines if any column in the specified row is null valued.- Specified by:
containsNull
in interfaceRecordTokenSequence
- Parameters:
index
- the row to check- Returns:
true
if at least one column is null valued,false
if none are
-
compareElement
public final int compareElement(int index, TokenValued value)
Description copied from interface:RecordTokenSequence
Compares 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:
compareElement
in interfaceRecordTokenSequence
- Specified by:
compareElement
in interfaceTokenSequence
- Parameters:
index
- the index of the tokenvalue
- the input port positioned at the token for comparison- Returns:
0
if the values are equal,1
if the sequence token value is greater,-1
if 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:TokenSequence
Compares the values of the tokens at the specified positions.- Specified by:
compareElements
in interfaceRecordTokenSequence
- Specified by:
compareElements
in interfaceTokenSequence
- Parameters:
lhsIndex
- the index of the left-hand elementrhsIndex
- the index of the right-hand element- Returns:
0
if the values are equal,1
if the left hand value is greater,-1
if 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:RecordTokenSequence
Gets an ElementComparator for the token array and given ordering. All columns will by sorted in the given order.- Specified by:
getElementComparator
in interfaceRecordTokenSequence
- Specified by:
getElementComparator
in interfaceTokenSequence
- Parameters:
sortOrder
- the desired ordering- Returns:
- an ElementComparator on the CompositeTokenArray.
-
getElementComparator
public final ElementComparator getElementComparator(TokenOrder... sortOrder)
Description copied from interface:RecordTokenSequence
Gets 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:
getElementComparator
in interfaceRecordTokenSequence
- Parameters:
sortOrder
- the desired ordering- Returns:
- an
ElementComparator
on this sequence
-
getElementComparator
public final ElementComparator getElementComparator(SortKey... sortKeys)
Description copied from interface:RecordTokenSequence
Gets anElementComparator
for the token array for the fields with the given names and the given token orders.- Specified by:
getElementComparator
in interfaceRecordTokenSequence
- Parameters:
sortKeys
- list of key fields and sort order for each- Returns:
- an
ElementComparator
on this sequence
-
getToken
public final RecordValued getToken(int index)
Description copied from interface:TokenSequence
Gets the value at the specified position.- Specified by:
getToken
in interfaceRecordTokenSequence
- Specified by:
getToken
in interfaceTokenSequence
- Parameters:
index
- the index of the token- Returns:
- the value
-
hashCode
public final int hashCode(int index)
Description copied from interface:TokenSequence
Gets the hash code for the token at the specified position.- Specified by:
hashCode
in 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:TokenSequence
Gets the string representation of the token at the specified position.- Specified by:
toString
in interfaceTokenSequence
- Parameters:
index
- the index of the token- Returns:
- the string representation of the token
-
newValueIterator
public RecordValuedIterator newValueIterator()
Description copied from interface:TokenSequence
Creates 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:
newValueIterator
in interfaceRecordTokenSequence
- Specified by:
newValueIterator
in interfaceTokenSequence
- Returns:
- an newly-created iterator over the non-null values of this sequence.
-
-