diff --git a/keyvi/include/keyvi/dictionary/fsa/automata.h b/keyvi/include/keyvi/dictionary/fsa/automata.h index 79c494b96..7a4a94b28 100644 --- a/keyvi/include/keyvi/dictionary/fsa/automata.h +++ b/keyvi/include/keyvi/dictionary/fsa/automata.h @@ -134,7 +134,7 @@ class Automata final { * @return index of root state. */ uint64_t GetStartState() const { - return dictionary_properties_->GetNumberOfStates() != 0 ? dictionary_properties_->GetStartState() : 0; + return dictionary_properties_->GetNumberOfKeys() != 0 ? dictionary_properties_->GetStartState() : 0; } uint64_t GetNumberOfKeys() const { return dictionary_properties_->GetNumberOfKeys(); } diff --git a/rust/test_data/empty-key-dict.kv b/rust/test_data/empty-key-dict.kv new file mode 100644 index 000000000..1c326ac33 Binary files /dev/null and b/rust/test_data/empty-key-dict.kv differ diff --git a/rust/tests/tests.rs b/rust/tests/tests.rs index 1c96a3c8e..9e3e95a8e 100644 --- a/rust/tests/tests.rs +++ b/rust/tests/tests.rs @@ -194,6 +194,15 @@ mod tests { } } + #[test] + fn get_all_items_empty() { + // uses dictionary created using keyvi < 0.7.2, see gh#368 + let dict = dictionary::Dictionary::new("test_data/empty-key-dict.kv").unwrap(); + + let all_items: Vec<_> = dict.get_all_items().collect(); + assert!(all_items.is_empty()); + } + #[test] fn multi_word_completions() { let mut values = vec![