Skip to content

Instantly share code, notes, and snippets.

@samklr
Created February 20, 2015 10:55
Show Gist options
  • Save samklr/0bcd46a3b4cb775206a0 to your computer and use it in GitHub Desktop.
Save samklr/0bcd46a3b4cb775206a0 to your computer and use it in GitHub Desktop.
Example of a specific data partitioner
class AlphabetPartitioner extends Partitioner {
def numPartitions = 26
def getPartition(key: Any): Int = key match {
case s: String => s(0).toUpper - 'A'
}
override def equals(other: Any): Boolean = other.isInstanceOf[AlphabetPartitioner]
override def hashCode: Int = 0
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment