本文整理汇总了Java中org.apache.flink.api.java.io.ParallelIteratorInputFormat类的典型用法代码示例。如果您正苦于以下问题:Java ParallelIteratorInputFormat类的具体用法?Java ParallelIteratorInputFormat怎么用?Java ParallelIteratorInputFormat使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ParallelIteratorInputFormat类属于org.apache.flink.api.java.io包,在下文中一共展示了ParallelIteratorInputFormat类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testReplicatedSourceToJoin
import org.apache.flink.api.java.io.ParallelIteratorInputFormat; //导入依赖的package包/类
@Test
public void testReplicatedSourceToJoin() throws Exception {
/*
* Test replicated source going into join
*/
final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
DataSet<Tuple1<Long>> source1 = env.createInput(new ReplicatingInputFormat<Long, GenericInputSplit>
(new ParallelIteratorInputFormat<Long>(new NumberSequenceIterator(0l, 1000l))), BasicTypeInfo.LONG_TYPE_INFO)
.map(new ToTuple());
DataSet<Tuple1<Long>> source2 = env.generateSequence(0l, 1000l).map(new ToTuple());
DataSet<Tuple> pairs = source1.join(source2).where(0).equalTo(0)
.projectFirst(0)
.sum(0);
List<Tuple> result = pairs.collect();
String expectedResult = "(500500)";
compareResultAsText(result, expectedResult);
}
示例2: testReplicatedSourceToJoin
import org.apache.flink.api.java.io.ParallelIteratorInputFormat; //导入依赖的package包/类
@Test
public void testReplicatedSourceToJoin() throws Exception {
/*
* Test replicated source going into join
*/
final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
DataSet<Tuple1<Long>> source1 = env.createInput(new ReplicatingInputFormat<Long, GenericInputSplit>
(new ParallelIteratorInputFormat<Long>(new NumberSequenceIterator(0L, 1000L))), BasicTypeInfo.LONG_TYPE_INFO)
.map(new ToTuple());
DataSet<Tuple1<Long>> source2 = env.generateSequence(0L, 1000L).map(new ToTuple());
DataSet<Tuple> pairs = source1.join(source2).where(0).equalTo(0)
.projectFirst(0)
.sum(0);
List<Tuple> result = pairs.collect();
String expectedResult = "(500500)";
compareResultAsText(result, expectedResult);
}
示例3: fromParallelCollection
import org.apache.flink.api.java.io.ParallelIteratorInputFormat; //导入依赖的package包/类
private <X> DataSource<X> fromParallelCollection(SplittableIterator<X> iterator, TypeInformation<X> type, String callLocationName) {
return new DataSource<>(this, new ParallelIteratorInputFormat<>(iterator), type, callLocationName);
}
示例4: fromParallelCollection
import org.apache.flink.api.java.io.ParallelIteratorInputFormat; //导入依赖的package包/类
/**
* Creates a new data set that contains elements in the iterator. The iterator is splittable, allowing the
* framework to create a parallel data source that returns the elements in the iterator.
* The iterator must be serializable (as defined in {@link java.io.Serializable}, because the
* execution environment may ship the elements into the cluster.
* <p>
* Because the iterator will remain unmodified until the actual execution happens, the type of data
* returned by the iterator must be given explicitly in the form of the type information.
* This method is useful for cases where the type is generic. In that case, the type class
* (as given in {@link #fromParallelCollection(SplittableIterator, Class)} does not supply all type information.
*
* @param iterator The iterator that produces the elements of the data set.
* @param type The TypeInformation for the produced data set.
* @return A DataSet representing the elements in the iterator.
*
* @see #fromParallelCollection(SplittableIterator, Class)
*/
public <X> DataSource<X> fromParallelCollection(SplittableIterator<X> iterator, TypeInformation<X> type) {
return new DataSource<X>(this, new ParallelIteratorInputFormat<X>(iterator), type);
}