def generate_keyvi(key_values, filename):
    dictionary_compiler = KeyOnlyDictionaryCompiler({"memory_limit_mb": "10"})
    for key in key_values:
        dictionary_compiler.Add(key)

    dictionary_compiler.Compile()
    dictionary_compiler.WriteToFile(filename)
Example #2
0
def test_manifest_after_compile():
    c = KeyOnlyDictionaryCompiler({"memory_limit_mb": "10"})
    c.Add("Leela")
    c.Add("Kif")
    c.Compile()
    c.SetManifest('{"author": "Zapp Brannigan"}')
    file_name = os.path.join(tempfile.gettempdir(), 'brannigan_manifest2.kv')
    try:
        c.WriteToFile(file_name)
        d = Dictionary(file_name)
        m = json.loads(d.GetManifest())
        assert m['author'] == "Zapp Brannigan"
        del d
    finally:
        os.remove(file_name)