Module org.elasticsearch.server
Class LongKeyedBucketOrds
java.lang.Object
org.elasticsearch.search.aggregations.bucket.terms.LongKeyedBucketOrds
- All Implemented Interfaces:
Closeable
,AutoCloseable
,Releasable
- Direct Known Subclasses:
LongKeyedBucketOrds.FromMany
,LongKeyedBucketOrds.FromManySmall
,LongKeyedBucketOrds.FromSingle
Maps owning bucket ordinals and long bucket keys to bucket ordinals.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
An iterator for buckets inside a particularowningBucketOrd
.static class
Implementation that works properly when collecting from many buckets.static class
Implementation that packs theowningbucketOrd
into the top bits of along
and uses the bottom bits for the value.static class
Implementation that only works if it is collecting from a single bucket. -
Method Summary
Modifier and TypeMethodDescriptionabstract long
add
(long owningBucketOrd, long value) Add theowningBucketOrd, value
pair.abstract long
bucketsInOrd
(long owningBucketOrd) Count the buckets inowningBucketOrd
.static LongKeyedBucketOrds
build
(BigArrays bigArrays, CardinalityUpperBound cardinality) Build aLongKeyedBucketOrds
who's values have unknown bounds.static LongKeyedBucketOrds
buildForValueRange
(BigArrays bigArrays, CardinalityUpperBound cardinality, long min, long max) Build aLongKeyedBucketOrds
who's values have known bounds.void
close()
abstract String
decribe()
Description used in profile results.abstract long
find
(long owningBucketOrd, long value) Find theowningBucketOrd, value
pair.abstract long
get
(long ordinal) Returns the value currently associated with the bucket ordinal.keyOrderedIterator
(long owningBucketOrd) Return an iterator for all keys in the given owning bucket, ordered in natural sort order.abstract long
The maximum possible usedowningBucketOrd
.abstract LongKeyedBucketOrds.BucketOrdsEnum
ordsEnum
(long owningBucketOrd) Build an iterator for buckets insideowningBucketOrd
in order of increasing ord.abstract long
size()
The number of collected buckets.
-
Method Details
-
build
Build aLongKeyedBucketOrds
who's values have unknown bounds.- Parameters:
cardinality
- - This should come from the owning aggregation, and is used as an upper bound on the owning bucket ordinals.
-
buildForValueRange
public static LongKeyedBucketOrds buildForValueRange(BigArrays bigArrays, CardinalityUpperBound cardinality, long min, long max) Build aLongKeyedBucketOrds
who's values have known bounds.- Parameters:
cardinality
- - This should come from the owning aggregation, and is used as an upper bound on the owning bucket ordinals.min
- - The minimum key value for this aggregationmax
- - The maximum key value for this aggregation
-
add
public abstract long add(long owningBucketOrd, long value) Add theowningBucketOrd, value
pair. Return the ord for their bucket if they have yet to be added, or-1-ord
if they were already present. -
bucketsInOrd
public abstract long bucketsInOrd(long owningBucketOrd) Count the buckets inowningBucketOrd
.Some aggregations expect this to be fast but most wouldn't mind particularly if it weren't.
-
find
public abstract long find(long owningBucketOrd, long value) Find theowningBucketOrd, value
pair. Return the ord for their bucket if they have been added or-1
if they haven't. -
get
public abstract long get(long ordinal) Returns the value currently associated with the bucket ordinal. -
size
public abstract long size()The number of collected buckets. -
maxOwningBucketOrd
public abstract long maxOwningBucketOrd()The maximum possible usedowningBucketOrd
. -
decribe
Description used in profile results. -
ordsEnum
Build an iterator for buckets insideowningBucketOrd
in order of increasing ord.When this is first returns it is "unpositioned" and you must call
LongKeyedBucketOrds.BucketOrdsEnum.next()
to move it to the first value. -
keyOrderedIterator
Return an iterator for all keys in the given owning bucket, ordered in natural sort order. This is suitable for aligning buckets across different instances of an aggregation.- Parameters:
owningBucketOrd
- Only return keys that occured under this owning bucket- Returns:
- a sorted iterator of long key values
-
close
public void close()- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in interfaceReleasable
-