Skip to content

Improve player lookups with inconsistent casing - #428

Merged
Jikoo merged 2 commits into
masterfrom
dev/improve_fuzzy_search
Sep 13, 2026
Merged

Jikoo merged 2 commits into
masterfrom
dev/improve_fuzzy_search

Conversation

@Jikoo

@Jikoo Jikoo commented Sep 13, 2026

Copy link
Copy Markdown
Owner

Replaces the Symmetrics Jaro-Winkler implementation with my own hand-rolled version of the algorithm modified to value case less for ASCII alphabetic characters.

I didn't look at the Symmetrics implementation until I was done so as to not accidentally copy their work, and then I got concerned about performance because their version was so wildly different (no wonder I didn't understand it before).
Turns out that either they did some wacky things or whatever modifications I did back when I jammed it into the project were really not great. I don't really care to point fingers, it's pretty safe to assume I didn't know what the heck I was doing.

Benchmark                      Mode  Cnt     Score     Error  Units
StringMetricRunner.fuzzy       avgt   25  2879.862 ±  70.049  ns/op
StringMetricRunner.symmetrics  avgt   25  4849.438 ± 145.610  ns/op

The new version runs in about 60% of the time of the old one. Could definitely speed that up by caching the input codepoint array for the search string, but that's probably not worth the struggle on the SQLite side.

This does not support non-ASCII characters. That could be done, but would likely require that the algorithm effectively run twice - once for raw, once for normalized, and then they could be combined into a weighted average. The normalized search string should also be cached externally.

Closes #427

@Jikoo
Jikoo enabled auto-merge (squash) September 13, 2026 17:13
@Jikoo

Jikoo commented Sep 13, 2026

Copy link
Copy Markdown
Owner Author

Oh yes, and very exciting, OpenInv's first test case! It's not much, but now I have less of an excuse to not write tests when bugs crop up! The internals still probably aren't worth the bother to test, but the Bukkit API side is rather more manageable.

@Jikoo
Jikoo merged commit fdf7f68 into master Sep 13, 2026
2 checks passed
@Jikoo
Jikoo deleted the dev/improve_fuzzy_search branch September 13, 2026 17:21
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.

Improve fuzzy search handling of different casing

1 participant