Skip to content

feat: add explicit pinyin query modes and boundary-safe matching - #3

Merged
DeoLeung merged 3 commits into
mainfrom
codex/pinyin-query-modes
Oct 13, 2026
Merged

DeoLeung merged 3 commits into
mainfrom
codex/pinyin-query-modes

Conversation

@DeoLeung

Copy link
Copy Markdown
Contributor

Summary

  • Add opt-in full, initials, autocomplete and compat query modes with separate public/internal APIs; keep legacy signatures and defaults unchanged.
  • Preserve umlauts, tones and explicit syllable boundaries. Keep valid final prefixes such as yon/lon whole, and bound pipe-delimited alternatives.
  • Keep the Rust extension and optional SQL backend independent. Rust tokenization remains SPI-free and parallel safe.
  • Add catalog-only 0.0.8 -> 0.0.9 migration without overwriting live dictionaries or stored generated values.
  • Pin integration tests to pg_search 0.26.1; PG19 beta4 uses a pinned-source experimental compatibility patch, not an official upstream PG19 package.

Validation

  • 69 Python tests, 738 pgTAP assertions and 16 Rust unit tests passed locally on PG19 beta4 / pg_search 0.26.1.
  • Genuine fresh-install/upgrade tests preserve old function OIDs, dictionaries and generated values. Actual parallel workers execute both public and pattern mode APIs.
  • SQL-only tests run without the Rust extension; additional pg_search checks cover sequential fallback, private exact bitmap intersections, and commit/rollback/VACUUM visibility.
  • cargo fmt --check, lib/binary checks, actionlint and deterministic dictionary rebuild passed. All 196,188 dictionary keys remain unchanged.
  • PG18 is configured in CI but was not part of the local validation. Shared/lossy bitmap paths are not covered by the local smoke tests. The local PG19 build used a cached SDK overlay, not a clean end-to-end build of the complete Docker recipe.

Benchmark

Fresh isolated database, 20,000 phrases, 2,000 queries per method, three rotated repeats. Raw IDs, plans, samples and source hashes are retained in benchmarks/p1_query_modes.json; readable results are in benchmarks/p1_query_modes.md.

  • All Rust/SQL pattern arrays and ranked IDs agree within each mode/storage. Every autocomplete corpus output is independently checked against source syllable positions.
  • Three identical-input exact-boundary contrasts retain all seven labeled positives; compat has four visible labeled false positives versus zero for full. This is targeted/top-k evidence, not general accuracy.
  • Plain-field full-query medians: Rust 400.313 ms, SQL 1,167.757 ms. Compat/full matching semantics differ, so this is not a parser-only speedup.
  • Pipe-wrapped fields are substantially slower. All modes share the same dual-field index, 3,514,368 bytes across three fresh builds; no index-reduction claim.
  • Shared host had approximately 33.3 GB swap and unrelated workloads. Timings do not establish stable performance gains and are not directly comparable with older P0/general reports.

README and specification document the APIs, upgrade steps, reproduction commands and limitations.

@DeoLeung
DeoLeung merged commit 382d65c into main Oct 13, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant