Support parse UUID without separator#11856
Merged
alexey-milovidov merged 5 commits intoClickHouse:masterfrom Jun 25, 2020
Merged
Support parse UUID without separator#11856alexey-milovidov merged 5 commits intoClickHouse:masterfrom
alexey-milovidov merged 5 commits intoClickHouse:masterfrom
Conversation
2e3541c to
b3ef9a9
Compare
src/IO/ReadHelpers.h
Outdated
| @@ -577,13 +636,18 @@ inline void readUUIDText(UUID & uuid, ReadBuffer & buf) | |||
| char s[36]; | |||
| size_t size = buf.read(s, 36); | |||
Member
There was a problem hiding this comment.
But how we will continue to read next data from buffer if we already read extra bytes?
src/IO/ReadHelpers.h
Outdated
| size_t dst_pos = 0; | ||
| for (; dst_pos < num_bytes; ++dst_pos) | ||
| { | ||
| dst[dst_pos] = UInt8(unhex(src[src_pos])) * 16 + UInt8(unhex(src[src_pos + 1])); |
Member
There was a problem hiding this comment.
The unhex2 function is exactly for this purpose.
src/IO/ReadHelpers.h
Outdated
| } | ||
|
|
||
| template <bool with_separator> | ||
| void parseUUID(const UInt8 * src36, UInt8 * dst16) |
Member
There was a problem hiding this comment.
This template is always used with explicit parameter. And it is implemented with two separate branches...
So, we can simply make two functions:
parseUUID
parseUUIDWithoutSeparator
src/IO/ReadHelpers.h
Outdated
| } | ||
| else | ||
| { | ||
| parseHex(&src36[0], &dst16[0], 4); |
Member
There was a problem hiding this comment.
Why don't parse it all with one call of parseHex?
b992f3f to
c3a38e7
Compare
Member
|
Better to add examples to docs about UUID |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
I hereby agree to the terms of the CLA available at: https://yandex.ru/legal/cla/?lang=en
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):
Support parse UUID without separator(separators are always removed in most implementations, this is helpful for users to write data)