triplestore

package
v0.0.0-...-a69b080 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2016 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package triplestore provides utilities for saving and querying triples with a sqlite3 backend.

Index

Constants

View Source
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

View Source
var DefaultTripleBatchSize = 1000

DefaultTripleBatchSize is the default number of triples to use when streaming.

Functions

func ArrayOpToSQL

func ArrayOpToSQL(q *protocol.ArrayOp) []string

func TripleToSQL

func TripleToSQL(triple *protocol.Triple) []string

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

func (ts *TripleStore) Query(query *protocol.Triple, limit int) ([]*protocol.Triple, error)

Query does a WHERE search with the set fields on query. A limit of -1 returns all results.

func (*TripleStore) QueryArrayOp

func (ts *TripleStore) QueryArrayOp(q *protocol.ArrayOp, limit int) ([]*protocol.Triple, error)

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.

Jump to

Keyboard shortcuts

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