Module org.elasticsearch.compute
Class LongBytesRefAdaptiveBlockHash
java.lang.Object
org.elasticsearch.compute.aggregation.blockhash.BlockHash
org.elasticsearch.compute.aggregation.blockhash.LongBytesRefAdaptiveBlockHash
- All Implemented Interfaces:
Closeable,AutoCloseable,SeenGroupIds,Releasable
An
AdaptiveBlockHash for the two-key (LONG, BYTES_REF) (or (BYTES_REF, LONG))
grouping shape. As long as both inputs arrive as vectors, it routes through a dictionary-aware fast
path: BytesRefBlockHash hashes the bytes column once (so for an OrdinalBytesRefVector
it pays per dictionary entry, not per row), and a LongLongHashTable combines
(bytesRefOrd, longKey) into a stable group id. As soon as a page brings a non-vector key
column (i.e. nulls or multivalues are possible), it migrates to a PackedValuesBlockHash —
which has correct null/MV semantics — and replays existing groups so ordinals stay stable.
Modeled after LongIntAdaptiveBlockHash. The migration encoding is variable-width because
the BYTES_REF column has no fixed size; everything else is the same.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.elasticsearch.compute.aggregation.blockhash.BlockHash
BlockHash.CategorizeDef, BlockHash.GroupSpec, BlockHash.SortKey, BlockHash.TopNDefNested classes/interfaces inherited from interface org.elasticsearch.compute.aggregation.SeenGroupIds
SeenGroupIds.Empty, SeenGroupIds.Range -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected BlockHashprotected final intprotected final List<BlockHash.GroupSpec> Fields inherited from class org.elasticsearch.compute.aggregation.blockhash.BlockHash
blockFactory -
Constructor Summary
ConstructorsConstructorDescriptionLongBytesRefAdaptiveBlockHash(List<BlockHash.GroupSpec> specs, BlockFactory blockFactory, int emitBatchSize, boolean reverseOutput) -
Method Summary
Modifier and TypeMethodDescriptionfinal voidadd(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.voidclose()final Block[]Returns an array ofBlocks containing keys.final 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.booleanWhether this hash has migrated off the dictionary-aware vector-only fast path ontoPackedValuesBlockHash.final IntVectornonEmpty()The grouping ids that are not empty.final intnumKeys()The number of unique keys in the hash.protected voidprepareAddInput(Page page) Prepare the delegate block hash to add input from the given page.protected voidprepareForLookup(Page page) Prepare the delegate block hash for a lookup on the given page.final BitArrayseenGroupIds(BigArrays bigArrays) The grouping ids that have been seen already.toString()Methods inherited from class org.elasticsearch.compute.aggregation.blockhash.BlockHash
build, buildCategorizeBlockHash, buildPackedValuesBlockHash, hashOrdToGroup, hashOrdToGroupNullReserved
-
Field Details
-
specs
-
emitBatchSize
protected final int emitBatchSize -
current
-
-
Constructor Details
-
LongBytesRefAdaptiveBlockHash
public LongBytesRefAdaptiveBlockHash(List<BlockHash.GroupSpec> specs, BlockFactory blockFactory, int emitBatchSize, boolean reverseOutput)
-
-
Method Details
-
prepareAddInput
Prepare the delegate block hash to add input from the given page. -
prepareForLookup
Prepare the delegate block hash for a lookup on the given page. -
migratedToPackedHash
public boolean migratedToPackedHash()Whether this hash has migrated off the dictionary-aware vector-only fast path ontoPackedValuesBlockHash. Once migrated, the hash never goes back. Intended for tests that need to pin "the fast path actually fired end-to-end" without scrapingObject.toString(). -
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
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 final 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
-
close
public void close() -
toString
-