提交 814b47a4 编写于 作者: M Michael Kolupaev

clickhouse: optimized bitmaskTo* functions [#CONV-6788].

上级 3cd4ad64
......@@ -573,13 +573,12 @@ public:
for (size_t row = 0; row < size; ++row)
{
T x = vec_from[row];
for (size_t i = 0; i < sizeof(T) * 8; ++i)
while (x)
{
T bit = static_cast<T>(1) << i;
if (x & bit)
{
res_values.push_back(bit);
}
T y = (x & (x - 1));
T bit = x ^ y;
x = y;
res_values.push_back(bit);
}
res_offsets[row] = res_values.size();
}
......
......@@ -51,16 +51,15 @@ public:
inline static void writeBitmask(T x, WriteBuffer & out)
{
bool first = true;
for (size_t i = 0; i < sizeof(T) * 8; ++i)
while (x)
{
T bit = static_cast<T>(1) << i;
if (x & bit)
{
if (!first)
out.write(",", 1);
first = false;
writeIntText(bit, out);
}
T y = (x & (x - 1));
T bit = x ^ y;
x = y;
if (!first)
out.write(",", 1);
first = false;
writeIntText(bit, out);
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册