Enum Class DefaultDocumentSerializer

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

public enum DefaultDocumentSerializer extends Enum<DefaultDocumentSerializer>
Default serializer for Document instances in the Flux platform.

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 CompressionUtils and marked with the format document via Data.DOCUMENT_FORMAT.

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 Document 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
      Throws:
      IllegalArgumentException - if the data cannot be parsed or is invalid
    • 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