org.apache.flink.util.IterableIterator Java Examples

The following examples show how to use org.apache.flink.util.IterableIterator. 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: NAryUnionPlanNode.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Override
public Iterable<PlanNode> getPredecessors() {
	final Iterator<Channel> channels = this.inputs.iterator();
	return new IterableIterator<PlanNode>() {

		@Override
		public boolean hasNext() {
			return channels.hasNext();
		}

		@Override
		public PlanNode next() {
			return channels.next().getSource();
		}

		@Override
		public void remove() {
			throw new UnsupportedOperationException();
		}
		
		@Override
		public Iterator<PlanNode> iterator() {
			return this;
		}
	};
}
 
Example #2
Source File: NAryUnionPlanNode.java    From flink with Apache License 2.0 6 votes vote down vote up
@Override
public Iterable<PlanNode> getPredecessors() {
	final Iterator<Channel> channels = this.inputs.iterator();
	return new IterableIterator<PlanNode>() {

		@Override
		public boolean hasNext() {
			return channels.hasNext();
		}

		@Override
		public PlanNode next() {
			return channels.next().getSource();
		}

		@Override
		public void remove() {
			throw new UnsupportedOperationException();
		}
		
		@Override
		public Iterator<PlanNode> iterator() {
			return this;
		}
	};
}
 
Example #3
Source File: NAryUnionPlanNode.java    From flink with Apache License 2.0 6 votes vote down vote up
@Override
public Iterable<PlanNode> getPredecessors() {
	final Iterator<Channel> channels = this.inputs.iterator();
	return new IterableIterator<PlanNode>() {

		@Override
		public boolean hasNext() {
			return channels.hasNext();
		}

		@Override
		public PlanNode next() {
			return channels.next().getSource();
		}

		@Override
		public void remove() {
			throw new UnsupportedOperationException();
		}
		
		@Override
		public Iterator<PlanNode> iterator() {
			return this;
		}
	};
}
 
Example #4
Source File: OuterJoinRecordStateViews.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
public Iterable<Tuple2<BaseRow, Integer>> getRecordsAndNumOfAssociations() throws Exception {
	return new IterableIterator<Tuple2<BaseRow, Integer>>() {

		private final Iterator<Map.Entry<BaseRow, Tuple2<Integer, Integer>>> backingIterable = recordState.entries().iterator();
		private Tuple2<BaseRow, Integer> tuple;
		private int remainingTimes = 0;

		@Override
		public boolean hasNext() {
			return backingIterable.hasNext() || remainingTimes > 0;
		}

		@Override
		public Tuple2<BaseRow, Integer> next() {
			if (remainingTimes > 0) {
				checkNotNull(tuple);
				remainingTimes--;
				return tuple;
			} else {
				Map.Entry<BaseRow, Tuple2<Integer, Integer>> entry = backingIterable.next();
				tuple = Tuple2.of(entry.getKey(), entry.getValue().f1);
				remainingTimes = entry.getValue().f0 - 1;
				return tuple;
			}
		}

		@Override
		public Iterator<Tuple2<BaseRow, Integer>> iterator() {
			return this;
		}
	};
}
 
Example #5
Source File: JoinRecordStateViews.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
public Iterable<BaseRow> getRecords() throws Exception {
	return new IterableIterator<BaseRow>() {

		private final Iterator<Map.Entry<BaseRow, Integer>> backingIterable = recordState.entries().iterator();
		private BaseRow record;
		private int remainingTimes = 0;

		@Override
		public boolean hasNext() {
			return backingIterable.hasNext() || remainingTimes > 0;
		}

		@Override
		public BaseRow next() {
			if (remainingTimes > 0) {
				checkNotNull(record);
				remainingTimes--;
				return record;
			} else {
				Map.Entry<BaseRow, Integer> entry = backingIterable.next();
				record = entry.getKey();
				remainingTimes = entry.getValue() - 1;
				return record;
			}
		}

		@Override
		public Iterator<BaseRow> iterator() {
			return this;
		}
	};
}
 
Example #6
Source File: OuterJoinRecordStateViews.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
public Iterable<Tuple2<RowData, Integer>> getRecordsAndNumOfAssociations() throws Exception {
	return new IterableIterator<Tuple2<RowData, Integer>>() {

		private final Iterator<Map.Entry<RowData, Tuple2<Integer, Integer>>> backingIterable = recordState.entries().iterator();
		private Tuple2<RowData, Integer> tuple;
		private int remainingTimes = 0;

		@Override
		public boolean hasNext() {
			return backingIterable.hasNext() || remainingTimes > 0;
		}

		@Override
		public Tuple2<RowData, Integer> next() {
			if (remainingTimes > 0) {
				checkNotNull(tuple);
				remainingTimes--;
				return tuple;
			} else {
				Map.Entry<RowData, Tuple2<Integer, Integer>> entry = backingIterable.next();
				tuple = Tuple2.of(entry.getKey(), entry.getValue().f1);
				remainingTimes = entry.getValue().f0 - 1;
				return tuple;
			}
		}

		@Override
		public Iterator<Tuple2<RowData, Integer>> iterator() {
			return this;
		}
	};
}
 
Example #7
Source File: JoinRecordStateViews.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
public Iterable<RowData> getRecords() throws Exception {
	return new IterableIterator<RowData>() {

		private final Iterator<Map.Entry<RowData, Integer>> backingIterable = recordState.entries().iterator();
		private RowData record;
		private int remainingTimes = 0;

		@Override
		public boolean hasNext() {
			return backingIterable.hasNext() || remainingTimes > 0;
		}

		@Override
		public RowData next() {
			if (remainingTimes > 0) {
				checkNotNull(record);
				remainingTimes--;
				return record;
			} else {
				Map.Entry<RowData, Integer> entry = backingIterable.next();
				record = entry.getKey();
				remainingTimes = entry.getValue() - 1;
				return record;
			}
		}

		@Override
		public Iterator<RowData> iterator() {
			return this;
		}
	};
}