<commit_before>package justin.db.replication

import justin.db.consistent_hashing.Ring.RingPartitionId
import justin.db.consistent_hashing.RingSize

object PreferenceList {
  def apply(baseId: RingPartitionId, n: N, ringSize: RingSize): List[RingPartitionId] = {
    (0 until n.n)
      .map(idx => (baseId + idx) % ringSize.size)
      .toList
  }
}<commit_msg>build preference list of node ids<commit_after>package justin.db.replication

import justin.db.consistent_hashing.Ring.RingPartitionId
import justin.db.consistent_hashing.{NodeId, Ring}

object PreferenceList {
  def apply(baseId: RingPartitionId, n: N, ring: Ring): List[NodeId] = {
    val coordinatorNodeId = ring.getNodeId(baseId)

    val maxPartitionId = baseId + n.n - 1
    val restNodesIds   = (baseId until maxPartitionId).toList.map(getNextNodeId(ring))

    (coordinatorNodeId :: restNodesIds).flatten
  }

  private def getNextNodeId(ring: Ring) = ring.nextPartitionId _ andThen ring.getNodeId _
}
{'fraction_non_alphanumeric': 0.10185185185185185, 'fraction_numerical': 0.00205761316872428, 'mean_word_length': 4.723529411764706, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, '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': '5629252', 'n_tokens_mistral': 334, 'n_tokens_neox': 319, 'n_words': 68}