Package com.illumon.iris.db.v2.utils
Interface ReadOnlyIndex
- All Superinterfaces:
AutoCloseable
,LongSizedDataStructure
,OrderedKeys
,SafeCloseable
- All Known Subinterfaces:
Index
- All Known Implementing Classes:
CurrentOnlyIndex
,SortedIndex
,TreeIndex
public interface ReadOnlyIndex extends OrderedKeys, SafeCloseable
Read-only subset of the
Index
interface.-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interface
ReadOnlyIndex.Evaluator<T extends Comparable<T>>
static interface
ReadOnlyIndex.Iterator
static interface
ReadOnlyIndex.RangeIterator
static interface
ReadOnlyIndex.SearchIterator
static interface
ReadOnlyIndex.TargetComparator
-
Field Summary
Fields Modifier and Type Field Description static ReadOnlyIndex.SearchIterator
EMPTY_ITERATOR
static long
NULL_KEY
-
Method Summary
Modifier and Type Method Description Index
clone()
Create a copy of this index.void
close()
Release all resources associated with this index.boolean
containsRange(long start, long end)
Queries whether this index contains every element in the range provided.void
copyImmutableGroupings(TupleSource source, TupleSource dest)
boolean
empty()
Queries whether this index is empty (i.e.long
find(long key)
Returns the position in [0..(size-1)] where the key is found.gnu.trove.list.array.TLongArrayList[]
findMissing(ReadOnlyIndex keys)
For the given keys Index, under the assertion that none of them are present in the current index, return the tentative insertion points in the current index with the count for each of themlong
findPrev(long key)
Returns the position in [0..(size-1)] where the key is found in the previous index.long
firstKey()
Get the first key in thisIndex
.long
firstKeyPrev()
default void
forAllLongs(LongConsumer lc)
boolean
forEachLong(LongAbortableConsumer lc)
Provide each value contained in this index, in increased sorted order to the consumer.long
get(long pos)
Returns the key at the given rank position.Map<Object,ReadOnlyIndex>
getGrouping(TupleSource tupleSource)
Get the current groupings for the specified columnMap<Object,ReadOnlyIndex>
getGroupingForKeySet(Set<Object> keys, TupleSource tupleSource)
Return a grouping that contains keys that match the values in keySet.void
getKeysForPositions(PrimitiveIterator.OfLong inputPositions, LongConsumer outputKeys)
Returns the sequence of (increasing) keys corresponding to the positions provided as input.long
getPrev(long pos)
Map<Object,ReadOnlyIndex>
getPrevGrouping(TupleSource tupleSource)
Get the previous groupings for the specified columnIndex
getPrevIndex()
Index
getSubIndexForKeySet(Set<Object> keySet, TupleSource tupleSource)
Return a subIndex that contains indices that match the values in keySet.boolean
hasGrouping(ColumnSource... keyColumns)
Check if the index contains grouping for the specified key columns.Index
intersect(ReadOnlyIndex range)
Returns a new index representing the intersection of the current index with the input indexIndex
invert(ReadOnlyIndex keys)
Returns an Index with the positions of keys in this Index.Index
invert(ReadOnlyIndex keys, long maximumPosition)
Returns the positions of keys in the current set as an Index, stopping at maximumPosition.default boolean
isEmpty()
Queries whether this index is empty (i.e.boolean
isFlat()
Returns whether or not this index is flat.boolean
isSorted()
ReadOnlyIndex.Iterator
iterator()
long
lastKey()
Get the last key in thisIndex
.long
lastKeyPrev()
Index
minus(ReadOnlyIndex indexToRemove)
Returns a new index representing the keys of the current set not present inside indexToRemove This operation is equivalent to set difference.default boolean
nonempty()
Queries whether this index is non-empty (i.e.default boolean
overlaps(ReadOnlyIndex index)
Returns true if an index has any overlap.boolean
overlapsRange(long start, long end)
Returns true if this index has any overlap with the provided range.ReadOnlyIndex.RangeIterator
rangeIterator()
int
refCount()
ReadOnlyIndex.SearchIterator
reverseIterator()
ReadOnlyIndex.SearchIterator
searchIterator()
Index
shift(long shiftAmount)
Returns a new index representing the keys in this index shifted by the amount indicated.long
size()
How many keys are in this index.long
sizePrev()
Index
subindexByKey(long startKey, long endKey)
Get a subset of this index within this range of keys.Index
subindexByPos(long startPos, long endPos)
Get a subset of this index within this range of positionsdefault Index
subindexByPos(Index posIndex)
Get a subset of this index within these range of positions.boolean
subsetOf(ReadOnlyIndex other)
Returns true if this index is a (possibly improper) subset of other.default void
toLongArray(long[] vs)
default void
toLongArray(long[] vs, int offset)
Index
union(ReadOnlyIndex indexToAdd)
Returns a new index representing the keys present in both this index and the argument index.default void
validate()
void
validate(String failMsg)
Methods inherited from interface com.illumon.iris.db.v2.utils.OrderedKeys
asIndex, asKeyIndicesChunk, asKeyRangesChunk, fillKeyIndicesChunk, fillKeyRangesChunk, forAllLongRanges, forEachLongRange, getAverageRunLengthEstimate, getOrderedKeysByKeyRange, getOrderedKeysByPosition, getOrderedKeysIterator, isContiguous
-
Field Details
-
NULL_KEY
static final long NULL_KEY- See Also:
- Constant Field Values
-
EMPTY_ITERATOR
-
-
Method Details
-
close
void close()Release all resources associated with this index.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceOrderedKeys
- Specified by:
close
in interfaceSafeCloseable
-
refCount
-
lastKey
long lastKey()Get the last key in thisIndex
.- Specified by:
lastKey
in interfaceOrderedKeys
- Returns:
- The last key, or
NULL_KEY
if there is none.
-
firstKey
long firstKey()Get the first key in thisIndex
.- Specified by:
firstKey
in interfaceOrderedKeys
- Returns:
- The first key, or
NULL_KEY
if there is none.
-
clone
Index clone()Create a copy of this index.- Returns:
- a copy of this index
-
invert
Returns an Index with the positions of keys in this Index. This can be thought of as an iterative find() over the values in keys, but all keys must exist within this index, because an Index result can not represent negative values.- Parameters:
keys
- the keys to find positions for- Returns:
- a new Index containing the positions of the keys in this index
-
invert
Returns the positions of keys in the current set as an Index, stopping at maximumPosition. This can be thought of as an iterative find() over the values in keys, but all keys must exist within this index, because an Index result can not represent negative values.- Parameters:
keys
- the keys to find positions formaximumPosition
- the largest position for which we will find a key- Returns:
- a new Index containing the positions of the keys in this index
-
findMissing
For the given keys Index, under the assertion that none of them are present in the current index, return the tentative insertion points in the current index with the count for each of them- Parameters:
keys
- the keys to identify insertion locations- Returns:
- two TLongArrayLists; [0] contains the positions, [1] contains the counts.
-
intersect
Returns a new index representing the intersection of the current index with the input index -
overlaps
Returns true if an index has any overlap. -
overlapsRange
boolean overlapsRange(long start, long end)Returns true if this index has any overlap with the provided range.- Parameters:
start
- Start of range, inclusive.end
- End of range, inclusive.- Returns:
- true if any value x in start <= x <= end is contained in this index.
-
subsetOf
Returns true if this index is a (possibly improper) subset of other.- Returns:
- true if every element of this exists within other
-
minus
Returns a new index representing the keys of the current set not present inside indexToRemove This operation is equivalent to set difference. This index is not modified. -
union
Returns a new index representing the keys present in both this index and the argument index.- Parameters:
indexToAdd
- an index whose keys will be joined with our own to produce a new index.- Returns:
- a new index with the union of the keys in both this index and indexToAdd.
-
shift
Returns a new index representing the keys in this index shifted by the amount indicated.- Parameters:
shiftAmount
- the amount to shift the keys in the index- Returns:
- a new index with the keys shifted by shiftAmount
-
getGrouping
Get the current groupings for the specified column- Parameters:
tupleSource
- the column to find groupings for- Returns:
- the map of groups for the provided index
-
getPrevGrouping
Get the previous groupings for the specified column- Parameters:
tupleSource
- the column to find previous groupings for- Returns:
- the map of previous groups for the provided index
-
getGroupingForKeySet
Return a grouping that contains keys that match the values in keySet.- Parameters:
keys
- a set of values that keyColumns should match. For a single keyColumns, the values within the set are the values that we would like to find. For multiple keyColumns, the values are SmartKeys.tupleSource
- the tuple factory for the keyColumns- Returns:
- an Map from keys to Indices, for each of the keys in keySet and this Index.
-
copyImmutableGroupings
-
hasGrouping
Check if the index contains grouping for the specified key columns.- Parameters:
keyColumns
- the keys to find groupings for- Returns:
- true if there are groupings for the specified keys.
-
getSubIndexForKeySet
Return a subIndex that contains indices that match the values in keySet.- Parameters:
keySet
- a set of values that keyColumns should match. For a single keyColumns, the values within the set are the values that we would like to find. For multiple keyColumns, the values are SmartKeys.tupleSource
- the tuple factory for the keyColumn- Returns:
- an Index containing only keys that match keySet.
-
forEachLong
Provide each value contained in this index, in increased sorted order to the consumer. If the consumer returns false for a key, stops after that key (does not provide any keys after that key).- Specified by:
forEachLong
in interfaceOrderedKeys
- Parameters:
lc
- the consumer.- Returns:
- false if the consumer returned false at some point, true if the consumer always returned true and all values in the index were consumed.
-
forAllLongs
- Specified by:
forAllLongs
in interfaceOrderedKeys
-
toLongArray
default void toLongArray(long[] vs) -
toLongArray
default void toLongArray(long[] vs, int offset) -
subindexByPos
Get a subset of this index within this range of positions- Parameters:
startPos
- The first position to included in the output (inclusive)endPos
- The last position to included in the output (exclusive)- Returns:
- A new index, containing only positions >= startPos and < endPos
-
subindexByKey
Get a subset of this index within this range of keys.- Parameters:
startKey
- The first key to include in the output.endKey
- The last key (inclusive) to include in the output.- Returns:
- A new index, containing only values >= startKey and <= endKey.
-
subindexByPos
Get a subset of this index within these range of positions.- Parameters:
posIndex
- The index of position-based ranges to extract.- Returns:
- A new index, containing values at the locations in the provided index.
-
get
long get(long pos)Returns the key at the given rank position.- Parameters:
pos
- a position in this index between 0 and size() - 1- Returns:
- the key at that rank.
-
getKeysForPositions
Returns the sequence of (increasing) keys corresponding to the positions provided as input.- Parameters:
inputPositions
- an iterator providing index positions in increasing order.outputKeys
- a consumer of corresponding keys for the positions provided as input.
-
getPrev
long getPrev(long pos) -
sizePrev
long sizePrev() -
getPrevIndex
Index getPrevIndex() -
firstKeyPrev
long firstKeyPrev() -
lastKeyPrev
long lastKeyPrev() -
find
long find(long key)Returns the position in [0..(size-1)] where the key is found. If not found, then return (-(position it would be) - 1), a la Array.binarySearch.- Parameters:
key
- the key to search for- Returns:
- a position from [0..(size-1)] if the key was found. If the key was not found, then (-position - 1) as in Array.binarySearch.
-
findPrev
long findPrev(long key)Returns the position in [0..(size-1)] where the key is found in the previous index. If not found, then return (-(position it would be) - 1), as in Array.binarySearch.- Parameters:
key
- the key to search for- Returns:
- a position from [0..(size-1)] if the key was found. If the key was not found, then (-position - 1) as in Array.binarySearch.
-
isSorted
boolean isSorted() -
iterator
-
searchIterator
ReadOnlyIndex.SearchIterator searchIterator() -
reverseIterator
ReadOnlyIndex.SearchIterator reverseIterator() -
rangeIterator
ReadOnlyIndex.RangeIterator rangeIterator() -
size
long size()How many keys are in this index.- Specified by:
size
in interfaceLongSizedDataStructure
- Specified by:
size
in interfaceOrderedKeys
- Returns:
- the number of keys in this index.
-
isFlat
boolean isFlat()Returns whether or not this index is flat. Unlike a table, this is a mutable property; which may change from step to step.- Returns:
- true if the index keys are continguous and start at zero.
-
empty
boolean empty()Queries whether this index is empty (i.e. has no keys).- Returns:
- true if the size() of this Index is zero, false if the size is greater than zero
-
isEmpty
default boolean isEmpty()Queries whether this index is empty (i.e. has no keys).- Specified by:
isEmpty
in interfaceOrderedKeys
- Returns:
- true if the size() of this Index is zero, false if the size is greater than zero
-
nonempty
default boolean nonempty()Queries whether this index is non-empty (i.e. has at least one key).- Returns:
- true if the size() of this Index greater than zero, false if the size is zero
-
containsRange
boolean containsRange(long start, long end)Queries whether this index contains every element in the range provided.- Parameters:
start
- Start of the range, inclusive.end
- End of the range, inclusive.- Returns:
- true if this index contains every element x in start <= x <= end.
-
validate
-
validate
default void validate()
-