src/murmur_nif.erl

-module(murmur_nif).

-on_load(init/0).

-export([
    murmur3_x64_128/1,
    murmur3_cassandra_x64_128/1
]).

-spec init() -> ok.
init() ->
    SoName = filename:join(code:priv_dir(murmur_nif), "murmur_nif"),
    erlang:load_nif(SoName, 0).

%% @doc MurmurHash3, 128-bit variant for 64-bit platforms (Austin
%% Appleby's standard implementation). Hashes Bin with seed 0 and
%% returns a 16-byte binary `<<H1:64, H2:64>>'.
-spec murmur3_x64_128(binary()) -> binary().
murmur3_x64_128(_Bin) ->
    erlang:nif_error(murmur_nif_not_loaded).

%% @doc Cassandra/Scylla-compatible variant of MurmurHash3 x64_128.
%% Identical to `murmur3_x64_128/1' except the input bytes are treated
%% as signed (matching Java's signed `byte' type), which changes the
%% sign-extension of the tail-block accumulator and produces hashes
%% that match the partitioner used by Cassandra and Scylla.
%%
%% Use this to compute partition tokens for token-aware routing.
-spec murmur3_cassandra_x64_128(binary()) -> binary().
murmur3_cassandra_x64_128(_Bin) ->
    erlang:nif_error(murmur_nif_not_loaded).