Skip to content

Conversation

@zbtzbtzbt
Copy link
Contributor

Proposed changes

1.使用了支持函数重载的注册逻辑 #201 ,支持hex对int和string两种类型参数
2.相比之前关闭的pr,vec版本也修复了hex(0)=0的bug,apache/doris#6837
3.相比之前关闭的pr,使得向量化和非向量化的hex函数对于相同输入,输出保持一致

Types of changes

What types of changes does your code introduce to Doris?
Put an x in the boxes that apply

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation Update (if none of the other choices apply)
  • Code refactor (Modify the code structure, format the code, etc...)
  • Optimization. Including functional usability improvements and performance improvements.
  • Dependency. Such as changes related to third-party components.
  • Other.

Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.

  • I have created an issue on (Fix #ISSUE) and described the bug/feature there in detail
  • Compiling and unit tests pass locally with my changes
  • I have added tests that prove my fix is effective or that my feature works
  • If these changes need document changes, I have updated the document
  • Any dependent changes have been merged

Further comments

If this is a relatively large or complex change, kick off the discussion at dev@doris.apache.org by explaining why you chose the solution you did and what alternatives you considered, etc...


void get_lambda_argument_types(DataTypes& arguments) const override {
check_number_of_arguments(arguments.size());
// check_number_of_arguments(arguments.size());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

注释代码直接删除了,不要留注释

Copy link
Contributor

@HappenLee HappenLee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

有一些小问题,得修改一下

using DataTypePtr = std::shared_ptr<const IDataType>;
using DataTypes = std::vector<DataTypePtr>;

struct defaultDataTypes{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

类需要首字母大写

*res = hexDigits[(src_str[i] >> 4) & 0x0F];
std::copy(res, res + 2, dst_str + 2 * i);
}
return 2*length;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

符号需要空格哈

};

// support hex variadic
struct hexStringDataTypes{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

同上

}

DataTypes get_variadic_argument_types_impl() const override{
return argument_types::types;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个是不是应该和name一样放在Impl类里面,这样扩展模板容易导致类膨胀的问题

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不能这样,像name那种写法的话,使用这个类的非重载函数都需要实现一遍。用这种默认参数的形式,其他代码不需要改动。

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

你让所有使用这个类的Impl统一继承一个公共类就行了

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

提交的这一版是未使用SFINAE方式的版本

if (iter != function_creators.end()) {
return iter->second()->build(arguments, return_type);
}
LOG(INFO) << "get_function() return nullptr in simple_function_factory.h";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里不要打日志了,直接DCHECK吧

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

'_ZN5doris13MathFunctions5unhexEPN9doris_udf15FunctionContextERKNS1_9StringValE', '', '', 'vec', ''],
[['unhex'], 'STRING', ['STRING'],
'_ZN5doris13MathFunctions5unhexEPN9doris_udf15FunctionContextERKNS1_9StringValE', '', '', '', ''],
'_ZN5doris13MathFunctions5unhexEPN9doris_udf15FunctionContextERKNS1_9StringValE', '', '', 'vec', ''],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个函数我看源码是always nullable的?

@zbtzbtzbt zbtzbtzbt force-pushed the function_hex branch 2 times, most recently from 825a84d to 12d42d5 Compare October 27, 2021 13:02
Copy link
Contributor

@HappenLee HappenLee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

有一些小的格式问题, 改一下,一些没用的代码删除一下

public:
FunctionBasePtr build(const ColumnsWithTypeAndName& arguments, const DataTypePtr& return_type) const final {

if(!return_type->equals(*get_return_type(arguments))){
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

符合之间需要空格,你这个代码是调试的吗?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

嗯是的,我删一下

@zbtzbtzbt zbtzbtzbt force-pushed the function_hex branch 2 times, most recently from 08f1f02 to a265c31 Compare November 1, 2021 03:34
@HappenLee HappenLee merged commit dcb0dcb into doris-vectorized:master Nov 2, 2021
HappenLee pushed a commit that referenced this pull request Nov 15, 2021
* support function hex, fix hex(0)=0, fix unhex bug, support nullable.

* format code and delete debug code.
@zbtzbtzbt zbtzbtzbt deleted the function_hex branch December 7, 2021 07:17
HappenLee pushed a commit that referenced this pull request Dec 16, 2021
* support function hex, fix hex(0)=0, fix unhex bug, support nullable.

* format code and delete debug code.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants