This repository has been archived by the owner on Feb 18, 2024. It is now read-only.
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.
Improved performance in cast Primitive to Binary/String again (4x) #651
Improved performance in cast Primitive to Binary/String again (4x) #651
Changes from 3 commits
f81fb27
219fa2c
fcccb35
e6192f5
7b22720
7e5d73c
52be4d7
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.
I think that this is unsound, even in
unsafe
code: a slice must always have initialized data on it. I propose a different implementation below that avoids introducing another API to theMutableBuffer
. LMK what you think.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.
Yes, I do agree with you. But now
MutableBuffer
is the only way to construct a BinaryArray, maybe we should exposevalues
,offsets
to outside.We can have temp
values
,offset
vectors in the cast kernel and then construct theMutableBuffer
by these two vectors.Refer to clickhouse's style:
https://github.com/ClickHouse/ClickHouse/blob/515cc74530d11e1b2b18a63141b66a15b94748ba/src/Columns/ColumnString.h
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.
this is a really cool idea!
I think we may go a step further, though: since the size is constant, the offsets will be
[0, N, 2N, ..., M*N]
and the values can be constructed directly fromlexical_core::write
, e.g. viaextend
. We also do not need to check for utf8 below because lexical_core guarantees this. We can even ignore the validity of the primitive array and continue writing whatever is in the null slot, and clone the validity.I think this implementation is best done without a
MutableBinaryArray
, though: we benefit from operating on the buffers directly in this case.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.
It's not constant,
T::FORMATTED_SIZE_DECIMAL
is the maximum size to reverse.