io.ray.streaming.api.partition.impl.KeyPartition Maven / Gradle / Ivy
package io.ray.streaming.api.partition.impl;
import io.ray.streaming.api.partition.Partition;
import io.ray.streaming.message.KeyRecord;
/**
* Partition the record by the key.
*
* @param Type of the partition key.
* @param Type of the input record.
*/
public class KeyPartition implements Partition> {
private int[] partitions = new int[1];
@Override
public int[] partition(KeyRecord keyRecord, int numPartition) {
partitions[0] = Math.abs(keyRecord.getKey().hashCode() % numPartition);
return partitions;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy