mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-23 16:12:01 +00:00
Bug fix for funciton fuzzBits
This commit is contained in:
parent
8d3858fc22
commit
26a529fc32
@ -99,18 +99,40 @@ public:
|
||||
ColumnString::Chars & chars_to = col_to->getChars();
|
||||
ColumnString::Offsets & offsets_to = col_to->getOffsets();
|
||||
|
||||
chars_to.resize(col_in->getChars().size());
|
||||
// TODO: Maybe we can share `col_in->getOffsets()` to `offsets_to.resize` like clever pointers? They are same
|
||||
offsets_to.resize(input_rows_count);
|
||||
size_t col_in_rows = col_in->getOffsets().size();
|
||||
|
||||
const auto * ptr_in = col_in->getChars().data();
|
||||
auto * ptr_to = chars_to.data();
|
||||
fuzzBits(ptr_in, ptr_to, chars_to.size(), inverse_probability);
|
||||
|
||||
for (size_t i = 0; i < input_rows_count; ++i)
|
||||
if (col_in_rows >= input_rows_count)
|
||||
{
|
||||
offsets_to[i] = col_in->getOffsets()[i];
|
||||
ptr_to[offsets_to[i] - 1] = 0;
|
||||
chars_to.resize(col_in->getChars().size());
|
||||
// TODO: Maybe we can share `col_in->getOffsets()` to `offsets_to.resize` like clever pointers? They are same
|
||||
offsets_to.resize(input_rows_count);
|
||||
|
||||
const auto * ptr_in = col_in->getChars().data();
|
||||
auto * ptr_to = chars_to.data();
|
||||
fuzzBits(ptr_in, ptr_to, chars_to.size(), inverse_probability);
|
||||
|
||||
for (size_t i = 0; i < input_rows_count; ++i)
|
||||
{
|
||||
offsets_to[i] = col_in->getOffsets()[i];
|
||||
ptr_to[offsets_to[i] - 1] = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
assert(col_in_rows == 1);
|
||||
chars_to.resize(col_in->getChars().size() * input_rows_count);
|
||||
offsets_to.resize(input_rows_count);
|
||||
size_t offset = col_in->getOffsets()[0];
|
||||
|
||||
const auto * ptr_in = col_in->getChars().data();
|
||||
auto * ptr_to = chars_to.data();
|
||||
|
||||
for (size_t i = 0; i < input_rows_count; ++i)
|
||||
{
|
||||
fuzzBits(ptr_in, ptr_to + i * offset, offset, inverse_probability);
|
||||
offsets_to[i] = (i + 1) * offset;
|
||||
ptr_to[offsets_to[i] - 1] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return col_to;
|
||||
|
@ -0,0 +1,5 @@
|
||||
String
|
||||
String
|
||||
String
|
||||
String
|
||||
String
|
@ -0,0 +1,3 @@
|
||||
SELECT toTypeName(fuzzBits('stringstring', 0.5)) from numbers(3);
|
||||
|
||||
SELECT toTypeName(fuzzBits('stringstring', 0.5)) from ( SELECT 1 AS x UNION ALL SELECT NULL ) group by x
|
Loading…
Reference in New Issue
Block a user