Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Maintenance] ^^^ is deprecated use bitwise instead #488

Merged
merged 1 commit into from
Nov 10, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions lib/kafka_ex/utils/murmur.ex
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Utility module that provides Murmur hashing algorithm.
"""

use Bitwise

Check warning on line 6 in lib/kafka_ex/utils/murmur.ex

View workflow job for this annotation

GitHub Actions / runner / Test (1.14, 25.2)

use Bitwise is deprecated. import Bitwise instead

# Arbitrary constant for murmur2 hashing
# https://github.com/aappleby/smhasher/blob/master/src/MurmurHash2.cpp#L39-L43
Expand All @@ -21,7 +21,7 @@
def murmur2(key) do
<<seed::signed-size(32)>> = <<@seed::size(32)>>
len = byte_size(key)
_murmur2(key, seed ^^^ len)
_murmur2(key, bxor(seed, len))
end

@doc """
Expand Down Expand Up @@ -54,27 +54,27 @@

defp _murmur2(<<a::little-size(32), rest::binary>>, h) do
k = mask32(a * @m)
k = k ^^^ ubsr32(k, @r)
k = bxor(k, ubsr32(k, @r))
k = mask32(k * @m)
h = mask32(h * @m)
_murmur2(rest, h ^^^ k)
_murmur2(rest, bxor(h, k))
end

defp _murmur2(<<a1::size(8), a2::size(8), a3::size(8)>>, h) do
_murmur2(<<a1, a2>>, h ^^^ mask32(a3 <<< 16))
_murmur2(<<a1, a2>>, bxor(h, mask32(a3 <<< 16)))
end

defp _murmur2(<<a1::size(8), a2::size(8)>>, h) do
_murmur2(<<a1>>, h ^^^ mask32(a2 <<< 8))
_murmur2(<<a1>>, bxor(h, mask32(a2 <<< 8)))
end

defp _murmur2(<<a1::size(8)>>, h) do
_murmur2("", mask32((h ^^^ a1) * @m))
_murmur2("", mask32(bxor(h, a1) * @m))
end

defp _murmur2("", h) do
h = h ^^^ ubsr32(h, 13)
h = bxor(h, ubsr32(h, 13))
h = mask32(h * @m)
h ^^^ ubsr32(h, 15)
bxor(h, ubsr32(h, 15))
end
end
Loading