diff options
author | ale <ale@incal.net> | 2019-09-26 12:10:23 +0100 |
---|---|---|
committer | ale <ale@incal.net> | 2019-09-26 12:10:23 +0100 |
commit | 97221e85d5ab47a1443a7aea0b0461bac5230854 (patch) | |
tree | 7a8fe4093e580f1db64822164fb406b866d2b402 /vendor/github.com/syndtr/goleveldb/leveldb/db_iter.go | |
parent | 64eb5fb23f64f209e3d813e017097044a111151f (diff) | |
download | crawl-97221e85d5ab47a1443a7aea0b0461bac5230854.tar.gz crawl-97221e85d5ab47a1443a7aea0b0461bac5230854.zip |
Update vendored dependencies
Diffstat (limited to 'vendor/github.com/syndtr/goleveldb/leveldb/db_iter.go')
-rw-r--r-- | vendor/github.com/syndtr/goleveldb/leveldb/db_iter.go | 43 |
1 files changed, 26 insertions, 17 deletions
diff --git a/vendor/github.com/syndtr/goleveldb/leveldb/db_iter.go b/vendor/github.com/syndtr/goleveldb/leveldb/db_iter.go index 03c24cd..e6e8ca5 100644 --- a/vendor/github.com/syndtr/goleveldb/leveldb/db_iter.go +++ b/vendor/github.com/syndtr/goleveldb/leveldb/db_iter.go @@ -78,13 +78,17 @@ func (db *DB) newIterator(auxm *memDB, auxt tFiles, seq uint64, slice *util.Rang } rawIter := db.newRawIterator(auxm, auxt, islice, ro) iter := &dbIter{ - db: db, - icmp: db.s.icmp, - iter: rawIter, - seq: seq, - strict: opt.GetStrict(db.s.o.Options, ro, opt.StrictReader), - key: make([]byte, 0), - value: make([]byte, 0), + db: db, + icmp: db.s.icmp, + iter: rawIter, + seq: seq, + strict: opt.GetStrict(db.s.o.Options, ro, opt.StrictReader), + disableSampling: db.s.o.GetDisableSeeksCompaction() || db.s.o.GetIteratorSamplingRate() <= 0, + key: make([]byte, 0), + value: make([]byte, 0), + } + if !iter.disableSampling { + iter.samplingGap = db.iterSamplingRate() } atomic.AddInt32(&db.aliveIters, 1) runtime.SetFinalizer(iter, (*dbIter).Release) @@ -107,13 +111,14 @@ const ( // dbIter represent an interator states over a database session. type dbIter struct { - db *DB - icmp *iComparer - iter iterator.Iterator - seq uint64 - strict bool - - smaplingGap int + db *DB + icmp *iComparer + iter iterator.Iterator + seq uint64 + strict bool + disableSampling bool + + samplingGap int dir dir key []byte value []byte @@ -122,10 +127,14 @@ type dbIter struct { } func (i *dbIter) sampleSeek() { + if i.disableSampling { + return + } + ikey := i.iter.Key() - i.smaplingGap -= len(ikey) + len(i.iter.Value()) - for i.smaplingGap < 0 { - i.smaplingGap += i.db.iterSamplingRate() + i.samplingGap -= len(ikey) + len(i.iter.Value()) + for i.samplingGap < 0 { + i.samplingGap += i.db.iterSamplingRate() i.db.sampleSeek(ikey) } } |