merge rename_fix

This commit is contained in:
Barak Michener 2014-07-03 16:02:54 -04:00
commit e4df9488e7
3 changed files with 32 additions and 32 deletions

View file

@ -72,7 +72,7 @@ func (it *Or) Clone() graph.Iterator {
for _, sub := range it.internalIterators {
or.AddSubIterator(sub.Clone())
}
it.CopyTagsFrom(it)
or.CopyTagsFrom(it)
return or
}

View file

@ -31,7 +31,7 @@ type AllIterator struct {
prefix []byte
dir graph.Direction
open bool
it ldbit.Iterator
iter ldbit.Iterator
ts *TripleStore
ro *opt.ReadOptions
}
@ -41,28 +41,28 @@ func NewAllIterator(prefix string, d graph.Direction, ts *TripleStore) *AllItera
iterator.BaseInit(&it.Base)
it.ro = &opt.ReadOptions{}
it.ro.DontFillCache = true
it.it = ts.db.NewIterator(nil, it.ro)
it.iter = ts.db.NewIterator(nil, it.ro)
it.prefix = []byte(prefix)
it.dir = d
it.open = true
it.ts = ts
it.it.Seek(it.prefix)
if !it.it.Valid() {
it.iter.Seek(it.prefix)
if !it.iter.Valid() {
it.open = false
it.it.Release()
it.iter.Release()
}
return &it
}
func (it *AllIterator) Reset() {
if !it.open {
it.it = it.ts.db.NewIterator(nil, it.ro)
it.iter = it.ts.db.NewIterator(nil, it.ro)
it.open = true
}
it.it.Seek(it.prefix)
if !it.it.Valid() {
it.iter.Seek(it.prefix)
if !it.iter.Valid() {
it.open = false
it.it.Release()
it.iter.Release()
}
}
@ -78,10 +78,10 @@ func (it *AllIterator) Next() (graph.Value, bool) {
return nil, false
}
var out []byte
out = make([]byte, len(it.it.Key()))
copy(out, it.it.Key())
it.it.Next()
if !it.it.Valid() {
out = make([]byte, len(it.iter.Key()))
copy(out, it.iter.Key())
it.iter.Next()
if !it.iter.Valid() {
it.Close()
}
if !bytes.HasPrefix(out, it.prefix) {
@ -97,10 +97,10 @@ func (it *AllIterator) Check(v graph.Value) bool {
return true
}
func (lit *AllIterator) Close() {
if lit.open {
lit.it.Release()
lit.open = false
func (it *AllIterator) Close() {
if it.open {
it.iter.Release()
it.open = false
}
}

View file

@ -32,7 +32,7 @@ type Iterator struct {
checkId []byte
dir graph.Direction
open bool
it ldbit.Iterator
iter ldbit.Iterator
ts *TripleStore
ro *opt.ReadOptions
originalPrefix string
@ -49,26 +49,26 @@ func NewIterator(prefix string, d graph.Direction, value graph.Value, ts *Triple
it.nextPrefix = append(it.nextPrefix, []byte(it.checkId[1:])...)
it.ro = &opt.ReadOptions{}
it.ro.DontFillCache = true
it.it = ts.db.NewIterator(nil, it.ro)
it.iter = ts.db.NewIterator(nil, it.ro)
it.open = true
it.ts = ts
ok := it.it.Seek(it.nextPrefix)
ok := it.iter.Seek(it.nextPrefix)
if !ok {
it.open = false
it.it.Release()
it.iter.Release()
}
return &it
}
func (it *Iterator) Reset() {
if !it.open {
it.it = it.ts.db.NewIterator(nil, it.ro)
it.iter = it.ts.db.NewIterator(nil, it.ro)
it.open = true
}
ok := it.it.Seek(it.nextPrefix)
ok := it.iter.Seek(it.nextPrefix)
if !ok {
it.open = false
it.it.Release()
it.iter.Release()
}
}
@ -80,13 +80,13 @@ func (it *Iterator) Clone() graph.Iterator {
func (it *Iterator) Close() {
if it.open {
it.it.Release()
it.iter.Release()
it.open = false
}
}
func (it *Iterator) Next() (graph.Value, bool) {
if it.it == nil {
if it.iter == nil {
it.Last = nil
return nil, false
}
@ -94,16 +94,16 @@ func (it *Iterator) Next() (graph.Value, bool) {
it.Last = nil
return nil, false
}
if !it.it.Valid() {
if !it.iter.Valid() {
it.Last = nil
it.Close()
return nil, false
}
if bytes.HasPrefix(it.it.Key(), it.nextPrefix) {
out := make([]byte, len(it.it.Key()))
copy(out, it.it.Key())
if bytes.HasPrefix(it.iter.Key(), it.nextPrefix) {
out := make([]byte, len(it.iter.Key()))
copy(out, it.iter.Key())
it.Last = out
ok := it.it.Next()
ok := it.iter.Next()
if !ok {
it.Close()
}