Repository navigation
Conversation
|
Workflow [PR], commit [7705e5f] Summary: ❌
|
|
Nice! IIRC |
It's still necessary. The high-performance path is only for column data which directly uses the SIMD-friendly foreach API, while literal/constant tokenization keeps the lightweight iterator path. |
35b0a48 to
693aa6c
Compare
This comment was marked as resolved.
This comment was marked as resolved.
Introduce a new tokenizer 'unicode_word' that splits text into tokens following Unicode word boundary rules (similar to UAX ClickHouse#29): - ASCII alphanumeric characters form tokens - Underscore can appear at start/middle/end but cannot be the only char - Colon connects letters only; dot and single quote connect same types - Chinese characters are split into single-character tokens - Supports configurable stop words (defaults to common CJK punctuation) Also adds tokensForLikePattern() function for LIKE pattern tokenization. Refactor: Replace nextInStringPadded/stringPaddedToBloomFilter with template-based forEachToken/forEachTokenToBloomFilter for cleaner code and better SSE optimization in SplitByNonAlphaTokenExtractor. The tokenizer can be used with: - tokens() function: tokens(str, 'unicode_word') - Full-text index: INDEX idx(col) TYPE text(tokenizer = unicode_word)
0943249 to
51ab256
Compare
This comment was marked as resolved.
This comment was marked as resolved.
george-larionov
left a comment
There was a problem hiding this comment.
Partial review, I will finish next week. Very nice PR overall, thanks.
|
@amosbird @george-larionov Would it be possible to split this PR in three PRs?
|
|
Sure, that makes sense. This review has already started though, so I’d prefer to let it finish first. Once it’s done, I’ll split this into three PRs as you suggested. |
There was a problem hiding this comment.
Here is my second round of review, not approving only because of @rschu1ze's comment about splitting the PR into multiple, which I think is a good idea. Once you finish any other changes due to comments I can approve the new PRs. Thanks!
| SELECT tokensForLikePattern('你', 'unicode_word'); -- single Unicode char | ||
| SELECT tokensForLikePattern('abc你好', 'unicode_word'); -- ASCII then Unicode | ||
| SELECT tokensForLikePattern(',。你好', 'unicode_word'); -- punctuation stop words skipped | ||
| SELECT tokensForLikePattern('你好%世界', 'unicode_word'); -- Unicode token with wildcards |
There was a problem hiding this comment.
I think it should be added to the documentation of this function that the wildcards are essentially meaningless for non-ASCII unicode characters
There was a problem hiding this comment.
This is tokenizer-specific. unicode_word splits non-ASCII characters into single-char tokens, so adjacent wildcards discard them. Other tokenizers might have different semantic.
This comment was marked as resolved.
This comment was marked as resolved.
Add a new unicode_word tokenizer that splits text using Unicode word boundary rules similar to UAX ClickHouse#29. ASCII alphanumeric characters form tokens with connectors (underscore, colon, dot, single quote), while non-ASCII Unicode characters become single-character tokens. Stop words (configurable, defaults to common CJK punctuation) are filtered out. The tokenizer is registered in TokenizerFactory and automatically available for text() indexes and the tokens()/tokensForLikePattern() functions. It supports LIKE pattern matching via nextInStringLike(). This is the third and final PR split from ClickHouse#90268.
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Introduce
unicode_wordtokenizer and refactor tokenization to a new high-performanceforEachTokencallback interface, replacing the old iterator-style API to support SIMD and stateful tokenizers.Documentation entry for user-facing changes
Details
A new tokenizer implementing a simplified
UAX #29–like word segmentation optimized for mixed Latin + CJK text:_may appear at token boundaries but cannot form a token alone:connects letters;.and quotes connect characters of the same typeExample:
This provides predictable, index-friendly tokenization while avoiding the complexity and cost of full UAX #29.
Introduces a new function tokensForLikePattern to tokenize LIKE patterns while respecting wildcard semantics:
%and_are treated as wildcards\%,\_) are treated as literalsExamples:
This function is primarily intended for debugging and testing purposes, and is used internally to analyze and validate tokenization behavior for LIKE patterns.
The existing iterator-style API (
nextInString,nextInStringPadded) is not suitable for:This PR replaces it with a new forEachToken callback interface, which:
All
Paddedvariants are removed. High-performance tokenization in ClickHouse is only used on column data, which is already padded, so the new API assumes padding by design.Benchmark:
clickhouse-benchmark \ --query "SELECT tokens(URL) FROM hits_10m_single FORMAT Null"Before
After
Latency improves across all percentiles, with ~10–12% higher throughput and lower median/ tail latency.