kojiromike commented on code in PR #1181:
URL: https://github.com/apache/avro/pull/1181#discussion_r1264789889
##########
lang/py/avro/schema.py:
##########
@@ -104,6 +115,50 @@ def _is_timezone_aware_datetime(dt: datetime.datetime) ->
bool:
return dt.tzinfo is not None and dt.tzinfo.utcoffset(dt) is not None
+# Fingerprint Constants
+_EMPTY64_FINGERPRINT: int = 0xC15D213AA4D7A795
+_FINGERPRINT_TABLE: tuple = tuple(reduce(lambda fp, _: (fp >> 1) ^
(_EMPTY64_FINGERPRINT & -(fp & 1)), range(8), i) for i in range(256))
+
+
+# All algorithms guaranteed by hashlib are supported:
+# - 'blake2b',
+# - 'blake2s',
+# - 'md5',
+# - 'sha1',
+# - 'sha224',
+# - 'sha256',
+# - 'sha384',
+# - 'sha3_224',
+# - 'sha3_256',
+# - 'sha3_384',
+# - 'sha3_512',
+# - 'sha512',
+# - 'shake_128',
+# - 'shake_256'
+SUPPORTED_ALGORITHMS: FrozenSet[str] = frozenset({"CRC-64-AVRO"} |
hashlib.algorithms_guaranteed)
+
+
+def _crc_64_fingerprint(data: bytes) -> bytes:
+ """The 64-bit Rabin Fingerprint.
+
+ As described in the Avro specification.
+
+ Args:
+ data: A bytes object containing the UTF-8 encoded parsing canonical
+ form of an Avro schema.
+ Returns:
+ A bytes object with a length of eight.
Review Comment:
Perhaps the endianness should be in the docstring, so it shows up in
`help()` output.
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]