Repository navigation
Conversation
`regexpMasked(base, masks = [...], custom_masks = [...])` produces the tokens of a base tokenizer (`splitByNonAlpha` or `splitByString`), with every match of a mask merged into one token. Built-in masks: `timestamp`, `ip`, `uuid`, `hex`, `number`, `path`, `url`; custom masks are RE2 patterns. Masks are tried only at base-token starts, the longest match wins and is extended to the next separator, so tokens never touch and do not depend on the surrounding text. - `TokenizerFactory`: tokenizers can be registered with a creator that receives the argument ASTs, for nested tokenizers and `name = value` arguments. - `TokenMasks`: built-in masks (Latin-1, ASCII case folding) with first-byte tables, prechecks and exact hand-written matchers for `number`, `path` and `url` (which also keep a scan linear); custom masks compiled into one longest-match alternation, validated (no anchors, no empty match, limits). - `RegexpMaskedTokenizer::forEachSpan` reports token offsets and whether a token is masked, for reuse by the `Log` type; it needs no padding. - Supported in `text` indexes, `tokens`, `hasAnyTokens`, `hasAllTokens` and `hasPhrase`; documented in `textindexes.mdx`. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Preview approval requiredThis pull request comes from a fork, so Mintlify won't build a preview until someone with write access approves commit |
|
Workflow [PR], commit [fdec62c] Summary: ❌
AI ReviewSummaryPR #131868 adds Findings
Final Verdict |
The inherited `stringToTokens` and `stringToBloomFilter` call `nextInString`
once per token, and each call starts a new `forEachSpan` with an empty
`TokenMasks::ScanState`. That lost the failed-match positions which keep the
`path` and `url` matchers linear, so a needle such as `repeat('a.', 100000)`
in `hasAllTokens`, `hasAnyTokens`, `hasPhrase` or a text index condition was
tokenized in quadratic time. Both methods now collect the tokens in one
`forEachSpan` pass. The linear-time gtest and the stateless test cover these
entry points.
Review: ClickHouse#131868 (comment)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
- `re2::Regexp::Walker` leaves `max_visits_` uninitialized until `Walk`, which `clang-analyzer-optin.cplusplus.UninitializedObject` reports for the derived `FirstBytesWalker` constructor: suppressed with a reason. - Escaped string literals rewritten as raw string literals. - The fixed seeds of the test's random generators are intentional (deterministic test data): suppressed with a reason. CI report: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=131868&sha=7802dfe132254ede3971abf4901cd9e40b5bfd27&name_0=PR&name_1=Build%20%28arm_tidy%2C%201%2F4%29 PR: ClickHouse#131868 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Object file sizes13 object files changed (+544.46 KiB total), 1 added.
711 more object files are built by the master warmup baseline only (it builds every object-file target, a pull request build only Compile time of recompiled translation units25 translation units recompiled, 180 s compile time in total, 24 of them have a recent master baseline. |
With a `splitByString` base whose separators are hexadecimal digits, such as
`regexpMasked(splitByString(['a']))` on `repeat('bbbbbbbba', n)`, every base
token started a `[0-9a-f]{8,}` match over the rest of the run, which was then
rejected for lacking a decimal digit, so tokenizing was quadratic. The `hex`
pattern now has an exact hand-written matcher: the match is the whole run of
hexadecimal digits, and a rejected run is recorded in `TokenMasks::ScanState`,
because every later start within it is rejected too. `LinearTime` and the
stateless test cover such a base.
Review: ClickHouse#131868 (comment)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…asked # Conflicts: # src/Interpreters/TokenizerFactory.h
Master enabled the `modernize-use-nodiscard` clang-tidy check in 7fbc444. Mark the `const` member functions added by this PR in `RegexpMaskedTokenizer`, `SplitByStringTokenizer` and `TokenMasks` accordingly. Co-Authored-By: Claude Opus 5.5 <[email protected]>
| <create_query>CREATE TABLE tib_log_non_alpha (s String, INDEX idx s TYPE text(tokenizer = splitByNonAlpha)) ENGINE = MergeTree ORDER BY tuple()</create_query> | ||
| <create_query>CREATE TABLE tib_log_by_string (s String, INDEX idx s TYPE text(tokenizer = splitByString([' ', '=', ',', '"']))) ENGINE = MergeTree ORDER BY tuple()</create_query> | ||
| <create_query>CREATE TABLE tib_log_by_string_multi (s String, INDEX idx s TYPE text(tokenizer = splitByString([', ', '="', ' ', '=']))) ENGINE = MergeTree ORDER BY tuple()</create_query> | ||
| <create_query>CREATE TABLE tib_log_regexp_masked (s String, INDEX idx s TYPE text(tokenizer = regexpMasked)) ENGINE = MergeTree ORDER BY tuple()</create_query> |
There was a problem hiding this comment.
[Major] Handle the new tokenizer in reference-server benchmark setup
The reference server does not have regexpMasked, but perf.py runs these new setup statements on both servers. Without a setup opt-out, the first CREATE TABLE raises BAD_ARGUMENTS with Unknown tokenizer: 'regexpMasked', and do_create aborts the entire text_index_build_tokenizers test before any timed queries run, including the existing tokenizer benchmarks. This is already the run error in the current performance report.
Please add do_not_check_in_pr="131868" to the new feature-dependent setup statements, as documented in tests/performance/README.md, and rerun the comparison. The harness will then measure the test on the new server and classify it as backward-incompatible instead of failing during setup.
AI review of a later commit does not approve the PR, see the AI Review comment.
A new tokenizer for text indexes on log messages.
regexpMaskedproduces the tokens of a base tokenizer (splitByNonAlphaby default, orsplitByString), but every match of a mask, a regular expression for a kind of value, becomes a single token. So10.0.0.1,2026-11-05 10:15:30.123+00:00,97a133f8-4d41-4e4f-b869-db7c48b6da4c,1.5GBorvar/lib/clickhouse/x.binare indexed and searched as one token each, instead of being split into many short and unselective ones.Semantics
masks = [...](all by default):timestamp(ISO 8601, access log, syslog),ip(IPv4, IPv6),uuid,hex,number,path,url.custom_masks = [...]adds RE2 patterns. All masks are case-insensitive.masks = []gives exactly the base tokenizer's tokens.hasAllTokens(col, needle, '<tokenizer>').Performance
Single thread,
tokensover 372 MB of the log lines fromtests/performance/tokenizers.xml(shared machine, about ±10%):splitByNonAlpha: ~650 MB/sregexpMasked(masks = []): ~690 MB/s (delegates to the base tokenizer)regexpMaskedwith all built-in masks: ~120 MB/sBuilding a text index on 500k rows takes about 33% longer than with
splitByNonAlpha. New queries are added totokenizers.xmlandtext_index_build_tokenizers.xml.Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Added the
regexpMaskedtokenizer for text indexes and token search functions. It splits text likesplitByNonAlphaorsplitByString, but keeps values matched by masks, such as IP addresses, UUIDs, timestamps, numbers, paths and URLs, as single tokens. Built-in masks are selected withmasks = [...], and additional masks can be given as regular expressions withcustom_masks = [...].🤖 Generated with Claude Code
Workflow [PR]
Sync PR [sync-upstream/pr/131868]