[Improvement](vectorized) change static_cast to assert_cast for reference (#12379)
* [Improvement](vectorized) change `static_cast` to `assert_cast` for reference
This commit is contained in:
@ -55,7 +55,7 @@ public:
|
||||
}
|
||||
|
||||
void insert_from(const IColumn& src, size_t n) override {
|
||||
data.push_back(static_cast<const Self&>(src).get_data()[n]);
|
||||
data.push_back(assert_cast<const Self&>(src).get_data()[n]);
|
||||
}
|
||||
|
||||
void insert_data(const char* pos, size_t /*length*/) override {
|
||||
@ -150,7 +150,7 @@ public:
|
||||
}
|
||||
|
||||
void insert_range_from(const IColumn& src, size_t start, size_t length) override {
|
||||
auto& col = static_cast<const Self&>(src);
|
||||
auto& col = assert_cast<const Self&>(src);
|
||||
auto& src_data = col.get_data();
|
||||
auto st = src_data.begin() + start;
|
||||
auto ed = st + length;
|
||||
@ -237,7 +237,7 @@ public:
|
||||
|
||||
void replace_column_data(const IColumn& rhs, size_t row, size_t self_row = 0) override {
|
||||
DCHECK(size() > self_row);
|
||||
data[self_row] = static_cast<const Self&>(rhs).data[row];
|
||||
data[self_row] = assert_cast<const Self&>(rhs).data[row];
|
||||
}
|
||||
|
||||
void replace_column_data_default(size_t self_row = 0) override {
|
||||
@ -254,7 +254,7 @@ MutableColumnPtr ColumnComplexType<T>::clone_resized(size_t size) const {
|
||||
auto res = this->create();
|
||||
|
||||
if (size > 0) {
|
||||
auto& new_col = static_cast<Self&>(*res);
|
||||
auto& new_col = assert_cast<Self&>(*res);
|
||||
new_col.data = this->data;
|
||||
}
|
||||
|
||||
|
||||
@ -35,7 +35,7 @@ namespace doris::vectorized {
|
||||
|
||||
template <typename T>
|
||||
int ColumnDecimal<T>::compare_at(size_t n, size_t m, const IColumn& rhs_, int) const {
|
||||
auto& other = static_cast<const Self&>(rhs_);
|
||||
auto& other = assert_cast<const Self&>(rhs_);
|
||||
const T& a = data[n];
|
||||
const T& b = other.data[m];
|
||||
|
||||
@ -157,7 +157,7 @@ MutableColumnPtr ColumnDecimal<T>::clone_resized(size_t size) const {
|
||||
auto res = this->create(0, scale);
|
||||
|
||||
if (size > 0) {
|
||||
auto& new_col = static_cast<Self&>(*res);
|
||||
auto& new_col = assert_cast<Self&>(*res);
|
||||
new_col.data.resize(size);
|
||||
|
||||
size_t count = std::min(this->size(), size);
|
||||
|
||||
@ -97,7 +97,7 @@ public:
|
||||
void resize(size_t n) override { data.resize(n); }
|
||||
|
||||
void insert_from(const IColumn& src, size_t n) override {
|
||||
data.push_back(static_cast<const Self&>(src).get_data()[n]);
|
||||
data.push_back(assert_cast<const Self&>(src).get_data()[n]);
|
||||
}
|
||||
|
||||
void insert_indices_from(const IColumn& src, const int* indices_begin,
|
||||
@ -215,7 +215,7 @@ public:
|
||||
|
||||
void replace_column_data(const IColumn& rhs, size_t row, size_t self_row = 0) override {
|
||||
DCHECK(size() > self_row);
|
||||
data[self_row] = static_cast<const Self&>(rhs).data[row];
|
||||
data[self_row] = assert_cast<const Self&>(rhs).data[row];
|
||||
}
|
||||
|
||||
void replace_column_data_default(size_t self_row = 0) override {
|
||||
|
||||
@ -20,6 +20,7 @@
|
||||
#include "vec/columns/column.h"
|
||||
#include "vec/columns/columns_common.h"
|
||||
#include "vec/common/arena.h"
|
||||
#include "vec/common/assert_cast.h"
|
||||
#include "vec/common/pod_array.h"
|
||||
|
||||
namespace doris::vectorized {
|
||||
@ -60,7 +61,7 @@ public:
|
||||
auto res = this->create(_item_size);
|
||||
|
||||
if (size > 0) {
|
||||
auto& new_col = static_cast<Self&>(*res);
|
||||
auto& new_col = assert_cast<Self&>(*res);
|
||||
new_col.resize(size);
|
||||
auto* new_data = new_col._data.data();
|
||||
|
||||
@ -75,7 +76,7 @@ public:
|
||||
|
||||
void insert_indices_from(const IColumn& src, const int* indices_begin,
|
||||
const int* indices_end) override {
|
||||
const Self& src_vec = static_cast<const Self&>(src);
|
||||
const Self& src_vec = assert_cast<const Self&>(src);
|
||||
auto origin_size = size();
|
||||
auto new_size = indices_end - indices_begin;
|
||||
if (_item_size == 0) {
|
||||
|
||||
@ -226,7 +226,7 @@ MutableColumnPtr ColumnVector<T>::clone_resized(size_t size) const {
|
||||
auto res = this->create();
|
||||
|
||||
if (size > 0) {
|
||||
auto& new_col = static_cast<Self&>(*res);
|
||||
auto& new_col = assert_cast<Self&>(*res);
|
||||
new_col.data.resize(size);
|
||||
|
||||
size_t count = std::min(this->size(), size);
|
||||
|
||||
@ -27,6 +27,7 @@
|
||||
#include "vec/columns/column.h"
|
||||
#include "vec/columns/column_impl.h"
|
||||
#include "vec/columns/column_vector_helper.h"
|
||||
#include "vec/common/assert_cast.h"
|
||||
#include "vec/common/unaligned.h"
|
||||
#include "vec/core/field.h"
|
||||
|
||||
@ -153,7 +154,7 @@ public:
|
||||
}
|
||||
|
||||
void insert_from(const IColumn& src, size_t n) override {
|
||||
data.push_back(static_cast<const Self&>(src).get_data()[n]);
|
||||
data.push_back(assert_cast<const Self&>(src).get_data()[n]);
|
||||
}
|
||||
|
||||
void insert_data(const char* pos, size_t /*length*/) override {
|
||||
@ -256,7 +257,7 @@ public:
|
||||
|
||||
/// This method implemented in header because it could be possibly devirtualized.
|
||||
int compare_at(size_t n, size_t m, const IColumn& rhs_, int nan_direction_hint) const override {
|
||||
return CompareHelper<T>::compare(data[n], static_cast<const Self&>(rhs_).data[m],
|
||||
return CompareHelper<T>::compare(data[n], assert_cast<const Self&>(rhs_).data[m],
|
||||
nan_direction_hint);
|
||||
}
|
||||
|
||||
@ -372,7 +373,7 @@ public:
|
||||
|
||||
void replace_column_data(const IColumn& rhs, size_t row, size_t self_row = 0) override {
|
||||
DCHECK(size() > self_row);
|
||||
data[self_row] = static_cast<const Self&>(rhs).data[row];
|
||||
data[self_row] = assert_cast<const Self&>(rhs).data[row];
|
||||
}
|
||||
|
||||
void replace_column_data_default(size_t self_row = 0) override {
|
||||
|
||||
Reference in New Issue
Block a user