Merge with new Next() interface
This commit is contained in:
commit
a1e5a53dd5
48 changed files with 677 additions and 654 deletions
|
|
@ -35,21 +35,19 @@ func NewMemstoreNodesAllIterator(ts *TripleStore) *NodesAllIterator {
|
|||
}
|
||||
|
||||
// No subiterators.
|
||||
func (it *AllIterator) SubIterators() []graph.Iterator {
|
||||
func (nit *NodesAllIterator) SubIterators() []graph.Iterator {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (nit *NodesAllIterator) Next() (graph.Value, bool) {
|
||||
next, out := nit.Int64.Next()
|
||||
if !out {
|
||||
return next, out
|
||||
func (nit *NodesAllIterator) Next() bool {
|
||||
if !nit.Int64.Next() {
|
||||
return false
|
||||
}
|
||||
i64 := next.(int64)
|
||||
_, ok := nit.ts.revIdMap[i64]
|
||||
_, ok := nit.ts.revIdMap[nit.Int64.Result().(int64)]
|
||||
if !ok {
|
||||
return nit.Next()
|
||||
}
|
||||
return next, out
|
||||
return true
|
||||
}
|
||||
|
||||
func NewMemstoreQuadsAllIterator(ts *TripleStore) *QuadsAllIterator {
|
||||
|
|
@ -59,13 +57,13 @@ func NewMemstoreQuadsAllIterator(ts *TripleStore) *QuadsAllIterator {
|
|||
return &out
|
||||
}
|
||||
|
||||
func (qit *QuadsAllIterator) Next() (graph.Value, bool) {
|
||||
next, out := qit.Int64.Next()
|
||||
func (qit *QuadsAllIterator) Next() bool {
|
||||
out := qit.Int64.Next()
|
||||
if out {
|
||||
i64 := next.(int64)
|
||||
i64 := qit.Int64.Result().(int64)
|
||||
if qit.ts.log[i64].DeletedBy != 0 || qit.ts.log[i64].Action == graph.Delete {
|
||||
return qit.Next()
|
||||
}
|
||||
}
|
||||
return next, out
|
||||
return out
|
||||
}
|
||||
|
|
|
|||
|
|
@ -99,7 +99,7 @@ func (it *Iterator) checkValid(index int64) bool {
|
|||
return it.ts.log[index].DeletedBy == 0
|
||||
}
|
||||
|
||||
func (it *Iterator) Next() (graph.Value, bool) {
|
||||
func (it *Iterator) Next() bool {
|
||||
graph.NextLogIn(it)
|
||||
if it.tree.Max() == nil || it.iterLast == it.tree.Max().(Int64) {
|
||||
return graph.NextLogOut(it, nil, false)
|
||||
|
|
@ -120,7 +120,7 @@ func (it *Iterator) Result() graph.Value {
|
|||
return it.result
|
||||
}
|
||||
|
||||
func (it *Iterator) NextResult() bool {
|
||||
func (it *Iterator) NextPath() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ import (
|
|||
)
|
||||
|
||||
func init() {
|
||||
graph.RegisterTripleStore("memstore", func(string, graph.Options) (graph.TripleStore, error) {
|
||||
graph.RegisterTripleStore("memstore", false, func(string, graph.Options) (graph.TripleStore, error) {
|
||||
return newTripleStore(), nil
|
||||
}, nil)
|
||||
}
|
||||
|
|
@ -145,14 +145,10 @@ func (ts *TripleStore) quadExists(t quad.Quad) (bool, int64) {
|
|||
}
|
||||
it := NewLlrbIterator(smallest_tree, "", ts)
|
||||
|
||||
for {
|
||||
val, ok := it.Next()
|
||||
if !ok {
|
||||
break
|
||||
}
|
||||
ival := val.(int64)
|
||||
if t == ts.log[ival].Quad {
|
||||
return true, ival
|
||||
for it.Next() {
|
||||
val := it.Result()
|
||||
if t == ts.log[val.(int64)].Quad {
|
||||
return true, val.(int64)
|
||||
}
|
||||
}
|
||||
return false, 0
|
||||
|
|
|
|||
|
|
@ -37,10 +37,10 @@ func (ts *TripleStore) optimizeLinksTo(it *iterator.LinksTo) (graph.Iterator, bo
|
|||
if primary.Type() == graph.Fixed {
|
||||
size, _ := primary.Size()
|
||||
if size == 1 {
|
||||
val, ok := graph.Next(primary)
|
||||
if !ok {
|
||||
panic("Sizes lie")
|
||||
if !graph.Next(primary) {
|
||||
panic("unexpected size during optimize")
|
||||
}
|
||||
val := primary.Result()
|
||||
newIt := ts.TripleIterator(it.Direction(), val)
|
||||
nt := newIt.Tagger()
|
||||
nt.CopyFrom(it)
|
||||
|
|
|
|||
|
|
@ -117,10 +117,10 @@ func TestIteratorsAndNextResultOrderA(t *testing.T) {
|
|||
outerAnd.AddSubIterator(fixed)
|
||||
outerAnd.AddSubIterator(hasa)
|
||||
|
||||
val, ok := outerAnd.Next()
|
||||
if !ok {
|
||||
if !outerAnd.Next() {
|
||||
t.Error("Expected one matching subtree")
|
||||
}
|
||||
val := outerAnd.Result()
|
||||
if ts.NameOf(val) != "C" {
|
||||
t.Errorf("Matching subtree should be %s, got %s", "barak", ts.NameOf(val))
|
||||
}
|
||||
|
|
@ -131,7 +131,7 @@ func TestIteratorsAndNextResultOrderA(t *testing.T) {
|
|||
)
|
||||
for {
|
||||
got = append(got, ts.NameOf(all.Result()))
|
||||
if !outerAnd.NextResult() {
|
||||
if !outerAnd.NextPath() {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
|
@ -141,8 +141,7 @@ func TestIteratorsAndNextResultOrderA(t *testing.T) {
|
|||
t.Errorf("Unexpected result, got:%q expect:%q", got, expect)
|
||||
}
|
||||
|
||||
val, ok = outerAnd.Next()
|
||||
if ok {
|
||||
if outerAnd.Next() {
|
||||
t.Error("More than one possible top level output?")
|
||||
}
|
||||
}
|
||||
|
|
@ -193,8 +192,7 @@ func TestRemoveTriple(t *testing.T) {
|
|||
hasa := iterator.NewHasA(ts, innerAnd, quad.Object)
|
||||
|
||||
newIt, _ := hasa.Optimize()
|
||||
_, ok := graph.Next(newIt)
|
||||
if ok {
|
||||
if graph.Next(newIt) {
|
||||
t.Error("E should not have any followers.")
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue