Module org.elasticsearch.server
Class BlockFormat
java.lang.Object
org.elasticsearch.index.codec.tsdb.pipeline.BlockFormat
Defines how each block of encoded values is written to the data file.
Data file layout:
+------------------+----------------------------------------+ | Block 0 | [bitmap][payload][stage metadata] | | Block 1 | [bitmap][payload][stage metadata] | | ... | ... | | Block N-1 | [bitmap][payload][stage metadata] | +------------------+----------------------------------------+ | Block Offsets | DirectMonotonicWriter encoded offsets | +------------------+----------------------------------------+
Each block contains:
- bitmap: 1 byte (
<= 8stages) or 2 bytes (> 8stages) indicating which stages were applied - payload: the encoded values written by the terminal payload stage
- stage metadata: per-stage metadata written by transformation stages (e.g., GCD divisor)
The layout is designed for sequential decoding: the bitmap comes first so the
decoder immediately knows which stages to reverse, followed by the payload and
then stage metadata in reverse stage order (see EncodingContext.writeStageMetadata(org.apache.lucene.store.DataOutput)).
This means the decoder can read every section in a single forward pass with no
seeking or buffering. See FieldDescriptor for the metadata file format
that describes pipeline configuration.
-
Method Summary
Modifier and TypeMethodDescriptionstatic intreadBlock(org.apache.lucene.store.DataInput in, long[] values, PayloadDecoder payloadStage, DecodingContext context, int payloadPosition) Reads a block of encoded values from the data input.static voidwriteBlock(org.apache.lucene.store.DataOutput out, long[] values, PayloadEncoder payloadStage, EncodingContext context) Writes a block of encoded values to the data output.
-
Method Details
-
writeBlock
public static void writeBlock(org.apache.lucene.store.DataOutput out, long[] values, PayloadEncoder payloadStage, EncodingContext context) throws IOException Writes a block of encoded values to the data output.- Parameters:
out- the data output streamvalues- the values to encodepayloadStage- the terminal payload encodercontext- the encoding context with block metadata- Throws:
IOException- if an I/O error occurs
-
readBlock
public static int readBlock(org.apache.lucene.store.DataInput in, long[] values, PayloadDecoder payloadStage, DecodingContext context, int payloadPosition) throws IOException Reads a block of encoded values from the data input.- Parameters:
in- the data input streamvalues- the output array to populatepayloadStage- the terminal payload decodercontext- the decoding context with block metadatapayloadPosition- the pipeline position of the payload stage- Returns:
- the number of values decoded
- Throws:
IOException- if an I/O error occurs
-