storage/engine: optionalize + document MVCCGet#33213
storage/engine: optionalize + document MVCCGet#33213craig[bot] merged 3 commits intocockroachdb:masterfrom
Conversation
petermattis
left a comment
There was a problem hiding this comment.
modulo small comment about the extra allocation caused by transforming the pointer to a slice.
Reviewed 34 of 34 files at r1.
Reviewable status:complete! 1 of 0 LGTMs obtained
pkg/storage/batcheval/cmd_get.go, line 47 at r2 (raw file):
var intents []roachpb.Intent if intent != nil { intents = append(intents, *intent)
This results in an extra allocation as we allocated once to return the *intent and again here to create the backing array for the slice. Is this worth worry about? Probably not.
pkg/storage/engine/engine.go, line 107 at r1 (raw file):
// MVCCGet is the internal implementation of the family of package-level // MVCCGet functions. The notable difference is that key/value pairs are // returned raw, as a buffer of varint-prefixed slices, alternating from key
This doesn't look accurate. Iterator.MVCCGet has the same interface as the package-level MVCCGet.
pkg/storage/engine/mvcc.go, line 681 at r1 (raw file):
// ... // keyA_Timestamp_0 : value of version_0 // keyB : MVCCMetadata of keyB
Is there a documentation comment elsewhere about the MVCC key structure? Seems a shame to remove this if this is the only comment describing the structure.
pkg/storage/engine/rocksdb.go, line 2257 at r1 (raw file):
state := C.MVCCGet( r.iter, goToCSlice(key), goToCTimestamp(timestamp), goToCTxn(opts.Txn), C.bool(!opts.Inconsistent), C.bool(opts.Tombstones),
I wonder if you should go the extra mile and change the libroach MVCCGet function parameter from consistent to inconsistent. It will be a bit confusing in the future to stumble across that polarity change.
benesch
left a comment
There was a problem hiding this comment.
Reviewable status:
complete! 0 of 0 LGTMs obtained (and 1 stale)
pkg/storage/batcheval/cmd_get.go, line 47 at r2 (raw file):
Previously, petermattis (Peter Mattis) wrote…
This results in an extra allocation as we allocated once to return the
*intentand again here to create the backing array for the slice. Is this worth worry about? Probably not.
Yeah, I figured it was safe because nothing perf-sensitive uses the Get API AFAIK. (E.g., result.FromIntents allocates again to construct the result.)
pkg/storage/engine/engine.go, line 107 at r1 (raw file):
Previously, petermattis (Peter Mattis) wrote…
This doesn't look accurate.
Iterator.MVCCGethas the same interface as the package-levelMVCCGet.
Oops, thanks for the fact check. Done.
pkg/storage/engine/mvcc.go, line 681 at r1 (raw file):
Previously, petermattis (Peter Mattis) wrote…
Is there a documentation comment elsewhere about the MVCC key structure? Seems a shame to remove this if this is the only comment describing the structure.
Good point. Not that I can find. I've moved the diagram to the doc.go in this package.
pkg/storage/engine/rocksdb.go, line 2257 at r1 (raw file):
Previously, petermattis (Peter Mattis) wrote…
I wonder if you should go the extra mile and change the
libroachMVCCGetfunction parameter fromconsistenttoinconsistent. It will be a bit confusing in the future to stumble across that polarity change.
Yeah, I'd been thinking about that. Done. Thanks for the push.
43e5ace to
0ed047e
Compare
petermattis
left a comment
There was a problem hiding this comment.
![]()
Reviewable status:
complete! 0 of 0 LGTMs obtained (and 1 stale)
pkg/storage/batcheval/cmd_get.go, line 47 at r2 (raw file):
Previously, benesch (Nikhil Benesch) wrote…
Yeah, I figured it was safe because nothing perf-sensitive uses the Get API AFAIK. (E.g., result.FromIntents allocates again to construct the result.)
Yeah, I'm ok with this.
For symmetry with 4678a31, which extracted an MVCCScanOptions struct. Also take the opportunity to update the documentation for MVCCGet. Release note: None
MVCCGet can only return zero or one intents. This is more naturally represented by a pointer than a slice. Adjust the return value accordingly so that callers do not need to check for MVCCGet returning multiple intents, which is obviously nonsense. Release note: None
For consistency with the Go signature, which uses inconsistent instead of consistent. Release note: None
|
TFTR! bors r=petermattis |
Build succeeded |
No description provided.