Class DocumentSerializer
- All Implemented Interfaces:
PofSerializer<dev.langchain4j.data.document.Document>
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondev.langchain4j.data.document.Documentdeserialize(PofReader in) Deserializes a Document object from the POF stream.voidSerializes a Document object to the POF stream.
-
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:
serializein interfacePofSerializer<dev.langchain4j.data.document.Document>- Parameters:
out- the POF writer to serialize the document todocument- the Document object to serialize- Throws:
IOException- if an I/O error occurs during serialization
-
deserialize
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:
deserializein interfacePofSerializer<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
-