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

org.apache.flink.lakesoul.sink.HashPartitioner Maven / Gradle / Ivy

There is a newer version: 2.5.1-flink-1.17
Show newest version
// SPDX-FileCopyrightText: 2023 LakeSoul Contributors
//
// SPDX-License-Identifier: Apache-2.0

package org.apache.flink.lakesoul.sink;

import org.apache.flink.api.common.functions.Partitioner;

public class HashPartitioner implements Partitioner {

  @Override
  public int partition(Long key, int numPartitions) {
    long hash = key;
    int part = (int) (hash % (long) numPartitions);
    return part < 0 ? (part + numPartitions) % numPartitions : part;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy