cliqz-oss / keyvi

Keyvi - a key value index that powers Cliqz search engine. It is an in-memory FST-based data structure highly optimized for size and lookup performance.
https://cliqz.com
Apache License 2.0
179 stars 38 forks source link

pykeyvi segfault 11 #225

Closed lexplua closed 7 years ago

lexplua commented 7 years ago

sample code

compiler = pykeyvi.StringDictionaryCompiler()
compiler.Add('a', 'b')
compiler.WriteToFile('dump1.kv')

Stacktrace

keyvi::dictionary::DictionaryCompiler<keyvi::dictionary::fsa::internal::SparseArrayPersistence<unsigned short>, keyvi::dictionary::fsa::internal::StringValueStore, keyvi::dictionary::sort::TpieSorter<keyvi::dictionary::sort::key_value_pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, keyvi::dictionary::fsa::ValueHandle> > >::WriteToFile<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >) + 243
1   pykeyvi.so                      0x000000010d0aef1b __pyx_pw_7pykeyvi_24StringDictionaryCompiler_15WriteToFile(_object*, _object*) + 411

OSX, Python 2.7/3.6

hendrikmuhs commented 7 years ago

You miss the Compile step, after Add:

compiler = pykeyvi.StringDictionaryCompiler()
compiler.Add('a', 'b')
compiler.Compile()
compiler.WriteToFile('dump1.kv')

For your code WriteToFile should throw an exception. Looks like that does not happen?

I will check it. Maybe the python binding does not handle it correctly.