Interface MetadataWriter
This is a dedicated interface rather than Lucene's DataOutput or Elasticsearch's
StreamOutput because the block layout places stage metadata after the payload
on disk ([bitmap][payload][stage metadata]), while transform stages produce metadata
before the payload during encoding. The encode pipeline buffers metadata in memory
and flushes it after the payload is written (see EncodingContext.writeStageMetadata(org.apache.lucene.store.DataOutput)).
This design favors the decode path: the decoder reads bitmap, payload, then metadata in a single forward pass with no buffering or seeking. Since decoding is far more frequent than encoding, the buffering cost is pushed to the encode side (once per block).
By decoupling stages from the buffering strategy, each stage writes metadata through this minimal interface without knowledge of the block layout or metadata ordering. This also simplifies backwards compatibility: the block layout or metadata ordering can change without modifying any stage implementation.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptiondefault voidempty()Marks the stage as applied without writing any metadata.writeByte(byte value) Writes a single byte.default MetadataWriterwriteBytes(byte[] bytes) Writes all bytes from the given array.writeBytes(byte[] bytes, int offset, int length) Writes bytes from the given array.writeInt(int value) Writes a fixed 4-byte integer in Lucene format.writeLong(long value) Writes a fixed 8-byte long in Lucene format.writeVInt(int value) Writes a variable-length integer.writeVLong(long value) Writes a variable-length long.writeZInt(int value) Writes a zigzag-encoded variable-length integer.writeZLong(long value) Writes a zigzag-encoded variable-length long.
-
Method Details
-
writeByte
Writes a single byte.- Parameters:
value- the byte to write- Returns:
- this writer for chaining
-
writeZInt
Writes a zigzag-encoded variable-length integer.- Parameters:
value- the integer to write- Returns:
- this writer for chaining
-
writeZLong
Writes a zigzag-encoded variable-length long.- Parameters:
value- the long to write- Returns:
- this writer for chaining
-
writeLong
Writes a fixed 8-byte long in Lucene format.- Parameters:
value- the long to write- Returns:
- this writer for chaining
-
writeInt
Writes a fixed 4-byte integer in Lucene format.- Parameters:
value- the integer to write- Returns:
- this writer for chaining
-
writeVInt
Writes a variable-length integer.- Parameters:
value- the integer to write- Returns:
- this writer for chaining
-
writeVLong
Writes a variable-length long.- Parameters:
value- the long to write- Returns:
- this writer for chaining
-
writeBytes
Writes bytes from the given array.- Parameters:
bytes- the source arrayoffset- the offset in the arraylength- the number of bytes to write- Returns:
- this writer for chaining
-
writeBytes
Writes all bytes from the given array.- Parameters:
bytes- the source array- Returns:
- this writer for chaining
-
empty
default void empty()Marks the stage as applied without writing any metadata. Use this for stages that always transform values but don't need to store any parameters for decoding.
-