Files
datastore/tests/performance/replace_string_fast_path.xml
Groene AIandClaude Opus 4.8 7279adecb4 Add performance test for replaceAll string fast paths
Covers the one-byte needle/replacement byte-flip path and the
needle == replacement no-op path in ReplaceStringImpl, addressing
the request for a perf test in PR #108178.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
2026-06-30 16:53:43 +00:00

22 lines
2.4 KiB
XML

<!-- Tests the fast paths in ReplaceStringImpl::vectorConstantConstant / vectorFixedConstantConstant (issue #106598):
1. one-byte needle + one-byte replacement in "replace all" mode: the string layout is unchanged, so the
column is copied once and matching bytes are flipped in place, skipping the Volnitsky search;
2. needle == replacement: a no-op for any needle length and both modes, so the column is copied verbatim. -->
<!-- _materialize_ because the shortcuts only apply to non-const haystack + const needle + const replacement -->
<test>
<!-- one-byte needle + one-byte replacement, replace all: byte-flip fast path -->
<query>WITH 'Many years later as he faced the firing squad, Colonel Aureliano Buendia was to remember that distant afternoon when his father took him to discover ice.' AS s SELECT replaceAll(materialize(s), ' ', '_') AS w FROM numbers_mt(5000000) FORMAT Null</query>
<!-- needle == replacement, one byte, replace all: verbatim-copy no-op -->
<query>WITH 'Many years later as he faced the firing squad, Colonel Aureliano Buendia was to remember that distant afternoon when his father took him to discover ice.' AS s SELECT replaceAll(materialize(s), ' ', ' ') AS w FROM numbers_mt(5000000) FORMAT Null</query>
<!-- needle == replacement, multi-byte, replace all: verbatim-copy no-op -->
<query>WITH 'Many years later as he faced the firing squad, Colonel Aureliano Buendia was to remember that distant afternoon when his father took him to discover ice.' AS s SELECT replaceAll(materialize(s), 'distant', 'distant') AS w FROM numbers_mt(5000000) FORMAT Null</query>
<!-- needle == replacement, multi-byte, replace one: verbatim-copy no-op -->
<query>WITH 'Many years later as he faced the firing squad, Colonel Aureliano Buendia was to remember that distant afternoon when his father took him to discover ice.' AS s SELECT replaceOne(materialize(s), 'distant', 'distant') AS w FROM numbers_mt(5000000) FORMAT Null</query>
<!-- needle == replacement, FixedString: vectorFixedConstantConstant verbatim-copy no-op -->
<query>WITH 'Many years later as he faced the firing squad, Colonel Aureliano Buendia was to remember that distant afternoon when his father took him to discover ice.' AS s SELECT replaceAll(materialize(toFixedString(s, 153)), 'distant', 'distant') AS w FROM numbers_mt(5000000) FORMAT Null</query>
</test>