[Function][Enhance] lower/upper case transfer function vectorized (#6253)

Currently, the function lower()/upper() can only handle one char at a time.
A vectorized function has been implemented, it makes performance 2 times faster. Here is the performance test:

The length of char: 26, test 100 times
vectorized-function-cost: 99491 ns
normal-function-cost: 134766 ns

The length of char: 260, test 100 times
vectorized-function-cost: 179341 ns
normal-function-cost: 344995 ns
This commit is contained in:
xinghuayu007
2021-07-26 09:38:07 +08:00
committed by GitHub
parent 8d1c1ef1e6
commit 13ef2c9e1d
5 changed files with 157 additions and 10 deletions

View File

@ -623,6 +623,25 @@ TEST_F(StringFunctionsTest, bit_length) {
delete context;
}
TEST_F(StringFunctionsTest, lower) {
ASSERT_EQ(StringVal("hello"), StringFunctions::lower(ctx, StringVal("hello")));
ASSERT_EQ(StringVal("hello"), StringFunctions::lower(ctx, StringVal("HELLO")));
ASSERT_EQ(StringVal("hello123"), StringFunctions::lower(ctx, StringVal("HELLO123")));
ASSERT_EQ(StringVal("hello, 123"), StringFunctions::lower(ctx, StringVal("HELLO, 123")));
ASSERT_EQ(StringVal::null(), StringFunctions::lower(ctx, StringVal::null()));
ASSERT_EQ(StringVal(""), StringFunctions::lower(ctx, StringVal("")));
}
TEST_F(StringFunctionsTest, upper) {
// function test
ASSERT_EQ(StringVal("HELLO"), StringFunctions::upper(ctx, StringVal("HELLO")));
ASSERT_EQ(StringVal("HELLO"), StringFunctions::upper(ctx, StringVal("hello")));
ASSERT_EQ(StringVal("HELLO123"), StringFunctions::upper(ctx, StringVal("hello123")));
ASSERT_EQ(StringVal("HELLO, 123"), StringFunctions::upper(ctx, StringVal("hello, 123")));
ASSERT_EQ(StringVal::null(), StringFunctions::upper(ctx, StringVal::null()));
ASSERT_EQ(StringVal(""), StringFunctions::upper(ctx, StringVal("")));
}
} // namespace doris
int main(int argc, char** argv) {