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


Java UserCodeObjectWrapper类代码示例

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


UserCodeObjectWrapper类属于org.apache.flink.api.common.operators.util包,在下文中一共展示了UserCodeObjectWrapper类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testInputFormatVertex

import org.apache.flink.api.common.operators.util.UserCodeObjectWrapper; //导入依赖的package包/类
@Test
public void testInputFormatVertex() {
	try {
		final TestInputFormat inputFormat = new TestInputFormat();
		final InputFormatVertex vertex = new InputFormatVertex("Name");
		new TaskConfig(vertex.getConfiguration()).setStubWrapper(new UserCodeObjectWrapper<InputFormat<?, ?>>(inputFormat));
		
		final ClassLoader cl = getClass().getClassLoader();
		
		vertex.initializeOnMaster(cl);
		InputSplit[] splits = vertex.getInputSplitSource().createInputSplits(77);
		
		assertNotNull(splits);
		assertEquals(1, splits.length);
		assertEquals(TestSplit.class, splits[0].getClass());
	}
	catch (Exception e) {
		e.printStackTrace();
		fail(e.getMessage());
	}
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:22,代码来源:JobTaskVertexTest.java

示例2: registerFileInputTask

import org.apache.flink.api.common.operators.util.UserCodeObjectWrapper; //导入依赖的package包/类
public void registerFileInputTask(AbstractInvokable inTask,
		Class<? extends DelimitedInputFormat<Record>> stubClass, String inPath, String delimiter)
{
	DelimitedInputFormat<Record> format;
	try {
		format = stubClass.newInstance();
	}
	catch (Throwable t) {
		throw new RuntimeException("Could not instantiate test input format.", t);
	}

	format.setFilePath(inPath);
	format.setDelimiter(delimiter);

	TaskConfig dsConfig = new TaskConfig(this.mockEnv.getTaskConfiguration());
	dsConfig.setStubWrapper(new UserCodeObjectWrapper<>(format));

	this.inputSplitProvider.addInputSplits(inPath, 5);
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:20,代码来源:TaskTestBase.java

示例3: createOutput

import org.apache.flink.api.common.operators.util.UserCodeObjectWrapper; //导入依赖的package包/类
private static OutputFormatVertex createOutput(JobGraph jobGraph, String resultPath, int numSubTasks, TypeSerializerFactory<?> serializer) {
	OutputFormatVertex output = JobGraphUtils.createFileOutput(jobGraph, "Output", numSubTasks);

	{
		TaskConfig taskConfig = new TaskConfig(output.getConfiguration());
		taskConfig.addInputToGroup(0);
		taskConfig.setInputSerializer(serializer, 0);

		@SuppressWarnings("unchecked")
		CsvOutputFormat outFormat = new CsvOutputFormat("\n", " ", LongValue.class, LongValue.class, LongValue.class);
		outFormat.setOutputFilePath(new Path(resultPath));
		
		taskConfig.setStubWrapper(new UserCodeObjectWrapper<CsvOutputFormat>(outFormat));
	}

	return output;
}
 
开发者ID:citlab,项目名称:vs.msc.ws14,代码行数:18,代码来源:BroadcastVarsNepheleITCase.java

示例4: createPointsInput

import org.apache.flink.api.common.operators.util.UserCodeObjectWrapper; //导入依赖的package包/类
private static InputFormatVertex createPointsInput(JobGraph jobGraph, String pointsPath, int numSubTasks, TypeSerializerFactory<?> serializer) {
	@SuppressWarnings("unchecked")
	CsvInputFormat pointsInFormat = new CsvInputFormat('|', IntValue.class, DoubleValue.class, DoubleValue.class, DoubleValue.class);
	InputFormatVertex pointsInput = JobGraphUtils.createInput(pointsInFormat, pointsPath, "[Points]", jobGraph, numSubTasks);
	{
		TaskConfig taskConfig = new TaskConfig(pointsInput.getConfiguration());
		taskConfig.addOutputShipStrategy(ShipStrategyType.FORWARD);
		taskConfig.setOutputSerializer(serializer);
		
		TaskConfig chainedMapper = new TaskConfig(new Configuration());
		chainedMapper.setDriverStrategy(DriverStrategy.COLLECTOR_MAP);
		chainedMapper.setStubWrapper(new UserCodeObjectWrapper<PointBuilder>(new PointBuilder()));
		chainedMapper.addOutputShipStrategy(ShipStrategyType.FORWARD);
		chainedMapper.setOutputSerializer(serializer);
		
		taskConfig.addChainedTask(ChainedCollectorMapDriver.class, chainedMapper, "Build points");
	}

	return pointsInput;
}
 
开发者ID:citlab,项目名称:vs.msc.ws14,代码行数:21,代码来源:KMeansIterativeNepheleITCase.java

示例5: createCentersInput

import org.apache.flink.api.common.operators.util.UserCodeObjectWrapper; //导入依赖的package包/类
private static InputFormatVertex createCentersInput(JobGraph jobGraph, String centersPath, int numSubTasks, TypeSerializerFactory<?> serializer) {
	@SuppressWarnings("unchecked")
	CsvInputFormat modelsInFormat = new CsvInputFormat('|', IntValue.class, DoubleValue.class, DoubleValue.class, DoubleValue.class);
	InputFormatVertex modelsInput = JobGraphUtils.createInput(modelsInFormat, centersPath, "[Models]", jobGraph, numSubTasks);

	{
		TaskConfig taskConfig = new TaskConfig(modelsInput.getConfiguration());
		taskConfig.addOutputShipStrategy(ShipStrategyType.FORWARD);
		taskConfig.setOutputSerializer(serializer);

		TaskConfig chainedMapper = new TaskConfig(new Configuration());
		chainedMapper.setDriverStrategy(DriverStrategy.COLLECTOR_MAP);
		chainedMapper.setStubWrapper(new UserCodeObjectWrapper<PointBuilder>(new PointBuilder()));
		chainedMapper.addOutputShipStrategy(ShipStrategyType.FORWARD);
		chainedMapper.setOutputSerializer(serializer);
		
		taskConfig.addChainedTask(ChainedCollectorMapDriver.class, chainedMapper, "Build centers");
	}

	return modelsInput;
}
 
开发者ID:citlab,项目名称:vs.msc.ws14,代码行数:22,代码来源:KMeansIterativeNepheleITCase.java

示例6: createOutput

import org.apache.flink.api.common.operators.util.UserCodeObjectWrapper; //导入依赖的package包/类
private static OutputFormatVertex createOutput(JobGraph jobGraph, String resultPath, int numSubTasks, TypeSerializerFactory<?> serializer) {
	
	OutputFormatVertex output = JobGraphUtils.createFileOutput(jobGraph, "Output", numSubTasks);

	{
		TaskConfig taskConfig = new TaskConfig(output.getConfiguration());
		taskConfig.addInputToGroup(0);
		taskConfig.setInputSerializer(serializer, 0);

		PointOutFormat outFormat = new PointOutFormat();
		outFormat.setOutputFilePath(new Path(resultPath));
		
		taskConfig.setStubWrapper(new UserCodeObjectWrapper<PointOutFormat>(outFormat));
	}

	return output;
}
 
开发者ID:citlab,项目名称:vs.msc.ws14,代码行数:18,代码来源:KMeansIterativeNepheleITCase.java

示例7: registerFileInputTask

import org.apache.flink.api.common.operators.util.UserCodeObjectWrapper; //导入依赖的package包/类
public void registerFileInputTask(AbstractInvokable inTask,
		Class<? extends DelimitedInputFormat> stubClass, String inPath, String delimiter)
{
	DelimitedInputFormat format;
	try {
		format = stubClass.newInstance();
	}
	catch (Throwable t) {
		throw new RuntimeException("Could not instantiate test input format.", t);
	}
	
	format.setFilePath(inPath);
	format.setDelimiter(delimiter);
	
	TaskConfig dsConfig = new TaskConfig(this.mockEnv.getTaskConfiguration());
	dsConfig.setStubWrapper(new UserCodeObjectWrapper<DelimitedInputFormat>(format));
	
	this.inputSplitProvider.addInputSplits(inPath, 5);

	inTask.setEnvironment(this.mockEnv);

	inTask.registerInputOutput();
}
 
开发者ID:citlab,项目名称:vs.msc.ws14,代码行数:24,代码来源:TaskTestBase.java

示例8: GenericDataSourceBase

import org.apache.flink.api.common.operators.util.UserCodeObjectWrapper; //导入依赖的package包/类
/**
 * Creates a new instance for the given file using the given input format.
 *
 * @param format The {@link org.apache.flink.api.common.io.InputFormat} implementation used to read the data.
 * @param operatorInfo The type information for the operator.
 * @param name The given name for the Pact, used in plans, logs and progress messages.
 */
public GenericDataSourceBase(T format, OperatorInformation<OUT> operatorInfo, String name) {
	super(operatorInfo, name);

	if (format == null) {
		throw new IllegalArgumentException("Input format may not be null.");
	}

	this.formatWrapper = new UserCodeObjectWrapper<T>(format);
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:17,代码来源:GenericDataSourceBase.java

示例9: registerFileOutputTask

import org.apache.flink.api.common.operators.util.UserCodeObjectWrapper; //导入依赖的package包/类
public void registerFileOutputTask(FileOutputFormat<Record> outputFormat, String outPath) {
	TaskConfig dsConfig = new TaskConfig(this.mockEnv.getTaskConfiguration());

	outputFormat.setOutputFilePath(new Path(outPath));
	outputFormat.setWriteMode(WriteMode.OVERWRITE);

	dsConfig.setStubWrapper(new UserCodeObjectWrapper<>(outputFormat));
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:9,代码来源:TaskTestBase.java

示例10: createIterationIntermediate

import org.apache.flink.api.common.operators.util.UserCodeObjectWrapper; //导入依赖的package包/类
private static AbstractJobVertex createIterationIntermediate(JobGraph jobGraph, int numSubTasks,
		TypeSerializerFactory<?> serializer, TypeComparatorFactory<?> comparator)
{
	// --------------- the intermediate (reduce to min id) ---------------
	AbstractJobVertex intermediate = JobGraphUtils.createTask(IterationIntermediatePactTask.class,
		"Find Min Component-ID", jobGraph, numSubTasks);
	TaskConfig intermediateConfig = new TaskConfig(intermediate.getConfiguration());
	{
		intermediateConfig.setIterationId(ITERATION_ID);

		intermediateConfig.addInputToGroup(0);
		intermediateConfig.setInputSerializer(serializer, 0);
		intermediateConfig.setInputComparator(comparator, 0);
		intermediateConfig.setInputLocalStrategy(0, LocalStrategy.SORT);
		intermediateConfig.setRelativeMemoryInput(0, MEM_FRAC_PER_CONSUMER);
		intermediateConfig.setFilehandlesInput(0, 64);
		intermediateConfig.setSpillingThresholdInput(0, 0.85f);

		intermediateConfig.setOutputSerializer(serializer);
		intermediateConfig.addOutputShipStrategy(ShipStrategyType.FORWARD);

		intermediateConfig.setDriver(GroupReduceDriver.class);
		intermediateConfig.setDriverStrategy(DriverStrategy.SORTED_GROUP_REDUCE);
		intermediateConfig.setDriverComparator(comparator, 0);
		intermediateConfig.setStubWrapper(
			new UserCodeObjectWrapper<WrappingReduceFunction>(new WrappingClassReduceFunction(MinimumComponentIDReduce.class)));
	}

	return intermediate;
}
 
开发者ID:citlab,项目名称:vs.msc.ws14,代码行数:31,代码来源:ConnectedComponentsNepheleITCase.java

示例11: createMapper

import org.apache.flink.api.common.operators.util.UserCodeObjectWrapper; //导入依赖的package包/类
private static AbstractJobVertex createMapper(JobGraph jobGraph, int numSubTasks, TypeSerializerFactory<?> inputSerializer,
		TypeSerializerFactory<?> broadcastVarSerializer, TypeSerializerFactory<?> outputSerializer,
		TypeComparatorFactory<?> outputComparator)
{
	AbstractJobVertex mapper = JobGraphUtils.createTask(IterationIntermediatePactTask.class,
		"Map (Select nearest center)", jobGraph, numSubTasks);
	
	TaskConfig intermediateConfig = new TaskConfig(mapper.getConfiguration());
	intermediateConfig.setIterationId(ITERATION_ID);
	
	intermediateConfig.setDriver(CollectorMapDriver.class);
	intermediateConfig.setDriverStrategy(DriverStrategy.COLLECTOR_MAP);
	intermediateConfig.addInputToGroup(0);
	intermediateConfig.setInputSerializer(inputSerializer, 0);
	
	intermediateConfig.setOutputSerializer(outputSerializer);
	intermediateConfig.addOutputShipStrategy(ShipStrategyType.PARTITION_HASH);
	intermediateConfig.setOutputComparator(outputComparator, 0);

	intermediateConfig.setBroadcastInputName("centers", 0);
	intermediateConfig.addBroadcastInputToGroup(0);
	intermediateConfig.setBroadcastInputSerializer(broadcastVarSerializer, 0);
	
	// the udf
	intermediateConfig.setStubWrapper(new UserCodeObjectWrapper<SelectNearestCenter>(new SelectNearestCenter()));
	
	return mapper;
}
 
开发者ID:citlab,项目名称:vs.msc.ws14,代码行数:29,代码来源:KMeansIterativeNepheleITCase.java

示例12: createReducer

import org.apache.flink.api.common.operators.util.UserCodeObjectWrapper; //导入依赖的package包/类
private static AbstractJobVertex createReducer(JobGraph jobGraph, int numSubTasks, TypeSerializerFactory<?> inputSerializer,
		TypeComparatorFactory<?> inputComparator, TypeSerializerFactory<?> outputSerializer)
{
	// ---------------- the tail (reduce) --------------------
	
	AbstractJobVertex tail = JobGraphUtils.createTask(IterationTailPactTask.class, "Reduce / Iteration Tail", jobGraph,
		numSubTasks);
	
	TaskConfig tailConfig = new TaskConfig(tail.getConfiguration());
	tailConfig.setIterationId(ITERATION_ID);
	tailConfig.setIsWorksetUpdate();
	
	// inputs and driver
	tailConfig.setDriver(GroupReduceDriver.class);
	tailConfig.setDriverStrategy(DriverStrategy.SORTED_GROUP_REDUCE);
	tailConfig.addInputToGroup(0);
	tailConfig.setInputSerializer(inputSerializer, 0);		
	tailConfig.setDriverComparator(inputComparator, 0);

	tailConfig.setInputLocalStrategy(0, LocalStrategy.SORT);
	tailConfig.setInputComparator(inputComparator, 0);
	tailConfig.setRelativeMemoryInput(0, MEMORY_FRACTION_PER_CONSUMER);
	tailConfig.setFilehandlesInput(0, 128);
	tailConfig.setSpillingThresholdInput(0, 0.9f);
	
	// output
	tailConfig.setOutputSerializer(outputSerializer);
	
	// the udf
	tailConfig.setStubWrapper(new UserCodeObjectWrapper<WrappingReduceFunction>(new WrappingReduceFunction(new RecomputeClusterCenter())));
	
	return tail;
}
 
开发者ID:citlab,项目名称:vs.msc.ws14,代码行数:34,代码来源:KMeansIterativeNepheleITCase.java

示例13: builder

import org.apache.flink.api.common.operators.util.UserCodeObjectWrapper; //导入依赖的package包/类
/**
 * Creates a Builder with the provided {@link ReduceFunction} implementation.
 * 
 * @param udf The {@link ReduceFunction} implementation for this Reduce contract.
 */
public static Builder builder(ReduceFunction udf) {
	UserCodeWrapper<ReduceFunction> original = new UserCodeObjectWrapper<ReduceFunction>(udf);
	UserCodeWrapper<GroupReduceFunction<Record, Record>> wrapped =
			new UserCodeObjectWrapper<GroupReduceFunction<Record, Record>>(new WrappingReduceFunction(udf));
	
	return new Builder(original, wrapped);
}
 
开发者ID:citlab,项目名称:vs.msc.ws14,代码行数:13,代码来源:ReduceOperator.java

示例14: InnerJoinOperatorBase

import org.apache.flink.api.common.operators.util.UserCodeObjectWrapper; //导入依赖的package包/类
public InnerJoinOperatorBase(FT udf, BinaryOperatorInformation<IN1, IN2, OUT> operatorInfo, int[] keyPositions1,
		int[] keyPositions2, String name) {
	super(new UserCodeObjectWrapper<FT>(udf), operatorInfo, keyPositions1, keyPositions2, name);
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:5,代码来源:InnerJoinOperatorBase.java

示例15: CoGroupRawOperatorBase

import org.apache.flink.api.common.operators.util.UserCodeObjectWrapper; //导入依赖的package包/类
public CoGroupRawOperatorBase(FT udf, BinaryOperatorInformation<IN1, IN2, OUT> operatorInfo, int[] keyPositions1, int[] keyPositions2, String name) {
	this(new UserCodeObjectWrapper<FT>(udf), operatorInfo, keyPositions1, keyPositions2, name);
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:4,代码来源:CoGroupRawOperatorBase.java


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