Skip to content

Commit

Permalink
rewrite merger methods
Browse files Browse the repository at this point in the history
  • Loading branch information
hendrikmuhs committed Jan 19, 2025
1 parent 17d5dcb commit 94f1461
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 43 deletions.
30 changes: 15 additions & 15 deletions python/src/pxds/dictionary_merger.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -9,38 +9,38 @@ cdef extern from "keyvi/dictionary/dictionary_types.h" namespace "keyvi::diction
cdef cppclass JsonDictionaryMerger:
JsonDictionaryMerger() except +
JsonDictionaryMerger(libcpp_map[libcpp_utf8_string, libcpp_utf8_string] value_store_params) except +
void Add(libcpp_utf8_string) except +
void SetManifest(libcpp_utf8_string) except +
void Merge(libcpp_utf8_string) nogil
void Add(libcpp_utf8_string) except + # wrap-as:add
void SetManifest(libcpp_utf8_string) except + # wrap-as:set_manifest
void Merge(libcpp_utf8_string) nogil # wrap-as:merge

cdef extern from "keyvi/dictionary/dictionary_types.h" namespace "keyvi::dictionary":
cdef cppclass CompletionDictionaryMerger:
CompletionDictionaryMerger() except +
CompletionDictionaryMerger(libcpp_map[libcpp_utf8_string, libcpp_utf8_string] value_store_params) except +
void Add(libcpp_utf8_string) except +
void SetManifest(libcpp_utf8_string) except +
void Merge(libcpp_utf8_string) nogil
void Add(libcpp_utf8_string) except + # wrap-as:add
void SetManifest(libcpp_utf8_string) except + # wrap-as:set_manifest
void Merge(libcpp_utf8_string) nogil # wrap-as:merge

cdef extern from "keyvi/dictionary/dictionary_types.h" namespace "keyvi::dictionary":
cdef cppclass StringDictionaryMerger:
StringDictionaryMerger() except +
StringDictionaryMerger(libcpp_map[libcpp_utf8_string, libcpp_utf8_string] value_store_params) except +
void Add(libcpp_utf8_string) except +
void SetManifest(libcpp_utf8_string) except +
void Merge(libcpp_utf8_string) nogil
void Add(libcpp_utf8_string) except + # wrap-as:add
void SetManifest(libcpp_utf8_string) except + # wrap-as:set_manifest
void Merge(libcpp_utf8_string) nogil # wrap-as:merge

cdef extern from "keyvi/dictionary/dictionary_types.h" namespace "keyvi::dictionary":
cdef cppclass KeyOnlyDictionaryMerger:
KeyOnlyDictionaryMerger() except +
KeyOnlyDictionaryMerger(libcpp_map[libcpp_utf8_string, libcpp_utf8_string] value_store_params) except +
void Add(libcpp_utf8_string) except +
void SetManifest(libcpp_utf8_string) except +
void Merge(libcpp_utf8_string) nogil
void Add(libcpp_utf8_string) except + # wrap-as:add
void SetManifest(libcpp_utf8_string) except + # wrap-as:set_manifest
void Merge(libcpp_utf8_string) nogil # wrap-as:merge

cdef extern from "keyvi/dictionary/dictionary_types.h" namespace "keyvi::dictionary":
cdef cppclass IntDictionaryMerger:
IntDictionaryMerger() except +
IntDictionaryMerger(libcpp_map[libcpp_utf8_string, libcpp_utf8_string] value_store_params) except +
void Add(libcpp_utf8_string) except +
void SetManifest(libcpp_utf8_string) except +
void Merge(libcpp_utf8_string) nogil
void Add(libcpp_utf8_string) except + # wrap-as:add
void SetManifest(libcpp_utf8_string) except + # wrap-as:set_manifest
void Merge(libcpp_utf8_string) nogil # wrap-as:merge
8 changes: 4 additions & 4 deletions python/tests/dictionary/dictionary_merger_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@ def test_merge(merger):
generate_keyvi(key_values_3, file_3)


merger.Add(file_1)
merger.Add(file_2)
merger.Add(file_3)
merger.Merge(merge_file)
merger.add(file_1)
merger.add(file_2)
merger.add(file_3)
merger.merge(merge_file)


merged_dictionary = Dictionary(merge_file, loading_strategy_types.populate_lazy)
Expand Down
8 changes: 4 additions & 4 deletions python/tests/dictionary/int_dictionary_merger_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ def test_merge(merger):
generate_keyvi(key_values_2, file_2)
generate_keyvi(key_values_3, file_3)

merger.Add(file_1)
merger.Add(file_2)
merger.Add(file_3)
merger.Merge(merge_file)
merger.add(file_1)
merger.add(file_2)
merger.add(file_3)
merger.merge(merge_file)

merged_dictionary = Dictionary(merge_file)

Expand Down
8 changes: 4 additions & 4 deletions python/tests/dictionary/key_only_dictionary_merger_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,10 @@ def test_merge(merger):
generate_keyvi(keys_2, file_2)
generate_keyvi(keys_3, file_3)

merger.Add(file_1)
merger.Add(file_2)
merger.Add(file_3)
merger.Merge(merge_file)
merger.add(file_1)
merger.add(file_2)
merger.add(file_3)
merger.merge(merge_file)

merged_dictionary = Dictionary(merge_file)

Expand Down
8 changes: 4 additions & 4 deletions python/tests/dictionary/string_dictionary_merger_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,10 @@ def test_merge(merger):
generate_keyvi(key_values_2, file_2)
generate_keyvi(key_values_3, file_3)

merger.Add(file_1)
merger.Add(file_2)
merger.Add(file_3)
merger.Merge(merge_file)
merger.add(file_1)
merger.add(file_2)
merger.add(file_3)
merger.merge(merge_file)

merged_dictionary = Dictionary(merge_file)

Expand Down
10 changes: 0 additions & 10 deletions python/tests/int/int_dictionary_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,6 @@ def test_manifest():
c.add("Leela", 20)
c["Kif"] = 2
c.set_manifest('{"drink": "slurm"}')
with tmp_dictionary(c, 'slurm.kv') as d:
m = json.loads(d.GetManifest())
assert m['drink'] == "slurm"

def test_manifest():
c = compiler.IntDictionaryCompilerSmallData({"memory_limit_mb":"10"})
c.add("Leela", 9223372036854775)
c["Kif"] = 2
c.set_manifest('{"drink": "slurm"}')
with tmp_dictionary(c, 'slurm.kv') as d:
m = json.loads(d.manifest())
assert 9223372036854775 == d.get('Leela').value
assert m['drink'] == "slurm"
4 changes: 2 additions & 2 deletions python/tests/statistics_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ def test_manifest_for_merger():
del c2

merger = JsonDictionaryMerger({"memory_limit_mb": "10"})
merger.SetManifest('{"author": "Fry"}')
merger.Merge('manifest_json_merged.kv')
merger.set_manifest('{"author": "Fry"}')
merger.merge('manifest_json_merged.kv')

d = Dictionary('manifest_json_merged.kv')
m = json.loads(d.manifest())
Expand Down

0 comments on commit 94f1461

Please sign in to comment.