[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:
@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user