elixir driver for cassandra/scylla
- Use a nif to gate https://cpp-driver.docs.scylladb.com/master/
- https://github.com/bencheeorg/benchee_json <- benchmarking runtimes
- https://github.com/vinoski/bitwise <- Nif Issues
- similar wrapper but for leveldb <- https://github.com/basho/eleveldb
TokenAware LB Policy for Xandra and Shard Awareness
- https://university.scylladb.com/courses/using-scylla-drivers/lessons/scylla-specific-drivers-overview-paging-and-shard-awareness/
- https://www.scylladb.com/2021/04/27/connect-faster-to-scylla-with-a-shard-aware-port/
- https://www.scylladb.com/glossary/cassandra-query-language-cql/
- https://monitoring.docs.scylladb.com/stable/use-monitoring/advisor/cqlNoTokenAware.html
Python Examples
- https://github.com/scylladb/python-driver/blob/64e7fad42ec88dfc72c7f12c389c3ef6c3f392fb/cassandra/pool.py#L659
- https://github.com/scylladb/scylladb/blob/master/docs/dev/protocol-extensions.md#intranode-sharding
- https://github.com/search?q=repo%3Ascylladb%2Fpython-driver%20shard_aware_port&type=code
- https://python-driver.docs.scylladb.com/stable/
Java Reference
- https://docs.datastax.com/en/drivers/java/2.1/com/datastax/driver/core/policies/TokenAwarePolicy.html
- https://github.com/apache/cassandra/blob/trunk/src/java/org/apache/cassandra/utils/MurmurHash.java#L28-L29git
Elixir NIF
-
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
- Wrap around the idea of distance: https://docs.datastax.com/en/developer/java-driver/3.6/manual/load_balancing/
- Look into fallback strats: https://docs.datastax.com/en/developer/java-driver/3.6/manual/load_balancing/#fallback-strategies