-
Notifications
You must be signed in to change notification settings - Fork 429
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sstable: factor out common iterator init code #3738
sstable: factor out common iterator init code #3738
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 3 of 3 files at r1, 2 of 2 files at r2, all commit messages.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @jbowens and @RaduBerinde)
sstable/reader_iter_single_lvl.go
line 204 at r1 (raw file):
ctx, r, v, transforms, lower, upper, filterer, useFilter, stats, categoryAndQoS, statsCollector, rp, bufferPool, ); err != nil { _ = i.Close()
There's a small change here in that on master we were not calling Close() if init()
returned an error.
Do we have enough testing of error paths (or a careful read of the Close code) to have some certainty that calling Close()
is safe, i.e., there isn't some partially initialized state that will blow up in Close (e.g. unexpected nil pointer or something).
edit: there are changes in the second commit that slightly alter the details of the question, but it still stands.
sstable/reader_iter_two_lvl.go
line 166 at r1 (raw file):
topLevelIndexH, err := r.readIndex(ctx, i.indexFilterRH, stats, &i.iterStats) if err != nil { _ = i.Close()
ditto
sstable/reader_iter_two_lvl.go
line 188 at r1 (raw file):
if err != nil { // blockIter.Close releases topLevelIndexH and always returns a nil error _ = i.Close()
ditto
Add `newSingleLevelIterator` and `newTwoLevelIterator` constructors.
This commits factors out most of the `singleLevelIterator` initialization code, so that `twoLevelIterator` can use it too.
d024140
to
1218456
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @jbowens and @sumeerbhola)
sstable/reader_iter_single_lvl.go
line 204 at r1 (raw file):
Previously, sumeerbhola wrote…
There's a small change here in that on master we were not calling Close() if
init()
returned an error.
Do we have enough testing of error paths (or a careful read of the Close code) to have some certainty that callingClose()
is safe, i.e., there isn't some partially initialized state that will blow up in Close (e.g. unexpected nil pointer or something).
edit: there are changes in the second commit that slightly alter the details of the question, but it still stands.
Good point, I added a test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 1 of 3 files at r3, 3 of 3 files at r4, all commit messages.
Reviewable status: all files reviewed, 4 unresolved discussions (waiting on @jbowens and @RaduBerinde)
sstable/reader_iter_single_lvl.go
line 204 at r1 (raw file):
Previously, RaduBerinde wrote…
Good point, I added a test.
Thanks
sstable/reader_iter_test.go
line 54 at r4 (raw file):
var stats base.InternalIteratorStats for k := 0; k < 20; k++ {
wondering why this iteration instead of simply creating each kind of iterator once?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: all files reviewed, 4 unresolved discussions (waiting on @jbowens and @sumeerbhola)
sstable/reader_iter_test.go
line 54 at r4 (raw file):
Previously, sumeerbhola wrote…
wondering why this iteration instead of simply creating each kind of iterator once?
Just so we reuse the same iterator from the pool (in case ae leave it in a bad state in this path)
We've had multiple issues with divergences between initializing the data block read handles. This PR removes the code duplication.
sstable: add constructors for iterators
Add
newSingleLevelIterator
andnewTwoLevelIterator
constructors.sstable: factor out common iterator init code
This commits factors out most of the
singleLevelIterator
initialization code, so that
twoLevelIterator
can use it too.