All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.twitter.hashing.Distributor.scala Maven / Gradle / Ivy

There is a newer version: 21.2.0
Show newest version
package com.twitter.hashing

trait Distributor[A] {
  def entryForHash(hash: Long): (Long, A)
  def partitionIdForHash(hash: Long): Long
  def nodeForHash(hash: Long): A
  def nodeCount: Int
  def nodes: Seq[A]
}

class SingletonDistributor[A](node: A) extends Distributor[A] {
  def entryForHash(hash: Long): (Long, A) = (hash, node)
  def partitionIdForHash(hash: Long): Long = hash
  def nodeForHash(hash: Long): A = node
  def nodeCount = 1
  def nodes: Seq[A] = Seq(node)
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy