HappenLee commented on a change in pull request #8384:
URL: https://github.com/apache/incubator-doris/pull/8384#discussion_r821359297
##########
File path: be/test/exprs/runtime_filter_test.cpp
##########
@@ -104,11 +104,17 @@ IRuntimeFilter*
create_runtime_filter(TRuntimeFilterType::type type, TQueryOptio
}
IRuntimeFilter* runtime_filter = nullptr;
- Status status = IRuntimeFilter::create(_runtime_stat,
-
_runtime_stat->instance_mem_tracker().get(), _obj_pool,
- &desc, options,
RuntimeFilterRole::PRODUCER, -1, &runtime_filter);
+ Status status = IRuntimeFilter::create(
+ _runtime_stat, _runtime_stat->instance_mem_tracker().get(),
_obj_pool, &desc, options,
+ RuntimeFilterRole::PRODUCER, -1, &runtime_filter);
+
assert(status.ok());
- return runtime_filter;
+
+ if (status.ok()) {
+ return runtime_filter;
Review comment:
?:
##########
File path: be/src/vec/functions/function_string.h
##########
@@ -1258,4 +1259,61 @@ class FunctionStringLocatePos : public IFunction {
}
};
+class FunctionReplace : public IFunction {
+public:
+ static constexpr auto name = "replace";
+ static FunctionPtr create() { return std::make_shared<FunctionReplace>(); }
+ String get_name() const override { return name; }
+ size_t get_number_of_arguments() const override { return 3; }
+
+ DataTypePtr get_return_type_impl(const DataTypes& arguments) const
override {
+ return std::make_shared<DataTypeString>();
+ }
+
+ DataTypes get_variadic_argument_types_impl() const override {
+ return {std::make_shared<DataTypeString>(),
std::make_shared<DataTypeString>(),
+ std::make_shared<DataTypeString>()};
+ }
+
+ bool use_default_implementation_for_constants() const override { return
true; }
+
+ Status execute_impl(FunctionContext* context, Block& block, const
ColumnNumbers& arguments,
+ size_t result, size_t input_rows_count) override {
+ auto col_origin =
+
block.get_by_position(arguments[0]).column->convert_to_full_column_if_const();
+ auto col_old =
+
block.get_by_position(arguments[1]).column->convert_to_full_column_if_const();
+ auto col_new =
+
block.get_by_position(arguments[2]).column->convert_to_full_column_if_const();
+
+ ColumnString::MutablePtr col_res = ColumnString::create();
+
+ for (int i = 0; i < input_rows_count; ++i) {
+ StringRef origin_str =
+ assert_cast<const
ColumnString*>(col_origin.get())->get_data_at(i);
+ StringRef old_str = assert_cast<const
ColumnString*>(col_old.get())->get_data_at(i);
+ StringRef new_str = assert_cast<const
ColumnString*>(col_new.get())->get_data_at(i);
+
+ std::string result =
+ replace(origin_str.to_string(), old_str.to_string(),
new_str.to_string());
+ col_res->insert_data(result.data(), result.length());
+ }
+
+ block.replace_by_position(result, std::move(col_res));
+ return Status::OK();
+ }
+
+private:
+ std::string replace(std::string str, std::string old_str, std::string
new_str) {
Review comment:
try to use `std::string_view`
##########
File path: be/test/exprs/runtime_filter_test.cpp
##########
@@ -486,24 +492,24 @@ TEST_F(RuntimeFilterTest,
runtime_filter_in_or_bloom_filter_bloom_filter_merge_b
auto rows1 = create_rows(&_obj_pool, 1, 3);
auto rows2 = create_rows(&_obj_pool, 4, 6);
- IRuntimeFilter* runtime_filter =
- create_runtime_filter(TRuntimeFilterType::IN_OR_BLOOM, &options,
_runtime_stat.get(), &_obj_pool);
+ IRuntimeFilter* runtime_filter = create_runtime_filter(
+ TRuntimeFilterType::IN_OR_BLOOM, &options, _runtime_stat.get(),
&_obj_pool);
insert(runtime_filter, build_expr_ctx, rows1);
ASSERT_FALSE(runtime_filter->is_bloomfilter());
runtime_filter->change_to_bloom_filter();
ASSERT_TRUE(runtime_filter->is_bloomfilter());
- IRuntimeFilter* runtime_filter2 =
- create_runtime_filter(TRuntimeFilterType::BLOOM, &options,
_runtime_stat.get(), &_obj_pool);
+ IRuntimeFilter* runtime_filter2 =
create_runtime_filter(TRuntimeFilterType::BLOOM, &options,
+
_runtime_stat.get(), &_obj_pool);
insert(runtime_filter2, build_expr_ctx, rows2);
ASSERT_TRUE(runtime_filter2->is_bloomfilter());
Status status = runtime_filter->merge_from(runtime_filter2->get_wrapper());
ASSERT_TRUE(status.ok());
ASSERT_FALSE(runtime_filter->is_ignored());
ASSERT_TRUE(runtime_filter->is_bloomfilter());
-//
ASSERT_TRUE(runtime_filter->get_profile()->get_info_string("RealRuntimeFilterType")
==
-//
::doris::to_string(doris::RuntimeFilterType::BLOOM_FILTER);
+ //
ASSERT_TRUE(runtime_filter->get_profile()->get_info_string("RealRuntimeFilterType")
==
Review comment:
del the unless code
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]