public void shard_data() { var partitions = new Dictionary <int, int>(); foreach (var item in _users) { var key = JenkinsPartitioner.ResolveToLogicalPartition(item, PARTITION_COUNTS); if (!partitions.ContainsKey(key)) { partitions.Add(key, 1); } else { partitions[key] = ++partitions[key]; } } var values = partitions.Values; var average = values.Average(); var stdev = Math.Sqrt(values.Select(v => Math.Pow(v - average, 2)).Sum() / PARTITION_COUNTS); Assert.True(values.Count == 10); Assert.True(stdev < 2); }
public void get_allways_the_same_partition_for_same_data() { var data = "some_string_data"; var partition1 = JenkinsPartitioner.ResolveToLogicalPartition(data, PARTITION_COUNTS); var partition2 = JenkinsPartitioner.ResolveToLogicalPartition(data, PARTITION_COUNTS); Assert.Equal(partition1, partition2); }