You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by GitBox <gi...@apache.org> on 2021/01/30 07:30:07 UTC

[GitHub] [ignite-python-thin-client] ivandasch commented on a change in pull request #5: IGNITE-14059: Fix hashing of complex objects

ivandasch commented on a change in pull request #5:
URL: https://github.com/apache/ignite-python-thin-client/pull/5#discussion_r567211910



##########
File path: pyignite/utils.py
##########
@@ -106,20 +106,37 @@ def unwrap_binary(client: 'Client', wrapped: tuple) -> object:
     return result
 
 
-def hashcode(string: Union[str, bytes]) -> int:
+def hashcode(data: Union[str, bytes]) -> int:
     """
     Calculate hash code used for identifying objects in Ignite binary API.
 
-    :param string: UTF-8-encoded string identifier of binary buffer,
+    :param data: UTF-8-encoded string identifier of binary buffer or byte array
     :return: hash code.
     """
-    result = 1 if isinstance(string, (bytes, bytearray)) else 0
-    for char in string:
-        try:
-            char = ord(char)
-        except TypeError:
-            pass
-        result = int_overflow(31 * result + char)
+    if isinstance(data, str):
+        """
+        For strings we iterate over code point which are of the int type
+        and can take up to 4 bytes and can only be positive.
+        """
+        result = 1 if isinstance(string, (bytes, bytearray)) else 0

Review comment:
       string is not defined
   ```
   result = 1 if isinstance(data, (bytes, bytearray)) else 0
   ```




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org