store4 is a Go package providing a fast in-memory quad store, with graph and subject views.
go get github.com/jimsmart/store4
import "github.com/jimsmart/store4"
import "github.com/jimsmart/store4"
s := store4.NewQuadStore()
s.Add("Alice", "knows", "Bob", "")
s.Add("Alice", "knows", "Charlie", "")
s.Add("Charlie", "knows", "Bob", "")
s.Add("Charlie", "age", 23, "")
// Find everyone that Alice knows, in any graph.
x := s.FindObjects("Alice", "knows", "*")
// Find everyone who knows Charlie, in the unnamed/default graph.
y := s.FindSubjects("knows", "Charlie", "")
// Iterate over all quads.
s.ForEach(func(s, p string, o interface{}, g string) {
// ...
})
// Iterate over quads matching given pattern.
s.ForEachWith("*", "*", "Bob", "*", func(s, p string, o interface{}, g string) {
// ...
})
// Remove all statements about Charlie, from all graphs.
s.Remove("Charlie", "*", "*", "*")
See GoDocs for more detailed examples.
GoDocs https://godoc.org/github.com/jimsmart/store4
Package store4 is extensively tested:
- 200+ Gingko specs (see *_test.go)
- Example code for most methods, with verified output (see *_examples_test.go)
To run the tests execute go test
inside the project folder.
For a full coverage report, try:
go test -coverprofile=coverage.out && go tool cover -html=coverage.out
Package store4 is copyright 2016 by Jim Smart and released under the MIT License
The internals of QuadStore draw heavily from the implementation of N3Store, a component of N3.js. The N3.js library is copyrighted by Ruben Verborgh and released under the MIT License.
- v0.0.1 (2021-04-19) Use Go modules. Enable CI using GitHub Actions. Remove Travis.