Skip to content

Commit

Permalink
refine
Browse files Browse the repository at this point in the history
  • Loading branch information
Mryange committed Nov 17, 2024
1 parent bdc8f80 commit 6bff40d
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 12 deletions.
5 changes: 4 additions & 1 deletion be/src/vec/functions/array/function_array_slice.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,11 @@ class FunctionArraySlice : public IFunction {
auto offset_column =
block.get_by_position(arguments[1]).column->convert_to_full_column_if_const();
ColumnPtr length_column = nullptr;
const ColumnInt64* length_column_int64 = nullptr;
if (arguments.size() > 2) {
length_column =
block.get_by_position(arguments[2]).column->convert_to_full_column_if_const();
length_column_int64 = assert_cast<const ColumnInt64*>(length_column.get());
}
// extract src array column
ColumnArrayExecutionData src;
Expand All @@ -92,7 +94,8 @@ class FunctionArraySlice : public IFunction {
ColumnArrayMutableData dst = create_mutable_data(src.nested_col, is_nullable);
dst.offsets_ptr->reserve(input_rows_count);
// execute
slice_array(dst, src, *offset_column, length_column.get());
const auto* offset_column_int64 = assert_cast<const ColumnInt64*>(offset_column.get());
slice_array(dst, src, *offset_column_int64, length_column_int64);
ColumnPtr res_column = assemble_column_array(dst);
block.replace_by_position(result, std::move(res_column));
return Status::OK();
Expand Down
6 changes: 3 additions & 3 deletions be/src/vec/functions/array/function_array_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,12 @@ MutableColumnPtr assemble_column_array(ColumnArrayMutableData& data) {
}

void slice_array(ColumnArrayMutableData& dst, ColumnArrayExecutionData& src,
const IColumn& offset_column, const IColumn* length_column) {
const ColumnInt64& offset_column, const ColumnInt64* length_column) {
size_t cur = 0;
for (size_t row = 0; row < src.offsets_ptr->size(); ++row) {
size_t off = (*src.offsets_ptr)[row - 1];
size_t len = (*src.offsets_ptr)[row] - off;
Int64 start = offset_column.get_int(row);
Int64 start = offset_column.get_element(row);
if (len == 0 || start == 0) {
dst.offsets_ptr->push_back(cur);
continue;
Expand All @@ -98,7 +98,7 @@ void slice_array(ColumnArrayMutableData& dst, ColumnArrayExecutionData& src,
}
Int64 end;
if (length_column) {
Int64 size = length_column->get_int(row);
Int64 size = length_column->get_element(row);
end = std::max((Int64)off, std::min((Int64)(off + len), start + size));
} else {
end = off + len;
Expand Down
2 changes: 1 addition & 1 deletion be/src/vec/functions/array/function_array_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ MutableColumnPtr assemble_column_array(ColumnArrayMutableData& data);

// array[offset:length]
void slice_array(ColumnArrayMutableData& dst, ColumnArrayExecutionData& src,
const IColumn& offset_column, const IColumn* length_column);
const ColumnInt64& offset_column, const ColumnInt64* length_column);

using ColumnArrayExecutionDatas = std::vector<ColumnArrayExecutionData>;
} // namespace doris::vectorized
14 changes: 8 additions & 6 deletions be/src/vec/functions/function_date_or_datetime_computation.h
Original file line number Diff line number Diff line change
Expand Up @@ -647,9 +647,10 @@ struct DateTimeAddIntervalImpl {
col_to->get_data(), null_map->get_data(),
delta_vec_column->get_data());
} else {
Op::constant_vector(sources_const->template get_value<FromType1>(),
col_to->get_data(), null_map->get_data(),
*not_nullable_column_ptr_arg1);
return Status::RuntimeError(
"Illegal column {} of first argument of function {}",
block.get_by_position(arguments[0]).column->get_name(),
Transform::name);
}
if (const auto* nullable_col = check_and_get_column<ColumnNullable>(
block.get_by_position(arguments[0]).column.get())) {
Expand Down Expand Up @@ -677,9 +678,10 @@ struct DateTimeAddIntervalImpl {
Op::constant_vector(sources_const->template get_value<FromType1>(),
col_to->get_data(), delta_vec_column->get_data());
} else {
Op::constant_vector(sources_const->template get_value<FromType1>(),
col_to->get_data(),
*block.get_by_position(arguments[1]).column);
return Status::RuntimeError(
"Illegal column {} of first argument of function {}",
block.get_by_position(arguments[0]).column->get_name(),
Transform::name);
}
block.replace_by_position(result, std::move(col_to));
}
Expand Down
4 changes: 3 additions & 1 deletion be/src/vec/sink/vtablet_block_convertor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
#include "vec/columns/column_nullable.h"
#include "vec/columns/column_string.h"
#include "vec/columns/column_struct.h"
#include "vec/columns/columns_number.h"
#include "vec/common/assert_cast.h"
#include "vec/core/block.h"
#include "vec/core/types.h"
Expand Down Expand Up @@ -532,6 +533,7 @@ Status OlapTableBlockConvertor::_fill_auto_inc_cols(vectorized::Block* block, si
} else if (const auto* src_nullable_column =
check_and_get_column<vectorized::ColumnNullable>(src_column_ptr)) {
auto src_nested_column_ptr = src_nullable_column->get_nested_column_ptr();
const auto* src_int_64 = assert_cast<const ColumnInt64*>(src_nested_column_ptr.get());
const auto& null_map_data = src_nullable_column->get_null_map_data();
dst_values.reserve(rows);
for (size_t i = 0; i < rows; i++) {
Expand All @@ -545,7 +547,7 @@ Status OlapTableBlockConvertor::_fill_auto_inc_cols(vectorized::Block* block, si

for (size_t i = 0; i < rows; i++) {
dst_values.emplace_back((null_map_data[i] != 0) ? _auto_inc_id_allocator.next_id()
: src_nested_column_ptr->get_int(i));
: src_int_64->get_element(i));
}
} else {
return Status::OK();
Expand Down

0 comments on commit 6bff40d

Please sign in to comment.