Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to define custom keys and Partitioners? #94

Closed
punit-naik opened this issue May 31, 2016 · 1 comment
Closed

How to define custom keys and Partitioners? #94

punit-naik opened this issue May 31, 2016 · 1 comment

Comments

@punit-naik
Copy link

I have a scala program in which I define custom keys and create custom partitioners. How can I do this using flambo?

Specifically I want the following code to be transformed into clojure using flambo:

case class RFMCKey(cId: String, R: Double, F: Double, M: Double, C: Double)
class RFMCPartitioner(partitions: Int) extends Partitioner {
 require(partitions >= 0, "Number of partitions ($partitions) cannot be negative.")
 override def numPartitions: Int = partitions
 override def getPartition(key: Any): Int = {
 val k = key.asInstanceOf[RFMCKey]
 k.cId.hashCode() % numPartitions
 }
}
object RFMCKey {
 implicit def orderingByIdAirportIdDelay[A <: RFMCKey] : Ordering[A] = {
    Ordering.by(k => (k.R, k.F * -1, k.M * -1, k.C * -1))
 }
}

How can I do this?

@sorenmacbeth
Copy link
Owner

I noticed that you already posted this question to the flambo-user mailing list, which is the appropriate place rather than an issue here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants