Module org.elasticsearch.server
Class OffsetCodecStage
java.lang.Object
org.elasticsearch.index.codec.tsdb.pipeline.numeric.stages.OffsetCodecStage
- All Implemented Interfaces:
NumericCodecStage,TransformDecoder,TransformEncoder
Offset removal transform stage.
Effectiveness
Applied when the minimum value is significant relative to the range. Skipped when:
- The range overflows (
max - min < 0as 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 Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionvoiddecode(long[] values, int valueCount, DecodingContext context) Reverses the transformation on values in-place using metadata from the context.static voiddecodeStatic(OffsetCodecStage stage, long[] values, int valueCount, DecodingContext context) voidencode(long[] values, int valueCount, EncodingContext context) Transforms values in-place and writes any metadata to the context.static voidencodeStatic(OffsetCodecStage stage, long[] values, int valueCount, EncodingContext context) byteid()Returns the unique stage identifier.
-
Field Details
-
INSTANCE
Singleton instance.
-
-
Method Details
-
id
public byte id()Description copied from interface:TransformEncoderReturns the unique stage identifier.- Specified by:
idin interfaceTransformDecoder- Specified by:
idin interfaceTransformEncoder- Returns:
- the stage ID byte
-
encode
Description copied from interface:TransformEncoderTransforms 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:
encodein interfaceTransformEncoder- Parameters:
values- the values to transform in-placevalueCount- the number of valid values in the arraycontext- the encoding context for metadata and stage tracking
-
decode
Description copied from interface:TransformDecoderReverses the transformation on values in-place using metadata from the context.- Specified by:
decodein interfaceTransformDecoder- Parameters:
values- the values to reverse-transform in-placevalueCount- the number of valid values in the arraycontext- 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
-