Class DeltaCodecStage
- All Implemented Interfaces:
NumericCodecStage,TransformDecoder,TransformEncoder
Effectiveness
Applied only when the sequence is monotonic (at least 2 increases with 0 decreases, or at least 2 decreases with 0 increases). Non-monotonic or constant sequences are skipped because deltas would not reduce the dynamic range.
Example
Monotonic ascending [100, 200, 350, 500] produces deltas [100, 150, 150]
with first value 100 stored as metadata.
Metadata layout
Written to the stage metadata section (see BlockFormat):
+---------------------+ | ZLong(first) | 1-10 bytes, zigzag-encoded first value +---------------------+
Zigzag encoding ensures small absolute values (both positive and negative) use few bytes, which is typical for the starting point of a monotonic 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(DeltaCodecStage 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(DeltaCodecStage 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(DeltaCodecStage stage, long[] values, int valueCount, EncodingContext context) throws IOException - Throws:
IOException
-
decodeStatic
public static void decodeStatic(DeltaCodecStage stage, long[] values, int valueCount, DecodingContext context) throws IOException - Throws:
IOException
-