當前位置: 首頁>>代碼示例>>Java>>正文


Java TaskConfig.addBroadcastInputToGroup方法代碼示例

本文整理匯總了Java中org.apache.flink.runtime.operators.util.TaskConfig.addBroadcastInputToGroup方法的典型用法代碼示例。如果您正苦於以下問題:Java TaskConfig.addBroadcastInputToGroup方法的具體用法?Java TaskConfig.addBroadcastInputToGroup怎麽用?Java TaskConfig.addBroadcastInputToGroup使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.flink.runtime.operators.util.TaskConfig的用法示例。


在下文中一共展示了TaskConfig.addBroadcastInputToGroup方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createMapper

import org.apache.flink.runtime.operators.util.TaskConfig; //導入方法依賴的package包/類
private static AbstractJobVertex createMapper(JobGraph jobGraph, int numSubTasks, TypeSerializerFactory<?> serializer) {
	AbstractJobVertex pointsInput = JobGraphUtils.createTask(RegularPactTask.class, "Map[DotProducts]", jobGraph, numSubTasks);

	{
		TaskConfig taskConfig = new TaskConfig(pointsInput.getConfiguration());

		taskConfig.setStubWrapper(new UserCodeClassWrapper<DotProducts>(DotProducts.class));
		taskConfig.addOutputShipStrategy(ShipStrategyType.FORWARD);
		taskConfig.setOutputSerializer(serializer);
		taskConfig.setDriver(CollectorMapDriver.class);
		taskConfig.setDriverStrategy(DriverStrategy.COLLECTOR_MAP);

		taskConfig.addInputToGroup(0);
		taskConfig.setInputLocalStrategy(0, LocalStrategy.NONE);
		taskConfig.setInputSerializer(serializer, 0);

		taskConfig.setBroadcastInputName("models", 0);
		taskConfig.addBroadcastInputToGroup(0);
		taskConfig.setBroadcastInputSerializer(serializer, 0);
	}

	return pointsInput;
}
 
開發者ID:citlab,項目名稱:vs.msc.ws14,代碼行數:24,代碼來源:BroadcastVarsNepheleITCase.java

示例2: createMapper

import org.apache.flink.runtime.operators.util.TaskConfig; //導入方法依賴的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

示例3: connectJobVertices

import org.apache.flink.runtime.operators.util.TaskConfig; //導入方法依賴的package包/類
/**
	 * NOTE: The channel for global and local strategies are different if we connect a union. The global strategy
	 * channel is then the channel into the union node, the local strategy channel the one from the union to the
	 * actual target operator.
	 *
	 * @param channel
	 * @param inputNumber
	 * @param sourceVertex
	 * @param sourceConfig
	 * @param targetVertex
	 * @param targetConfig
	 * @param isBroadcast
	 * @throws CompilerException
	 */
	private DistributionPattern connectJobVertices(Channel channel, int inputNumber,
			final AbstractJobVertex sourceVertex, final TaskConfig sourceConfig,
			final AbstractJobVertex targetVertex, final TaskConfig targetConfig, boolean isBroadcast)
	throws CompilerException
	{
		// ------------ connect the vertices to the job graph --------------
		final DistributionPattern distributionPattern;

		switch (channel.getShipStrategy()) {
			case FORWARD:
				distributionPattern = DistributionPattern.POINTWISE;
				break;
			case PARTITION_RANDOM:
			case BROADCAST:
			case PARTITION_HASH:
			case PARTITION_RANGE:
			case PARTITION_FORCED_REBALANCE:
				distributionPattern = DistributionPattern.BIPARTITE;
				break;
			default:
				throw new RuntimeException("Unknown runtime ship strategy: " + channel.getShipStrategy());
		}
		
		targetVertex.connectNewDataSetAsInput(sourceVertex, distributionPattern);
		
//		sourceVertex.conn/ectTo(targetVertex, channelType, distributionPattern);

		// -------------- configure the source task's ship strategy strategies in task config --------------
		final int outputIndex = sourceConfig.getNumOutputs();
		sourceConfig.addOutputShipStrategy(channel.getShipStrategy());
		if (outputIndex == 0) {
			sourceConfig.setOutputSerializer(channel.getSerializer());
		}
		if (channel.getShipStrategyComparator() != null) {
			sourceConfig.setOutputComparator(channel.getShipStrategyComparator(), outputIndex);
		}
		
		if (channel.getShipStrategy() == ShipStrategyType.PARTITION_RANGE) {
			
			final DataDistribution dataDistribution = channel.getDataDistribution();
			if(dataDistribution != null) {
				sourceConfig.setOutputDataDistribution(dataDistribution, outputIndex);
			} else {
				throw new RuntimeException("Range partitioning requires data distribution");
				// TODO: inject code and configuration for automatic histogram generation
			}
		}
//		if (targetContract instanceof GenericDataSink) {
//			final DataDistribution distri = ((GenericDataSink) targetContract).getDataDistribution();
//			if (distri != null) {
//				configForOutputShipStrategy.setOutputDataDistribution(distri);
//			}
//		}
		
		// ---------------- configure the receiver -------------------
		if (isBroadcast) {
			targetConfig.addBroadcastInputToGroup(inputNumber);
		} else {
			targetConfig.addInputToGroup(inputNumber);
		}
		return distributionPattern;
	}
 
開發者ID:citlab,項目名稱:vs.msc.ws14,代碼行數:77,代碼來源:NepheleJobGraphGenerator.java


注:本文中的org.apache.flink.runtime.operators.util.TaskConfig.addBroadcastInputToGroup方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。