Skip to content

Commit

Permalink
address comment
Browse files Browse the repository at this point in the history
  • Loading branch information
SeaRise committed Oct 9, 2021
1 parent 2593610 commit 399d306
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 31 deletions.
12 changes: 6 additions & 6 deletions dbms/src/Columns/ColumnArray.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -312,12 +312,12 @@ int ColumnArray::compareAt(size_t n, size_t m, const IColumn & rhs_, int nan_dir
namespace
{
template <bool positive>
struct less
struct Less
{
const ColumnArray & parent;
int nan_direction_hint;

less(const ColumnArray & parent_, int nan_direction_hint_)
Less(const ColumnArray & parent_, int nan_direction_hint_)
: parent(parent_)
, nan_direction_hint(nan_direction_hint_)
{}
Expand Down Expand Up @@ -702,16 +702,16 @@ void ColumnArray::getPermutation(bool reverse, size_t limit, int nan_direction_h
if (limit)
{
if (reverse)
std::partial_sort(res.begin(), res.begin() + limit, res.end(), less<false>(*this, nan_direction_hint));
std::partial_sort(res.begin(), res.begin() + limit, res.end(), Less<false>(*this, nan_direction_hint));
else
std::partial_sort(res.begin(), res.begin() + limit, res.end(), less<true>(*this, nan_direction_hint));
std::partial_sort(res.begin(), res.begin() + limit, res.end(), Less<true>(*this, nan_direction_hint));
}
else
{
if (reverse)
std::sort(res.begin(), res.end(), less<false>(*this, nan_direction_hint));
std::sort(res.begin(), res.end(), Less<false>(*this, nan_direction_hint));
else
std::sort(res.begin(), res.end(), less<true>(*this, nan_direction_hint));
std::sort(res.begin(), res.end(), Less<true>(*this, nan_direction_hint));
}
}

Expand Down
3 changes: 1 addition & 2 deletions dbms/src/Columns/ColumnDecimal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,11 @@ StringRef ColumnDecimal<T>::serializeValueIntoArena(size_t n, Arena & arena, cha
{
/// serialize Decimal256 in `Non-trivial, Binary` way, the serialization logical is
/// copied from https://github.com/pingcap/boost-extra/blob/master/boost/multiprecision/cpp_int/serialize.hpp#L149
size_t mem_size;
const typename T::NativeType::backend_type & val = data[n].value.backend();
bool s = val.sign();
size_t limb_count = val.size();

mem_size = sizeof(bool) + sizeof(size_t) + limb_count * sizeof(boost::multiprecision::limb_type);
size_t mem_size = sizeof(bool) + sizeof(size_t) + limb_count * sizeof(boost::multiprecision::limb_type);

auto * pos = arena.allocContinue(mem_size, begin);
auto * current_pos = pos;
Expand Down
42 changes: 21 additions & 21 deletions dbms/src/Columns/ColumnNullable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,11 @@ void getExtremesFromNullableContent(const ColumnVector<T> & col, const NullMap &

} // namespace

template <typename... Ts, typename F>
static void castNestedColumn(const IColumn * nested_column, F && f)
{
((typeid_cast<const Ts *>(nested_column) ? (f(*typeid_cast<const Ts *>(nested_column))) : false) || ...);
}

void ColumnNullable::getExtremes(Field & min, Field & max) const
{
Expand All @@ -478,29 +483,24 @@ void ColumnNullable::getExtremes(Field & min, Field & max) const

const auto & null_map = getNullMapData();

if (const auto * const col = typeid_cast<const ColumnInt8 *>(nested_column.get()))
getExtremesFromNullableContent<Int8>(*col, null_map, min, max);
else if (const auto * const col = typeid_cast<const ColumnInt16 *>(nested_column.get()))
getExtremesFromNullableContent<Int16>(*col, null_map, min, max);
else if (const auto * const col = typeid_cast<const ColumnInt32 *>(nested_column.get()))
getExtremesFromNullableContent<Int32>(*col, null_map, min, max);
else if (const auto * const col = typeid_cast<const ColumnInt64 *>(nested_column.get()))
getExtremesFromNullableContent<Int64>(*col, null_map, min, max);
else if (const auto * const col = typeid_cast<const ColumnUInt8 *>(nested_column.get()))
getExtremesFromNullableContent<UInt8>(*col, null_map, min, max);
else if (const auto * const col = typeid_cast<const ColumnUInt16 *>(nested_column.get()))
getExtremesFromNullableContent<UInt16>(*col, null_map, min, max);
else if (const auto * const col = typeid_cast<const ColumnUInt32 *>(nested_column.get()))
getExtremesFromNullableContent<UInt32>(*col, null_map, min, max);
else if (const auto * const col = typeid_cast<const ColumnUInt64 *>(nested_column.get()))
getExtremesFromNullableContent<UInt64>(*col, null_map, min, max);
else if (const auto * const col = typeid_cast<const ColumnFloat32 *>(nested_column.get()))
getExtremesFromNullableContent<Float32>(*col, null_map, min, max);
else if (const auto * const col = typeid_cast<const ColumnFloat64 *>(nested_column.get()))
getExtremesFromNullableContent<Float64>(*col, null_map, min, max);
castNestedColumn<
ColumnInt8,
ColumnInt16,
ColumnInt32,
ColumnInt64,
ColumnUInt8,
ColumnUInt16,
ColumnUInt32,
ColumnUInt64,
ColumnFloat32,
ColumnFloat64>(nested_column.get(), [&](const auto & column) {
using ColumnType = std::decay_t<decltype(column)>;
using ValueType = typename ColumnType::value_type;
getExtremesFromNullableContent<ValueType>(column, null_map, min, max);
return true;
});
}


ColumnPtr ColumnNullable::replicate(const Offsets & offsets) const
{
ColumnPtr replicated_data = getNestedColumn().replicate(offsets);
Expand Down
5 changes: 3 additions & 2 deletions dbms/src/Columns/ColumnsCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,10 @@ size_t countBytesInFilter(const UInt8 * filt, size_t sz)
const Int8 * end64 = pos + sz / 64 * 64;

for (; pos < end64; pos += 64)
{
count += __builtin_popcountll(toBits64(pos));

/// TODO Add duff device for tail?
}
/// TODO Add duff device for tail?
#endif

for (; pos < end; ++pos)
Expand Down

0 comments on commit 399d306

Please sign in to comment.