Avoiding Negative Hash Codes from Java's String.hashCode() in Sharding Scenarios
When sharding data by a non-integer primary key or a composite key (usually concatenated in to a string), developers often rely on Java's built-in String.hashCode() method to derive a hash value, which is then used for modulo-based sharding. While convenient, this approach can produce negative hash codes, leading to invalid shard numbers. Under ...
Posted on Tue, 19 May 2026 15:09:12 +0000 by brianbehrens