Skip to content

Commit

Permalink
[Refactor](exec) Refactor some unreasonable code in exec
Browse files Browse the repository at this point in the history
  • Loading branch information
HappenLee committed Oct 29, 2024
1 parent 5f10b21 commit b5d8ffa
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 9 deletions.
3 changes: 2 additions & 1 deletion be/src/pipeline/exec/hashjoin_build_sink.h
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ struct ProcessHashTableBuild {
bool* has_null_key) {
if (short_circuit_for_null || ignore_null) {
// first row is mocked and is null
// TODO: Need to test the for loop. break may better
for (uint32_t i = 1; i < _rows; i++) {
if ((*null_map)[i]) {
*has_null_key = true;
Expand Down Expand Up @@ -231,4 +232,4 @@ struct ProcessHashTableBuild {
};

} // namespace doris::pipeline
#include "common/compile_check_end.h"
#include "common/compile_check_end.h"
2 changes: 1 addition & 1 deletion be/src/pipeline/exec/hashjoin_probe_operator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ bool HashJoinProbeLocalState::_need_probe_null_map(vectorized::Block& block,
const std::vector<int>& res_col_ids) {
for (size_t i = 0; i < _probe_expr_ctxs.size(); ++i) {
if (!_shared_state->is_null_safe_eq_join[i]) {
auto column = block.get_by_position(res_col_ids[i]).column.get();
const auto* column = block.get_by_position(res_col_ids[i]).column.get();
if (check_and_get_column<vectorized::ColumnNullable>(*column)) {
return true;
}
Expand Down
4 changes: 2 additions & 2 deletions be/src/vec/core/block.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1083,7 +1083,7 @@ Status MutableBlock::add_rows(const Block* block, size_t row_begin, size_t lengt
return Status::OK();
}

Status MutableBlock::add_rows(const Block* block, std::vector<int64_t> rows) {
Status MutableBlock::add_rows(const Block* block, const std::vector<int64_t>& rows) {
RETURN_IF_CATCH_EXCEPTION({
DCHECK_LE(columns(), block->columns());
const auto& block_data = block->get_columns_with_type_and_name();
Expand All @@ -1093,7 +1093,7 @@ Status MutableBlock::add_rows(const Block* block, std::vector<int64_t> rows) {
auto& dst = _columns[i];
const auto& src = *block_data[i].column.get();
dst->reserve(dst->size() + length);
for (size_t row : rows) {
for (auto row : rows) {
// we can introduce a new function like `insert_assume_reserved` for IColumn.
dst->insert_from(src, row);
}
Expand Down
2 changes: 1 addition & 1 deletion be/src/vec/core/block.h
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,7 @@ class MutableBlock {
Status add_rows(const Block* block, const uint32_t* row_begin, const uint32_t* row_end,
const std::vector<int>* column_offset = nullptr);
Status add_rows(const Block* block, size_t row_begin, size_t length);
Status add_rows(const Block* block, std::vector<int64_t> rows);
Status add_rows(const Block* block, const std::vector<int64_t>& rows);

/// remove the column with the specified name
void erase(const String& name);
Expand Down
4 changes: 2 additions & 2 deletions be/src/vec/sink/vrow_distribution.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ VRowDistribution::_get_partition_function() {

Status VRowDistribution::_save_missing_values(
std::vector<std::vector<std::string>>& col_strs, // non-const ref for move
int col_size, Block* block, std::vector<int64_t> filter,
int col_size, Block* block, const std::vector<int64_t>& filter,
const std::vector<const NullMap*>& col_null_maps) {
// de-duplication for new partitions but save all rows.
RETURN_IF_ERROR(_batching_block->add_rows(block, filter));
Expand Down Expand Up @@ -311,7 +311,7 @@ Status VRowDistribution::_generate_rows_distribution_for_auto_partition(
auto num_rows = block->rows();
std::vector<uint16_t> partition_keys = _vpartition->get_partition_keys();

auto partition_col = block->get_by_position(partition_keys[0]);
auto& partition_col = block->get_by_position(partition_keys[0]);
_missing_map.clear();
_missing_map.reserve(partition_col.column->size());
bool stop_processing = false;
Expand Down
2 changes: 1 addition & 1 deletion be/src/vec/sink/vrow_distribution.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ class VRowDistribution {
std::pair<vectorized::VExprContextSPtrs, vectorized::VExprSPtrs> _get_partition_function();

Status _save_missing_values(std::vector<std::vector<std::string>>& col_strs, int col_size,
Block* block, std::vector<int64_t> filter,
Block* block, const std::vector<int64_t>& filter,
const std::vector<const NullMap*>& col_null_maps);

void _get_tablet_ids(vectorized::Block* block, int32_t index_idx,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ void testNullSafeEqualToFalse() {
assertRewrite(new NullSafeEqual(new IntegerLiteral(0), NullLiteral.INSTANCE), BooleanLiteral.FALSE);
}

// "NULL <=> Null" to false
// "NULL <=> Null" to true
@Test
void testNullSafeEqualToTrue() {
executor = new ExpressionRuleExecutor(ImmutableList.of(
Expand Down

0 comments on commit b5d8ffa

Please sign in to comment.