Class TemporalityAccessor

java.lang.Object
org.elasticsearch.compute.aggregation.TemporalityAccessor

public class TemporalityAccessor extends Object
Helper class for efficiently resolving metric temporality (CUMULATIVE or DELTA) from a BytesRefBlock. Optimizes for common access patterns by detecting constant blocks, ordinal-based blocks, or falling back to dynamic per-position lookups.
  • Constructor Details

  • Method Details

    • constant

      public static TemporalityAccessor constant(Temporality constantTemporality)
      Creates an accessor that always returns the given constant temporality.
    • create

      public static TemporalityAccessor create(BytesRefBlock temporalityBlock, Temporality defaultTemporality)
      Creates an accessor for the given temporality block that throws InvalidTemporalityException when an unrecognized temporality value is encountered.
      Parameters:
      temporalityBlock - the block containing temporality values as BytesRef strings ("cumulative" or "delta")
      defaultTemporality - the temporality to use for null values
    • create

      public static TemporalityAccessor create(BytesRefBlock temporalityBlock, Temporality defaultTemporality, Function<org.apache.lucene.util.BytesRef,Temporality> invalidTemporalityHandler)
      Creates an accessor for the given temporality block, automatically selecting the most efficient access mode.
      Parameters:
      temporalityBlock - the block containing temporality values as BytesRef strings ("cumulative" or "delta")
      defaultTemporality - the temporality to use for null values
      invalidTemporalityHandler - called when an unrecognized temporality value is encountered
    • block

      public BytesRefBlock block()
    • get

      public Temporality get(int position)
      Returns the temporality for the given position.