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

io.ray.streaming.api.partition.impl.KeyPartition Maven / Gradle / Ivy

There is a newer version: 1.10.0
Show newest version
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