public abstract class NodeDb extends java.lang.Object implements Node
NodeRef} refers to exactly one NodeDb instance, and if required can set that instance to `null`, thus
freeing up memory, e.g. if heap memory is low. While {NodeRef} instances are very small (they will never be
garbage collected), NodeDb instances consume a bit more space.
Adjacent nodes and edge properties are stored in a flat array (adjacentNodesWithEdgeProperties).
Edges only exist virtually and are created on request. This allows for a small memory footprint, especially given
that most graph domains have magnitudes more edges than nodes.| Modifier and Type | Method and Description |
|---|---|
Edge |
addEdge(java.lang.String label,
Node inNode,
java.util.Map<java.lang.String,java.lang.Object> keyValues)
Add an outgoing edge to the node with provided label and edge properties as key/value pairs.
|
Edge |
addEdge(java.lang.String label,
Node inNode,
java.lang.Object... keyValues)
Add an outgoing edge to the node with provided label and edge properties as key/value pairs.
|
void |
addEdgeSilent(java.lang.String label,
Node inNode,
java.util.Map<java.lang.String,java.lang.Object> keyValues)
Add an outgoing edge to the node with provided label and edge properties as key/value pairs.
|
void |
addEdgeSilent(java.lang.String label,
Node inNode,
java.lang.Object... keyValues)
Add an outgoing edge to the node with provided label and edge properties as key/value pairs.
|
int |
blockLength(int offsetPosition)
Returns the length of an edge type block in the adjacentNodesWithEdgeProperties array.
|
protected int |
blockOffsetToOccurrence(Direction direction,
java.lang.String label,
NodeRef otherNode,
int blockOffset)
If there are multiple edges between the same two nodes with the same label, we use the
`occurrence` to differentiate between those edges.
|
java.util.Iterator<Node> |
both() |
java.util.Iterator<Node> |
both(java.lang.String... edgeLabels) |
java.util.Iterator<Edge> |
bothE() |
java.util.Iterator<Edge> |
bothE(java.lang.String... edgeLabels) |
java.util.Iterator<Node> |
createAdjacentNodeIteratorByOffSet(int offsetPos) |
<P> P |
edgeProperty(Direction direction,
Edge edge,
int blockOffset,
java.lang.String key) |
java.util.Map<java.lang.String,java.lang.Object> |
edgePropertyMap(Direction direction,
Edge edge,
int blockOffset) |
<V> java.util.Optional<V> |
edgePropertyOption(Direction direction,
Edge edge,
int blockOffset,
java.lang.String key) |
boolean |
equals(java.lang.Object obj) |
java.lang.Object[] |
getAdjacentNodesWithEdgeProperties() |
int[] |
getEdgeOffsets() |
PackedIntArray |
getEdgeOffsetsPackedArray() |
<V> java.util.Iterator<V> |
getEdgeProperties(Direction direction,
Edge edge,
int blockOffset,
java.lang.String... keys) |
int |
getStrideSize(java.lang.String edgeLabel) |
Graph |
graph() |
int |
hashCode() |
long |
id() |
java.util.Iterator<Node> |
in() |
java.util.Iterator<Node> |
in(java.lang.String... edgeLabels) |
java.util.Iterator<Edge> |
inE() |
java.util.Iterator<Edge> |
inE(java.lang.String... edgeLabels) |
Edge |
instantiateDummyEdge(java.lang.String label,
NodeRef outNode,
NodeRef inNode)
to follow the tinkerpop api, instantiate and return a dummy edge, which doesn't really exist in the graph
|
boolean |
isDirty() |
java.lang.String |
label() |
abstract NodeLayoutInformation |
layoutInformation() |
void |
markAsClean() |
void |
markAsDirty() |
protected int |
occurrenceToBlockOffset(Direction direction,
java.lang.String label,
NodeRef adjacentNode,
int occurrence) |
java.util.Iterator<Node> |
out() |
java.util.Iterator<Node> |
out(java.lang.String... edgeLabels) |
java.util.Iterator<Edge> |
outE() |
java.util.Iterator<Edge> |
outE(java.lang.String... edgeLabels) |
protected int |
outEdgeCount() |
<A> A |
property(PropertyKey<A> key) |
java.util.Set<java.lang.String> |
propertyKeys() |
java.util.Map<java.lang.String,java.lang.Object> |
propertyMap()
Map with all properties
|
<A> java.util.Optional<A> |
propertyOption(PropertyKey<A> key) |
java.util.Optional<java.lang.Object> |
propertyOption(java.lang.String key) |
void |
remove() |
protected void |
removeEdge(Direction direction,
java.lang.String label,
int blockOffset)
Removes an 'edge', i.e.
|
void |
removeEdgeProperty(Direction direction,
java.lang.String edgeLabel,
java.lang.String key,
int blockOffset) |
void |
removeProperty(java.lang.String key) |
protected abstract void |
removeSpecificProperty(java.lang.String key) |
void |
setAdjacentNodesWithEdgeProperties(java.lang.Object[] adjacentNodesWithEdgeProperties) |
void |
setEdgeOffsets(int[] edgeOffsets) |
<V> void |
setEdgeProperty(Direction direction,
java.lang.String edgeLabel,
java.lang.String key,
V value,
int blockOffset) |
void |
setProperty(Property<?> property) |
<A> void |
setProperty(PropertyKey<A> key,
A value) |
void |
setProperty(java.lang.String key,
java.lang.Object value) |
int |
startIndex(int offsetPosition) |
int |
storeAdjacentNode(Direction direction,
java.lang.String edgeLabel,
NodeRef adjacentNode,
java.lang.Object... edgeKeyValues) |
long |
trim()
Trims the node to save storage: shrinks overallocations
|
protected abstract void |
updateSpecificProperty(java.lang.String key,
java.lang.Object value) |
abstract java.util.Map<java.lang.String,java.lang.Object> |
valueMap() |
public final NodeRef ref
protected NodeDb(NodeRef ref)
public abstract NodeLayoutInformation layoutInformation()
public java.lang.Object[] getAdjacentNodesWithEdgeProperties()
public void setAdjacentNodesWithEdgeProperties(java.lang.Object[] adjacentNodesWithEdgeProperties)
public int[] getEdgeOffsets()
public PackedIntArray getEdgeOffsetsPackedArray()
public void setEdgeOffsets(int[] edgeOffsets)
public abstract java.util.Map<java.lang.String,java.lang.Object> valueMap()
public <A> A property(PropertyKey<A> key)
public <A> java.util.Optional<A> propertyOption(PropertyKey<A> key)
propertyOption in interface Elementpublic java.util.Optional<java.lang.Object> propertyOption(java.lang.String key)
propertyOption in interface Elementpublic java.util.Map<java.lang.String,java.lang.Object> propertyMap()
ElementpropertyMap in interface Elementpublic java.util.Set<java.lang.String> propertyKeys()
propertyKeys in interface Elementpublic void setProperty(java.lang.String key,
java.lang.Object value)
setProperty in interface Elementpublic <A> void setProperty(PropertyKey<A> key, A value)
setProperty in interface Elementpublic void setProperty(Property<?> property)
setProperty in interface Elementpublic void removeProperty(java.lang.String key)
removeProperty in interface Elementprotected abstract void updateSpecificProperty(java.lang.String key,
java.lang.Object value)
protected abstract void removeSpecificProperty(java.lang.String key)
public void markAsDirty()
public void markAsClean()
public <V> java.util.Iterator<V> getEdgeProperties(Direction direction, Edge edge, int blockOffset, java.lang.String... keys)
public java.util.Map<java.lang.String,java.lang.Object> edgePropertyMap(Direction direction, Edge edge, int blockOffset)
public <V> java.util.Optional<V> edgePropertyOption(Direction direction, Edge edge, int blockOffset, java.lang.String key)
public <P> P edgeProperty(Direction direction, Edge edge, int blockOffset, java.lang.String key)
public <V> void setEdgeProperty(Direction direction, java.lang.String edgeLabel, java.lang.String key, V value, int blockOffset)
public void removeEdgeProperty(Direction direction, java.lang.String edgeLabel, java.lang.String key, int blockOffset)
public Edge addEdge(java.lang.String label, Node inNode, java.lang.Object... keyValues)
NodeString
property keys and the even numbered arguments are the related property values.public Edge addEdge(java.lang.String label, Node inNode, java.util.Map<java.lang.String,java.lang.Object> keyValues)
Nodepublic void addEdgeSilent(java.lang.String label,
Node inNode,
java.lang.Object... keyValues)
NodeString
property keys and the even numbered arguments are the related property values.
Just like {{{addEdge2}}, but doesn't instantiate and return a dummy edgeaddEdgeSilent in interface Nodepublic void addEdgeSilent(java.lang.String label,
Node inNode,
java.util.Map<java.lang.String,java.lang.Object> keyValues)
NodeaddEdgeSilent in interface Nodepublic java.util.Iterator<Node> out(java.lang.String... edgeLabels)
public java.util.Iterator<Node> in(java.lang.String... edgeLabels)
public java.util.Iterator<Node> both(java.lang.String... edgeLabels)
public java.util.Iterator<Edge> outE(java.lang.String... edgeLabels)
public java.util.Iterator<Edge> inE(java.lang.String... edgeLabels)
public java.util.Iterator<Edge> bothE(java.lang.String... edgeLabels)
protected int outEdgeCount()
protected final int blockOffsetToOccurrence(Direction direction, java.lang.String label, NodeRef otherNode, int blockOffset)
protected final int occurrenceToBlockOffset(Direction direction, java.lang.String label, NodeRef adjacentNode, int occurrence)
direction - OUT or INlabel - the edge labeloccurrence - if there are multiple edges between the same two nodes with the same label,
this is used to differentiate between those edges.
Both nodes use the same occurrence index in their `adjacentNodesWithEdgeProperties` array for the same edge.protected final void removeEdge(Direction direction, java.lang.String label, int blockOffset)
blockOffset - must have been initializedpublic final java.util.Iterator<Node> createAdjacentNodeIteratorByOffSet(int offsetPos)
public int storeAdjacentNode(Direction direction, java.lang.String edgeLabel, NodeRef adjacentNode, java.lang.Object... edgeKeyValues)
public int startIndex(int offsetPosition)
public final int getStrideSize(java.lang.String edgeLabel)
public final int blockLength(int offsetPosition)
public final Edge instantiateDummyEdge(java.lang.String label, NodeRef outNode, NodeRef inNode)
public long trim()
public final boolean isDirty()
public int hashCode()
hashCode in class java.lang.Objectpublic boolean equals(java.lang.Object obj)
equals in class java.lang.Object