Class CacheEntryCodec
PersistentCacheEntry
instances.
This class defines the binary format used to persist cache entries independently of the underlying storage technology. Implementations for ChronicleMap, MapDB, or other storage backends can reuse this codec to ensure a consistent on-disk representation.
Each serialized entry consists of the entry creation timestamp followed by a
serialized form of the cached DataRetrievalResponse, prefixed with a
type discriminator that identifies the concrete response type.
Serialization is performed into a temporary in-memory buffer before any bytes are written to the provided output. This ensures that partially serialized entries are never committed if serialization fails.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static enumType discriminator used in the serialized format to identify the kind of cached response stored in the entry. -
Method Summary
Modifier and TypeMethodDescriptionprotected static org.apache.jena.graph.NodeParses a JenaNodefrom its N-Triples string representation.static PersistentCacheEntryDeserializes a cache entry from the provided input.protected static StringserializeNode(org.apache.jena.graph.Node node) Serializes a JenaNodeinto its N-Triples string representation.static voidwrite(DataOutput out, PersistentCacheEntry entry) Serializes the given cache entry to the provided output.
-
Method Details
-
write
Serializes the given cache entry to the provided output.Serialization is first performed into a temporary buffer and only written to
outafter successful completion. This prevents partially serialized entries from being persisted if an error occurs during serialization.This method blocks until the
DataRetrievalResponsecontained in the cache entry becomes available.[creationTime: long] [type: int] SOLUTION_MAPPING_RESPONSE: [numMappings: int] repeat numMappings: [bindingSize: int] repeat bindingSize: [varName: UTF-8] [node: UTF-8] TPF_RESPONSE: [numMatchingTriples: int] repeat numMatchingTriples: [subject: UTF-8] [predicate: UTF-8] [object: UTF-8] [numMetadataTriples: int] repeat numMetadataTriples: [subject: UTF-8] [predicate: UTF-8] [object: UTF-8] [nextPageURL: UTF-8 or null] CARDINALITY_RESPONSE: [cardinality: int]- Parameters:
out- destination to which the serialized representation is writtenentry- cache entry to serialize- Throws:
IOException- if writing to the output failsIllegalStateException- if the response type is unsupported or the contained future cannot be resolved
-
read
Deserializes a cache entry from the provided input.The input must contain data encoded according to the binary format defined by
write(DataOutput, PersistentCacheEntry).The deserialized response is wrapped in a completed
CompletableFuturepreserving the original creation timestamp.- Parameters:
in- source containing a serialized cache entry- Returns:
- reconstructed cache entry
- Throws:
IOException- if the serialized representation cannot be readIllegalStateException- if an unsupported response type identifier is encountered
-
serializeNode
Serializes a JenaNodeinto its N-Triples string representation.- Parameters:
node- the node to serialize
-
deserializeNode
Parses a JenaNodefrom its N-Triples string representation.- Parameters:
s- the serialized node
-