finished rearranging the code

This commit is contained in:
myrrc 2020-12-22 19:45:03 +03:00
parent 2db721b647
commit 57bb75b75b

View File

@ -314,7 +314,12 @@ public:
if constexpr(op_case == OpCase::LeftConstant) static_assert(!IsDecimalNumber<A>);
if constexpr(op_case == OpCase::RightConstant) static_assert(!IsDecimalNumber<B>);
const size_t size = a.size();
size_t size;
if constexpr(op_case == OpCase::LeftConstant)
size = b.size();
else
size = a.size();
if constexpr (is_plus_minus_compare)
{
@ -390,10 +395,11 @@ private:
Operation<NativeResultType, NativeResultType>>;
template <OpCase op_case, OpCase target>
static auto unwrap(const auto& elem, int i)
static auto unwrap(const auto& elem, size_t i)
{
if constexpr(op_case == target)
return undec(elem);
else
return undec(elem[i]);
}
@ -1062,9 +1068,9 @@ public:
if constexpr (std::is_same_v<ResultDataType, InvalidType>)
return nullptr;
static_assert(!std::is_same_v<ResultDataType, InvalidType>);
else // we can't avoid the else because otherwise the compiler may assume the ResultDataType may be Invalid
// and that would produce the compile error.
{
using T0 = typename LeftDataType::FieldType;
using T1 = typename RightDataType::FieldType;
using ResultType = typename ResultDataType::FieldType;
@ -1089,7 +1095,9 @@ public:
col_left_const, col_right_const,
col_left, col_right,
col_left_size);
else //can't avoid else and another indentation level, otherwise the compiler would try to instantiate
// ColVecResult for Decimals which would lead to a compile error.
{
using OpImpl = BinaryOperationImpl<T0, T1, Op<T0, T1>, ResultType>;
/// non-vector result
@ -1103,6 +1111,7 @@ public:
}
typename ColVecResult::MutablePtr col_res = ColVecResult::create();
auto & vec_res = col_res->getData();
vec_res.resize(col_left_size);
@ -1116,17 +1125,21 @@ public:
}
else if (col_left_const && col_right)
{
const T0 value = col_left_const->template getValue<T0>();
OpImpl::template process<OpCase::LeftConstant>(
col_left_const->template getValue<T0>(),
&value,
col_right->getData().data(),
vec_res.data(),
vec_res.size());
}
else if (col_left && col_right_const)
{
const T1 value = col_right_const->template getValue<T1>();
OpImpl::template process<OpCase::RightConstant>(
col_left->getData().data(),
col_right_const->template getValue<T1>(),
&value,
vec_res.data(),
vec_res.size());
}
@ -1135,6 +1148,8 @@ public:
return col_res;
}
}
}
ColumnPtr executeImpl(const ColumnsWithTypeAndName & arguments, const DataTypePtr & result_type, size_t input_rows_count) const override
{