Make Memstore work with the QuadWriter
This commit is contained in:
parent
81b3bf9881
commit
dcb495d145
6 changed files with 167 additions and 141 deletions
|
|
@ -24,8 +24,11 @@ type AllIterator struct {
|
|||
ts *TripleStore
|
||||
}
|
||||
|
||||
func NewMemstoreAllIterator(ts *TripleStore) *AllIterator {
|
||||
var out AllIterator
|
||||
type NodesAllIterator AllIterator
|
||||
type QuadsAllIterator AllIterator
|
||||
|
||||
func NewMemstoreNodesAllIterator(ts *TripleStore) *NodesAllIterator {
|
||||
var out NodesAllIterator
|
||||
out.Int64 = *iterator.NewInt64(1, ts.idCounter-1)
|
||||
out.ts = ts
|
||||
return &out
|
||||
|
|
@ -36,15 +39,33 @@ func (it *AllIterator) SubIterators() []graph.Iterator {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (it *AllIterator) Next() (graph.Value, bool) {
|
||||
next, out := it.Int64.Next()
|
||||
func (nit *NodesAllIterator) Next() (graph.Value, bool) {
|
||||
next, out := nit.Int64.Next()
|
||||
if !out {
|
||||
return next, out
|
||||
}
|
||||
i64 := next.(int64)
|
||||
_, ok := it.ts.revIdMap[i64]
|
||||
_, ok := nit.ts.revIdMap[i64]
|
||||
if !ok {
|
||||
return it.Next()
|
||||
return nit.Next()
|
||||
}
|
||||
return next, out
|
||||
}
|
||||
|
||||
func NewMemstoreQuadsAllIterator(ts *TripleStore) *QuadsAllIterator {
|
||||
var out QuadsAllIterator
|
||||
out.Int64 = *iterator.NewInt64(1, ts.quadIdCounter-1)
|
||||
out.ts = ts
|
||||
return &out
|
||||
}
|
||||
|
||||
func (qit *QuadsAllIterator) Next() (graph.Value, bool) {
|
||||
next, out := qit.Int64.Next()
|
||||
if out {
|
||||
i64 := next.(int64)
|
||||
if qit.ts.log[i64].DeletedBy != 0 || qit.ts.log[i64].Action == graph.Delete {
|
||||
return qit.Next()
|
||||
}
|
||||
}
|
||||
return next, out
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue