graphie

package module
v0.0.0-...-1d2b7da Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 21, 2015 License: MIT Imports: 1 Imported by: 0

README

graphie

A graph database written for and in Go.

Not finished yet, don't use it.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrDriverNotFound = errors.New("Driver not found")
)

Functions

func RegisterDriver

func RegisterDriver(name string, fn driverSetupFn)

Types

type Attrs

type Attrs map[string]interface{}

type FilterFn

type FilterFn func(n INode) bool

type Graph

type Graph struct {
	// contains filtered or unexported fields
}

func NewGraph

func NewGraph(driverName string, driverAttrs string, dbname string) (*Graph, error)

func (*Graph) Close

func (g *Graph) Close() error

func (*Graph) Labels

func (g *Graph) Labels(labels ...string) *LabelGroup
func (g *Graph) Link(nodeFrom, nodeTo NodeID, attrs Attrs) error

type IAtomicInstructions

type IAtomicInstructions interface {
	// Adds exactly one new node to the database (with a new unique ID)
	Add(label string, attrs Attrs) (INode, error)

	// Removes one node
	Remove(id NodeID) error

	// Query
	Get(label string) (IQueryBuilder, error)
	Build() IQueryBuilder

	// Links
	Link(from, to INode, attrs Attrs) error
}

type ICollection

type ICollection interface {
	Add(attrs Attrs) (INode, error)
	Get(attrs Attrs) (INode, error)
	Has(attrs Attrs) (bool, error)
	Remove(node INode) error
	Link(from, to INode, attrs Attrs) error
	Unlink(from, to INode, attrs Attrs) error
}

type INode

type INode interface {
	ID() NodeID

	// Attributes
	Set(key string, value interface{}) error
	Has(key string) (bool, error)
	Get(key string) (interface{}, error)

	// In/out nodes
	In() INodeSet
	Out() INodeSet
	Both() INodeSet

	// The following methods are for convenient use; they panic on error.
	SafeSet(key string, value interface{})
	SafeHas(key string) bool
	SafeGet(key string) interface{}
}

type INodeSet

type INodeSet interface {
	Len() int
}

type IQueryBuilder

type IQueryBuilder interface {
	// Node properties
	HasLabel(label string) IQueryBuilder                      // filters all vertices for
	HasAttrKey(key string) IQueryBuilder                      // TODO: Uses Filter(), for convenient use
	HasAttrValue(key string, value interface{}) IQueryBuilder // TODO: Uses Filter(), for convenient use
	// HasValueGt[e](), HasValueLt[e](), HasValueBetween(), ... <-- for int* and time., for convenient use, using Filter()
	Filter(filterFn FilterFn) IQueryBuilder // filters all nodes at that stage

	Attr(key, value string) IQueryBuilder

	// Vertices
	In(edgeAttrs ...Attrs) IQueryBuilder
	Out(edgeAttrs ...Attrs) IQueryBuilder
	Both(edgeAttrs ...Attrs) IQueryBuilder

	// Set operations
	Intersect(b IQueryBuilder) IQueryBuilder
	Union(b IQueryBuilder) IQueryBuilder

	// Morphisms
	Follow(m IQueryBuilder) IQueryBuilder

	// Executors
	Count() int
	All() INodeSet
	Limit(n int) INodeSet
	Iterate() chan<- INode
}

type IStorage

type IStorage interface {
	ICollection

	Close() error
}

type LabelGroup

type LabelGroup struct {
	// contains filtered or unexported fields
}

func (*LabelGroup) Add

func (lg *LabelGroup) Add(attrs Attrs) (NodeID, error)
func (lg *LabelGroup) EnsureIndexLinks(attr_name string) error

func (*LabelGroup) EnsureIndexNodes

func (lg *LabelGroup) EnsureIndexNodes(attr_name string) error

func (*LabelGroup) Merge

func (lg *LabelGroup) Merge(attrs Attrs) (NodeID, error)

func (*LabelGroup) MustAdd

func (lg *LabelGroup) MustAdd(attrs Attrs) NodeID

func (*LabelGroup) Query

func (lg *LabelGroup) Query() *Query
type Link struct {
	Other NodeID
	Attrs Attrs
}

type Node

type Node interface {
	Link(to Node, attrs Attrs) error
}

type NodeID

type NodeID uint64

type Query

type Query struct {
	// contains filtered or unexported fields
}

type Storage

type Storage interface {
	// Initializes the underlying storage, creates appropriate indexes and
	// establishes a connection, if not done yet
	Start(attrs string, dbname string) error

	// Stops the storage and shuts it down properly
	Stop() error

	EnsureIndexNodes(labels []string, attrName string) error
	EnsureIndexLinks(labels []string, attrName string) error

	// Elementary CRUD operations for nodes
	Add(labels []string, attrs Attrs) (NodeID, error)
	Merge(labels []string, attrs Attrs) (NodeID, error)
	Link(from, to NodeID, attrs Attrs) error
	Unlink(from, to NodeID, attrs Attrs) error
	Remove(id NodeID) error

	// Edge handling
	In(id NodeID) ([]*Link, error)
	Out(id NodeID) ([]*Link, error)

	// Attribute handling
	Set(id NodeID, key string, value interface{}) error
	Get(id NodeID, key string) (interface{}, error)
	Has(id NodeID, key string) (bool, error)
	Attrs(id NodeID) (Attrs, error)
}

Directories

Path Synopsis
example
storages
happy
Package happy is the main backend storage for graphie.
Package happy is the main backend storage for graphie.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL