当前位置: 首页>>代码示例>>Java>>正文


Java OutputFormat.configure方法代码示例

本文整理汇总了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());
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:26,代码来源:CassandraConnectorITCase.java

示例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();
}
 
开发者ID:citlab,项目名称:vs.msc.ws14,代码行数:11,代码来源:GenericDataSinkBase.java

示例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);
	}
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:46,代码来源:GenericDataSinkBase.java


注:本文中的org.apache.flink.api.common.io.OutputFormat.configure方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。