本文整理汇总了Java中org.apache.flink.api.common.io.OutputFormat.configure方法的典型用法代码示例。如果您正苦于以下问题:Java OutputFormat.configure方法的具体用法?Java OutputFormat.configure怎么用?Java OutputFormat.configure使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.flink.api.common.io.OutputFormat
的用法示例。
在下文中一共展示了OutputFormat.configure方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testCassandraBatchFormats
import org.apache.flink.api.common.io.OutputFormat; //导入方法依赖的package包/类
@Test
public void testCassandraBatchFormats() throws Exception {
OutputFormat<Tuple3<String, Integer, Integer>> sink = new CassandraOutputFormat<>(injectTableName(INSERT_DATA_QUERY), builder);
sink.configure(new Configuration());
sink.open(0, 1);
for (Tuple3<String, Integer, Integer> value : collection) {
sink.writeRecord(value);
}
sink.close();
InputFormat<Tuple3<String, Integer, Integer>, InputSplit> source = new CassandraInputFormat<>(injectTableName(SELECT_DATA_QUERY), builder);
source.configure(new Configuration());
source.open(null);
List<Tuple3<String, Integer, Integer>> result = new ArrayList<>();
while (!source.reachedEnd()) {
result.add(source.nextRecord(new Tuple3<String, Integer, Integer>()));
}
source.close();
Assert.assertEquals(20, result.size());
}
示例2: executeOnCollections
import org.apache.flink.api.common.io.OutputFormat; //导入方法依赖的package包/类
protected void executeOnCollections(List<IN> inputData) throws Exception {
OutputFormat<IN> format = this.formatWrapper.getUserCodeObject();
format.configure(this.parameters);
format.open(0, 1);
for (IN element : inputData) {
format.writeRecord(element);
}
format.close();
}
示例3: executeOnCollections
import org.apache.flink.api.common.io.OutputFormat; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
protected void executeOnCollections(List<IN> inputData, RuntimeContext ctx, ExecutionConfig executionConfig) throws Exception {
OutputFormat<IN> format = this.formatWrapper.getUserCodeObject();
TypeInformation<IN> inputType = getInput().getOperatorInfo().getOutputType();
if (this.localOrdering != null) {
int[] sortColumns = this.localOrdering.getFieldPositions();
boolean[] sortOrderings = this.localOrdering.getFieldSortDirections();
final TypeComparator<IN> sortComparator;
if (inputType instanceof CompositeType) {
sortComparator = ((CompositeType<IN>) inputType).createComparator(sortColumns, sortOrderings, 0, executionConfig);
} else if (inputType instanceof AtomicType) {
sortComparator = ((AtomicType<IN>) inputType).createComparator(sortOrderings[0], executionConfig);
} else {
throw new UnsupportedOperationException("Local output sorting does not support type "+inputType+" yet.");
}
Collections.sort(inputData, new Comparator<IN>() {
@Override
public int compare(IN o1, IN o2) {
return sortComparator.compare(o1, o2);
}
});
}
if(format instanceof InitializeOnMaster) {
((InitializeOnMaster)format).initializeGlobal(1);
}
format.configure(this.parameters);
if(format instanceof RichOutputFormat){
((RichOutputFormat<?>) format).setRuntimeContext(ctx);
}
format.open(0, 1);
for (IN element : inputData) {
format.writeRecord(element);
}
format.close();
if(format instanceof FinalizeOnMaster) {
((FinalizeOnMaster)format).finalizeGlobal(1);
}
}