Class GraphBinaryStorage
java.lang.Object
org.apache.tinkerpop.gremlin.tinkergraph.structure.storage.AbstractLogStorage
org.apache.tinkerpop.gremlin.tinkergraph.structure.storage.GraphBinaryStorage
- All Implemented Interfaces:
AutoCloseable,TinkerStorage
The GraphBinary
TinkerStorage codec on top of AbstractLogStorage. The base owns the durable
log-structured machinery (file layout, VERSION marker, CRC framing, replay fold, SyncMode
durability, crash-safe and threshold compaction); this class supplies only how an element is encoded and decoded.
Rather than serialize a whole DetachedVertex/DetachedEdge (which repeats every property key and
label as a full string on every element and wraps each property in a VertexProperty envelope), this codec
writes element components directly: element ids and property values go through GraphBinary's scalar
serializers (a one-byte DataType tag plus the raw value), while labels, property keys, and meta-property
keys are dictionary-encoded to small integer refs. The dictionary is a single dense namespace built by first
appearance; new entries are emitted as OP_DICT_APPEND records inside the same frame, before the entries
that reference them, so a torn trailing frame drops a ref and its user atomically.
Vertex-property ids are auto-generated and, by default, not persisted (they are regenerated on load); element and
edge ids are always preserved. The snapshot streams one element per frame, so compaction never holds a second full
copy of the graph in heap.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidReset any per-replay decode state (e.g. a dictionary) before a fold begins.protected voidconfigureCodec(org.apache.commons.configuration2.Configuration config) Read any codec-specific configuration.protected voiddecodeFrame(byte[] record, Map<Object, DetachedVertex> vertices, Map<Object, DetachedEdge> edges) Decode one record payload, folding its puts and deletes into the supplied maps (last-write-wins per id).protected byte[]encodeCommit(long txVersion, Collection<TinkerStorageMutation<TinkerVertex>> changedVertices, Collection<TinkerStorageMutation<TinkerEdge>> changedEdges) Encode a committing transaction's changeset into a single record payload (the framing is added by the caller).protected voidwriteSnapshot(TinkerStorageGraph graph, DataOutputStream out) Write the entire current committed state of the graph tooutas framed records (viaAbstractLogStorage.writeFrame(java.io.DataOutputStream, byte[])), for compaction.Methods inherited from class org.apache.tinkerpop.gremlin.tinkergraph.structure.storage.AbstractLogStorage
clear, close, compact, compact, failStop, flush, isFailed, isReadOnly, maybeCompact, open, openEmptyLog, openLogForAppend, persist, replay, writeFrame
-
Constructor Details
-
GraphBinaryStorage
public GraphBinaryStorage()
-
-
Method Details
-
configureCodec
protected void configureCodec(org.apache.commons.configuration2.Configuration config) Description copied from class:AbstractLogStorageRead any codec-specific configuration. Called once duringAbstractLogStorage.open(org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerStorageGraph, org.apache.commons.configuration2.Configuration). Default is a no-op.- Overrides:
configureCodecin classAbstractLogStorage
-
beginReplay
protected void beginReplay()Description copied from class:AbstractLogStorageReset any per-replay decode state (e.g. a dictionary) before a fold begins. Default is a no-op.- Overrides:
beginReplayin classAbstractLogStorage
-
encodeCommit
protected byte[] encodeCommit(long txVersion, Collection<TinkerStorageMutation<TinkerVertex>> changedVertices, Collection<TinkerStorageMutation<TinkerEdge>> changedEdges) throws IOException Description copied from class:AbstractLogStorageEncode a committing transaction's changeset into a single record payload (the framing is added by the caller). A failed encode fails only its own transaction and later commits are still accepted, so on failure an implementation must undo any codec state it changed while encoding, such as dictionary entries.- Specified by:
encodeCommitin classAbstractLogStorage- Throws:
IOException
-
writeSnapshot
Description copied from class:AbstractLogStorageWrite the entire current committed state of the graph tooutas framed records (viaAbstractLogStorage.writeFrame(java.io.DataOutputStream, byte[])), for compaction. The file header has already been written toout.- Specified by:
writeSnapshotin classAbstractLogStorage- Throws:
IOException
-
decodeFrame
protected void decodeFrame(byte[] record, Map<Object, DetachedVertex> vertices, Map<Object, throws IOExceptionDetachedEdge> edges) Description copied from class:AbstractLogStorageDecode one record payload, folding its puts and deletes into the supplied maps (last-write-wins per id).- Specified by:
decodeFramein classAbstractLogStorage- Throws:
IOException
-