Skip to content

Commit

Permalink
[refactor](column) remove get_family_name interface in column
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangstar333 committed Nov 13, 2024
1 parent a586bac commit de097de
Show file tree
Hide file tree
Showing 21 changed files with 49 additions and 79 deletions.
2 changes: 1 addition & 1 deletion be/src/vec/columns/column.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ namespace doris::vectorized {

std::string IColumn::dump_structure() const {
std::stringstream res;
res << get_family_name() << "(size = " << size();
res << get_name() << "(size = " << size();

ColumnCallback callback = [&](ColumnPtr& subcolumn) {
res << ", " << subcolumn->dump_structure();
Expand Down
10 changes: 3 additions & 7 deletions be/src/vec/columns/column.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,7 @@ class IColumn : public COW<IColumn> {
using Offsets = PaddedPODArray<Offset>;

/// Name of a Column. It is used in info messages.
virtual std::string get_name() const { return get_family_name(); }

/// Name of a Column kind, without parameters (example: FixedString, Array).
virtual const char* get_family_name() const = 0;
virtual std::string get_name() const = 0;

/** If column isn't constant, returns nullptr (or itself).
* If column is constant, transforms constant to full column (if column type allows such transform) and return it.
Expand Down Expand Up @@ -462,8 +459,7 @@ class IColumn : public COW<IColumn> {
* For array/map/struct types, we compare with nested column element and offsets size
*/
virtual int compare_at(size_t n, size_t m, const IColumn& rhs, int nan_direction_hint) const {
throw doris::Exception(ErrorCode::NOT_IMPLEMENTED_ERROR,
"compare_at for " + std::string(get_family_name()));
throw doris::Exception(ErrorCode::NOT_IMPLEMENTED_ERROR, "compare_at for " + get_name());
}

/**
Expand All @@ -485,7 +481,7 @@ class IColumn : public COW<IColumn> {
virtual void get_permutation(bool reverse, size_t limit, int nan_direction_hint,
Permutation& res) const {
throw doris::Exception(ErrorCode::NOT_IMPLEMENTED_ERROR,
"get_permutation for " + std::string(get_family_name()));
"get_permutation for " + get_name());
}

/** Copies each element according offsets parameter.
Expand Down
1 change: 0 additions & 1 deletion be/src/vec/columns/column_array.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ class ColumnArray final : public COWHelper<IColumn, ColumnArray> {
using ColumnOffsets = ColumnVector<Offset64>;

std::string get_name() const override;
const char* get_family_name() const override { return "Array"; }
bool is_column_array() const override { return true; }
bool is_variable_length() const override { return true; }

Expand Down
2 changes: 1 addition & 1 deletion be/src/vec/columns/column_complex.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ class ColumnComplexType final : public COWHelper<IColumn, ColumnComplexType<T>>

void resize(size_t n) override { data.resize(n); }

const char* get_family_name() const override { return TypeName<T>::get(); }
std::string get_name() const override { return TypeName<T>::get(); }

MutableColumnPtr clone_resized(size_t size) const override;

Expand Down
2 changes: 0 additions & 2 deletions be/src/vec/columns/column_const.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,6 @@ class ColumnConst final : public COWHelper<IColumn, ColumnConst> {

std::string get_name() const override { return "Const(" + data->get_name() + ")"; }

const char* get_family_name() const override { return "Const"; }

void resize(size_t new_size) override { s = new_size; }

MutableColumnPtr clone_resized(size_t new_size) const override {
Expand Down
2 changes: 1 addition & 1 deletion be/src/vec/columns/column_decimal.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ class ColumnDecimal final : public COWHelper<IColumn, ColumnDecimal<T>> {
ColumnDecimal(const ColumnDecimal& src) : data(src.data), scale(src.scale) {}

public:
const char* get_family_name() const override { return TypeName<T>::get(); }
std::string get_name() const override { return TypeName<T>::get(); }

bool is_numeric() const override { return false; }
bool is_column_decimal() const override { return true; }
Expand Down
2 changes: 1 addition & 1 deletion be/src/vec/columns/column_dictionary.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ class ColumnDictionary final : public COWHelper<IColumn, ColumnDictionary<T>> {

void reserve(size_t n) override { _codes.reserve(n); }

const char* get_family_name() const override { return "ColumnDictionary"; }
std::string get_name() const override { return "ColumnDictionary"; }

MutableColumnPtr clone_resized(size_t size) const override {
DCHECK(size == 0);
Expand Down
2 changes: 1 addition & 1 deletion be/src/vec/columns/column_fixed_length_object.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class ColumnFixedLengthObject final : public COWHelper<IColumn, ColumnFixedLengt
_data(src._data.begin(), src._data.end()) {}

public:
const char* get_family_name() const override { return "ColumnFixedLengthObject"; }
std::string get_name() const override { return "ColumnFixedLengthObject"; }

size_t size() const override { return _item_count; }

Expand Down
1 change: 0 additions & 1 deletion be/src/vec/columns/column_map.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ class ColumnMap final : public COWHelper<IColumn, ColumnMap> {
}

std::string get_name() const override;
const char* get_family_name() const override { return "Map"; }

void for_each_subcolumn(ColumnCallback callback) override {
callback(keys_column);
Expand Down
2 changes: 1 addition & 1 deletion be/src/vec/columns/column_nothing.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class ColumnNothing final : public COWHelper<IColumnDummy, ColumnNothing> {
void insert(const Field&) override { ++s; }

public:
const char* get_family_name() const override { return "Nothing"; }
std::string get_name() const override { return "Nothing"; }
MutableColumnPtr clone_dummy(size_t s_) const override { return ColumnNothing::create(s_); }

bool structure_equals(const IColumn& rhs) const override {
Expand Down
1 change: 0 additions & 1 deletion be/src/vec/columns/column_nullable.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,6 @@ class ColumnNullable final : public COWHelper<IColumn, ColumnNullable>, public N
bool could_shrinked_column() override;
bool is_variable_length() const override { return nested_column->is_variable_length(); }

const char* get_family_name() const override { return "Nullable"; }
std::string get_name() const override { return "Nullable(" + nested_column->get_name() + ")"; }
MutableColumnPtr clone_resized(size_t size) const override;
size_t size() const override {
Expand Down
6 changes: 3 additions & 3 deletions be/src/vec/columns/column_object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1935,7 +1935,7 @@ void ColumnObject::update_crc_with_value(size_t start, size_t end, uint32_t& has

std::string ColumnObject::debug_string() const {
std::stringstream res;
res << get_family_name() << "(num_row = " << num_rows;
res << get_name() << "(num_row = " << num_rows;
for (auto& entry : subcolumns) {
if (entry->data.is_finalized()) {
res << "[column:" << entry->data.data[0]->dump_structure()
Expand All @@ -1952,8 +1952,8 @@ Status ColumnObject::sanitize() const {
for (const auto& subcolumn : subcolumns) {
if (subcolumn->data.is_finalized()) {
auto column = subcolumn->data.get_least_common_type()->create_column();
std::string original = subcolumn->data.get_finalized_column().get_family_name();
std::string expected = column->get_family_name();
std::string original = subcolumn->data.get_finalized_column().get_name();
std::string expected = column->get_name();
if (original != expected) {
return Status::InternalError("Incompatible type between {} and {}, debug_info:",
original, expected, debug_string());
Expand Down
68 changes: 27 additions & 41 deletions be/src/vec/columns/column_object.h
Original file line number Diff line number Diff line change
Expand Up @@ -373,14 +373,11 @@ class ColumnObject final : public COWHelper<IColumn, ColumnObject> {

std::string get_name() const override {
if (is_scalar_variant()) {
return "var_scalar(" + get_root()->get_name() + ")";
return "variant_scalar(" + get_root()->get_name() + ")";
}
return "variant";
}

/// Part of interface
const char* get_family_name() const override { return "Variant"; }

size_t size() const override;

MutableColumnPtr clone_resized(size_t new_size) const override;
Expand Down Expand Up @@ -462,132 +459,121 @@ class ColumnObject final : public COWHelper<IColumn, ColumnObject> {
// Not implemented
MutableColumnPtr get_shrinked_column() override {
throw doris::Exception(ErrorCode::NOT_IMPLEMENTED_ERROR,
"get_shrinked_column" + std::string(get_family_name()));
"get_shrinked_column" + get_name());
}

Int64 get_int(size_t /*n*/) const override {
throw doris::Exception(ErrorCode::NOT_IMPLEMENTED_ERROR,
"get_int" + std::string(get_family_name()));
throw doris::Exception(ErrorCode::NOT_IMPLEMENTED_ERROR, "get_int" + get_name());
}

bool get_bool(size_t /*n*/) const override {
throw doris::Exception(ErrorCode::NOT_IMPLEMENTED_ERROR,
"get_bool" + std::string(get_family_name()));
throw doris::Exception(ErrorCode::NOT_IMPLEMENTED_ERROR, "get_bool" + get_name());
}

void insert_many_fix_len_data(const char* pos, size_t num) override {
throw doris::Exception(ErrorCode::NOT_IMPLEMENTED_ERROR,
"insert_many_fix_len_data" + std::string(get_family_name()));
"insert_many_fix_len_data" + get_name());
}

void insert_many_dict_data(const int32_t* data_array, size_t start_index, const StringRef* dict,
size_t data_num, uint32_t dict_num = 0) override {
throw doris::Exception(ErrorCode::NOT_IMPLEMENTED_ERROR,
"insert_many_dict_data" + std::string(get_family_name()));
"insert_many_dict_data" + get_name());
}

void insert_many_binary_data(char* data_array, uint32_t* len_array,
uint32_t* start_offset_array, size_t num) override {
throw doris::Exception(ErrorCode::NOT_IMPLEMENTED_ERROR,
"insert_many_binary_data" + std::string(get_family_name()));
"insert_many_binary_data" + get_name());
}

void insert_many_continuous_binary_data(const char* data, const uint32_t* offsets,
const size_t num) override {
throw doris::Exception(
ErrorCode::NOT_IMPLEMENTED_ERROR,
"insert_many_continuous_binary_data" + std::string(get_family_name()));
throw doris::Exception(ErrorCode::NOT_IMPLEMENTED_ERROR,
"insert_many_continuous_binary_data" + get_name());
}

void insert_many_strings(const StringRef* strings, size_t num) override {
throw doris::Exception(ErrorCode::NOT_IMPLEMENTED_ERROR,
"insert_many_strings" + std::string(get_family_name()));
"insert_many_strings" + get_name());
}

void insert_many_strings_overflow(const StringRef* strings, size_t num,
size_t max_length) override {
throw doris::Exception(ErrorCode::NOT_IMPLEMENTED_ERROR,
"insert_many_strings_overflow" + std::string(get_family_name()));
"insert_many_strings_overflow" + get_name());
}

void insert_many_raw_data(const char* pos, size_t num) override {
throw doris::Exception(ErrorCode::NOT_IMPLEMENTED_ERROR,
"insert_many_raw_data" + std::string(get_family_name()));
"insert_many_raw_data" + get_name());
}

size_t get_max_row_byte_size() const override {
throw doris::Exception(ErrorCode::NOT_IMPLEMENTED_ERROR,
"get_max_row_byte_size" + std::string(get_family_name()));
"get_max_row_byte_size" + get_name());
}

void serialize_vec(std::vector<StringRef>& keys, size_t num_rows,
size_t max_row_byte_size) const override {
throw doris::Exception(ErrorCode::NOT_IMPLEMENTED_ERROR,
"serialize_vec" + std::string(get_family_name()));
throw doris::Exception(ErrorCode::NOT_IMPLEMENTED_ERROR, "serialize_vec" + get_name());
}

void serialize_vec_with_null_map(std::vector<StringRef>& keys, size_t num_rows,
const uint8_t* null_map) const override {
throw doris::Exception(ErrorCode::NOT_IMPLEMENTED_ERROR,
"serialize_vec_with_null_map" + std::string(get_family_name()));
"serialize_vec_with_null_map" + get_name());
}

void deserialize_vec(std::vector<StringRef>& keys, const size_t num_rows) override {
throw doris::Exception(ErrorCode::NOT_IMPLEMENTED_ERROR,
"deserialize_vec" + std::string(get_family_name()));
throw doris::Exception(ErrorCode::NOT_IMPLEMENTED_ERROR, "deserialize_vec" + get_name());
}

void deserialize_vec_with_null_map(std::vector<StringRef>& keys, const size_t num_rows,
const uint8_t* null_map) override {
throw doris::Exception(ErrorCode::NOT_IMPLEMENTED_ERROR,
"deserialize_vec_with_null_map" + std::string(get_family_name()));
"deserialize_vec_with_null_map" + get_name());
}

Status filter_by_selector(const uint16_t* sel, size_t sel_size, IColumn* col_ptr) const {
throw doris::Exception(ErrorCode::NOT_IMPLEMENTED_ERROR,
"filter_by_selector" + std::string(get_family_name()));
throw doris::Exception(ErrorCode::NOT_IMPLEMENTED_ERROR, "filter_by_selector" + get_name());
}

bool structure_equals(const IColumn&) const override {
throw doris::Exception(ErrorCode::NOT_IMPLEMENTED_ERROR,
"structure_equals" + std::string(get_family_name()));
throw doris::Exception(ErrorCode::NOT_IMPLEMENTED_ERROR, "structure_equals" + get_name());
}

StringRef get_raw_data() const override {
throw doris::Exception(ErrorCode::NOT_IMPLEMENTED_ERROR,
"get_raw_data" + std::string(get_family_name()));
throw doris::Exception(ErrorCode::NOT_IMPLEMENTED_ERROR, "get_raw_data" + get_name());
}

size_t size_of_value_if_fixed() const override {
throw doris::Exception(ErrorCode::NOT_IMPLEMENTED_ERROR,
"size_of_value_if_fixed" + std::string(get_family_name()));
"size_of_value_if_fixed" + get_name());
}

StringRef get_data_at(size_t) const override {
throw doris::Exception(ErrorCode::NOT_IMPLEMENTED_ERROR,
"get_data_at" + std::string(get_family_name()));
throw doris::Exception(ErrorCode::NOT_IMPLEMENTED_ERROR, "get_data_at" + get_name());
}

StringRef serialize_value_into_arena(size_t n, Arena& arena,
char const*& begin) const override {
throw doris::Exception(ErrorCode::NOT_IMPLEMENTED_ERROR,
"serialize_value_into_arena" + std::string(get_family_name()));
"serialize_value_into_arena" + get_name());
}

const char* deserialize_and_insert_from_arena(const char* pos) override {
throw doris::Exception(
ErrorCode::NOT_IMPLEMENTED_ERROR,
"deserialize_and_insert_from_arena" + std::string(get_family_name()));
throw doris::Exception(ErrorCode::NOT_IMPLEMENTED_ERROR,
"deserialize_and_insert_from_arena" + get_name());
}

void insert_data(const char* pos, size_t length) override {
throw doris::Exception(ErrorCode::NOT_IMPLEMENTED_ERROR,
"insert_data" + std::string(get_family_name()));
throw doris::Exception(ErrorCode::NOT_IMPLEMENTED_ERROR, "insert_data" + get_name());
}

void replace_column_data(const IColumn&, size_t row, size_t self_row) override {
throw doris::Exception(ErrorCode::NOT_IMPLEMENTED_ERROR,
"replace_column_data" + std::string(get_family_name()));
"replace_column_data" + get_name());
}

private:
Expand Down
2 changes: 1 addition & 1 deletion be/src/vec/columns/column_set.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class ColumnSet final : public COWHelper<IColumnDummy, ColumnSet> {
ColumnSet(size_t s_, const ConstSetPtr& data_) : data(data_) { s = s_; }
ColumnSet(const ColumnSet&) = default;

const char* get_family_name() const override { return "Set"; }
std::string get_name() const override { return "Set"; }
MutableColumnPtr clone_dummy(size_t s_) const override { return ColumnSet::create(s_, data); }

ConstSetPtr get_data() const { return data; }
Expand Down
2 changes: 1 addition & 1 deletion be/src/vec/columns/column_string.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ class ColumnStr final : public COWHelper<IColumn, ColumnStr<T>> {
bool is_variable_length() const override { return true; }
// used in string ut testd
void sanity_check() const;
const char* get_family_name() const override { return "String"; }
std::string get_name() const override { return "String"; }

size_t size() const override { return offsets.size(); }

Expand Down
1 change: 0 additions & 1 deletion be/src/vec/columns/column_struct.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ class ColumnStruct final : public COWHelper<IColumn, ColumnStruct> {

std::string get_name() const override;
bool is_column_struct() const override { return true; }
const char* get_family_name() const override { return "Struct"; }
MutableColumnPtr clone_empty() const override;
MutableColumnPtr clone_resized(size_t size) const override;
size_t size() const override { return columns.at(0)->size(); }
Expand Down
5 changes: 0 additions & 5 deletions be/src/vec/columns/column_vector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -264,11 +264,6 @@ void ColumnVector<T>::get_permutation(bool reverse, size_t limit, int nan_direct
}
}

template <typename T>
const char* ColumnVector<T>::get_family_name() const {
return TypeName<T>::get();
}

template <typename T>
MutableColumnPtr ColumnVector<T>::clone_resized(size_t size) const {
auto res = this->create();
Expand Down
2 changes: 1 addition & 1 deletion be/src/vec/columns/column_vector.h
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ class ColumnVector final : public COWHelper<IColumn, ColumnVector<T>> {

void resize(size_t n) override { data.resize(n); }

const char* get_family_name() const override;
std::string get_name() const override { return TypeName<T>::get(); }

MutableColumnPtr clone_resized(size_t size) const override;

Expand Down
2 changes: 1 addition & 1 deletion be/src/vec/columns/predicate_column.h
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ class PredicateColumnType final : public COWHelper<IColumn, PredicateColumnType<

void reserve(size_t n) override { data.reserve(n); }

const char* get_family_name() const override { return TypeName<T>::get(); }
std::string get_name() const override { return TypeName<T>::get(); }

MutableColumnPtr clone_resized(size_t size) const override {
DCHECK(size == 0);
Expand Down
2 changes: 1 addition & 1 deletion be/src/vec/functions/function_string.h
Original file line number Diff line number Diff line change
Expand Up @@ -1387,7 +1387,7 @@ class FunctionStringConcatWs : public IFunction {
fmt::format("unsupported nested array of type {} for function {}",
is_column_nullable(array_column.get_data())
? array_column.get_data().get_name()
: array_column.get_data().get_family_name(),
: array_column.get_data().get_name(),
get_name()));
}
// Concat string in array
Expand Down
11 changes: 5 additions & 6 deletions be/src/vec/functions/match.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,11 @@ Status FunctionMatchBase::execute_impl(FunctionContext* context, Block& block,
if (source_col->is_column_array()) {
array_col = check_and_get_column<ColumnArray>(source_col.get());
if (array_col && !array_col->get_data().is_column_string()) {
return Status::NotSupported(
fmt::format("unsupported nested array of type {} for function {}",
is_column_nullable(array_col->get_data())
? array_col->get_data().get_name()
: array_col->get_data().get_family_name(),
get_name()));
return Status::NotSupported(fmt::format(
"unsupported nested array of type {} for function {}",
is_column_nullable(array_col->get_data()) ? array_col->get_data().get_name()
: array_col->get_data().get_name(),
get_name()));
}

if (is_column_nullable(array_col->get_data())) {
Expand Down

0 comments on commit de097de

Please sign in to comment.