WallBreaker is a similarity search algorithm that overcomes the "wall effect" in traditional left-to-right Levenshtein automata traversal. This algorithm has been fully implemented in liblevenshtein-rust using the Full SCDAWG approach.
Traditional approximate string matching starts from the left edge of the pattern and must explore all prefixes up to error bound b before any filtering occurs. For example, with max_distance = 16, the algorithm must visit all dictionary prefixes of length 0-16, even though most lead to dead ends.
Instead of left-to-right traversal:
This avoids the wasteful initial exploration, dramatically improving performance for large error bounds.
Status: Implemented and Tested Approach: Option A - Full SCDAWG Implementation Date: 2025-12-26 Tests: 35 new tests, all passing (982 total library tests)
use liblevenshtein::dictionary::scdawg::Scdawg;
use liblevenshtein::wallbreaker::WallBreaker;
// Build SCDAWG dictionary
let dict = Scdawg::<()>::from_terms(vec!["cathedral", "category", "catering"]);
// Create WallBreaker with max distance 2
let wb = WallBreaker::new(&dict, 2);
// Find approximate matches
for result in wb.query("cathedrel") {
println!("{} (distance {})", result.term, result.distance);
}
// Output: cathedral (distance 1)
Scdawg<V> - Byte-level (ASCII) SCDAWG dictionaryScdawgChar<V> - Character-level (Unicode/UTF-8) SCDAWG dictionarySubstringDictionary - Trait for dictionaries supporting exact substring searchBidirectionalDictionaryNode - Trait for nodes supporting backward traversalWallBreaker<D> - Main WallBreaker query builderWallBreakerQuery<D> - Iterator over approximate matchesWallBreakerResult - Result containing matched term and distancePatternSplitter - Splits queries using pigeonhole principlePatternPiece - A piece of the split patternTitle: "WallBreaker - overcoming the wall effect in similarity search" Authors: Stefan Gerdjikov, Stoyan Mihov, Petar Mitankin, Klaus U. Schulz Published: EDBT/ICDT 2013
Key Result: 0.088ms average query time for 100-character patterns with 16 errors in 750K word lexicon.
| File | Lines | Description |
|---|---|---|
src/dictionary/substring.rs | ~120 | SubstringMatch, SubstringDictionary, BidirectionalDictionaryNode traits |
src/dictionary/scdawg.rs | ~1300 | Byte-level SCDAWG implementation (ASCII) |
src/dictionary/scdawg_char.rs | ~800 | Character-level SCDAWG (Unicode/UTF-8) |
src/wallbreaker/mod.rs | ~200 | WallBreaker struct and module exports |
src/wallbreaker/pattern_splitter.rs | ~275 | PatternSplitter using pigeonhole principle |
src/wallbreaker/extension.rs | ~460 | BidirectionalExtension for left/right traversal |
src/wallbreaker/query_iterator.rs | ~230 | WallBreakerQuery iterator with deduplication |
Scdawg) and UTF-8 (ScdawgChar) variants/src/wallbreaker/ - WallBreaker implementation/src/dictionary/scdawg.rs - SCDAWG dictionary backend/src/dictionary/scdawg_char.rs - Unicode SCDAWG variant/src/dictionary/substring.rs - Substring search traitsDocumentation follows the same Apache-2.0 license as the main library.
Last Updated: 2025-12-26 Status: ✅ Implemented and Tested Approach: Full SCDAWG (Option A)
Can you improve this documentation?Edit on GitHub
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |