Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Embed key into dict entry #541
Embed key into dict entry #541
Changes from 1 commit
2610832
0936730
f4c54c9
a56e2c9
029917f
3c7d958
7801c7e
9958967
e714f2c
4d30109
88c7a4d
417b15a
e00a633
d9d1cd3
32cafc6
67872b1
1c7fc68
c61bd70
ce76a16
11400e2
4ca43ce
825c82f
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
why do you need this double information about the header size? you can extract it from the "sds", right?
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.
An sds
s
is a pointer to where the string content starts, so it can be used as a C string. It does not point to the start of the allocation. The header is store before the char data in the same allocation, i.e. ats[-1]
,s[-2]
, etc. The header is backwards-encoded in some way, so the byte ats[-1]
says which kind of header it is and how large the header is.When we store this embedded, we want to be able to restore the sds pointer, so we store the size of the header size in the first. When we restore the sds pointer, we can find it using S (the offset to the string contents).
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.
You mean the callers of this function can call
sdsHdrSize(s[-1])
themselves? I'm not sure if it's public.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.
Yea, right agree. I am not so supportive of the desire to keep something as sds when it's not, but that's already in my overall comment, maybe I'll elaborate more there. Thanks
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.
key
is being used throughout the engine as asds
so changing that would be even more touchpoint. We could dynamically build it on thedictGetKey
call but that would be additional penalty. Hence, storing it as a sds made the most sense.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.
I have the same question, the low 3bit in sdshdr.flag have told us the header length, and exposing function
sdsHdrSize
will not lead to coupling between dict.c and sds.c, I don't see any harm in it.