public class SubgraphManager
extends java.lang.Object
Constructor and Description |
---|
SubgraphManager() |
Modifier and Type | Method and Description |
---|---|
static RAMStorageGraph |
decodeSubgraph(java.lang.String sgraphString) |
static void |
dumpGraphToFile(java.io.File file,
StorageGraph graph,
boolean outputByteBuffers)
Debugging method: will write the complete StorageGraph in a File where lines
are sorted by the graph's key handles.
|
static java.lang.String |
encodeSubgraph(StorageGraph sgraph) |
static java.lang.Object |
get(StorageGraph subgraph,
HyperGraph graph)
Assuming a single root, write the
StorageGraph to (merge it with)
the HyperGraph for the sole purpose of reading back a run-time
atom. |
static HGHandle[] |
getAtomTargets(java.lang.Object atom) |
static java.util.Map<HGHandle,HGHandle> |
getLocalTypes(HyperGraph graph,
java.util.Map<java.lang.String,java.lang.String> typeClasses)
Return a map between remote type handles and local type handles.
|
static Json |
getTransferAtomRepresentation(HyperGraph graph,
HGHandle atom) |
static Json |
getTransferAtomRepresentation(HyperGraph graph,
java.util.Set<HGHandle> S)
Returns a structure ready to be embedded in a message for atom transfer.
|
static java.lang.Object |
getTransferGraphRepresentation(HyperGraph graph,
HGTraversal traversal) |
static java.lang.Object |
getTransferObjectRepresentation(HyperGraph graph,
HGHandle atomHandle,
java.lang.Object atom,
HGHandle typeHandle)
Serialize an arbitrary object (not necessarily stored in the database) as a hypergraph atom for
wire transmission.
|
static java.lang.Object |
readAtom(HGHandle handle,
HyperGraph graph,
RefResolver<HGHandle,HGAtomType> typeResolver,
StorageGraph subgraph) |
static void |
store(StorageGraph subgraph,
HGStore store) |
static void |
store(StorageGraph subgraph,
HGStore store,
java.util.Map<HGPersistentHandle,HGPersistentHandle> substitute)
Write the passed in
StorageGraph to the permanent
HGStore in a single transaction. |
static java.util.Set<HGHandle> |
writeTransferedGraph(Json atom,
HyperGraph graph)
IMPORTANT: Assumes atom does not exist locally! Writes directly to storage and updates relevant indexes
based on that assumptions.
|
static java.util.Set<HGHandle> |
writeTransferedGraph(Json atom,
HyperGraph graph,
Mapping<Pair<HGHandle,java.lang.Object>,HGHandle> atomFinder) |
public static java.lang.String encodeSubgraph(StorageGraph sgraph)
public static RAMStorageGraph decodeSubgraph(java.lang.String sgraphString)
public static void dumpGraphToFile(java.io.File file, StorageGraph graph, boolean outputByteBuffers)
file
- public static void store(StorageGraph subgraph, HGStore store)
public static void store(StorageGraph subgraph, HGStore store, java.util.Map<HGPersistentHandle,HGPersistentHandle> substitute)
Write the passed in StorageGraph
to the permanent
HGStore
in a single transaction. The StorageGraph
must be small enough to fit in a single transaction. How small exactly
that is depends on the underlying storage mechanism, available memory,
available transactional locks etc.
You can specify a map from data in the StorageGraph
to "local"
HGStore
data in the substitute
parameter. This map
states that a given key is to replaced by the given value during storage. Elements
in this map's domain are not written because they have equivalents in the
HGStore
already. Moreover, whenever a link from the StorageGraph
parameter points to one of the elements in map's domain it is replaced by the
corresponding element of the map's range.
public static HGHandle[] getAtomTargets(java.lang.Object atom)
public static java.lang.Object get(StorageGraph subgraph, HyperGraph graph)
StorageGraph
to (merge it with)
the HyperGraph
for the sole purpose of reading back a run-time
atom. Then delete that atom from the graph.
NOTE: this method assumes that the single atom represented in the StorageGraph
parameter does not exist locally in the HyperGraph.subgraph
- graph
- public static Json getTransferAtomRepresentation(HyperGraph graph, HGHandle atom)
public static Json getTransferAtomRepresentation(HyperGraph graph, java.util.Set<HGHandle> S)
Returns a structure ready to be embedded in a message for atom transfer.
graph
- atom
- public static java.lang.Object getTransferObjectRepresentation(HyperGraph graph, HGHandle atomHandle, java.lang.Object atom, HGHandle typeHandle)
graph
- atom
- typeHandle
- public static java.lang.Object getTransferGraphRepresentation(HyperGraph graph, HGTraversal traversal)
public static java.lang.Object readAtom(HGHandle handle, HyperGraph graph, RefResolver<HGHandle,HGAtomType> typeResolver, StorageGraph subgraph)
public static java.util.Set<HGHandle> writeTransferedGraph(Json atom, HyperGraph graph) throws java.lang.ClassNotFoundException
atom
- graph
- java.lang.ClassNotFoundException
public static java.util.Map<HGHandle,HGHandle> getLocalTypes(HyperGraph graph, java.util.Map<java.lang.String,java.lang.String> typeClasses)
Return a map between remote type handles and local type handles. A remote type handle
is mapped to a local type handle if their corresponding classes, as provided by the
typeClasses
map argument, are the same. A remote type
handle is mapped to itself if either (1) there's no association with a class in the typeClasses
map (i.e. the classname is the empty string) or
(2) it is associated with a class that cannot be found locally.
graph
- typeClasses
- java.lang.ClassNotFoundException
public static java.util.Set<HGHandle> writeTransferedGraph(Json atom, HyperGraph graph, Mapping<Pair<HGHandle,java.lang.Object>,HGHandle> atomFinder) throws java.lang.ClassNotFoundException
atom
- A Structs representation of a transfered graph.graph
- The HyperGraph instance to be written to.atomFinder
- Return handles of existing atoms so that they are not stored
again or under a different handle. This parameter can be null in which
case existing atoms (with the same handle) are overwritten and equivalents
(same "information import", but different handle) are ignored.java.lang.ClassNotFoundException