org.apache.flink.api.common.distributions.RangeBoundaries Java Examples

The following examples show how to use org.apache.flink.api.common.distributions.RangeBoundaries. 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: AssignRangeIndex.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Override
public void mapPartition(Iterable<IN> values, Collector<Tuple2<Integer, IN>> out) throws Exception {

	List<Object> broadcastVariable = getRuntimeContext().getBroadcastVariable("RangeBoundaries");
	if (broadcastVariable == null || broadcastVariable.size() != 1) {
		throw new RuntimeException("AssignRangePartition require a single RangeBoundaries as broadcast input.");
	}
	Object[][] boundaryObjects = (Object[][]) broadcastVariable.get(0);
	RangeBoundaries rangeBoundaries = new CommonRangeBoundaries(typeComparator.createComparator(), boundaryObjects);

	Tuple2<Integer, IN> tupleWithPartitionId = new Tuple2<>();

	for (IN record : values) {
		tupleWithPartitionId.f0 = rangeBoundaries.getRangeIndex(record);
		tupleWithPartitionId.f1 = record;
		out.collect(tupleWithPartitionId);
	}
}
 
Example #2
Source File: AssignRangeIndex.java    From flink with Apache License 2.0 6 votes vote down vote up
@Override
public void mapPartition(Iterable<IN> values, Collector<Tuple2<Integer, IN>> out) throws Exception {

	List<Object> broadcastVariable = getRuntimeContext().getBroadcastVariable("RangeBoundaries");
	if (broadcastVariable == null || broadcastVariable.size() != 1) {
		throw new RuntimeException("AssignRangePartition require a single RangeBoundaries as broadcast input.");
	}
	Object[][] boundaryObjects = (Object[][]) broadcastVariable.get(0);
	RangeBoundaries rangeBoundaries = new CommonRangeBoundaries(typeComparator.createComparator(), boundaryObjects);

	Tuple2<Integer, IN> tupleWithPartitionId = new Tuple2<>();

	for (IN record : values) {
		tupleWithPartitionId.f0 = rangeBoundaries.getRangeIndex(record);
		tupleWithPartitionId.f1 = record;
		out.collect(tupleWithPartitionId);
	}
}
 
Example #3
Source File: AssignRangeIndex.java    From flink with Apache License 2.0 6 votes vote down vote up
@Override
public void mapPartition(Iterable<IN> values, Collector<Tuple2<Integer, IN>> out) throws Exception {

	List<Object> broadcastVariable = getRuntimeContext().getBroadcastVariable("RangeBoundaries");
	if (broadcastVariable == null || broadcastVariable.size() != 1) {
		throw new RuntimeException("AssignRangePartition require a single RangeBoundaries as broadcast input.");
	}
	Object[][] boundaryObjects = (Object[][]) broadcastVariable.get(0);
	RangeBoundaries rangeBoundaries = new CommonRangeBoundaries(typeComparator.createComparator(), boundaryObjects);

	Tuple2<Integer, IN> tupleWithPartitionId = new Tuple2<>();

	for (IN record : values) {
		tupleWithPartitionId.f0 = rangeBoundaries.getRangeIndex(record);
		tupleWithPartitionId.f1 = record;
		out.collect(tupleWithPartitionId);
	}
}