Module org.elasticsearch.compute
Class TimeSeriesBlockHash
java.lang.Object
org.elasticsearch.compute.aggregation.blockhash.BlockHash
org.elasticsearch.compute.aggregation.blockhash.TimeSeriesBlockHash
- All Implemented Interfaces:
Closeable,AutoCloseable,SeenGroupIds,org.elasticsearch.core.Releasable
An optimized block hash that receives two blocks: tsid and timestamp, which are sorted.
Since the incoming data is sorted, this block hash checks tsid ordinals to avoid redundant
hash lookups for consecutive positions with the same tsid and timestamp.
Delegates to a
BytesRefLongBlockHash for the actual hashing.-
Nested Class Summary
Nested classes/interfaces inherited from class org.elasticsearch.compute.aggregation.blockhash.BlockHash
BlockHash.CategorizeDef, BlockHash.GroupSpec, BlockHash.TopNDefNested classes/interfaces inherited from interface org.elasticsearch.compute.aggregation.SeenGroupIds
SeenGroupIds.Empty, SeenGroupIds.Range -
Field Summary
Fields inherited from class org.elasticsearch.compute.aggregation.blockhash.BlockHash
blockFactory -
Constructor Summary
ConstructorsConstructorDescriptionTimeSeriesBlockHash(int tsidChannel, int timestampChannel, boolean reverseOutput, boolean trackTimestamp, BlockFactory blockFactory) -
Method Summary
Modifier and TypeMethodDescriptionvoidadd(Page page, GroupingAggregatorFunction.AddInput addInput) Add all values for the "group by" columns in the page to the hash and pass the ordinals to the providedGroupingAggregatorFunction.AddInput.longaddExtraGroup(int tsid, long timestamp) voidclose()longgetGroupId(long tsid, long timestamp) Block[]Returns an array ofBlocks containing keys.org.elasticsearch.core.ReleasableIterator<IntBlock> lookup(Page page, ByteSizeValue targetBlockSize) Lookup all values for the "group by" columns in the page to the hash and return anIteratorof the values.longlongnonEmpty()The grouping ids that are not empty.longintnumKeys()The number of unique keys in the hash.seenGroupIds(BigArrays bigArrays) The grouping ids that have been seen already.longtimestampForGroup(long groupId) toString()inttsidForGroup(long groupId) Methods inherited from class org.elasticsearch.compute.aggregation.blockhash.BlockHash
build, buildCategorizeBlockHash, buildPackedValuesBlockHash, hashOrdToGroup, hashOrdToGroupNullReserved
-
Constructor Details
-
TimeSeriesBlockHash
public TimeSeriesBlockHash(int tsidChannel, int timestampChannel, boolean reverseOutput, boolean trackTimestamp, BlockFactory blockFactory)
-
-
Method Details
-
close
public void close() -
add
Description copied from class:BlockHashAdd all values for the "group by" columns in the page to the hash and pass the ordinals to the providedGroupingAggregatorFunction.AddInput.This call will not
Releasable.close()addInput. -
lookup
public org.elasticsearch.core.ReleasableIterator<IntBlock> lookup(Page page, ByteSizeValue targetBlockSize) Description copied from class:BlockHashLookup all values for the "group by" columns in the page to the hash and return anIteratorof the values. The sum ofBlock.getPositionCount()for all blocks returned by the iterator will equalPage.getPositionCount()but will "target" a size oftargetBlockSize.The returned
ReleasableIteratormay retain a reference toBlocks inside thePage. Close it to release those references. -
getKeys
Description copied from class:BlockHashReturns an array ofBlocks containing keys.- Specified by:
getKeysin classBlockHash- Parameters:
selected- The groupIds to include in the results. These are the same groupIds returned byBlockHash.nonEmpty()and fed into aggregations as part ofBlockHash.add(org.elasticsearch.compute.data.Page, org.elasticsearch.compute.aggregation.GroupingAggregatorFunction.AddInput).
-
nonEmpty
Description copied from class:BlockHashThe grouping ids that are not empty. We use this because some block hashes reserve space for grouping ids and then don't end up using them. For example,BooleanBlockHashdoes this by always assigningfalseto0andtrueto1. It's only after collection when we know if there actually were anytrueorfalsevalues received. -
numKeys
public int numKeys()Description copied from class:BlockHashThe number of unique keys in the hash. -
seenGroupIds
Description copied from interface:SeenGroupIdsThe grouping ids that have been seen already. ThisBitArrayis kept and mutated by the caller so make a copy if it's something you need your own copy of it.- Specified by:
seenGroupIdsin interfaceSeenGroupIds- Specified by:
seenGroupIdsin classBlockHash
-
tsidForGroup
public int tsidForGroup(long groupId) -
timestampForGroup
public long timestampForGroup(long groupId) -
getGroupId
public long getGroupId(long tsid, long timestamp) -
addExtraGroup
public long addExtraGroup(int tsid, long timestamp) -
numGroups
public long numGroups() -
minTimestamp
public long minTimestamp() -
maxTimestamp
public long maxTimestamp() -
toString
-