public final class SparseRecordTokenList extends Object implements MutableRecordTokenSequence
MutableRecordTokenSequence
which stores
data sparsely. That is, zero values are not stored. This is a much
more efficient mechanism when the majority of values are zero.Constructor and Description |
---|
SparseRecordTokenList(RecordRegisterStorage storage)
Create a list using the specified storage.
|
SparseRecordTokenList(RecordTokenType type,
int capacity)
Create an empty array with the specified type.
|
Modifier and Type | Method and 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 this sequence.
|
void |
appendNull(int count)
Appends the specified number of null values to this 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 start,
int length,
TokenValued value)
Sets the tokens in the specified subsequence to the given value.
|
ScalarTokenSequence |
getColumn(int index)
Gets the
ScalarTokenSequence containing the specified
column data. |
ElementComparator |
getElementComparator(SortKey... sortKeys)
Gets an
ElementComparator 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 start,
int length)
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 start,
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.
|
String |
toString() |
String |
toString(int index)
Gets the string representation of the token at the specified
position.
|
public SparseRecordTokenList(RecordTokenType type, int capacity)
type
- the record schemacapacity
- the initial capacity.public SparseRecordTokenList(RecordRegisterStorage storage)
storage
- the data storage for the listpublic ScalarTokenSequence getColumn(int index)
RecordTokenSequence
ScalarTokenSequence
containing the specified
column data.getColumn
in interface RecordTokenSequence
index
- the column sequence to get. Indexes are zero-based
and ordered identically to the fields in the
RecordTokenType
for this array.ScalarTokenSequence
containing the token
values for the column.public int columns()
RecordTokenSequence
columns
in interface RecordTokenSequence
public int size()
TokenSequence
size
in interface TokenSequence
public RecordTokenType getType()
TokenTyped
getType
in interface RecordTyped
getType
in interface TokenTyped
public void reset()
MutableTokenSequence
reset
in interface MutableTokenSequence
public int hashCode(int index)
TokenSequence
hashCode
in interface TokenSequence
index
- the index of the tokenpublic boolean containsNull(int index)
RecordTokenSequence
containsNull
in interface RecordTokenSequence
index
- the row to checktrue
if at least one column is null
valued, false
if none arepublic boolean isNull(int index)
TokenSequence
isNull
in interface TokenSequence
index
- the index of the tokentrue
if the element is null,
false
otherwisepublic final String toString(int index)
TokenSequence
toString
in interface TokenSequence
index
- the index of the tokenpublic int compareElement(int index, TokenValued value)
RecordTokenSequence
The source sequence must be composite and have the same number of columns as this sequence. All columns must be of comparable types.
compareElement
in interface RecordTokenSequence
compareElement
in interface TokenSequence
index
- the index of the tokenvalue
- the input port positioned at the token for
comparison0
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.public int compareElements(int lhsIndex, int rhsIndex)
TokenSequence
compareElements
in interface RecordTokenSequence
compareElements
in interface TokenSequence
lhsIndex
- the index of the left-hand elementrhsIndex
- the index of the right-hand element0
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.public ElementComparator getElementComparator(TokenOrder sortOrder)
RecordTokenSequence
getElementComparator
in interface RecordTokenSequence
getElementComparator
in interface TokenSequence
sortOrder
- the desired orderingpublic ElementComparator getElementComparator(TokenOrder... sortOrder)
RecordTokenSequence
getElementComparator
in interface RecordTokenSequence
sortOrder
- the desired orderingElementComparator
on this sequencepublic ElementComparator getElementComparator(SortKey... sortKeys)
RecordTokenSequence
ElementComparator
for the token array for the
fields with the given names and the given token orders.getElementComparator
in interface RecordTokenSequence
sortKeys
- list of key fields and sort order for eachElementComparator
on this sequencepublic RecordValued getToken(int index)
TokenSequence
getToken
in interface RecordTokenSequence
getToken
in interface TokenSequence
index
- the index of the tokenpublic RecordSettable getTokenSetter(int index)
MutableTokenSequence
getTokenSetter
in interface MutableTokenSequence
getTokenSetter
in interface MutableRecordTokenSequence
index
- the positionpublic RecordValuedIterator newValueIterator()
TokenSequence
newValueIterator
in interface RecordTokenSequence
newValueIterator
in interface TokenSequence
public void appendNull()
MutableTokenSequence
appendNull
in interface MutableTokenSequence
public void appendNull(int count)
MutableTokenSequence
appendNull
in interface MutableTokenSequence
count
- the number of null values to appendpublic void appendZero()
MutableTokenSequence
appendZero
in interface MutableTokenSequence
public void appendZero(int count)
MutableTokenSequence
appendZero
in interface MutableTokenSequence
count
- the number of zero values to appendpublic void append(TokenValued value)
TokenAppendable
The data types of the sequence and the value must be compatible. If the types are not identical, appropriate coercion will be attempted.
append
in interface TokenAppendable
value
- the token value to appendpublic void append(TokenValued value, long count)
TokenAppendable
The data types of the sequence and the value must be compatible. If the types are not identical, appropriate coercion will be attempted.
append
in interface TokenAppendable
value
- the token value to appendcount
- the number of copies to appendpublic void append(TokenSequence data)
TokenAppendable
The data types of the sequences must be compatible. If not identical, appropriate coercion will be attempted.
append
in interface TokenAppendable
data
- the sequence to appendpublic void append(TokenSequence data, int start, int length)
TokenAppendable
The data types of the sequences must be compatible. If not identical, appropriate coercion will be attempted.
append
in interface TokenAppendable
data
- the sequence containing tokens to appendstart
- the starting index of the subsequence in the sourcelength
- the length of the subsequencepublic void setNull(int index)
MutableTokenSequence
setNull
in interface MutableTokenSequence
index
- the position of the token in the arraypublic void setNull(int start, int length)
MutableTokenSequence
setNull
in interface MutableTokenSequence
start
- the starting index of the subsequence in the arraylength
- the length of the subsequencepublic void setZero(int index)
MutableTokenSequence
setZero
in interface MutableTokenSequence
index
- the position of the token in the arraypublic void setZero(int start, int length)
MutableTokenSequence
setZero
in interface MutableTokenSequence
start
- the starting index of the subsequence in the arraylength
- the length of the subsequencepublic void setValue(int index, TokenValued value)
MutableTokenSequence
setValue
in interface MutableTokenSequence
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.public void fillValue(int start, int length, TokenValued value)
MutableTokenSequence
fillValue
in interface MutableTokenSequence
start
- the starting index of the subsequence in the arraylength
- the length of the subsequencevalue
- the value to which to set the tokens. This value
must be of an appropriate type for the arraypublic void setValues(int start, TokenSequence values, int offset, int length)
MutableTokenSequence
setValues
in interface MutableTokenSequence
start
- 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 position offset
in
values
will be assigned to the token at position
start
, and so on.length
- the number of tokens to copyCopyright © 2024 Actian Corporation. All rights reserved.