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


Java UserCodeWrapper.getUserCodeObject方法代码示例

本文整理汇总了Java中org.apache.flink.api.common.operators.util.UserCodeWrapper.getUserCodeObject方法的典型用法代码示例。如果您正苦于以下问题:Java UserCodeWrapper.getUserCodeObject方法的具体用法?Java UserCodeWrapper.getUserCodeObject怎么用?Java UserCodeWrapper.getUserCodeObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.flink.api.common.operators.util.UserCodeWrapper的用法示例。


在下文中一共展示了UserCodeWrapper.getUserCodeObject方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: initializeOnMaster

import org.apache.flink.api.common.operators.util.UserCodeWrapper; //导入方法依赖的package包/类
@Override
public void initializeOnMaster(ClassLoader loader) throws Exception {
	if (this.outputFormat == null) {
		TaskConfig cfg = new TaskConfig(getConfiguration());
		UserCodeWrapper<OutputFormat<?>> wrapper = cfg.<OutputFormat<?>>getStubWrapper(loader);
	
		if (wrapper == null) {
			throw new Exception("No output format present in OutputFormatVertex's task configuration.");
		}

		this.outputFormat = wrapper.getUserCodeObject(OutputFormat.class, loader);
		this.outputFormat.configure(cfg.getStubParameters());
	}
	
	if (this.outputFormat instanceof InitializeOnMaster) {
		((InitializeOnMaster) this.outputFormat).initializeGlobal(getParallelism());
	}
}
 
开发者ID:citlab,项目名称:vs.msc.ws14,代码行数:19,代码来源:OutputFormatVertex.java

示例2: initializeOnMaster

import org.apache.flink.api.common.operators.util.UserCodeWrapper; //导入方法依赖的package包/类
@Override
public void initializeOnMaster(ClassLoader loader) throws Exception {
	if (inputFormat == null) {
		TaskConfig cfg = new TaskConfig(getConfiguration());
		UserCodeWrapper<InputFormat<?, ?>> wrapper = cfg.<InputFormat<?, ?>>getStubWrapper(loader);
		
		if (wrapper == null) {
			throw new Exception("No input format present in InputFormatVertex's task configuration.");
		}
		
		inputFormat = wrapper.getUserCodeObject(InputFormat.class, loader);
		inputFormat.configure(cfg.getStubParameters());
	}
	
	setInputSplitSource(inputFormat);
}
 
开发者ID:citlab,项目名称:vs.msc.ws14,代码行数:17,代码来源:InputFormatVertex.java

示例3: testWrappedCoGroupClass

import org.apache.flink.api.common.operators.util.UserCodeWrapper; //导入方法依赖的package包/类
@Test
public void testWrappedCoGroupClass() {
	try {
		CoGroupOperator coGroupOp = CoGroupOperator.builder(TestCoGroupFunction.class, LongValue.class, 1, 2).build();
		
		UserCodeWrapper<org.apache.flink.api.common.functions.CoGroupFunction<Record, Record, Record>> udf = coGroupOp.getUserCodeWrapper();
		UserCodeWrapper<org.apache.flink.api.common.functions.CoGroupFunction<Record, Record, Record>> copy = SerializationUtils.clone(udf);
		org.apache.flink.api.common.functions.CoGroupFunction<Record, Record, Record> cogrouper = copy.getUserCodeObject();
		
		// prepare the coGpuü
		final List<Record> target = new ArrayList<Record>();
		Collector<Record> collector = new Collector<Record>() {
			@Override
			public void collect(Record record) {
				target.add(record);
			}
			@Override
			public void close() {}
		};
		
		List<Record> source1 = new ArrayList<Record>();
		source1.add(new Record(new IntValue(42)));
		source1.add(new Record(new IntValue(13)));
		
		List<Record> source2 = new ArrayList<Record>();
		source2.add(new Record(new LongValue(11)));
		source2.add(new Record(new LongValue(17)));
		
		// test coGroup
		cogrouper.coGroup(source1, source2, collector);
		assertEquals(4, target.size());
		assertEquals(new IntValue(42), target.get(0).getField(0, IntValue.class));
		assertEquals(new IntValue(13), target.get(1).getField(0, IntValue.class));
		assertEquals(new LongValue(11), target.get(2).getField(0, LongValue.class));
		assertEquals(new LongValue(17), target.get(3).getField(0, LongValue.class));
		target.clear();
	}
	catch (Exception e) {
		e.printStackTrace();
		fail(e.getMessage());
	}
}
 
开发者ID:citlab,项目名称:vs.msc.ws14,代码行数:43,代码来源:CoGroupWrappingFunctionTest.java

示例4: testWrappedReduceClass

import org.apache.flink.api.common.operators.util.UserCodeWrapper; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void testWrappedReduceClass() {
	try {
		ReduceOperator reduceOp = ReduceOperator.builder(TestReduceFunction.class).build();
		
		UserCodeWrapper<GroupReduceFunction<Record, Record>> udf = reduceOp.getUserCodeWrapper();
		UserCodeWrapper<GroupReduceFunction<Record, Record>> copy = SerializationUtils.clone(udf);
		GroupReduceFunction<Record, Record> reducer = copy.getUserCodeObject();
		
		// prepare the reduce / combine tests
		final List<Record> target = new ArrayList<Record>();
		Collector<Record> collector = new Collector<Record>() {
			@Override
			public void collect(Record record) {
				target.add(record);
			}
			@Override
			public void close() {}
		};
		
		List<Record> source = new ArrayList<Record>();
		source.add(new Record(new IntValue(42), new LongValue(11)));
		source.add(new Record(new IntValue(13), new LongValue(17)));
		
		// test reduce
		reducer.reduce(source, collector);
		assertEquals(2, target.size());
		assertEquals(new IntValue(42), target.get(0).getField(0, IntValue.class));
		assertEquals(new LongValue(11), target.get(0).getField(1, LongValue.class));
		assertEquals(new IntValue(13), target.get(1).getField(0, IntValue.class));
		assertEquals(new LongValue(17), target.get(1).getField(1, LongValue.class));
		target.clear();
		
		// test combine
		((FlatCombineFunction<Record>) reducer).combine(source, collector);
		assertEquals(2, target.size());
		assertEquals(new IntValue(42), target.get(0).getField(0, IntValue.class));
		assertEquals(new LongValue(11), target.get(0).getField(1, LongValue.class));
		assertEquals(new IntValue(13), target.get(1).getField(0, IntValue.class));
		assertEquals(new LongValue(17), target.get(1).getField(1, LongValue.class));
		target.clear();
	}
	catch (Exception e) {
		e.printStackTrace();
		fail(e.getMessage());
	}
}
 
开发者ID:citlab,项目名称:vs.msc.ws14,代码行数:49,代码来源:ReduceWrappingFunctionTest.java


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