Module org.elasticsearch.server
Class DecodingContext
java.lang.Object
org.elasticsearch.index.codec.tsdb.pipeline.DecodingContext
- All Implemented Interfaces:
MetadataReader
Mutable per-block context for decoding, tracking the position bitmap and
delegating metadata reads to the underlying
DataInput. Reused
across blocks via clear().-
Constructor Summary
ConstructorsConstructorDescriptionDecodingContext(int blockSize, int pipelineLength) Creates a decoding context. -
Method Summary
Modifier and TypeMethodDescriptionintReturns the block size.voidclear()Resets this context for reuse with the next block.booleanisStageApplied(int position) Returnstrueif the stage at the given position was applied.metadata()Returns the metadata reader for accessing stage metadata.intReturns the number of stages in the pipeline.bytereadByte()Reads a single byte.voidreadBytes(byte[] bytes, int offset, int length) Reads bytes into the given array.intreadInt()Reads a fixed 4-byte integer in Lucene format.longreadLong()Reads a fixed 8-byte long in Lucene format.intreadVInt()Reads a variable-length integer.longReads a variable-length long.intreadZInt()Reads a zigzag-encoded variable-length integer.longReads a zigzag-encoded variable-length long.voidsetDataInput(org.apache.lucene.store.DataInput dataInput) Sets the data input stream for reading block data and stage metadata.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.elasticsearch.index.codec.tsdb.pipeline.MetadataReader
readBytes
-
Constructor Details
-
DecodingContext
public DecodingContext(int blockSize, int pipelineLength) Creates a decoding context.- Parameters:
blockSize- the number of values per blockpipelineLength- the number of stages in the pipeline
-
-
Method Details
-
setDataInput
public void setDataInput(org.apache.lucene.store.DataInput dataInput) Sets the data input stream for reading block data and stage metadata.- Parameters:
dataInput- the data input stream
-
pipelineLength
public int pipelineLength()Returns the number of stages in the pipeline.- Returns:
- the pipeline length
-
isStageApplied
public boolean isStageApplied(int position) Returnstrueif the stage at the given position was applied.- Parameters:
position- the zero-based stage index- Returns:
- whether the stage was applied
-
metadata
Returns the metadata reader for accessing stage metadata.- Returns:
- the metadata reader
-
blockSize
public int blockSize()Returns the block size.- Returns:
- the number of values per block
-
clear
public void clear()Resets this context for reuse with the next block.NOTE: dataInput is intentionally nulled. Unlike EncodingContext which owns its MetadataBuffer, DecodingContext does not own the DataInput (it is injected). Nulling forces the caller to provide a fresh DataInput via
setDataInput(org.apache.lucene.store.DataInput)before each block, which is a fail-fast against silently reading garbage from a stale stream. -
readByte
Description copied from interface:MetadataReaderReads a single byte.- Specified by:
readBytein interfaceMetadataReader- Returns:
- the byte value
- Throws:
IOException- if an I/O error occurs
-
readZInt
Description copied from interface:MetadataReaderReads a zigzag-encoded variable-length integer.- Specified by:
readZIntin interfaceMetadataReader- Returns:
- the decoded integer
- Throws:
IOException- if an I/O error occurs
-
readZLong
Description copied from interface:MetadataReaderReads a zigzag-encoded variable-length long.- Specified by:
readZLongin interfaceMetadataReader- Returns:
- the decoded long
- Throws:
IOException- if an I/O error occurs
-
readLong
Description copied from interface:MetadataReaderReads a fixed 8-byte long in Lucene format.- Specified by:
readLongin interfaceMetadataReader- Returns:
- the long value
- Throws:
IOException- if an I/O error occurs
-
readInt
Description copied from interface:MetadataReaderReads a fixed 4-byte integer in Lucene format.- Specified by:
readIntin interfaceMetadataReader- Returns:
- the integer value
- Throws:
IOException- if an I/O error occurs
-
readVInt
Description copied from interface:MetadataReaderReads a variable-length integer.- Specified by:
readVIntin interfaceMetadataReader- Returns:
- the decoded integer
- Throws:
IOException- if an I/O error occurs
-
readVLong
Description copied from interface:MetadataReaderReads a variable-length long.- Specified by:
readVLongin interfaceMetadataReader- Returns:
- the decoded long
- Throws:
IOException- if an I/O error occurs
-
readBytes
Description copied from interface:MetadataReaderReads bytes into the given array.- Specified by:
readBytesin interfaceMetadataReader- Parameters:
bytes- the destination arrayoffset- the offset in the arraylength- the number of bytes to read- Throws:
IOException- if an I/O error occurs
-