Merge branch 'master' into nexter
Conflicts: graph/leveldb/all_iterator.go graph/leveldb/iterator.go graph/memstore/triplestore.go query/gremlin/finals.go
This commit is contained in:
commit
62785d25c2
37 changed files with 882 additions and 467 deletions
|
|
@ -101,13 +101,13 @@ func newTripleStore() *TripleStore {
|
|||
return &ts
|
||||
}
|
||||
|
||||
func (ts *TripleStore) AddTripleSet(triples []*quad.Quad) {
|
||||
func (ts *TripleStore) AddTripleSet(triples []quad.Quad) {
|
||||
for _, t := range triples {
|
||||
ts.AddTriple(t)
|
||||
}
|
||||
}
|
||||
|
||||
func (ts *TripleStore) tripleExists(t *quad.Quad) (bool, int64) {
|
||||
func (ts *TripleStore) tripleExists(t quad.Quad) (bool, int64) {
|
||||
smallest := -1
|
||||
var smallest_tree *llrb.LLRB
|
||||
for d := quad.Subject; d <= quad.Label; d++ {
|
||||
|
|
@ -134,19 +134,19 @@ func (ts *TripleStore) tripleExists(t *quad.Quad) (bool, int64) {
|
|||
|
||||
for it.Next() {
|
||||
val := it.Result()
|
||||
if t.Equals(&ts.triples[val.(int64)]) {
|
||||
if t == ts.triples[val.(int64)] {
|
||||
return true, val.(int64)
|
||||
}
|
||||
}
|
||||
return false, 0
|
||||
}
|
||||
|
||||
func (ts *TripleStore) AddTriple(t *quad.Quad) {
|
||||
func (ts *TripleStore) AddTriple(t quad.Quad) {
|
||||
if exists, _ := ts.tripleExists(t); exists {
|
||||
return
|
||||
}
|
||||
var tripleID int64
|
||||
ts.triples = append(ts.triples, *t)
|
||||
ts.triples = append(ts.triples, t)
|
||||
tripleID = ts.tripleIdCounter
|
||||
ts.size++
|
||||
ts.tripleIdCounter++
|
||||
|
|
@ -175,7 +175,7 @@ func (ts *TripleStore) AddTriple(t *quad.Quad) {
|
|||
// TODO(barakmich): Add VIP indexing
|
||||
}
|
||||
|
||||
func (ts *TripleStore) RemoveTriple(t *quad.Quad) {
|
||||
func (ts *TripleStore) RemoveTriple(t quad.Quad) {
|
||||
var tripleID int64
|
||||
var exists bool
|
||||
tripleID = 0
|
||||
|
|
@ -221,8 +221,8 @@ func (ts *TripleStore) RemoveTriple(t *quad.Quad) {
|
|||
}
|
||||
}
|
||||
|
||||
func (ts *TripleStore) Quad(index graph.Value) *quad.Quad {
|
||||
return &ts.triples[index.(int64)]
|
||||
func (ts *TripleStore) Quad(index graph.Value) quad.Quad {
|
||||
return ts.triples[index.(int64)]
|
||||
}
|
||||
|
||||
func (ts *TripleStore) TripleIterator(d quad.Direction, value graph.Value) graph.Iterator {
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ import (
|
|||
// \-->|#D#|------------->+---+
|
||||
// +---+
|
||||
//
|
||||
var simpleGraph = []*quad.Quad{
|
||||
var simpleGraph = []quad.Quad{
|
||||
{"A", "follows", "B", ""},
|
||||
{"C", "follows", "B", ""},
|
||||
{"C", "follows", "D", ""},
|
||||
|
|
@ -51,7 +51,7 @@ var simpleGraph = []*quad.Quad{
|
|||
{"G", "status", "cool", "status_graph"},
|
||||
}
|
||||
|
||||
func makeTestStore(data []*quad.Quad) (*TripleStore, []pair) {
|
||||
func makeTestStore(data []quad.Quad) (*TripleStore, []pair) {
|
||||
seen := make(map[string]struct{})
|
||||
ts := newTripleStore()
|
||||
var (
|
||||
|
|
@ -174,7 +174,7 @@ func TestLinksToOptimization(t *testing.T) {
|
|||
func TestRemoveTriple(t *testing.T) {
|
||||
ts, _ := makeTestStore(simpleGraph)
|
||||
|
||||
ts.RemoveTriple(&quad.Quad{"E", "follows", "F", ""})
|
||||
ts.RemoveTriple(quad.Quad{"E", "follows", "F", ""})
|
||||
|
||||
fixed := ts.FixedIterator()
|
||||
fixed.Add(ts.ValueOf("E"))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue