#graveldb persistent (on disk) graph database library for embedded use
just dabbling around with creating an embedded persistent graph database in go.
This is an exercise in learning go for me. I intend to use it as a generic backing store for other applications like note taking etc..
uses leveldb as a backing store
it sort of works right now. it's a very basic property graph.. there are no optimizations for queries yet there is no write collision prevention, yet, so do writes serially (addvertex, addedge, deletevertex, deleteedge) - now implemented writelocks using mutex for now
just follow the graph_test.go - open a graph, add/delete vertices, add/delete edges, and query using edge following, e.g vertex.OutEdges() /vertex.InEdges() and edge.OutVertex(), edge.InVertex()..
you can also manually check for interesting edges using edge.labels or interesting vertices and edges using properties.
the structure (and interfaces) of the graph database tries to follow most of the blueprint graph api..
- Graph: An object that contains vertices and edges.
- Element: An object that can have any number of key/value pairs associated with it (i.e. properties)
- Vertex: An object that has incoming and outgoing edges.
- Edge: An object that has a tail and head vertex.
- Element: An object that can have any number of key/value pairs associated with it (i.e. properties)
A property graph has these elements:
- a set of vertices
- each vertex has a unique identifier.
- each vertex has a set of outgoing edges.
- each vertex has a set of incoming edges.
- each vertex has a collection of properties defined by a map from key to value.
- a set of edges
- each edge has a unique identifier.
- each edge has an outgoing tail vertex.
- each edge has an incoming head vertex.
- each edge has a label that denotes the type of relationship between its two vertices.
- each edge has a collection of properties defined by a map from key to value.
the graph will be persisted in databases / tables on disk. These are the database descriptions
the edges are indexed in a hexastore derived index implementation
-
element
-
key=element id
-
value= type (vertex or edge)
-
hexastore
-
key = one of * spo::A::C::B * sop::A::B::C * ops::B::C::A * osp::B::A::C * pso::C::A::B * pos::C::B::A where * A is element id for vertex as originating vertex or subject * B is element id for vertex as terminating vertex or object * C is element id for edge connecting the vertii or predicate
-
value = label
-
edges - mostly for quick rehydration -- will be removed later
-
key = edge (element id)
-
value = subject (outvertex), object (invertex), label
-
property
-
key = elemenid::property
-
value = value
-
meta
-
metadata about store
-
some of the keys that might be used are 1. nextid 1. number of vertexes 1. number of edges