Module org.elasticsearch.server
Record Class BitPackCodecStage
java.lang.Object
java.lang.Record
org.elasticsearch.index.codec.tsdb.pipeline.numeric.stages.BitPackCodecStage
- Record Components:
forUtil- the utility for encoding and decoding packed values
- All Implemented Interfaces:
PayloadCodecStage,PayloadDecoder,PayloadEncoder
public record BitPackCodecStage(DocValuesForUtil forUtil)
extends Record
implements PayloadCodecStage
Bit-packing terminal payload stage.
Effectiveness
Always applied as the terminal stage. Computes the minimum number of bits
needed to represent the largest value, then packs all values at that bit width
using DocValuesForUtil.
Example
Values [0, 50, 100, 150] need 8 bits per value (max=150), so 128
values are packed into 128 bytes instead of 1024 bytes (raw longs).
Payload layout
Written directly to the data stream as the payload section of the block
(see BlockFormat):
+------------------------+---------------------------------------------+ | VInt(bitsPerValue) | ForUtil packed data | | 1-5 bytes | ceil(blockSize * bitsPerValue / 8) bytes | +------------------------+---------------------------------------------+
The bitsPerValue is rounded by DocValuesForUtil.roundBits(int) to
align with ForUtil's SIMD-friendly block widths. This data is written to the
payload section of the block, not through the metadata buffer. The packed data
size depends on both the bit width and the block size.
-
Constructor Summary
ConstructorsConstructorDescriptionBitPackCodecStage(DocValuesForUtil forUtil) Creates an instance of aBitPackCodecStagerecord class. -
Method Summary
Modifier and TypeMethodDescriptionintdecode(long[] values, org.apache.lucene.store.DataInput in, DecodingContext context) Deserializes bytes from the input stream back to values.voidencode(long[] values, int valueCount, org.apache.lucene.store.DataOutput out, EncodingContext context) Serializes values to the output stream.final booleanIndicates whether some other object is "equal to" this one.forUtil()Returns the value of theforUtilrecord component.final inthashCode()Returns a hash code value for this object.byteid()Returns the unique stage identifier.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
BitPackCodecStage
Creates an instance of aBitPackCodecStagerecord class.- Parameters:
forUtil- the value for theforUtilrecord component
-
-
Method Details
-
id
public byte id()Description copied from interface:PayloadEncoderReturns the unique stage identifier.- Specified by:
idin interfacePayloadDecoder- Specified by:
idin interfacePayloadEncoder- Returns:
- the stage ID byte
-
encode
public void encode(long[] values, int valueCount, org.apache.lucene.store.DataOutput out, EncodingContext context) throws IOException Description copied from interface:PayloadEncoderSerializes values to the output stream.- Specified by:
encodein interfacePayloadEncoder- Parameters:
values- the values to encodevalueCount- the number of valid values in the arrayout- the data output streamcontext- the encoding context with block metadata- Throws:
IOException- if an I/O error occurs
-
decode
public int decode(long[] values, org.apache.lucene.store.DataInput in, DecodingContext context) throws IOException Description copied from interface:PayloadDecoderDeserializes bytes from the input stream back to values.- Specified by:
decodein interfacePayloadDecoder- Parameters:
values- the output array to populatein- the data input streamcontext- the decoding context with block metadata- Returns:
- the number of values decoded
- Throws:
IOException- if an I/O error occurs
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
forUtil
Returns the value of theforUtilrecord component.- Returns:
- the value of the
forUtilrecord component
-