Java Code Examples for org.apache.flink.util.MathUtils#murmurHash()

The following examples show how to use org.apache.flink.util.MathUtils#murmurHash() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: StreamingOperatorsITCase.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Override
public void run(SourceContext<Tuple2<Integer, Integer>> ctx) throws Exception {
	for (int i = 0; i < numElements; i++) {
		// keys '1' and '2' hash to different buckets
		Tuple2<Integer, Integer> result = new Tuple2<>(1 + (MathUtils.murmurHash(i) % numKeys), i);
		ctx.collect(result);
	}
}
 
Example 2
Source File: StreamingOperatorsITCase.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
public void run(SourceContext<Tuple2<Integer, Integer>> ctx) throws Exception {
	for (int i = 0; i < numElements; i++) {
		// keys '1' and '2' hash to different buckets
		Tuple2<Integer, Integer> result = new Tuple2<>(1 + (MathUtils.murmurHash(i) % numKeys), i);
		ctx.collect(result);
	}
}
 
Example 3
Source File: StreamingOperatorsITCase.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
public void run(SourceContext<Tuple2<Integer, Integer>> ctx) throws Exception {
	for (int i = 0; i < numElements; i++) {
		// keys '1' and '2' hash to different buckets
		Tuple2<Integer, Integer> result = new Tuple2<>(1 + (MathUtils.murmurHash(i) % numKeys), i);
		ctx.collect(result);
	}
}
 
Example 4
Source File: OutputEmitter.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
private int hashPartitionDefault(T record, int numberOfChannels) {
	int hash = this.comparator.hash(record);

	return MathUtils.murmurHash(hash) % numberOfChannels;
}
 
Example 5
Source File: BinaryHashPartitioner.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
public int selectChannel(SerializationDelegate<StreamRecord<BaseRow>> record) {
	return MathUtils.murmurHash(
			getHashFunc().hashCode(record.getInstance().getValue())) % numberOfChannels;
}
 
Example 6
Source File: OutputEmitter.java    From flink with Apache License 2.0 4 votes vote down vote up
private int hashPartitionDefault(T record, int numberOfChannels) {
	int hash = this.comparator.hash(record);

	return MathUtils.murmurHash(hash) % numberOfChannels;
}
 
Example 7
Source File: BinaryHashPartitioner.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
public int selectChannel(SerializationDelegate<StreamRecord<RowData>> record) {
	return MathUtils.murmurHash(
			getHashFunc().hashCode(record.getInstance().getValue())) % numberOfChannels;
}
 
Example 8
Source File: OutputEmitter.java    From flink with Apache License 2.0 4 votes vote down vote up
private int hashPartitionDefault(T record, int numberOfChannels) {
	int hash = this.comparator.hash(record);

	return MathUtils.murmurHash(hash) % numberOfChannels;
}
 
Example 9
Source File: KeyGroupRangeAssignment.java    From Flink-CEPplus with Apache License 2.0 2 votes vote down vote up
/**
 * Assigns the given key to a key-group index.
 *
 * @param keyHash the hash of the key to assign
 * @param maxParallelism the maximum supported parallelism, aka the number of key-groups.
 * @return the key-group to which the given key is assigned
 */
public static int computeKeyGroupForKeyHash(int keyHash, int maxParallelism) {
	return MathUtils.murmurHash(keyHash) % maxParallelism;
}
 
Example 10
Source File: KeyGroupRangeAssignment.java    From flink with Apache License 2.0 2 votes vote down vote up
/**
 * Assigns the given key to a key-group index.
 *
 * @param keyHash the hash of the key to assign
 * @param maxParallelism the maximum supported parallelism, aka the number of key-groups.
 * @return the key-group to which the given key is assigned
 */
public static int computeKeyGroupForKeyHash(int keyHash, int maxParallelism) {
	return MathUtils.murmurHash(keyHash) % maxParallelism;
}
 
Example 11
Source File: KeyGroupRangeAssignment.java    From flink with Apache License 2.0 2 votes vote down vote up
/**
 * Assigns the given key to a key-group index.
 *
 * @param keyHash the hash of the key to assign
 * @param maxParallelism the maximum supported parallelism, aka the number of key-groups.
 * @return the key-group to which the given key is assigned
 */
public static int computeKeyGroupForKeyHash(int keyHash, int maxParallelism) {
	return MathUtils.murmurHash(keyHash) % maxParallelism;
}