Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion be/src/pipeline/exec/hashjoin_build_sink.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,7 @@ Status HashJoinBuildSinkOperatorX::sink(RuntimeState* state, vectorized::Block*
if (local_state._build_side_mutable_block.empty()) {
auto tmp_build_block = vectorized::VectorizedUtils::create_empty_columnswithtypename(
_child->row_desc());
tmp_build_block = *(tmp_build_block.create_same_struct_block(1, false));
tmp_build_block = *(tmp_build_block.create_same_struct_block_with_type(1));
local_state._build_col_ids.resize(_build_expr_ctxs.size());
RETURN_IF_ERROR(local_state._do_evaluate(tmp_build_block, local_state._build_expr_ctxs,
*local_state._build_expr_call_timer,
Expand Down
11 changes: 11 additions & 0 deletions be/src/vec/columns/column.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,11 @@ namespace doris::vectorized {

class Arena;
class ColumnSorter;
class IDataType;

using EqualFlags = std::vector<uint8_t>;
using EqualRange = std::pair<int, int>;
using DataTypePtr = std::shared_ptr<const IDataType>;

/// Declares interface to store columns in memory.
class IColumn : public COW<IColumn> {
Expand Down Expand Up @@ -308,6 +310,15 @@ class IColumn : public COW<IColumn> {
}
}

/// for ColumnVector with type date/datetime, the default value depend on data type.
virtual void insert_default_with_type(DataTypePtr type) { insert_default(); }

void insert_many_defaults_with_type(size_t length, DataTypePtr type) {
for (size_t i = 0; i < length; ++i) {
insert_default_with_type(type);
}
}

/** Removes last n elements.
* Is used to support exception-safety of several operations.
* For example, sometimes insertion should be reverted if we catch an exception during operation processing.
Expand Down
7 changes: 7 additions & 0 deletions be/src/vec/columns/column_nullable.h
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,13 @@ class ColumnNullable final : public COWHelper<IColumn, ColumnNullable>, public N
_need_update_has_null = false;
}

void insert_default_with_type(DataTypePtr type) override {
get_nested_column().insert_default_with_type(type);
get_null_map_data().push_back(1);
_has_null = true;
_need_update_has_null = false;
}

void insert_many_defaults(size_t length) override {
get_nested_column().insert_many_defaults(length);
get_null_map_data().resize_fill(get_null_map_data().size() + length, 1);
Expand Down
6 changes: 6 additions & 0 deletions be/src/vec/columns/column_struct.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,12 @@ void ColumnStruct::insert_default() {
}
}

void ColumnStruct::insert_default_with_type(DataTypePtr type) {
for (auto& column : columns) {
column->insert_default_with_type(type);
}
}

void ColumnStruct::pop_back(size_t n) {
for (auto& column : columns) {
column->pop_back(n);
Expand Down
1 change: 1 addition & 0 deletions be/src/vec/columns/column_struct.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ class ColumnStruct final : public COWHelper<IColumn, ColumnStruct> {
void insert(const Field& x) override;
void insert_from(const IColumn& src_, size_t n) override;
void insert_default() override;
void insert_default_with_type(DataTypePtr type) override;
void pop_back(size_t n) override;
StringRef serialize_value_into_arena(size_t n, Arena& arena, char const*& begin) const override;
const char* deserialize_and_insert_from_arena(const char* pos) override;
Expand Down
15 changes: 15 additions & 0 deletions be/src/vec/columns/column_vector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include <ostream>
#include <string>

#include "util/binary_cast.hpp"
#include "util/hash_util.hpp"
#include "util/simd/bits.h"
#include "vec/columns/column_impl.h"
Expand All @@ -40,6 +41,7 @@
#include "vec/core/sort_block.h"
#include "vec/core/types.h"
#include "vec/data_types/data_type.h"
#include "vec/runtime/vdatetime_value.h"

namespace doris::vectorized {

Expand Down Expand Up @@ -505,6 +507,19 @@ void ColumnVector<T>::replace_column_null_data(const uint8_t* __restrict null_ma
}
}

template <typename T>
void ColumnVector<T>::insert_default_with_type(DataTypePtr type) {
if (WhichDataType(type).is_date_or_datetime()) {
data.push_back(binary_cast<VecDateTimeValue, Int64>(VecDateTimeValue::DEFAULT_VALUE));
} else if (WhichDataType(type).is_date_v2()) {
data.push_back(DateV2Value<DateV2ValueType>::DEFAULT_VALUE.to_date_int_val());
} else if (WhichDataType(type).is_date_time_v2()) {
data.push_back(DateV2Value<DateTimeV2ValueType>::DEFAULT_VALUE.to_date_int_val());
} else {
insert_default();
}
}

/// Explicit template instantiations - to avoid code bloat in headers.
template class ColumnVector<UInt8>;
template class ColumnVector<UInt16>;
Expand Down
9 changes: 3 additions & 6 deletions be/src/vec/columns/column_vector.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,9 @@

class SipHash;

namespace doris {
namespace vectorized {
namespace doris::vectorized {
class Arena;
class ColumnSorter;
} // namespace vectorized
} // namespace doris

namespace doris::vectorized {

/** Stuff for comparing numbers.
* Integer values are compared as usual.
Expand Down Expand Up @@ -241,6 +236,8 @@ class ColumnVector final : public COWHelper<IColumn, ColumnVector<T>> {

void insert_default() override { data.push_back(T()); }

void insert_default_with_type(DataTypePtr type) override;

void insert_many_defaults(size_t length) override {
size_t old_size = data.size();
data.resize(old_size + length);
Expand Down
10 changes: 10 additions & 0 deletions be/src/vec/core/block.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1193,6 +1193,16 @@ std::unique_ptr<Block> Block::create_same_struct_block(size_t size, bool is_rese
return temp_block;
}

std::unique_ptr<Block> Block::create_same_struct_block_with_type(size_t size) const {
auto temp_block = Block::create_unique();
for (const auto& d : data) {
auto column = d.type->create_column();
column->insert_many_defaults_with_type(size, d.type);
temp_block->insert({std::move(column), d.type, d.name});
}
return temp_block;
}

void Block::shrink_char_type_column_suffix_zero(const std::vector<size_t>& char_type_idx) {
for (auto idx : char_type_idx) {
if (idx < data.size()) {
Expand Down
2 changes: 2 additions & 0 deletions be/src/vec/core/block.h
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,8 @@ class Block {
Status deserialize(const PBlock& pblock);

std::unique_ptr<Block> create_same_struct_block(size_t size, bool is_reserve = false) const;
// only used for hashjoin build side to mock a row into block.
std::unique_ptr<Block> create_same_struct_block_with_type(size_t size) const;

/** Compares (*this) n-th row and rhs m-th row.
* Returns negative number, 0, or positive number (*this) n-th row is less, equal, greater than rhs m-th row respectively.
Expand Down
Loading
Loading