storage

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package storage provides the底层 storage layer for gograph using Pebble as the underlying key-value store. It handles data marshaling, key generation, and basic CRUD operations.

Package storage provides the底层 storage layer for gograph using Pebble as the underlying key-value store.

Index

Constants

View Source
const (
	KeyPrefixNode       = "node:"
	KeyPrefixRel        = "rel:"
	KeyPrefixLabel      = "label:"
	KeyPrefixProp       = "prop:"
	KeyPrefixAdj        = "adj:"
	KeyPrefixMeta       = "meta:"
	KeyPrefixIndexCount = "meta:index_count"
)

Variables

This section is empty.

Functions

func AdjKey

func AdjKey(nodeID, relType, direction, relID string) []byte

AdjKey returns the storage key for an adjacency entry.

func AdjKeyPrefix

func AdjKeyPrefix(nodeID string) []byte

AdjKeyPrefix returns the key prefix for all adjacency entries of a node.

func AdjKeyPrefixNodeAndType

func AdjKeyPrefixNodeAndType(nodeID, relType string) []byte

AdjKeyPrefixNodeAndType returns the key prefix for all adjacency entries of a node with a specific relationship type.

func AdjKeyPrefixNodeAndTypeAndDir

func AdjKeyPrefixNodeAndTypeAndDir(nodeID, relType, direction string) []byte

AdjKeyPrefixNodeAndTypeAndDir returns the key prefix for all adjacency entries of a node with a specific relationship type and direction.

func LabelKey

func LabelKey(labelName, nodeID string) []byte

LabelKey returns the storage key for a label index entry.

func LabelKeyPrefix

func LabelKeyPrefix(labelName string) []byte

LabelKeyPrefix returns the key prefix for all entries with the given label.

func Marshal

func Marshal(v interface{}) ([]byte, error)

Marshal encodes a value to bytes using Gob encoding.

func NodeKey

func NodeKey(nodeID string) []byte

NodeKey returns the storage key for a node with the given ID.

func PropertyKey

func PropertyKey(labelName, propName, propValue string) []byte

PropertyKey returns the storage key for a property index entry.

func PropertyKeyPrefix

func PropertyKeyPrefix(labelName, propName string) []byte

PropertyKeyPrefix returns the key prefix for all entries with the given label and property name.

func RelKey

func RelKey(relID string) []byte

RelKey returns the storage key for a relationship with the given ID.

func Unmarshal

func Unmarshal(data []byte, v interface{}) error

Unmarshal decodes bytes to a value using Gob encoding.

Types

type Batch

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

func (*Batch) Close

func (b *Batch) Close() error

func (*Batch) Commit

func (b *Batch) Commit() error

func (*Batch) Delete

func (b *Batch) Delete(key []byte) error

func (*Batch) Put

func (b *Batch) Put(key, value []byte) error

type DB

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

func Open

func Open(path string) (*DB, error)

Open opens a database at the given path and returns a DB instance.

func (*DB) Close

func (db *DB) Close() error

func (*DB) Delete

func (db *DB) Delete(key []byte) error

func (*DB) Get

func (db *DB) Get(key []byte) ([]byte, error)

func (*DB) NewBatch

func (db *DB) NewBatch() *Batch

func (*DB) NewIter

func (db *DB) NewIter(opts *pebble.IterOptions) (*Iterator, error)

func (*DB) Put

func (db *DB) Put(key, value []byte) error

type Iterator

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

func (*Iterator) Close

func (i *Iterator) Close() error

func (*Iterator) Error

func (i *Iterator) Error() error

func (*Iterator) Key

func (i *Iterator) Key() []byte

func (*Iterator) Next

func (i *Iterator) Next() bool

func (*Iterator) Prev

func (i *Iterator) Prev() bool

func (*Iterator) SeekGE

func (i *Iterator) SeekGE(key []byte) bool

func (*Iterator) SeekLT

func (i *Iterator) SeekLT(key []byte) bool

func (*Iterator) Valid

func (i *Iterator) Valid() bool

func (*Iterator) Value

func (i *Iterator) Value() []byte

Jump to

Keyboard shortcuts

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