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 ¶
- type Store
- func (s *Store) Add(ctx context.Context, t term.Triple, _ term.Term) error
- func (s *Store) AddN(ctx context.Context, quads []term.Quad) error
- func (s *Store) Bind(ctx context.Context, prefix string, namespace term.URIRef) error
- func (s *Store) ContextAware() bool
- func (s *Store) Contexts(ctx context.Context, _ *term.Triple) store.TermIterator
- func (s *Store) Count(ctx context.Context, pattern term.TriplePattern, _ term.Term) (int, error)
- func (s *Store) Exists(ctx context.Context, pattern term.TriplePattern, _ term.Term) (bool, error)
- func (s *Store) Len(ctx context.Context, _ term.Term) (int, error)
- func (s *Store) Namespace(ctx context.Context, prefix string) (term.URIRef, bool, error)
- func (s *Store) Namespaces(ctx context.Context) store.NamespaceIterator
- func (s *Store) Prefix(ctx context.Context, namespace term.URIRef) (string, bool, error)
- func (s *Store) Remove(ctx context.Context, pattern term.TriplePattern, _ term.Term) error
- func (s *Store) Set(ctx context.Context, t term.Triple, _ term.Term) error
- func (s *Store) TransactionAware() bool
- func (s *Store) Triples(ctx context.Context, pattern term.TriplePattern, _ term.Term) store.TripleIterator
- func (s *Store) TriplesWithLimit(ctx context.Context, pattern term.TriplePattern, _ term.Term, ...) store.TripleIterator
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 (*Store) ContextAware ¶
func (*Store) Namespaces ¶
func (s *Store) Namespaces(ctx context.Context) store.NamespaceIterator
func (*Store) TransactionAware ¶
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