Skip to content
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

Keys for the table data #1356

Merged
merged 3 commits into from
Jun 16, 2015
Merged

Keys for the table data #1356

merged 3 commits into from
Jun 16, 2015

Conversation

vivekmenezes
Copy link
Contributor

Keys for the table data

@tbg tbg added the PTAL label Jun 12, 2015
// TableDataPrefix prefixes all Table data to aid in transitioning
// key:value data to Table data, and for ease of debugging.
TableDataPrefix = proto.Key("table-")
TableDataPrefixLength = 6
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/6/len(TableDataPrefix)/g?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seeing how this value is used, I'd just nuke it and use len(TableDataPrefix) when needed.

@petermattis
Copy link
Collaborator

@vivekmenezes Github is far inferior to Mondrian when it comes to code reviews. I do not receive notification when you've uploaded a new patch set and cannot easily tell when you've addressed a comment. It is good practice to respond to every comment someone makes on your PR with a "Done" or "Note done and here is why...".

@vivekmenezes vivekmenezes force-pushed the vivek/keys branch 3 times, most recently from c77be71 to 38e4a05 Compare June 16, 2015 01:20
@vivekmenezes
Copy link
Contributor Author

Ready for another viewing

@@ -62,7 +59,7 @@ func NodeStatusKey(nodeID int32) proto.Key {

// MakeNameMetadataKey returns the key for the namespace.
func MakeNameMetadataKey(parentID uint32, name string) proto.Key {
k := make([]byte, 0, len(NameMetadataPrefix)+maxVarintSize+len(name))
k := make([]byte, 0, len(NameMetadataPrefix)+binary.MaxVarintLen64+len(name))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're not using encoding/binary for encoding our varints, so it is incorrect to use binary.MaxVarintLen64 here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see it being used by Encoding() in

util/encoding/encoding.go

Should I rename maxVarintSize to MaxEncodeUvarint and export it from util/encoding/encoding.go package then?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should I rename maxVarintSize to MaxEncodeUvarint and export it from util/encoding/encoding.go package then?

Yep

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The use of binary.PutVarint in util/encoding.Encode should really be removed. Looks like the only use of that method is by engine.Increment() which appears to be unused.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will look at taking that out in a new PR

On Tue, Jun 16, 2015 at 10:14 AM Peter Mattis [email protected]
wrote:

In keys/keys.go
#1356 (comment):

@@ -62,7 +59,7 @@ func NodeStatusKey(nodeID int32) proto.Key {

// MakeNameMetadataKey returns the key for the namespace.
func MakeNameMetadataKey(parentID uint32, name string) proto.Key {

  • k := make([]byte, 0, len(NameMetadataPrefix)+maxVarintSize+len(name))
  • k := make([]byte, 0, len(NameMetadataPrefix)+binary.MaxVarintLen64+len(name))

The use of binary.PutVarint in util/encoding.Encode should really be
removed. Looks like the only use of that method is by engine.Increment()
which appears to be unused.


Reply to this email directly or view it on GitHub
https://github.com/cockroachdb/cockroach/pull/1356/files#r32524472.

@petermattis
Copy link
Collaborator

LGTM modulo the binary.MaxVarintLen64 issue.

@@ -287,6 +287,11 @@ func DecodeVarintDecreasing(b []byte) ([]byte, int64) {
return leftover, ^v
}

const (
// MaxUvarintSize is the maximum size in bytes of an encoded uvarint.
MaxUvarintSize = 10
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/10/9/g

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah yes

@petermattis
Copy link
Collaborator

LGTM

@vivekmenezes vivekmenezes changed the title Vivek/keys Keys for the table data Jun 16, 2015
vivekmenezes added a commit that referenced this pull request Jun 16, 2015
@vivekmenezes vivekmenezes merged commit f879530 into master Jun 16, 2015
@tbg tbg removed the PTAL label Jun 16, 2015
@vivekmenezes vivekmenezes deleted the vivek/keys branch June 16, 2015 14:36
@@ -62,7 +58,7 @@ func NodeStatusKey(nodeID int32) proto.Key {

// MakeNameMetadataKey returns the key for the namespace.
func MakeNameMetadataKey(parentID uint32, name string) proto.Key {
k := make([]byte, 0, len(NameMetadataPrefix)+maxVarintSize+len(name))
k := make([]byte, 0, len(NameMetadataPrefix)+encoding.MaxUvarintSize+len(name))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is still incorrect

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

disregard, encoding is util/encoding!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants