compactstore

package
v0.1.17 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package compactstore is an in-memory goRDFlib store that holds a large graph in a fraction of the memory goRDFlib's own MemoryStore does.

MemoryStore keeps three nested indexes (subject → predicate → object, and the two rotations) with the triple at every leaf. Up to goRDFlib v0.9.1 the inner levels were Go maps, almost all of them singletons since most objects are literals that appear once, and a map costs several hundred bytes however few entries it holds, so a triple cost around 1.7 KB there. goRDFlib v0.9.2 keeps small inner levels in slices and brought that to around 640 bytes per triple on a million triples with unique objects. This store interns every distinct term once, keeps each triple as three 32-bit ids, and indexes them with postings lists, so a triple costs a few dozen bytes plus its share of the terms, around 530 bytes per triple on the same graph, most of it the terms themselves. It is what `sal build` holds the graph it commits in.

The store holds one unnamed graph and never fails on its own: the only error it returns is that of a context that is already done when a call starts, which the store.Store contract requires.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Store

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

Store implements store.Store and store.QueryableStore for a single unnamed graph. It is safe for concurrent use the way MemoryStore is: an iteration holds the read lock until it ends, so a store must not be mutated from inside one.

func New

func New() *Store

New returns an empty store.

func (*Store) Add

func (s *Store) Add(ctx context.Context, t term.Triple, _ term.Term) error

func (*Store) AddN

func (s *Store) AddN(ctx context.Context, quads []term.Quad) error

func (*Store) Bind

func (s *Store) Bind(ctx context.Context, prefix string, namespace term.URIRef) error

func (*Store) ContextAware

func (s *Store) ContextAware() bool

func (*Store) Contexts

func (s *Store) Contexts(ctx context.Context, _ *term.Triple) store.TermIterator

Contexts yields nothing: the store holds one unnamed graph.

func (*Store) Count

func (s *Store) Count(ctx context.Context, pattern term.TriplePattern, _ term.Term) (int, error)

func (*Store) Exists

func (s *Store) Exists(ctx context.Context, pattern term.TriplePattern, _ term.Term) (bool, error)

func (*Store) Len

func (s *Store) Len(ctx context.Context, _ term.Term) (int, error)

func (*Store) Namespace

func (s *Store) Namespace(ctx context.Context, prefix string) (term.URIRef, bool, error)

func (*Store) Namespaces

func (s *Store) Namespaces(ctx context.Context) store.NamespaceIterator

func (*Store) Prefix

func (s *Store) Prefix(ctx context.Context, namespace term.URIRef) (string, bool, error)

func (*Store) Remove

func (s *Store) Remove(ctx context.Context, pattern term.TriplePattern, _ term.Term) error

func (*Store) Set

func (s *Store) Set(ctx context.Context, t term.Triple, _ term.Term) error

func (*Store) TransactionAware

func (s *Store) TransactionAware() bool

func (*Store) Triples

func (s *Store) Triples(ctx context.Context, pattern term.TriplePattern, _ term.Term) store.TripleIterator

Triples yields the matching triples; it yields ctx's error once and stops if the context is done.

func (*Store) TriplesWithLimit

func (s *Store) TriplesWithLimit(ctx context.Context, pattern term.TriplePattern, _ term.Term, limit, offset int) store.TripleIterator

Jump to

Keyboard shortcuts

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