dbms: Server: changes to make the code a tad more readable [#METR-19266]

This commit is contained in:
Alexey Arno 2016-10-18 15:36:36 +03:00
parent 2a0c842966
commit a4f2f74b8e
3 changed files with 25 additions and 9 deletions

View File

@ -131,7 +131,17 @@ static inline T ALWAYS_INLINE packFixed(
for (size_t j = 0; j < keys_size; ++j) for (size_t j = 0; j < keys_size; ++j)
{ {
bool is_null = has_bitmap && (bitmap[j / 8] & (UINT8_C(1) << (j % 8))); bool is_null;
if (!has_bitmap)
is_null = false;
else
{
size_t bucket = j / 8;
size_t off = j % 8;
is_null = ((bitmap[bucket] >> off) & 1) == 1;
}
if (is_null) if (is_null)
continue; continue;

View File

@ -289,7 +289,6 @@ protected:
const auto & nullable_col = static_cast<const ColumnNullable &>(*col); const auto & nullable_col = static_cast<const ColumnNullable &>(*col);
actual_columns.push_back(nullable_col.getNestedColumn().get()); actual_columns.push_back(nullable_col.getNestedColumn().get());
null_maps.push_back(nullable_col.getNullValuesByteMap().get()); null_maps.push_back(nullable_col.getNullValuesByteMap().get());
has_nullable_columns = true;
} }
else else
{ {
@ -333,7 +332,6 @@ protected:
private: private:
ConstColumnPlainPtrs actual_columns; ConstColumnPlainPtrs actual_columns;
ConstColumnPlainPtrs null_maps; ConstColumnPlainPtrs null_maps;
bool has_nullable_columns = false;
}; };
/// Case where nullable keys are not supported. /// Case where nullable keys are not supported.
@ -422,7 +420,7 @@ struct AggregationMethodKeysFixed
{ {
static constexpr auto bitmap_size = has_nullable_keys ? std::tuple_size<KeysNullMap<Key>>::value : 0; static constexpr auto bitmap_size = has_nullable_keys ? std::tuple_size<KeysNullMap<Key>>::value : 0;
/// In any hash key value, column values to be read start just after the bitmap, if it exists. /// In any hash key value, column values to be read start just after the bitmap, if it exists.
size_t offset = bitmap_size; size_t pos = bitmap_size;
for (size_t i = 0; i < keys_size; ++i) for (size_t i = 0; i < keys_size; ++i)
{ {
@ -449,7 +447,7 @@ struct AggregationMethodKeysFixed
/// corresponding key is nullable. Update the null map accordingly. /// corresponding key is nullable. Update the null map accordingly.
size_t bucket = i / 8; size_t bucket = i / 8;
size_t offset = i % 8; size_t offset = i % 8;
bool val = (reinterpret_cast<const char *>(&value.first)[bucket] >> offset) & 1; UInt8 val = (reinterpret_cast<const UInt8 *>(&value.first)[bucket] >> offset) & 1;
null_map->insert(val); null_map->insert(val);
is_null = val == 1; is_null = val == 1;
} }
@ -461,8 +459,8 @@ struct AggregationMethodKeysFixed
else else
{ {
size_t size = key_sizes[i]; size_t size = key_sizes[i];
observed_column->insertData(reinterpret_cast<const char *>(&value.first) + offset, size); observed_column->insertData(reinterpret_cast<const char *>(&value.first) + pos, size);
offset += size; pos += size;
} }
} }
} }

View File

@ -1599,7 +1599,11 @@ bool FunctionArrayUniq::execute128bit(
{ {
const auto & null_map = static_cast<const ColumnUInt8 &>(*null_maps[i]).getData(); const auto & null_map = static_cast<const ColumnUInt8 &>(*null_maps[i]).getData();
if (null_map[j] == 1) if (null_map[j] == 1)
bitmap[i / 8] |= UINT8_C(1) << (i % 8); {
size_t bucket = i / 8;
size_t offset = i % 8;
bitmap[bucket] |= UInt8(1) << offset;
}
} }
} }
set.insert(packFixed<UInt128>(j, count, columns, key_sizes, bitmap)); set.insert(packFixed<UInt128>(j, count, columns, key_sizes, bitmap));
@ -1909,7 +1913,11 @@ bool FunctionArrayEnumerateUniq::execute128bit(
{ {
const auto & null_map = static_cast<const ColumnUInt8 &>(*null_maps[i]).getData(); const auto & null_map = static_cast<const ColumnUInt8 &>(*null_maps[i]).getData();
if (null_map[j] == 1) if (null_map[j] == 1)
bitmap[i / 8] |= UINT8_C(1) << (i % 8); {
size_t bucket = i / 8;
size_t offset = i % 8;
bitmap[bucket] |= UInt8(1) << offset;
}
} }
} }
res_values[j] = ++indices[packFixed<UInt128>(j, count, columns, key_sizes, bitmap)]; res_values[j] = ++indices[packFixed<UInt128>(j, count, columns, key_sizes, bitmap)];