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
-
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.RandomBuilder, Index.SequentialBuilder, Index.ShiftInversionHelperNested classes/interfaces inherited from interface com.illumon.iris.db.v2.utils.OrderedKeys
OrderedKeys.IteratorNested classes/interfaces inherited from interface com.illumon.iris.db.v2.utils.ReadOnlyIndex
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_BUILDERFields inherited from interface com.illumon.iris.db.v2.utils.OrderedKeys
EMPTYFields inherited from interface com.illumon.iris.db.v2.utils.ReadOnlyIndex
EMPTY_ITERATOR, NULL_KEY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclone()Create a copy of this index.voidcopyImmutableGroupings(TupleSource source, TupleSource dest) booleangnu.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 themgetGrouping(TupleSource tupleSource) Get the current groupings for the specified columngetGroupingForKeySet(Set<Object> keys, TupleSource tupleSource) Return a grouping that contains keys that match the values in keySet.getPrevGrouping(TupleSource tupleSource) Get the previous groupings for the specified columngetSubIndexForKeySet(Set<Object> keys, TupleSource tupleSource) Return a subIndex that contains indices that match the values in keySet.booleanhasGrouping(ColumnSource... keyColumns) Check if the index contains grouping for the specified key columns.inthashCode()voidinsert(ReadOnlyIndex added) Add all of the keys inaddedto this index if they are not already present.invert(ReadOnlyIndex keys) Returns an Index with the positions of keys in this Index.invert(ReadOnlyIndex keys, long maximumPosition) The only used implementation of invert is in the TreeIndex, really the guts of it are in BspNodeIndex.final booleanisFlat()Returns whether or not this index is flat.final booleanisSorted()protected final voidonClear()protected final voidonInsert(ReadOnlyIndex added) protected final voidonRemove(ReadOnlyIndex removed) protected final voidonRetain(ReadOnlyIndex intersected) protected final voidonUpdate(ReadOnlyIndex added, ReadOnlyIndex removed) voidremove(ReadOnlyIndex removed) Remove all of the keys inremovedthat are present in this index.toString()protected voidupdateGroupingOnInsert(long key) On an insertion operation, we clear all of our mappings so that they are not out-of-date.protected voidupdateGroupingOnInsert(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 voidupdateGroupingOnRemove(long key) On an insertion operation, we clear all of our mappings so that they are not out-of-date.protected voidupdateGroupingOnRemove(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 voidupdateGroupingOnRemoveRange(long start, long end) On an insertion operation, we clear all of our mappings so that they are not out-of-date.protected voidupdateGroupingOnRetain(Index intersected) protected voidupdateGroupingOnRetainRange(long start, long end) protected voidupdateGroupOnInsertRange(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, runsUpperBoundMethods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface com.illumon.iris.db.v2.utils.Index
clear, compact, extract, initializePreviousValue, insert, insert, insertRange, insertWithShift, remove, remove, removeRange, retain, retainRange, shiftInPlace, updateMethods inherited from interface java.lang.Iterable
forEach, iterator, spliteratorMethods inherited from interface com.fishlib.base.log.LogOutputAppendable
appendMethods inherited from interface com.illumon.iris.db.util.LongSizedDataStructure
intSize, intSizeMethods inherited from interface com.illumon.iris.db.v2.utils.OrderedKeys
asIndex, asKeyIndicesChunk, asKeyRangesChunk, fillKeyIndicesChunk, fillKeyRangesChunk, forAllLongRanges, forEachLongRange, getAverageRunLengthEstimate, getOrderedKeysByKeyRange, getOrderedKeysByPosition, getOrderedKeysIterator, isContiguousMethods 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, subindexByPos, subIndexForReversePos, subsetOf, toLongArray, toLongArray, union, validate, validate
-
Constructor Details
-
SortedIndex
public SortedIndex()
-
-
Method Details
-
clone
Description copied from interface:ReadOnlyIndexCreate a copy of this index.- Specified by:
clonein interfaceReadOnlyIndex- Overrides:
clonein classObject- Returns:
- a copy of this index
-
onUpdate
-
onRemove
-
onRetain
-
onInsert
-
onClear
protected final void onClear() -
isSorted
public final boolean isSorted()- Specified by:
isSortedin interfaceReadOnlyIndex
-
isFlat
public final boolean isFlat()Description copied from interface:ReadOnlyIndexReturns whether or not this index is flat. Unlike a table, this is a mutable property; which may change from step to step.- Specified by:
isFlatin interfaceReadOnlyIndex- Returns:
- Whether this index is flat (that is, contiguous from 0 to size - 1)
-
insert
Description copied from interface:IndexAdd all of the keys inaddedto this index if they are not already present. -
remove
Description copied from interface:IndexRemove all of the keys inremovedthat are present in this index. -
invert
Description copied from interface:ReadOnlyIndexReturns 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:
invertin 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:
invertin 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:ReadOnlyIndexFor 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:
findMissingin 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:ReadOnlyIndexGet the current groupings for the specified column- Specified by:
getGroupingin interfaceReadOnlyIndex- Parameters:
tupleSource- the column to find groupings for- Returns:
- the map of groups for the provided index
-
copyImmutableGroupings
- Specified by:
copyImmutableGroupingsin interfaceReadOnlyIndex
-
getGroupingForKeySet
Description copied from interface:ReadOnlyIndexReturn a grouping that contains keys that match the values in keySet.- Specified by:
getGroupingForKeySetin 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:ReadOnlyIndexReturn a subIndex that contains indices that match the values in keySet.- Specified by:
getSubIndexForKeySetin 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:ReadOnlyIndexGet the previous groupings for the specified column- Specified by:
getPrevGroupingin 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:ReadOnlyIndexCheck if the index contains grouping for the specified key columns.- Specified by:
hasGroupingin interfaceReadOnlyIndex- Parameters:
keyColumns- the keys to find groupings for- Returns:
- true if there are groupings for the specified keys.
-
clearMappings
public void clearMappings()
-