عجفت الغور

elixir driver for cassandra/scylla

elixir, Cassandra

TokenAware LB Policy for Xandra and Shard Awareness

Python Examples

Java Reference

Elixir NIF

  • https://github.com/lpgauth/murmur

  • Possibly something like this? -

    defmodule ShardCalculator do
      @min_token -1 <<< 63
      @token_max 1 <<< 64
    
      def calculate_shard(token, ignore_msb, nr_shards) do
        # Bias the token
        biased_token = token - @min_token
    
        # Left shift by ignore_msb bits
        biased_token = biased_token <<< ignore_msb
    
        # Multiply by number of shards and perform truncating division
        shard = div(biased_token * nr_shards, @token_max)
        shard
      end
    end
    
    defmodule ShardCalculator do
      @min_token -1 <<< 63
      @token_max 1 <<< 64
    
      def calculate_shard(token, ignore_msb, nr_shards) do
        token = token - @min_token
        token = token <<< ignore_msb
    
        tok_lo = token &&& 0xFFFFFFFF
        tok_hi = token >>> 32
    
        mul1 = tok_lo * nr_shards
        mul2 = tok_hi * nr_shards
    
        sum = (mul1 >>> 32) + mul2
        sum >>> 32
      end
    end
    

Existing Xandra

Worklist