Package com.illumon.iris.db.v2.utils
Class SortedIndex
java.lang.Object
com.illumon.iris.db.v2.utils.OrderedKeysAsChunkImpl
com.illumon.iris.db.v2.utils.SortedIndex
- All Implemented Interfaces:
com.fishlib.base.log.LogOutputAppendable
,LongSizedDataStructure
,Index
,OrderedKeys
,ReadOnlyIndex
,SafeCloseable
,AutoCloseable
,Iterable<Long>
- Direct Known Subclasses:
TreeIndex
public abstract class SortedIndex extends OrderedKeysAsChunkImpl implements Index
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.illumon.iris.db.v2.utils.Index
Index.AbstractRandomBuilder, Index.AdaptiveIndexBuilder, Index.Factory, Index.IndexUpdateCoalescer, Index.LegacyIndexUpdateCoalescer, Index.RandomBuilder, Index.SequentialBuilder, Index.ShiftInversionHelper
Nested classes/interfaces inherited from interface com.illumon.iris.db.v2.utils.OrderedKeys
OrderedKeys.Iterator
Nested classes/interfaces inherited from interface com.illumon.iris.db.v2.utils.ReadOnlyIndex
ReadOnlyIndex.Evaluator<T extends Comparable<T>>, ReadOnlyIndex.Iterator, ReadOnlyIndex.RangeIterator, ReadOnlyIndex.SearchIterator, ReadOnlyIndex.TargetComparator
-
Field Summary
Fields inherited from interface com.illumon.iris.db.v2.utils.Index
BAD_RANGES_AS_ERROR, CURRENT_FACTORY, FACTORY, USE_PRIORITY_QUEUE_RANDOM_BUILDER, VALIDATE_COALESCED_UPDATES
-
Constructor Summary
Constructors Constructor Description SortedIndex()
-
Method Summary
Modifier and Type Method Description void
clearMappings()
Index
clone()
Create a copy of this index.void
copyImmutableGroupings(TupleSource source, TupleSource dest)
boolean
equals(Object obj)
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 themMap<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.Map<Object,ReadOnlyIndex>
getPrevGrouping(TupleSource tupleSource)
Get the previous groupings for the specified columnIndex
getSubIndexForKeySet(Set<Object> keys, 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.int
hashCode()
void
insert(ReadOnlyIndex added)
Add all of the keys inadded
to this index if they are not already present.Index
invert(ReadOnlyIndex keys)
Returns an Index with the positions of keys in this Index.Index
invert(ReadOnlyIndex keys, long maximumPosition)
The only used implementation of invert is in the TreeIndex, really the guts of it are in BspNodeIndex.boolean
isFlat()
Returns whether or not this index is flat.boolean
isSorted()
protected void
onClear()
protected void
onInsert(ReadOnlyIndex added)
protected void
onRemove(ReadOnlyIndex removed)
protected void
onRetain(ReadOnlyIndex intersected)
protected void
onUpdate(ReadOnlyIndex added, ReadOnlyIndex removed)
void
remove(ReadOnlyIndex removed)
Remove all of the keys inremoved
that are present in this index.String
toString()
protected void
updateGroupingOnInsert(long key)
On an insertion operation, we clear all of our mappings so that they are not out-of-date.protected void
updateGroupingOnInsert(LongChunk<Attributes.OrderedKeyIndices> keys, int offset, int length)
On an insertion operation, we clear all of our mappings so that they are not out-of-date.protected void
updateGroupingOnRemove(long key)
On an insertion operation, we clear all of our mappings so that they are not out-of-date.protected void
updateGroupingOnRemove(LongChunk<Attributes.OrderedKeyIndices> keys, int offset, int length)
On an insertion operation, we clear all of our mappings so that they are not out-of-date.protected void
updateGroupingOnRemoveRange(long start, long end)
On an insertion operation, we clear all of our mappings so that they are not out-of-date.protected void
updateGroupingOnRetain(Index intersected)
protected void
updateGroupingOnRetainRange(long start, long end)
protected void
updateGroupOnInsertRange(long start, long end)
On an insertion operation, we clear all of our mappings so that they are not out-of-date.Methods inherited from class com.illumon.iris.db.v2.utils.OrderedKeysAsChunkImpl
asKeyIndicesChunk, asKeyRangesChunk, close, closeOrderedKeysAsChunkImpl, invalidateOrderedKeysAsChunkImpl, lastKey, rangesCountUpperBound, runsUpperBound
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface com.illumon.iris.db.v2.utils.Index
clear, compact, extract, initializePreviousValue, insert, insert, insertRange, insertWithShift, remove, remove, removeRange, retain, retainRange, shiftInPlace, update
Methods inherited from interface com.illumon.iris.db.v2.utils.OrderedKeys
asIndex, asKeyIndicesChunk, asKeyRangesChunk, fillKeyIndicesChunk, fillKeyRangesChunk, forAllLongRanges, forEachLongRange, getAverageRunLengthEstimate, getOrderedKeysByKeyRange, getOrderedKeysByPosition, getOrderedKeysIterator, isContiguous
Methods inherited from interface com.illumon.iris.db.v2.utils.ReadOnlyIndex
close, containsRange, empty, find, findPrev, firstKey, firstKeyPrev, forAllLongs, forEachLong, get, getKeysForPositions, getPrev, getPrevIndex, intersect, isEmpty, iterator, lastKey, lastKeyPrev, minus, nonempty, overlaps, overlapsRange, rangeIterator, refCount, reverseIterator, searchIterator, shift, size, sizePrev, subindexByKey, subindexByPos, subindexByPos, subsetOf, toLongArray, toLongArray, union, validate, validate
-
Constructor Details
-
SortedIndex
public SortedIndex()
-
-
Method Details
-
clone
Description copied from interface:ReadOnlyIndex
Create a copy of this index.- Specified by:
clone
in interfaceReadOnlyIndex
- Overrides:
clone
in classObject
- Returns:
- a copy of this index
-
onUpdate
-
onRemove
-
onRetain
-
onInsert
-
onClear
protected final void onClear() -
isSorted
public final boolean isSorted()- Specified by:
isSorted
in interfaceReadOnlyIndex
-
isFlat
public final boolean isFlat()Description copied from interface:ReadOnlyIndex
Returns whether or not this index is flat. Unlike a table, this is a mutable property; which may change from step to step.- Specified by:
isFlat
in interfaceReadOnlyIndex
- Returns:
- Whether this index is flat (that is, contiguous from 0 to size - 1)
-
insert
Description copied from interface:Index
Add all of the keys inadded
to this index if they are not already present. -
remove
Description copied from interface:Index
Remove all of the keys inremoved
that are present in this index. -
invert
Description copied from interface:ReadOnlyIndex
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.- Specified by:
invert
in interfaceReadOnlyIndex
- Parameters:
keys
- the keys to find positions for- Returns:
- a new Index containing the positions of the keys in this index
-
invert
The only used implementation of invert is in the TreeIndex, really the guts of it are in BspNodeIndex. This version is inefficient as it simply performs O(keys) find operations; which is O(keys * lg size), because there is no memory about what you've already found. It serves as a reasonable reference for what the invert operation is "meant" to do. Note maximumPosition is inclusive.- Specified by:
invert
in interfaceReadOnlyIndex
- 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
Description copied from interface:ReadOnlyIndex
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- Specified by:
findMissing
in interfaceReadOnlyIndex
- Parameters:
keys
- the keys to identify insertion locations- Returns:
- two TLongArrayLists; [0] contains the positions, [1] contains the counts.
-
toString
-
equals
-
hashCode
public int hashCode() -
updateGroupingOnInsert
protected void updateGroupingOnInsert(long key)On an insertion operation, we clear all of our mappings so that they are not out-of-date. -
updateGroupingOnInsert
protected void updateGroupingOnInsert(LongChunk<Attributes.OrderedKeyIndices> keys, int offset, int length)On an insertion operation, we clear all of our mappings so that they are not out-of-date. -
updateGroupOnInsertRange
protected void updateGroupOnInsertRange(long start, long end)On an insertion operation, we clear all of our mappings so that they are not out-of-date. -
updateGroupingOnRemove
protected void updateGroupingOnRemove(long key)On an insertion operation, we clear all of our mappings so that they are not out-of-date. -
updateGroupingOnRemoveRange
protected void updateGroupingOnRemoveRange(long start, long end)On an insertion operation, we clear all of our mappings so that they are not out-of-date. -
updateGroupingOnRemove
protected void updateGroupingOnRemove(LongChunk<Attributes.OrderedKeyIndices> keys, int offset, int length)On an insertion operation, we clear all of our mappings so that they are not out-of-date. -
updateGroupingOnRetainRange
protected void updateGroupingOnRetainRange(long start, long end) -
updateGroupingOnRetain
-
getGrouping
Description copied from interface:ReadOnlyIndex
Get the current groupings for the specified column- Specified by:
getGrouping
in interfaceReadOnlyIndex
- Parameters:
tupleSource
- the column to find groupings for- Returns:
- the map of groups for the provided index
-
copyImmutableGroupings
- Specified by:
copyImmutableGroupings
in interfaceReadOnlyIndex
-
getGroupingForKeySet
Description copied from interface:ReadOnlyIndex
Return a grouping that contains keys that match the values in keySet.- Specified by:
getGroupingForKeySet
in interfaceReadOnlyIndex
- 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.
-
getSubIndexForKeySet
Description copied from interface:ReadOnlyIndex
Return a subIndex that contains indices that match the values in keySet.- Specified by:
getSubIndexForKeySet
in interfaceReadOnlyIndex
- 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 keyColumn- Returns:
- an Index containing only keys that match keySet.
-
getPrevGrouping
Description copied from interface:ReadOnlyIndex
Get the previous groupings for the specified column- Specified by:
getPrevGrouping
in interfaceReadOnlyIndex
- Parameters:
tupleSource
- the column to find previous groupings for- Returns:
- the map of previous groups for the provided index
-
hasGrouping
Description copied from interface:ReadOnlyIndex
Check if the index contains grouping for the specified key columns.- Specified by:
hasGrouping
in interfaceReadOnlyIndex
- Parameters:
keyColumns
- the keys to find groupings for- Returns:
- true if there are groupings for the specified keys.
-
clearMappings
public void clearMappings()
-