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 { for _, sub := range it.internalIterators {
or.AddSubIterator(sub.Clone()) or.AddSubIterator(sub.Clone())
} }
it.CopyTagsFrom(it) or.CopyTagsFrom(it)
return or return or
} }

View file

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

View file

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