org.apache.flink.runtime.util.ReusingKeyGroupedIterator Java Examples

The following examples show how to use org.apache.flink.runtime.util.ReusingKeyGroupedIterator. 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: ReusingSortMergeCoGroupIterator.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
public ReusingSortMergeCoGroupIterator(
		MutableObjectIterator<T1> input1,
		MutableObjectIterator<T2> input2, TypeSerializer<T1>
		serializer1, TypeComparator<T1> groupingComparator1,
		TypeSerializer<T2> serializer2,
		TypeComparator<T2> groupingComparator2,
		TypePairComparator<T1, T2> pairComparator)
{

	this.comp = pairComparator;

	this.iterator1 = new ReusingKeyGroupedIterator<T1>(input1, serializer1, groupingComparator1);
	this.iterator2 = new ReusingKeyGroupedIterator<T2>(input2, serializer2, groupingComparator2);
}
 
Example #2
Source File: ReusingSortMergeCoGroupIterator.java    From flink with Apache License 2.0 5 votes vote down vote up
public ReusingSortMergeCoGroupIterator(
		MutableObjectIterator<T1> input1,
		MutableObjectIterator<T2> input2, TypeSerializer<T1>
		serializer1, TypeComparator<T1> groupingComparator1,
		TypeSerializer<T2> serializer2,
		TypeComparator<T2> groupingComparator2,
		TypePairComparator<T1, T2> pairComparator)
{

	this.comp = pairComparator;

	this.iterator1 = new ReusingKeyGroupedIterator<T1>(input1, serializer1, groupingComparator1);
	this.iterator2 = new ReusingKeyGroupedIterator<T2>(input2, serializer2, groupingComparator2);
}
 
Example #3
Source File: ReusingSortMergeCoGroupIterator.java    From flink with Apache License 2.0 5 votes vote down vote up
public ReusingSortMergeCoGroupIterator(
		MutableObjectIterator<T1> input1,
		MutableObjectIterator<T2> input2, TypeSerializer<T1>
		serializer1, TypeComparator<T1> groupingComparator1,
		TypeSerializer<T2> serializer2,
		TypeComparator<T2> groupingComparator2,
		TypePairComparator<T1, T2> pairComparator)
{

	this.comp = pairComparator;

	this.iterator1 = new ReusingKeyGroupedIterator<T1>(input1, serializer1, groupingComparator1);
	this.iterator2 = new ReusingKeyGroupedIterator<T2>(input2, serializer2, groupingComparator2);
}
 
Example #4
Source File: ReusingMergeOuterJoinIterator.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
@Override
protected <T> KeyGroupedIterator<T> createKeyGroupedIterator(MutableObjectIterator<T> input, TypeSerializer<T> serializer, TypeComparator<T> comparator) {
	return new ReusingKeyGroupedIterator<>(input, serializer, comparator);
}
 
Example #5
Source File: ReusingMergeInnerJoinIterator.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
@Override
protected <T> KeyGroupedIterator<T> createKeyGroupedIterator(MutableObjectIterator<T> input, TypeSerializer<T> serializer, TypeComparator<T> comparator) {
	return new ReusingKeyGroupedIterator<T>(input, serializer, comparator);
}
 
Example #6
Source File: CombiningUnilateralSortMergerITCase.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
private static Iterator<Integer> getReducingIterator(MutableObjectIterator<Tuple2<Integer, Integer>> data, TypeSerializer<Tuple2<Integer, Integer>> serializer, TypeComparator<Tuple2<Integer, Integer>>  comparator) {
	
	final ReusingKeyGroupedIterator<Tuple2<Integer, Integer>>  groupIter = new ReusingKeyGroupedIterator<> (data, serializer, comparator);
	
	return new Iterator<Integer>() {
		
		private boolean hasNext = false;

		@Override
		public boolean hasNext() {
			if (hasNext) {
				return true;
			}
			
			try {
				hasNext = groupIter.nextKey();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
			return hasNext;
		}

		@Override
		public Integer next() {
			if (hasNext()) {
				hasNext = false;
				
				Iterator<Tuple2<Integer, Integer>> values = groupIter.getValues();
				
				Tuple2<Integer, Integer> rec;
				int cnt = 0;
				while (values.hasNext()) {
					rec = values.next();
					cnt += rec.f1;
				}
				
				return cnt;
			} else {
				throw new NoSuchElementException();
			}
		}

		@Override
		public void remove() {
			throw new UnsupportedOperationException();
		}
		
	};
}
 
Example #7
Source File: ReusingMergeOuterJoinIterator.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
protected <T> KeyGroupedIterator<T> createKeyGroupedIterator(MutableObjectIterator<T> input, TypeSerializer<T> serializer, TypeComparator<T> comparator) {
	return new ReusingKeyGroupedIterator<>(input, serializer, comparator);
}
 
Example #8
Source File: ReusingMergeInnerJoinIterator.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
protected <T> KeyGroupedIterator<T> createKeyGroupedIterator(MutableObjectIterator<T> input, TypeSerializer<T> serializer, TypeComparator<T> comparator) {
	return new ReusingKeyGroupedIterator<T>(input, serializer, comparator);
}
 
Example #9
Source File: CombiningUnilateralSortMergerITCase.java    From flink with Apache License 2.0 4 votes vote down vote up
private static Iterator<Integer> getReducingIterator(MutableObjectIterator<Tuple2<Integer, Integer>> data, TypeSerializer<Tuple2<Integer, Integer>> serializer, TypeComparator<Tuple2<Integer, Integer>>  comparator) {
	
	final ReusingKeyGroupedIterator<Tuple2<Integer, Integer>>  groupIter = new ReusingKeyGroupedIterator<> (data, serializer, comparator);
	
	return new Iterator<Integer>() {
		
		private boolean hasNext = false;

		@Override
		public boolean hasNext() {
			if (hasNext) {
				return true;
			}
			
			try {
				hasNext = groupIter.nextKey();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
			return hasNext;
		}

		@Override
		public Integer next() {
			if (hasNext()) {
				hasNext = false;
				
				Iterator<Tuple2<Integer, Integer>> values = groupIter.getValues();
				
				Tuple2<Integer, Integer> rec;
				int cnt = 0;
				while (values.hasNext()) {
					rec = values.next();
					cnt += rec.f1;
				}
				
				return cnt;
			} else {
				throw new NoSuchElementException();
			}
		}

		@Override
		public void remove() {
			throw new UnsupportedOperationException();
		}
		
	};
}
 
Example #10
Source File: ReusingMergeOuterJoinIterator.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
protected <T> KeyGroupedIterator<T> createKeyGroupedIterator(MutableObjectIterator<T> input, TypeSerializer<T> serializer, TypeComparator<T> comparator) {
	return new ReusingKeyGroupedIterator<>(input, serializer, comparator);
}
 
Example #11
Source File: ReusingMergeInnerJoinIterator.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
protected <T> KeyGroupedIterator<T> createKeyGroupedIterator(MutableObjectIterator<T> input, TypeSerializer<T> serializer, TypeComparator<T> comparator) {
	return new ReusingKeyGroupedIterator<T>(input, serializer, comparator);
}
 
Example #12
Source File: CombiningUnilateralSortMergerITCase.java    From flink with Apache License 2.0 4 votes vote down vote up
private static Iterator<Integer> getReducingIterator(MutableObjectIterator<Tuple2<Integer, Integer>> data, TypeSerializer<Tuple2<Integer, Integer>> serializer, TypeComparator<Tuple2<Integer, Integer>>  comparator) {
	
	final ReusingKeyGroupedIterator<Tuple2<Integer, Integer>>  groupIter = new ReusingKeyGroupedIterator<> (data, serializer, comparator);
	
	return new Iterator<Integer>() {
		
		private boolean hasNext = false;

		@Override
		public boolean hasNext() {
			if (hasNext) {
				return true;
			}
			
			try {
				hasNext = groupIter.nextKey();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
			return hasNext;
		}

		@Override
		public Integer next() {
			if (hasNext()) {
				hasNext = false;
				
				Iterator<Tuple2<Integer, Integer>> values = groupIter.getValues();
				
				Tuple2<Integer, Integer> rec;
				int cnt = 0;
				while (values.hasNext()) {
					rec = values.next();
					cnt += rec.f1;
				}
				
				return cnt;
			} else {
				throw new NoSuchElementException();
			}
		}

		@Override
		public void remove() {
			throw new UnsupportedOperationException();
		}
		
	};
}