Rename triple entities were relevant

This commit is contained in:
kortschak 2014-08-27 21:27:01 +09:30
parent ddf8849e60
commit 443a091b72
62 changed files with 664 additions and 664 deletions

View file

@ -273,7 +273,7 @@ func (it *Iterator) Contains(v graph.Value) bool {
}
offset := PositionOf(val, it.dir, it.qs)
if bytes.HasPrefix(val.key[offset:], it.checkId) {
// You may ask, why don't we check to see if it's a valid (not deleted) triple
// You may ask, why don't we check to see if it's a valid (not deleted) quad
// again?
//
// We've already done that -- in order to get the graph.Value token in the

View file

@ -32,7 +32,7 @@ import (
)
func init() {
graph.RegisterTripleStore("bolt", true, newQuadStore, createNewBolt)
graph.RegisterQuadStore("bolt", true, newQuadStore, createNewBolt)
}
var (
@ -77,7 +77,7 @@ func createNewBolt(path string, _ graph.Options) error {
return nil
}
func newQuadStore(path string, options graph.Options) (graph.TripleStore, error) {
func newQuadStore(path string, options graph.Options) (graph.QuadStore, error) {
var qs QuadStore
var err error
db, err := bolt.Open(path, 0600, nil)
@ -136,12 +136,12 @@ func bucketFor(d [4]quad.Direction) []byte {
return []byte{d[0].Prefix(), d[1].Prefix(), d[2].Prefix(), d[3].Prefix()}
}
func (qs *QuadStore) createKeyFor(d [4]quad.Direction, triple quad.Quad) []byte {
func (qs *QuadStore) createKeyFor(d [4]quad.Direction, q quad.Quad) []byte {
key := make([]byte, 0, (hashSize * 4))
key = append(key, qs.convertStringToByteHash(triple.Get(d[0]))...)
key = append(key, qs.convertStringToByteHash(triple.Get(d[1]))...)
key = append(key, qs.convertStringToByteHash(triple.Get(d[2]))...)
key = append(key, qs.convertStringToByteHash(triple.Get(d[3]))...)
key = append(key, qs.convertStringToByteHash(q.Get(d[0]))...)
key = append(key, qs.convertStringToByteHash(q.Get(d[1]))...)
key = append(key, qs.convertStringToByteHash(q.Get(d[2]))...)
key = append(key, qs.convertStringToByteHash(q.Get(d[3]))...)
return key
}
@ -243,11 +243,11 @@ func (qs *QuadStore) buildQuadWrite(tx *bolt.Tx, q quad.Quad, id int64, isAdd bo
}
if isAdd && len(entry.History)%2 == 1 {
glog.Error("Adding a valid triple ", entry)
glog.Error("Adding a valid quad ", entry)
return graph.ErrQuadExists
}
if !isAdd && len(entry.History)%2 == 0 {
glog.Error("Deleting an invalid triple ", entry)
glog.Error("Deleting an invalid quad ", entry)
return graph.ErrQuadNotExist
}
@ -373,7 +373,7 @@ func (qs *QuadStore) Quad(k graph.Value) quad.Quad {
return json.Unmarshal(data, &q)
})
if err != nil {
glog.Error("Error getting triple: ", err)
glog.Error("Error getting quad: ", err)
return quad.Quad{}
}
return q
@ -459,7 +459,7 @@ func (qs *QuadStore) getMetadata() error {
return err
}
func (qs *QuadStore) TripleIterator(d quad.Direction, val graph.Value) graph.Iterator {
func (qs *QuadStore) QuadIterator(d quad.Direction, val graph.Value) graph.Iterator {
var bucket []byte
switch d {
case quad.Subject:
@ -480,11 +480,11 @@ func (qs *QuadStore) NodesAllIterator() graph.Iterator {
return NewAllIterator(nodeBucket, quad.Any, qs)
}
func (qs *QuadStore) TriplesAllIterator() graph.Iterator {
func (qs *QuadStore) QuadsAllIterator() graph.Iterator {
return NewAllIterator(posBucket, quad.Predicate, qs)
}
func (qs *QuadStore) TripleDirection(val graph.Value, d quad.Direction) graph.Value {
func (qs *QuadStore) QuadDirection(val graph.Value, d quad.Direction) graph.Value {
v := val.(*Token)
offset := PositionOf(v, d, qs)
if offset != -1 {

View file

@ -19,16 +19,16 @@ import (
"github.com/google/cayley/graph/iterator"
)
func (ts *QuadStore) OptimizeIterator(it graph.Iterator) (graph.Iterator, bool) {
func (qs *QuadStore) OptimizeIterator(it graph.Iterator) (graph.Iterator, bool) {
switch it.Type() {
case graph.LinksTo:
return ts.optimizeLinksTo(it.(*iterator.LinksTo))
return qs.optimizeLinksTo(it.(*iterator.LinksTo))
}
return it, false
}
func (ts *QuadStore) optimizeLinksTo(it *iterator.LinksTo) (graph.Iterator, bool) {
func (qs *QuadStore) optimizeLinksTo(it *iterator.LinksTo) (graph.Iterator, bool) {
subs := it.SubIterators()
if len(subs) != 1 {
return it, false
@ -41,7 +41,7 @@ func (ts *QuadStore) optimizeLinksTo(it *iterator.LinksTo) (graph.Iterator, bool
panic("unexpected size during optimize")
}
val := primary.Result()
newIt := ts.TripleIterator(it.Direction(), val)
newIt := qs.QuadIterator(it.Direction(), val)
nt := newIt.Tagger()
nt.CopyFrom(it)
for _, tag := range primary.Tagger().Tags() {