Skip to content

Support parse UUID without separator#11856

Merged
alexey-milovidov merged 5 commits intoClickHouse:masterfrom
zhang2014:feature/uuid_without_separator
Jun 25, 2020
Merged

Support parse UUID without separator#11856
alexey-milovidov merged 5 commits intoClickHouse:masterfrom
zhang2014:feature/uuid_without_separator

Conversation

@zhang2014
Copy link
Copy Markdown
Contributor

I hereby agree to the terms of the CLA available at: https://yandex.ru/legal/cla/?lang=en

Changelog category (leave one):

  • Improvement

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)

@zhang2014 zhang2014 force-pushed the feature/uuid_without_separator branch from 2e3541c to b3ef9a9 Compare June 22, 2020 09:31
@@ -577,13 +636,18 @@ inline void readUUIDText(UUID & uuid, ReadBuffer & buf)
char s[36];
size_t size = buf.read(s, 36);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

But how we will continue to read next data from buffer if we already read extra bytes?

@alexey-milovidov alexey-milovidov self-assigned this Jun 22, 2020
@blinkov blinkov added the pr-improvement Pull request with some product improvements label Jun 22, 2020
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]));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The unhex2 function is exactly for this purpose.

}

template <bool with_separator>
void parseUUID(const UInt8 * src36, UInt8 * dst16)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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

}
else
{
parseHex(&src36[0], &dst16[0], 4);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why don't parse it all with one call of parseHex?

@zhang2014 zhang2014 force-pushed the feature/uuid_without_separator branch from b992f3f to c3a38e7 Compare June 23, 2020 03:16
@alexey-milovidov alexey-milovidov merged commit 9de5db9 into ClickHouse:master Jun 25, 2020
@qoega
Copy link
Copy Markdown
Member

qoega commented Jul 27, 2020

Better to add examples to docs about UUID

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-improvement Pull request with some product improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants