Skip to content

Commit

Permalink
Optimize expression LIKE() ESCAPE() for bin collator (pingcap#5489)
Browse files Browse the repository at this point in the history
  • Loading branch information
solotzg authored Aug 2, 2022
1 parent 4972cf3 commit 30fc64c
Show file tree
Hide file tree
Showing 5 changed files with 637 additions and 50 deletions.
14 changes: 4 additions & 10 deletions dbms/src/Functions/CollationOperatorOptimized.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,19 +60,16 @@ __attribute__((flatten, always_inline)) inline void LoopTwoColumns(
{
ColumnString::Offset a_prev_offset = 0;
ColumnString::Offset b_prev_offset = 0;
const auto * a_ptr = reinterpret_cast<const char *>(a_data.data());
const auto * b_ptr = reinterpret_cast<const char *>(b_data.data());

for (size_t i = 0; i < size; ++i)
{
auto a_size = a_offsets[i] - a_prev_offset;
auto b_size = b_offsets[i] - b_prev_offset;

// Remove last zero byte.
func({a_ptr, a_size - 1}, {b_ptr, b_size - 1}, i);

a_ptr += a_size;
b_ptr += b_size;
func({reinterpret_cast<const char *>(&a_data[a_prev_offset]), a_size - 1},
{reinterpret_cast<const char *>(&b_data[b_prev_offset]), b_size - 1},
i);

a_prev_offset = a_offsets[i];
b_prev_offset = b_offsets[i];
Expand All @@ -89,16 +86,13 @@ __attribute__((flatten, always_inline)) inline void LoopOneColumn(
F && func)
{
ColumnString::Offset a_prev_offset = 0;
const auto * a_ptr = reinterpret_cast<const char *>(a_data.data());

for (size_t i = 0; i < size; ++i)
{
auto a_size = a_offsets[i] - a_prev_offset;

// Remove last zero byte.
func({a_ptr, a_size - 1}, i);

a_ptr += a_size;
func({reinterpret_cast<const char *>(&a_data[a_prev_offset]), a_size - 1}, i);
a_prev_offset = a_offsets[i];
}
}
Expand Down
Loading

0 comments on commit 30fc64c

Please sign in to comment.