Class DocumentSerializer

java.lang.Object
com.oracle.coherence.rag.internal.pof.DocumentSerializer
All Implemented Interfaces:
PofSerializer<dev.langchain4j.data.document.Document>

public class DocumentSerializer extends Object implements PofSerializer<dev.langchain4j.data.document.Document>
POF serializer for LangChain4J Document objects.

This class provides serialization and deserialization support for Document objects using Coherence POF (Portable Object Format). It enables efficient storage and transmission of document objects across Coherence cluster nodes while preserving all document content and metadata.

The serializer handles both the document text content and its associated metadata map, ensuring that all document information is preserved during the serialization process.

Since:
25.09
Author:
Aleks Seovic 2025.07.04
  • Constructor Details

    • DocumentSerializer

      public DocumentSerializer()
  • Method Details

    • serialize

      public void serialize(PofWriter out, dev.langchain4j.data.document.Document document) throws IOException
      Serializes a Document object to the POF stream.

      This method writes the document's text content and metadata to the POF output stream in a structured format that can be efficiently read back during deserialization.

      Specified by:
      serialize in interface PofSerializer<dev.langchain4j.data.document.Document>
      Parameters:
      out - the POF writer to serialize the document to
      document - the Document object to serialize
      Throws:
      IOException - if an I/O error occurs during serialization
    • deserialize

      public dev.langchain4j.data.document.Document deserialize(PofReader in) throws IOException
      Deserializes a Document object from the POF stream.

      This method reads the document's text content and metadata from the POF input stream and reconstructs a complete Document object with all original information preserved.

      Specified by:
      deserialize in interface PofSerializer<dev.langchain4j.data.document.Document>
      Parameters:
      in - the POF reader to deserialize the document from
      Returns:
      a new Document object with the deserialized content and metadata
      Throws:
      IOException - if an I/O error occurs during deserialization