<commit_before>defmodule FtChat.Distribution do

    defmodule NodeRing do
        defstruct [:rules, :replication, :partitions]

        def new(nodes, replication, partitions \\ 32) do
            num_nodes = Enum.count nodes
            ring =
                1..partitions
                |> Enum.map(fn i ->
                    Enum.at nodes, (rem(i - 1, num_nodes))
                end)
            %HashRing {
                rules: List.to_tuple(ring),
                replication: replication,
                partitions: partitions
            }
        end

        def get_node_for(ring, value) do
            hash = :erlang.phash2 value
            lower_index = rem(hash, ring.partitions)
            upper_index = lower_index + ring.replication - 1
            lower_index..upper_index
            |> Enum.map(&(elem ring.rules, rem(&1, ring.partitions)))
        end

    end
    
end
<commit_msg>Fix module name<commit_after>defmodule FtChat.Distribution do

    defmodule NodeRing do
        defstruct [:rules, :replication, :partitions]

        def new(nodes, replication, partitions \\ 32) do
            num_nodes = Enum.count nodes
            ring =
                1..partitions
                |> Enum.map(fn i ->
                    Enum.at nodes, (rem(i - 1, num_nodes))
                end)
            %NodeRing {
                rules: List.to_tuple(ring),
                replication: replication,
                partitions: partitions
            }
        end

        def get_node_for(ring, value) do
            hash = :erlang.phash2 value
            lower_index = rem(hash, ring.partitions)
            upper_index = lower_index + ring.replication - 1
            lower_index..upper_index
            |> Enum.map(&(elem ring.rules, rem(&1, ring.partitions)))
        end

    end

end

{'fraction_non_alphanumeric': 0.08771929824561403, 'fraction_numerical': 0.007675438596491228, 'mean_word_length': 1.4431057563587684, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '875479', 'n_tokens_mistral': 530, 'n_tokens_neox': 483, 'n_words': 120}