Class SortedRangesOrderedKeys
- All Implemented Interfaces:
LongSizedDataStructure
,OrderedKeys
,SafeCloseable
,AutoCloseable
-
Field Summary
Fields inherited from interface com.illumon.iris.db.v2.utils.OrderedKeys
EMPTY
-
Method Summary
Modifier and TypeMethodDescriptionasIndex()
Get anIndex
representation of thisOrderedKeys
.void
close()
Free any resources associated with this object.protected final void
void
fillKeyIndicesChunk
(WritableLongChunk<? extends Attributes.KeyIndices> chunkToFill) Fill the suppliedWritableLongChunk
with individual keys from thisOrderedKeys
.void
fillKeyRangesChunk
(WritableLongChunk<Attributes.OrderedKeyRanges> chunkToFill) Fill the suppliedWritableLongChunk
with key ranges from thisOrderedKeys
.long
firstKey()
Get the first key in thisOrderedKeys
.boolean
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.boolean
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.long
Get an estimate of the average (mean) length of runs of adjacent keys in thisOrderedKeys
.getOrderedKeysByKeyRange
(long start, long end) Get an ordered subset of the keys in thisOrderedKeys
for a key range.getOrderedKeysByPosition
(long pos, long length) Get an ordered subset of the keys in thisOrderedKeys
for a position range.com.illumon.iris.db.v2.utils.sortedranges.SortedRangesOrderedKeys.Iterator
Get anOrderedKeys.Iterator
over thisOrderedKeys
.boolean
isEmpty()
True if the size of thisOrderedkeys
is zero.long
lastKey()
Get the last key in thisOrderedKeys
.long
long
size()
Get the number of keys in thisOrderedKeys
.void
validate()
Methods inherited from class com.illumon.iris.db.v2.utils.OrderedKeysAsChunkImpl
asKeyIndicesChunk, asKeyRangesChunk, closeOrderedKeysAsChunkImpl, invalidateOrderedKeysAsChunkImpl, runsUpperBound
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.illumon.iris.db.util.LongSizedDataStructure
intSize, intSize
Methods inherited from interface com.illumon.iris.db.v2.utils.OrderedKeys
forAllLongRanges, forAllLongs, isContiguous
-
Method Details
-
close
public void close()Description copied from interface:OrderedKeys
Free any resources associated with this object.
Using any
OrderedKeys
methods afterclose()
is an error and may produce exceptions or undefined results.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceOrderedKeys
- Specified by:
close
in interfaceSafeCloseable
- Overrides:
close
in classOrderedKeysAsChunkImpl
-
closeSortedArrayOrderedKeys
protected final void closeSortedArrayOrderedKeys() -
getOrderedKeysIterator
public com.illumon.iris.db.v2.utils.sortedranges.SortedRangesOrderedKeys.Iterator getOrderedKeysIterator()Description copied from interface:OrderedKeys
Get anOrderedKeys.Iterator
over thisOrderedKeys
.- Returns:
- A new iterator, positioned at the first key
-
getOrderedKeysByPosition
Description copied from interface:OrderedKeys
Get an ordered subset of the keys in this
OrderedKeys
for a position range. The result will contain the set of keys inthis
that 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.- Parameters:
pos
- 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:OrderedKeys
Get an ordered subset of the keys in this
OrderedKeys
for a key range. The returned set will be the intersection of the keys inthis
with 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.- Parameters:
start
- The minimum key to includeend
- The maximum key to include- Returns:
- The subset as an
OrderedKeys
, which may bethis
-
asIndex
Description copied from interface:OrderedKeys
Get anIndex
representation of thisOrderedKeys
.- Returns:
- An
Index
representation for the same keys in the same order
-
fillKeyIndicesChunk
Description copied from interface:OrderedKeys
Fill the supplied
WritableLongChunk
with individual keys from thisOrderedKeys
.The chunk's capacity is assumed to be big enough.
- Parameters:
chunkToFill
- A chunk to fill with individual keys
-
fillKeyRangesChunk
Description copied from interface:OrderedKeys
Fill the supplied
WritableLongChunk
with key ranges from thisOrderedKeys
.The chunk's capacity is assumed to be big enough.
- Parameters:
chunkToFill
- A chunk to fill with key ranges
-
isEmpty
public boolean isEmpty()Description copied from interface:OrderedKeys
True if the size of thisOrderedkeys
is zero.- Returns:
- True if there are no elements in this
OrderedKeys
.
-
firstKey
public long firstKey()Description copied from interface:OrderedKeys
Get the first key in thisOrderedKeys
.- Returns:
- The first key, or
ReadOnlyIndex.NULL_KEY
if there is none.
-
lastKey
public long lastKey()Description copied from interface:OrderedKeys
Get the last key in thisOrderedKeys
.- Specified by:
lastKey
in interfaceOrderedKeys
- Specified by:
lastKey
in classOrderedKeysAsChunkImpl
- Returns:
- The last key, or
ReadOnlyIndex.NULL_KEY
if there is none.
-
size
public long size()Description copied from interface:OrderedKeys
Get the number of keys in thisOrderedKeys
.- Returns:
- The size, in [0,
Long.MAX_VALUE
]
-
getAverageRunLengthEstimate
public long getAverageRunLengthEstimate()Description copied from interface:OrderedKeys
Get 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
OrderedKeys
should return an arbitrary valid value, usually 1.- Returns:
- An estimate of the average run length in this
OrderedKeys
, in [1,size()
]
-
forEachLong
Description copied from interface:OrderedKeys
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.- Parameters:
lac
- 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:OrderedKeys
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.- Parameters:
lrac
- a consumer to feed the individual key values to.- Returns:
- false if the consumer provided ever returned false, true otherwise.
-
rangesCountUpperBound
public long rangesCountUpperBound()- Specified by:
rangesCountUpperBound
in classOrderedKeysAsChunkImpl
-
validate
public void validate()
-