Skip to content

Commit

Permalink
minmax: fix copy index data in a wrong way (#8302)
Browse files Browse the repository at this point in the history
close #8301
  • Loading branch information
Lloyd-Pottiger authored Nov 3, 2023
1 parent ec00c9a commit 5f75bdc
Showing 1 changed file with 36 additions and 12 deletions.
48 changes: 36 additions & 12 deletions dbms/src/Storages/DeltaMerge/Index/MinMaxIndex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -305,10 +305,13 @@ RSResults MinMaxIndex::checkNullableEqual(
size_t pos = i * 2;
size_t prev_offset = pos == 0 ? 0 : offsets[pos - 1];
// todo use StringRef instead of String
auto min = String(chars[prev_offset], offsets[pos] - prev_offset - 1);
// When using String, we should use reinterpret_cast<const char *>(&chars[prev_offset]) instead of chars[prev_offset]
// so that it will call constructor `constexpr basic_string( const CharT* s, const Allocator& alloc = Allocator())`
// rather than `constexpr basic_string( size_type count, CharT ch, const Allocator& alloc = Allocator() );`
auto min = String(reinterpret_cast<const char *>(&chars[prev_offset]), offsets[pos] - prev_offset - 1);
pos = i * 2 + 1;
prev_offset = offsets[pos - 1];
auto max = String(chars[prev_offset], offsets[pos] - prev_offset - 1);
auto max = String(reinterpret_cast<const char *>(&chars[prev_offset]), offsets[pos] - prev_offset - 1);
results[i - start_pack] = RoughCheck::checkEqual<String>(value, type, min, max);
}
return results;
Expand Down Expand Up @@ -404,10 +407,13 @@ RSResults MinMaxIndex::checkNullableIn(
size_t pos = i * 2;
size_t prev_offset = pos == 0 ? 0 : offsets[pos - 1];
// todo use StringRef instead of String
auto min = String(chars[prev_offset], offsets[pos] - prev_offset - 1);
// When using String, we should use reinterpret_cast<const char *>(&chars[prev_offset]) instead of chars[prev_offset]
// so that it will call constructor `constexpr basic_string( const CharT* s, const Allocator& alloc = Allocator())`
// rather than `constexpr basic_string( size_type count, CharT ch, const Allocator& alloc = Allocator() );`
auto min = String(reinterpret_cast<const char *>(&chars[prev_offset]), offsets[pos] - prev_offset - 1);
pos = i * 2 + 1;
prev_offset = offsets[pos - 1];
auto max = String(chars[prev_offset], offsets[pos] - prev_offset - 1);
auto max = String(reinterpret_cast<const char *>(&chars[prev_offset]), offsets[pos] - prev_offset - 1);
results[i - start_pack] = RoughCheck::checkIn<String>(values, type, min, max);
}
return results;
Expand Down Expand Up @@ -495,10 +501,13 @@ RSResults MinMaxIndex::checkEqual(size_t start_pack, size_t pack_count, const Fi
size_t pos = i * 2;
size_t prev_offset = pos == 0 ? 0 : offsets[pos - 1];
// todo use StringRef instead of String
auto min = String(chars[prev_offset], offsets[pos] - prev_offset - 1);
// When using String, we should use reinterpret_cast<const char *>(&chars[prev_offset]) instead of chars[prev_offset]
// so that it will call constructor `constexpr basic_string( const CharT* s, const Allocator& alloc = Allocator())`
// rather than `constexpr basic_string( size_type count, CharT ch, const Allocator& alloc = Allocator() );`
auto min = String(reinterpret_cast<const char *>(&chars[prev_offset]), offsets[pos] - prev_offset - 1);
pos = i * 2 + 1;
prev_offset = offsets[pos - 1];
auto max = String(chars[prev_offset], offsets[pos] - prev_offset - 1);
auto max = String(reinterpret_cast<const char *>(&chars[prev_offset]), offsets[pos] - prev_offset - 1);
results[i - start_pack] = RoughCheck::checkEqual<String>(value, type, min, max);
}
return results;
Expand Down Expand Up @@ -588,10 +597,13 @@ RSResults MinMaxIndex::checkIn(
size_t pos = i * 2;
size_t prev_offset = pos == 0 ? 0 : offsets[pos - 1];
// todo use StringRef instead of String
auto min = String(chars[prev_offset], offsets[pos] - prev_offset - 1);
// When using String, we should use reinterpret_cast<const char *>(&chars[prev_offset]) instead of chars[prev_offset]
// so that it will call constructor `constexpr basic_string( const CharT* s, const Allocator& alloc = Allocator())`
// rather than `constexpr basic_string( size_type count, CharT ch, const Allocator& alloc = Allocator() );`
auto min = String(reinterpret_cast<const char *>(&chars[prev_offset]), offsets[pos] - prev_offset - 1);
pos = i * 2 + 1;
prev_offset = offsets[pos - 1];
auto max = String(chars[prev_offset], offsets[pos] - prev_offset - 1);
auto max = String(reinterpret_cast<const char *>(&chars[prev_offset]), offsets[pos] - prev_offset - 1);
results[i - start_pack] = RoughCheck::checkIn<String>(values, type, min, max);
}
return results;
Expand Down Expand Up @@ -682,10 +694,13 @@ RSResults MinMaxIndex::checkNullableGreater(
size_t pos = i * 2;
size_t prev_offset = pos == 0 ? 0 : offsets[pos - 1];
// todo use StringRef instead of String
auto min = String(chars[prev_offset], offsets[pos] - prev_offset - 1);
// When using String, we should use reinterpret_cast<const char *>(&chars[prev_offset]) instead of chars[prev_offset]
// so that it will call constructor `constexpr basic_string( const CharT* s, const Allocator& alloc = Allocator())`
// rather than `constexpr basic_string( size_type count, CharT ch, const Allocator& alloc = Allocator() );`
auto min = String(reinterpret_cast<const char *>(&chars[prev_offset]), offsets[pos] - prev_offset - 1);
pos = i * 2 + 1;
prev_offset = offsets[pos - 1];
auto max = String(chars[prev_offset], offsets[pos] - prev_offset - 1);
auto max = String(reinterpret_cast<const char *>(&chars[prev_offset]), offsets[pos] - prev_offset - 1);
results[i - start_pack] = RoughCheck::checkGreater<String>(value, type, min, max);
}
return results;
Expand Down Expand Up @@ -778,10 +793,13 @@ RSResults MinMaxIndex::checkGreater(
size_t pos = i * 2;
size_t prev_offset = pos == 0 ? 0 : offsets[pos - 1];
// todo use StringRef instead of String
auto min = String(chars[prev_offset], offsets[pos] - prev_offset - 1);
// When using String, we should use reinterpret_cast<const char *>(&chars[prev_offset]) instead of chars[prev_offset]
// so that it will call constructor `constexpr basic_string( const CharT* s, const Allocator& alloc = Allocator())`
// rather than `constexpr basic_string( size_type count, CharT ch, const Allocator& alloc = Allocator() );`
auto min = String(reinterpret_cast<const char *>(&chars[prev_offset]), offsets[pos] - prev_offset - 1);
pos = i * 2 + 1;
prev_offset = offsets[pos - 1];
auto max = String(chars[prev_offset], offsets[pos] - prev_offset - 1);
auto max = String(reinterpret_cast<const char *>(&chars[prev_offset]), offsets[pos] - prev_offset - 1);
results[i - start_pack] = RoughCheck::checkGreater<String>(value, type, min, max);
}
return results;
Expand Down Expand Up @@ -873,6 +891,9 @@ RSResults MinMaxIndex::checkNullableGreaterEqual(
size_t pos = i * 2;
size_t prev_offset = pos == 0 ? 0 : offsets[pos - 1];
// todo use StringRef instead of String
// When using String, we should use reinterpret_cast<const char *>(&chars[prev_offset]) instead of chars[prev_offset]
// so that it will call constructor `constexpr basic_string( const CharT* s, const Allocator& alloc = Allocator())`
// rather than `constexpr basic_string( size_type count, CharT ch, const Allocator& alloc = Allocator() );`
auto min = String(reinterpret_cast<const char *>(&chars[prev_offset]), offsets[pos] - prev_offset - 1);
pos = i * 2 + 1;
prev_offset = offsets[pos - 1];
Expand Down Expand Up @@ -970,6 +991,9 @@ RSResults MinMaxIndex::checkGreaterEqual(
size_t pos = i * 2;
size_t prev_offset = pos == 0 ? 0 : offsets[pos - 1];
// todo use StringRef instead of String
// When using String, we should use reinterpret_cast<const char *>(&chars[prev_offset]) instead of chars[prev_offset]
// so that it will call constructor `constexpr basic_string( const CharT* s, const Allocator& alloc = Allocator())`
// rather than `constexpr basic_string( size_type count, CharT ch, const Allocator& alloc = Allocator() );`
auto min = String(reinterpret_cast<const char *>(&chars[prev_offset]), offsets[pos] - prev_offset - 1);
pos = i * 2 + 1;
prev_offset = offsets[pos - 1];
Expand Down

0 comments on commit 5f75bdc

Please sign in to comment.