Documentation ¶
Overview ¶
Package triplestore provides utilities for saving and querying triples with a sqlite3 backend.
Index ¶
- Constants
- Variables
- func ArrayOpToSQL(q *protocol.ArrayOp) []string
- func TripleToSQL(triple *protocol.Triple) []string
- type Info
- type TripleStore
- func (ts *TripleStore) Bloom(keyspace *protocol.Keyspace) (*boom.ScalableBloomFilter, error)
- func (ts *TripleStore) EachTripleBatch(size int) (<-chan []*protocol.Triple, <-chan error)
- func (ts *TripleStore) Insert(triples []*protocol.Triple) int
- func (ts *TripleStore) Query(query *protocol.Triple, limit int) ([]*protocol.Triple, error)
- func (ts *TripleStore) QueryArrayOp(q *protocol.ArrayOp, limit int) ([]*protocol.Triple, error)
- func (ts *TripleStore) Size() (*Info, error)
- func (ts *TripleStore) TriplesMatchingBloom(filter *boom.ScalableBloomFilter) (<-chan []*protocol.Triple, <-chan error)
Constants ¶
const ( // BloomFalsePositiveRate with 1 million items is about 5.14MB in size. Scales linearly. // http://hur.st/bloomfilter?n=1000000&p=1.0E-9 BloomFalsePositiveRate = 1.0e-9 )
Variables ¶
var DefaultTripleBatchSize = 1000
DefaultTripleBatchSize is the default number of triples to use when streaming.
Functions ¶
func ArrayOpToSQL ¶
func TripleToSQL ¶
Types ¶
type Info ¶
type Info struct {
Triples, DiskSize, AvailableSpace uint64
}
Info represents the state of the database.
type TripleStore ¶
type TripleStore struct {
// contains filtered or unexported fields
}
func NewTripleStore ¶
func NewTripleStore(file string, logger *log.Logger) (*TripleStore, error)
NewTripleStore returns a TripleStore with the specified file.
func (*TripleStore) Bloom ¶
func (ts *TripleStore) Bloom(keyspace *protocol.Keyspace) (*boom.ScalableBloomFilter, error)
Bloom returns a ScalableBloomFilter containing all the triples the current node has in the optional keyspace.
func (*TripleStore) EachTripleBatch ¶
func (ts *TripleStore) EachTripleBatch(size int) (<-chan []*protocol.Triple, <-chan error)
EachTripleBatch is used to stream triples from the database in batches of the specified size.
func (*TripleStore) Insert ¶
func (ts *TripleStore) Insert(triples []*protocol.Triple) int
Insert saves a bunch of triples and returns the number asserted.
func (*TripleStore) Query ¶
Query does a WHERE search with the set fields on query. A limit of -1 returns all results.
func (*TripleStore) QueryArrayOp ¶
QueryArrayOp runs an ArrayOp against the local triple store.
func (*TripleStore) Size ¶
func (ts *TripleStore) Size() (*Info, error)
Size returns an info object about the number of triples and file size of the database.
func (*TripleStore) TriplesMatchingBloom ¶
func (ts *TripleStore) TriplesMatchingBloom(filter *boom.ScalableBloomFilter) (<-chan []*protocol.Triple, <-chan error)
TriplesMatchingBloom streams triples in batches of 1000 that match the bloom filter.