Skip to content

an experiment in embedded persistent graph database in go

Notifications You must be signed in to change notification settings

lexlapax/cgraveldb

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

72 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

#graveldb persistent (on disk) graph database library for embedded use

intro

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.

concept

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.

A property graph has these elements:

  1. a set of vertices
  2. each vertex has a unique identifier.
  3. each vertex has a set of outgoing edges.
  4. each vertex has a set of incoming edges.
  5. each vertex has a collection of properties defined by a map from key to value.
  6. a set of edges
  7. each edge has a unique identifier.
  8. each edge has an outgoing tail vertex.
  9. each edge has an incoming head vertex.
  10. each edge has a label that denotes the type of relationship between its two vertices.
  11. each edge has a collection of properties defined by a map from key to value.

implementation

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

  1. element

  2. key=element id

  3. value= type (vertex or edge)

  4. hexastore

  5. 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

  6. value = label

  7. edges - mostly for quick rehydration -- will be removed later

  8. key = edge (element id)

  9. value = subject (outvertex), object (invertex), label

  10. property

  11. key = elemenid::property

  12. value = value

  13. meta

  14. metadata about store

  15. some of the keys that might be used are 1. nextid 1. number of vertexes 1. number of edges

About

an experiment in embedded persistent graph database in go

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages