xiaokang commented on code in PR #10169: URL: https://github.com/apache/doris/pull/10169#discussion_r905018251
########## be/src/vec/functions/like.cpp: ########## @@ -129,6 +130,42 @@ Status FunctionLikeBase::vector_vector(const ColumnString::Chars& values, const ColumnString::Offsets& pattern_offsets, ColumnUInt8::Container& result, const LikeFn& function, LikeSearchState* search_state) { + // for constant_substring_fn, use long run length search for performance + if (constant_substring_fn == + *(function.target<doris::Status (*)(LikeSearchState * state, const StringValue&, + const StringValue&, unsigned char*)>())) { + // treat continous multi string data as a long string data + const UInt8* begin = values.data(); + const UInt8* end = begin + values.size(); + const UInt8* pos = begin; + + /// Current index in the array of strings. + size_t i = 0; + size_t needle_size = search_state->substring_pattern.get_pattern_length(); + + /// We will search for the next occurrence in all strings at once. + while (pos < end) { + // search return matched substring start offset + pos = (UInt8*)search_state->substring_pattern.search((char*)pos, end - pos); + if (pos >= end) break; + + /// Determine which index it refers to. + /// begin + value_offsets[i] is the start offset of string at i+1 + while (begin + value_offsets[i] <= pos) ++i; + + /// We check that the entry does not pass through the boundaries of strings. Review Comment: OK. thanks for you careful review! -- 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: commits-unsubscr...@doris.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org