java.lang.Object
org.elasticsearch.index.codec.tsdb.pipeline.numeric.stages.OffsetCodecStage
All Implemented Interfaces:
NumericCodecStage, TransformDecoder, TransformEncoder

public final class OffsetCodecStage extends Object implements NumericCodecStage
Offset removal transform stage.

Effectiveness

Applied when the minimum value is significant relative to the range. Skipped when:

  • The range overflows (max - min < 0 as unsigned)
  • The minimum is already zero
  • The absolute minimum is small relative to the absolute maximum (|min| < |max| >>> 2, compared unsigned)

Example

Values [1000, 1050, 1100, 1150] with min=1000 produces [0, 50, 100, 150].

Metadata layout

Written to the stage metadata section (see BlockFormat):

   +---------------------+
   | ZLong(min)          |  1-10 bytes, zigzag-encoded minimum value
   +---------------------+
 

Zigzag encoding is used because the minimum can be negative (e.g., after a preceding delta stage produces negative deltas for a descending sequence).

  • Field Details

  • Method Details

    • id

      public byte id()
      Description copied from interface: TransformEncoder
      Returns the unique stage identifier.
      Specified by:
      id in interface TransformDecoder
      Specified by:
      id in interface TransformEncoder
      Returns:
      the stage ID byte
    • encode

      public void encode(long[] values, int valueCount, EncodingContext context)
      Description copied from interface: TransformEncoder
      Transforms values in-place and writes any metadata to the context.

      If the stage determines that the transformation would not be effective, it may return without modifying the values or writing metadata. The pipeline checks EncodingContext.isStageApplied(int) to detect this.

      Specified by:
      encode in interface TransformEncoder
      Parameters:
      values - the values to transform in-place
      valueCount - the number of valid values in the array
      context - the encoding context for metadata and stage tracking
    • decode

      public void decode(long[] values, int valueCount, DecodingContext context) throws IOException
      Description copied from interface: TransformDecoder
      Reverses the transformation on values in-place using metadata from the context.
      Specified by:
      decode in interface TransformDecoder
      Parameters:
      values - the values to reverse-transform in-place
      valueCount - the number of valid values in the array
      context - the decoding context for reading stage metadata
      Throws:
      IOException - if an I/O error occurs while reading metadata
    • encodeStatic

      public static void encodeStatic(OffsetCodecStage stage, long[] values, int valueCount, EncodingContext context) throws IOException
      Throws:
      IOException
    • decodeStatic

      public static void decodeStatic(OffsetCodecStage stage, long[] values, int valueCount, DecodingContext context) throws IOException
      Throws:
      IOException