Enum Class DefaultDocumentSerializer

java.lang.Object
java.lang.Enum<DefaultDocumentSerializer>
io.fluxzero.common.search.DefaultDocumentSerializer
All Implemented Interfaces:
Serializable, Comparable<DefaultDocumentSerializer>, Constable

public enum DefaultDocumentSerializer extends Enum<DefaultDocumentSerializer>
Default serializer for Document instances in the Fluxzero Runtime.

This serializer uses the MessagePack binary format to efficiently encode and decode documents for storage or transport. It supports compression and is version-aware, allowing for future extension of the format.

Serialization Format

The current (version 0) serialization includes:
  • int format version (currently 0)
  • String document ID
  • Instant timestamp (as epoch millis)
  • Instant end timestamp (as epoch millis)
  • String collection name
  • List<Entry> entries and their associated List<Path>

Compression is applied to the final byte output using CompressionAlgorithm.ZSTD and marked with the format document via Data.DOCUMENT_FORMAT. Readers accept ZSTD and historical LZ4 envelopes; LZ4 decoding uses the bounds-checked Java implementation.

See Also:
  • Enum Constant Details

  • Method Details

    • values

      public static DefaultDocumentSerializer[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static DefaultDocumentSerializer valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • serialize

      public Data<byte[]> serialize(Document document)
      Serializes the given Document into a compressed binary Data container.
      Parameters:
      document - the document to serialize
      Returns:
      the serialized form of the document
      Throws:
      IllegalArgumentException - if the document cannot be serialized
    • deserialize

      public Map<Document.Entry, List<Document.Path>> deserialize(Data<byte[]> document)
      Deserializes a Data blob containing a compressed, binary Document. The data must be in the correct format and contain a supported version.
      Parameters:
      document - the data to deserialize
      Returns:
      the reconstructed Document entries
      Throws:
      IllegalArgumentException - if the data cannot be parsed or is invalid
    • deserializeMetadata

      public Metadata deserializeMetadata(Data<byte[]> document)
      Reads metadata without constructing payload entries for documents that have no metadata. The complete document is still validated. Documents with metadata reuse the ordinary parser on the same decompressed buffer, preserving its entry ordering and duplicate-entry semantics. No decode cache is retained.
      Parameters:
      document - the encoded document
      Returns:
      its stored metadata, or empty metadata when no metadata paths are present
      Throws:
      IllegalArgumentException - if the format is unsupported or the document cannot be parsed
    • canDeserialize

      public boolean canDeserialize(Data<byte[]> data)
      Checks whether the given Data object is in a format that this serializer can deserialize.
      Parameters:
      data - the data blob
      Returns:
      true if the format is document, false otherwise