github-actions[bot] commented on code in PR #28556:
URL: https://github.com/apache/doris/pull/28556#discussion_r1429578055
##########
be/src/vec/functions/function_ip.h:
##########
@@ -348,4 +348,108 @@
}
};
+class FunctionIsIPv4String : public IFunction {
+private:
+ Status execute_type(Block& block, const ColumnWithTypeAndName& argument,
size_t result) const {
+ const ColumnPtr& column = argument.column;
+
+ if (const auto* col_src = typeid_cast<const
ColumnString*>(column.get())) {
+ auto col_res = ColumnInt8::create();
+
+ for (size_t i = 0; i < col_src->size(); ++i) {
+ auto ipv4_str = col_src->get_data_at(i).to_string();
+ if (ipv4_str.size() > IPV4_MAX_TEXT_LENGTH ||
+ !IPv4Value::is_valid_string(ipv4_str)) {
+ col_res->insert_value(0);
+ } else {
+ col_res->insert_value(1);
+ }
+ }
+
+ DCHECK_EQ(col_res->size(), col_src->size());
+
+ block.replace_by_position(
+ result, ColumnNullable::create(std::move(col_res),
+
ColumnUInt8::create(col_src->size(), 0)));
+ return Status::OK();
+ }
+
+ return Status::RuntimeError("Illegal column {} of argument of function
{}",
+ argument.column->get_name(), get_name());
+ }
+
+public:
+ static constexpr auto name = "isipv4string";
+ static FunctionPtr create() { return
std::make_shared<FunctionIsIPv4String>(); }
+
+ String get_name() const override { return name; }
+
+ size_t get_number_of_arguments() const override { return 1; }
+
+ DataTypePtr get_return_type_impl(const DataTypes& arguments) const
override {
Review Comment:
warning: method 'get_return_type_impl' can be made static
[readability-convert-member-functions-to-static]
```suggestion
static DataTypePtr get_return_type_impl(const DataTypes& arguments)
override {
```
##########
be/src/vec/functions/function_ip.h:
##########
@@ -348,4 +348,108 @@
}
};
+class FunctionIsIPv4String : public IFunction {
+private:
+ Status execute_type(Block& block, const ColumnWithTypeAndName& argument,
size_t result) const {
+ const ColumnPtr& column = argument.column;
+
+ if (const auto* col_src = typeid_cast<const
ColumnString*>(column.get())) {
+ auto col_res = ColumnInt8::create();
+
+ for (size_t i = 0; i < col_src->size(); ++i) {
+ auto ipv4_str = col_src->get_data_at(i).to_string();
+ if (ipv4_str.size() > IPV4_MAX_TEXT_LENGTH ||
+ !IPv4Value::is_valid_string(ipv4_str)) {
+ col_res->insert_value(0);
+ } else {
+ col_res->insert_value(1);
+ }
+ }
+
+ DCHECK_EQ(col_res->size(), col_src->size());
+
+ block.replace_by_position(
+ result, ColumnNullable::create(std::move(col_res),
+
ColumnUInt8::create(col_src->size(), 0)));
+ return Status::OK();
+ }
+
+ return Status::RuntimeError("Illegal column {} of argument of function
{}",
+ argument.column->get_name(), get_name());
+ }
+
+public:
+ static constexpr auto name = "isipv4string";
+ static FunctionPtr create() { return
std::make_shared<FunctionIsIPv4String>(); }
+
+ String get_name() const override { return name; }
+
+ size_t get_number_of_arguments() const override { return 1; }
+
+ DataTypePtr get_return_type_impl(const DataTypes& arguments) const
override {
+ return make_nullable(std::make_shared<DataTypeInt8>());
+ }
+
+ bool use_default_implementation_for_nulls() const override { return true; }
+
+ Status execute_impl(FunctionContext* context, Block& block, const
ColumnNumbers& arguments,
+ size_t result, size_t input_rows_count) const override
{
+ ColumnWithTypeAndName& argument = block.get_by_position(arguments[0]);
+ DCHECK(argument.type->get_type_id() == TypeIndex::String);
+ return execute_type(block, argument, result);
+ }
+};
+
+class FunctionIsIPv6String : public IFunction {
+private:
+ Status execute_type(Block& block, const ColumnWithTypeAndName& argument,
size_t result) const {
Review Comment:
warning: method 'execute_type' can be made static
[readability-convert-member-functions-to-static]
```suggestion
static Status execute_type(Block& block, const ColumnWithTypeAndName&
argument, size_t result) {
```
##########
be/src/vec/functions/function_ip.h:
##########
@@ -348,4 +348,108 @@ class FunctionIPv6NumToString : public IFunction {
}
};
+class FunctionIsIPv4String : public IFunction {
+private:
+ Status execute_type(Block& block, const ColumnWithTypeAndName& argument,
size_t result) const {
Review Comment:
warning: method 'execute_type' can be made static
[readability-convert-member-functions-to-static]
```suggestion
static Status execute_type(Block& block, const ColumnWithTypeAndName&
argument, size_t result) {
```
##########
be/src/vec/functions/function_ip.h:
##########
@@ -348,4 +348,108 @@
}
};
+class FunctionIsIPv4String : public IFunction {
+private:
+ Status execute_type(Block& block, const ColumnWithTypeAndName& argument,
size_t result) const {
+ const ColumnPtr& column = argument.column;
+
+ if (const auto* col_src = typeid_cast<const
ColumnString*>(column.get())) {
+ auto col_res = ColumnInt8::create();
+
+ for (size_t i = 0; i < col_src->size(); ++i) {
+ auto ipv4_str = col_src->get_data_at(i).to_string();
+ if (ipv4_str.size() > IPV4_MAX_TEXT_LENGTH ||
+ !IPv4Value::is_valid_string(ipv4_str)) {
+ col_res->insert_value(0);
+ } else {
+ col_res->insert_value(1);
+ }
+ }
+
+ DCHECK_EQ(col_res->size(), col_src->size());
+
+ block.replace_by_position(
+ result, ColumnNullable::create(std::move(col_res),
+
ColumnUInt8::create(col_src->size(), 0)));
+ return Status::OK();
+ }
+
+ return Status::RuntimeError("Illegal column {} of argument of function
{}",
+ argument.column->get_name(), get_name());
+ }
+
+public:
+ static constexpr auto name = "isipv4string";
+ static FunctionPtr create() { return
std::make_shared<FunctionIsIPv4String>(); }
+
+ String get_name() const override { return name; }
+
+ size_t get_number_of_arguments() const override { return 1; }
+
+ DataTypePtr get_return_type_impl(const DataTypes& arguments) const
override {
+ return make_nullable(std::make_shared<DataTypeInt8>());
+ }
+
+ bool use_default_implementation_for_nulls() const override { return true; }
+
+ Status execute_impl(FunctionContext* context, Block& block, const
ColumnNumbers& arguments,
+ size_t result, size_t input_rows_count) const override
{
+ ColumnWithTypeAndName& argument = block.get_by_position(arguments[0]);
+ DCHECK(argument.type->get_type_id() == TypeIndex::String);
+ return execute_type(block, argument, result);
+ }
+};
+
+class FunctionIsIPv6String : public IFunction {
+private:
+ Status execute_type(Block& block, const ColumnWithTypeAndName& argument,
size_t result) const {
+ const ColumnPtr& column = argument.column;
+
+ if (const auto* col_src = typeid_cast<const
ColumnString*>(column.get())) {
+ auto col_res = ColumnInt8::create();
+
+ for (size_t i = 0; i < col_src->size(); ++i) {
+ auto ipv6_str = col_src->get_data_at(i).to_string();
+ if (ipv6_str.size() > IPV6_MAX_TEXT_LENGTH ||
+ !IPv6Value::is_valid_string(ipv6_str)) {
+ col_res->insert_value(0);
+ } else {
+ col_res->insert_value(1);
+ }
+ }
+
+ DCHECK_EQ(col_res->size(), col_src->size());
+
+ block.replace_by_position(
+ result, ColumnNullable::create(std::move(col_res),
+
ColumnUInt8::create(col_src->size(), 0)));
+ return Status::OK();
+ }
+
+ return Status::RuntimeError("Illegal column {} of argument of function
{}",
+ argument.column->get_name(), get_name());
+ }
+
+public:
+ static constexpr auto name = "isipv6string";
+ static FunctionPtr create() { return
std::make_shared<FunctionIsIPv6String>(); }
+
+ String get_name() const override { return name; }
+
+ size_t get_number_of_arguments() const override { return 1; }
+
+ DataTypePtr get_return_type_impl(const DataTypes& arguments) const
override {
Review Comment:
warning: method 'get_return_type_impl' can be made static
[readability-convert-member-functions-to-static]
```suggestion
static DataTypePtr get_return_type_impl(const DataTypes& arguments)
override {
```
--
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]