Skip to content

Commit

Permalink
rename index methods
Browse files Browse the repository at this point in the history
  • Loading branch information
hendrikmuhs committed Jan 19, 2025
1 parent 94f1461 commit adc0961
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 14 deletions.
25 changes: 23 additions & 2 deletions python/src/addons/Index.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

self.inst.get().Delete(key)

def Get (self, key, default = None):
def get (self, key, default = None):
"""Return the value for key if key is in the dictionary, else default."""
if isinstance(key, unicode):
key = key.encode('utf-8')
Expand All @@ -50,6 +50,9 @@
py_result.inst = _r
return py_result

def Get(self, *args):
return call_deprecated_method("Get", "get", self.get, *args)

def __contains__(self, key):
if isinstance(key, unicode):
key = key.encode('utf-8')
Expand All @@ -72,7 +75,7 @@
py_result.inst = _r
return py_result

def MSet(self, list key_values ):
def mset(self, list key_values ):
assert isinstance(key_values, list), 'arg in_0 wrong type'
cdef shared_ptr[libcpp_vector[libcpp_pair[libcpp_utf8_string,libcpp_utf8_string]]] cpp_key_values = shared_ptr[libcpp_vector[libcpp_pair[libcpp_utf8_string,libcpp_utf8_string]]](new libcpp_vector[libcpp_pair[libcpp_utf8_string,libcpp_utf8_string]]())
cdef libcpp_pair[libcpp_utf8_string, libcpp_utf8_string] cpp_kv
Expand All @@ -92,3 +95,21 @@
cpp_key_values.get().push_back(cpp_kv)

self.inst.get().MSet(cpp_key_values)

def MSet(self, *args):
return call_deprecated_method("MSet", "mset", self.mset, *args)

def Set(self, *args):
return call_deprecated_method("Set", "set", self.set, *args)

def GetNear(self, *args):
return call_deprecated_method("GetNear", "get_near", self.get_near, *args)

def GetFuzzy(self, *args):
return call_deprecated_method("GetFuzzy", "get_fuzzy", self.get_fuzzy, *args)

def Delete(self, *args):
return call_deprecated_method("Delete", "delete", self.delete, *args)

def Flush(self, *args):
return call_deprecated_method("Flush", "flush", self.flush, *args)
11 changes: 10 additions & 1 deletion python/src/addons/ReadOnlyIndex.pyx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@


def Get (self, key, default = None):
def get (self, key, default = None):
"""Return the value for key if key is in the dictionary, else default."""
if isinstance(key, unicode):
key = key.encode('utf-8')
Expand All @@ -14,6 +14,9 @@
py_result.inst = _r
return py_result

def Get(self, *args):
return call_deprecated_method("Get", "get", self.get, *args)

def __contains__(self, key):
if isinstance(key, unicode):
key = key.encode('utf-8')
Expand All @@ -35,3 +38,9 @@
cdef Match py_result = Match.__new__(Match)
py_result.inst = _r
return py_result

def GetNear(self, *args):
return call_deprecated_method("GetNear", "get_near", self.get_near, *args)

def GetFuzzy(self, *args):
return call_deprecated_method("GetFuzzy", "get_fuzzy", self.get_fuzzy, *args)
16 changes: 8 additions & 8 deletions python/src/pxds/index.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ cdef extern from "keyvi/index/index.h" namespace "keyvi::index":
cdef cppclass Index:
Index(libcpp_utf8_string) except+ # wrap-ignore
Index(libcpp_utf8_string, libcpp_map[libcpp_utf8_string, libcpp_utf8_string] params) except+ # wrap-ignore
void Set(libcpp_utf8_string, libcpp_utf8_string) except+
void MSet(shared_ptr[libcpp_vector[libcpp_pair[libcpp_utf8_string, libcpp_utf8_string]]]) # wrap-ignore
_MatchIteratorPair GetNear (libcpp_utf8_string, size_t minimum_prefix_length) except +
_MatchIteratorPair GetNear (libcpp_utf8_string, size_t minimum_prefix_length, bool greedy) except +
_MatchIteratorPair GetFuzzy(libcpp_utf8_string, int32_t max_edit_distance, size_t minimum_exact_prefix) except +
void Delete(libcpp_utf8_string) except+
void Flush() except+
void Flush(bool) except+
void Set(libcpp_utf8_string, libcpp_utf8_string) except+ # wrap-as:set
void MSet(shared_ptr[libcpp_vector[libcpp_pair[libcpp_utf8_string, libcpp_utf8_string]]]) except+ # wrap-ignore
_MatchIteratorPair GetNear (libcpp_utf8_string, size_t minimum_prefix_length) except + # wrap-as:get_near
_MatchIteratorPair GetNear (libcpp_utf8_string, size_t minimum_prefix_length, bool greedy) except + # wrap-as:get_near
_MatchIteratorPair GetFuzzy(libcpp_utf8_string, int32_t max_edit_distance, size_t minimum_exact_prefix) except + # wrap-as:get_fuzzy
void Delete(libcpp_utf8_string) except+ # wrap-as:delete
void Flush() except+ # wrap-as:flush
void Flush(bool) except+ # wrap-as:flush
bool Contains(libcpp_utf8_string) # wrap-ignore
shared_ptr[Match] operator[](libcpp_utf8_string) # wrap-ignore
6 changes: 3 additions & 3 deletions python/src/pxds/read_only_index.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ cdef extern from "keyvi/index/read_only_index.h" namespace "keyvi::index":
ReadOnlyIndex(libcpp_utf8_string, libcpp_map[libcpp_utf8_string, libcpp_utf8_string] params) except+
bool Contains(libcpp_utf8_string) # wrap-ignore
shared_ptr[Match] operator[](libcpp_utf8_string) # wrap-ignore
_MatchIteratorPair GetFuzzy(libcpp_utf8_string, int32_t max_edit_distance, size_t minimum_exact_prefix) except+
_MatchIteratorPair GetNear (libcpp_utf8_string, size_t minimum_prefix_length) except +
_MatchIteratorPair GetNear (libcpp_utf8_string, size_t minimum_prefix_length, bool greedy) except +
_MatchIteratorPair GetFuzzy(libcpp_utf8_string, int32_t max_edit_distance, size_t minimum_exact_prefix) except+ # wrap-as:get_fuzzy
_MatchIteratorPair GetNear (libcpp_utf8_string, size_t minimum_prefix_length) except + # wrap-as:get_near
_MatchIteratorPair GetNear (libcpp_utf8_string, size_t minimum_prefix_length, bool greedy) except + # wrap-as:get_near

0 comments on commit adc0961

Please sign in to comment.