Class ShiftedOrderedKeys
- All Implemented Interfaces:
LongSizedDataStructure,OrderedKeys,SafeCloseable,AutoCloseable
-
Field Summary
Fields inherited from interface com.illumon.iris.db.v2.utils.OrderedKeys
EMPTY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionasIndex()Get anIndexrepresentation of thisOrderedKeys.final voidclear()voidclose()Free any resources associated with this object.voidfillKeyIndicesChunk(WritableLongChunk<? extends Attributes.KeyIndices> chunkToFill) Fill the suppliedWritableLongChunkwith individual keys from thisOrderedKeys.voidfillKeyRangesChunk(WritableLongChunk<Attributes.OrderedKeyRanges> chunkToFill) Fill the suppliedWritableLongChunkwith key ranges from thisOrderedKeys.longfirstKey()Get the first key in thisOrderedKeys.voidvoidbooleanforEachLong(LongAbortableConsumer consumer) For as long as the consumer wants more keys, call accept on the consumer with the individual key instances in this OrderedKeys, in increasing order.booleanforEachLongRange(LongRangeAbortableConsumer consumer) For as long as the consumer wants more ranges, call accept on the consumer with the individual key ranges in this OrderedKeys, in increasing order.longGet an estimate of the average (mean) length of runs of adjacent keys in thisOrderedKeys.getOrderedKeysByKeyRange(long startKeyInclusive, long endKeyInclusive) Get an ordered subset of the keys in thisOrderedKeysfor a key range.getOrderedKeysByPosition(long startPositionInclusive, long length) Get an ordered subset of the keys in thisOrderedKeysfor a position range.com.illumon.iris.db.v2.utils.ShiftedOrderedKeys.IteratorGet anOrderedKeys.Iteratorover thisOrderedKeys.booleanisEmpty()True if the size of thisOrderedkeysis zero.longlastKey()Get the last key in thisOrderedKeys.longvoidreset(OrderedKeys toWrap, long shiftAmount) longsize()Get the number of keys in thisOrderedKeys.static OrderedKeyswrap(OrderedKeys toWrap, long shiftAmount) Methods inherited from class com.illumon.iris.db.v2.utils.OrderedKeysAsChunkImpl
asKeyIndicesChunk, asKeyRangesChunk, closeOrderedKeysAsChunkImpl, invalidateOrderedKeysAsChunkImpl, runsUpperBoundMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.illumon.iris.db.util.LongSizedDataStructure
intSize, intSizeMethods inherited from interface com.illumon.iris.db.v2.utils.OrderedKeys
asKeyIndicesChunk, asKeyRangesChunk, isContiguous
-
Constructor Details
-
ShiftedOrderedKeys
public ShiftedOrderedKeys()
-
-
Method Details
-
wrap
-
reset
-
clear
public final void clear() -
getOrderedKeysIterator
public com.illumon.iris.db.v2.utils.ShiftedOrderedKeys.Iterator getOrderedKeysIterator()Description copied from interface:OrderedKeysGet anOrderedKeys.Iteratorover thisOrderedKeys.- Specified by:
getOrderedKeysIteratorin interfaceOrderedKeys- Returns:
- A new iterator, positioned at the first key
-
getOrderedKeysByPosition
Description copied from interface:OrderedKeysGet an ordered subset of the keys in this
OrderedKeysfor a position range. The result will contain the set of keys inthisthat lie at positions in the half-open range [startPositionInclusive,startPositionInclusive + length). The returned reference is owned by the caller, who should callclose()when it is done with it.- Specified by:
getOrderedKeysByPositionin interfaceOrderedKeys- Parameters:
startPositionInclusive- The position of the first key to includelength- The number of keys to include- Returns:
- The subset as an
OrderedKeys, which may bethis
-
getOrderedKeysByKeyRange
Description copied from interface:OrderedKeysGet an ordered subset of the keys in this
OrderedKeysfor a key range. The returned set will be the intersection of the keys inthiswith the keys in the closed interval [startKeyInclusive,endKeyInclusive]. The returned reference is owned by the caller, who should callclose()when it is done with it.- Specified by:
getOrderedKeysByKeyRangein interfaceOrderedKeys- Parameters:
startKeyInclusive- The minimum key to includeendKeyInclusive- The maximum key to include- Returns:
- The subset as an
OrderedKeys, which may bethis
-
asIndex
Description copied from interface:OrderedKeysGet anIndexrepresentation of thisOrderedKeys.- Specified by:
asIndexin interfaceOrderedKeys- Returns:
- An
Indexrepresentation for the same keys in the same order
-
fillKeyIndicesChunk
Description copied from interface:OrderedKeysFill the supplied
WritableLongChunkwith individual keys from thisOrderedKeys.The chunk's capacity is assumed to be big enough.
- Specified by:
fillKeyIndicesChunkin interfaceOrderedKeys- Parameters:
chunkToFill- A chunk to fill with individual keys
-
fillKeyRangesChunk
Description copied from interface:OrderedKeysFill the supplied
WritableLongChunkwith key ranges from thisOrderedKeys.The chunk's capacity is assumed to be big enough.
- Specified by:
fillKeyRangesChunkin interfaceOrderedKeys- Parameters:
chunkToFill- A chunk to fill with key ranges
-
isEmpty
public boolean isEmpty()Description copied from interface:OrderedKeysTrue if the size of thisOrderedkeysis zero.- Specified by:
isEmptyin interfaceOrderedKeys- Returns:
- True if there are no elements in this
OrderedKeys.
-
firstKey
public long firstKey()Description copied from interface:OrderedKeysGet the first key in thisOrderedKeys.- Specified by:
firstKeyin interfaceOrderedKeys- Returns:
- The first key, or
ReadOnlyIndex.NULL_KEYif there is none.
-
lastKey
public long lastKey()Description copied from interface:OrderedKeysGet the last key in thisOrderedKeys.- Specified by:
lastKeyin interfaceOrderedKeys- Specified by:
lastKeyin classOrderedKeysAsChunkImpl- Returns:
- The last key, or
ReadOnlyIndex.NULL_KEYif there is none.
-
size
public long size()Description copied from interface:OrderedKeysGet the number of keys in thisOrderedKeys.- Specified by:
sizein interfaceLongSizedDataStructure- Specified by:
sizein interfaceOrderedKeys- Returns:
- The size, in [0,
Long.MAX_VALUE]
-
getAverageRunLengthEstimate
public long getAverageRunLengthEstimate()Description copied from interface:OrderedKeysGet an estimate of the average (mean) length of runs of adjacent keys in this
OrderedKeys.Implementations should strive to keep this method efficient (O(1) preferred) at the expense of accuracy.
Empty
OrderedKeysshould return an arbitrary valid value, usually 1.- Specified by:
getAverageRunLengthEstimatein interfaceOrderedKeys- Returns:
- An estimate of the average run length in this
OrderedKeys, in [1,size()]
-
forEachLong
Description copied from interface:OrderedKeysFor as long as the consumer wants more keys, call accept on the consumer with the individual key instances in this OrderedKeys, in increasing order.- Specified by:
forEachLongin interfaceOrderedKeys- Parameters:
consumer- a consumer to feed the individual key values to.- Returns:
- false if the consumer provided ever returned false, true otherwise.
-
forEachLongRange
Description copied from interface:OrderedKeysFor as long as the consumer wants more ranges, call accept on the consumer with the individual key ranges in this OrderedKeys, in increasing order.- Specified by:
forEachLongRangein interfaceOrderedKeys- Parameters:
consumer- a consumer to feed the individual key values to.- Returns:
- false if the consumer provided ever returned false, true otherwise.
-
forAllLongs
- Specified by:
forAllLongsin interfaceOrderedKeys
-
forAllLongRanges
- Specified by:
forAllLongRangesin interfaceOrderedKeys
-
close
public void close()Description copied from interface:OrderedKeysFree any resources associated with this object.
Using any
OrderedKeysmethods afterclose()is an error and may produce exceptions or undefined results.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceOrderedKeys- Specified by:
closein interfaceSafeCloseable- Overrides:
closein classOrderedKeysAsChunkImpl
-
rangesCountUpperBound
public long rangesCountUpperBound()- Specified by:
rangesCountUpperBoundin classOrderedKeysAsChunkImpl
-