API Reference¶
This document categorizes the core structures and exported methods by code modules and packages.
1. pkg/api¶
This package contains high-level, general-purpose graph library interface abstractions exposed to external users.
-
func Open(path string, opts ...DBOption) (*DB, error)Opens the database file at the specified path. If it does not exist, initializes it as a Pebble KV store structure. -
type DBOption func(*DB)Configuration definition using the functional options pattern. -
func WithObservability(o *cypher.Observability) DBOptionCreates aDBOptionthat allows injection of configured logging, tracing, and monitoring metrics. -
type DB structThe core thread-safe graph database instance that controls interaction with the underlying engine: func (db *DB) Exec(ctx context.Context, cypherQuery string, args ...interface{}) (Result, error)func (db *DB) Query(ctx context.Context, cypherQuery string, args ...interface{}) (*Rows, error)func (db *DB) BeginTx(ctx context.Context, opts *TxOptions) (*Tx, error)func (db *DB) Close() error-
func (db *DB) IsClosed() bool -
type Result = cypher.ResultContains the status and count after graph modification operations (alias): AffectedNodes int: Number of affected nodes.AffectedRels int: Number of affected relationships.Rows []map[string]interface{}: Internal matched data rows (used for chained execution).-
Columns []string: Internal column names. -
type Rows structThe graph engine's iteration cursor: func (r *Rows) Next() boolfunc (r *Rows) Scan(dest ...interface{}) errorfunc (r *Rows) Columns() []string-
func (r *Rows) Close() error -
type Tx structSafe concurrent multi-version control transaction wrapper: func (tx *Tx) Exec(cypherQuery string, args ...interface{}) (Result, error)func (tx *Tx) Query(cypherQuery string, args ...interface{}) (*Rows, error)func (tx *Tx) Commit() errorfunc (tx *Tx) Rollback() error
2. pkg/cypher¶
Package for handling Cypher query statements and their execution environment.
-
type Executor structContext object for executing abstract syntax trees. Composed ofCreator,Matcher, andModifier. -
func NewExecutor(store *storage.DB, opts ...ExecutorOption) *ExecutorCreates an executor instance. -
type Observability structComposed of three capability interfaces:Logger,Tracer, andMeter. -
func NewObservability(opts ...ObservabilityOption) *ObservabilityGenerates an observer with default empty implementations, which can be replaced viaWithLogger,WithTracer,WithMeter.
3. pkg/graph¶
Describes the core graph database model and serialization metadata.
type Mutator interfaceDefines abstract mutation capabilities for transactions/storage, enabling entities to participate in underlying transactions:Put(key, value []byte) error-
Delete(key []byte) error -
type Index structManages efficient index construction and querying for node labels and properties. -
type AdjacencyList structThe adjacency list structure for graphs, supporting O(1) bidirectional relationship queries and maintenance. -
type Node struct ID stringLabels []stringProperties map[string]PropertyValue
Provides convenience methods like GetProperty, SetProperty, HasLabel, RemoveLabel.
type Relationship structID stringStartNodeID stringEndNodeID stringType string-
Properties map[string]PropertyValue -
type PropertyValue structWraps primitive data types: Type() PropertyTypeStringValue() stringIntValue() int64FloatValue() float64BoolValue() bool
4. pkg/storage¶
Contains efficient interaction with the underlying Pebble and defines binary key-value pairs for custom graph databases.
-
func Open(path string) (*DB, error)Opens the KV persistence layer. -
func (db *DB) Put(key, value []byte) error func (db *DB) Get(key []byte) ([]byte, error)func (db *DB) Delete(key []byte) errorfunc Marshal(v interface{}) ([]byte, error)func Unmarshal(data []byte, v interface{}) error