本文整理匯總了Java中org.apache.flink.runtime.operators.util.TaskConfig.setInputComparator方法的典型用法代碼示例。如果您正苦於以下問題:Java TaskConfig.setInputComparator方法的具體用法?Java TaskConfig.setInputComparator怎麽用?Java TaskConfig.setInputComparator使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.flink.runtime.operators.util.TaskConfig
的用法示例。
在下文中一共展示了TaskConfig.setInputComparator方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: createIterationIntermediate
import org.apache.flink.runtime.operators.util.TaskConfig; //導入方法依賴的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;
}
示例2: createReducer
import org.apache.flink.runtime.operators.util.TaskConfig; //導入方法依賴的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;
}
示例3: addLocalInfoFromChannelToConfig
import org.apache.flink.runtime.operators.util.TaskConfig; //導入方法依賴的package包/類
private void addLocalInfoFromChannelToConfig(Channel channel, TaskConfig config, int inputNum, boolean isBroadcastChannel) {
// serializer
if (isBroadcastChannel) {
config.setBroadcastInputSerializer(channel.getSerializer(), inputNum);
if (channel.getLocalStrategy() != LocalStrategy.NONE || (channel.getTempMode() != null && channel.getTempMode() != TempMode.NONE)) {
throw new CompilerException("Found local strategy or temp mode on a broadcast variable channel.");
} else {
return;
}
} else {
config.setInputSerializer(channel.getSerializer(), inputNum);
}
// local strategy
if (channel.getLocalStrategy() != LocalStrategy.NONE) {
config.setInputLocalStrategy(inputNum, channel.getLocalStrategy());
if (channel.getLocalStrategyComparator() != null) {
config.setInputComparator(channel.getLocalStrategyComparator(), inputNum);
}
}
assignLocalStrategyResources(channel, config, inputNum);
// materialization / caching
if (channel.getTempMode() != null) {
final TempMode tm = channel.getTempMode();
boolean needsMemory = false;
// Don't add a pipeline breaker if the data exchange is already blocking, EXCEPT the channel is within an iteration.
if (tm.breaksPipeline() &&
(channel.isOnDynamicPath() || channel.getDataExchangeMode() != DataExchangeMode.BATCH) ) {
config.setInputAsynchronouslyMaterialized(inputNum, true);
needsMemory = true;
}
if (tm.isCached()) {
config.setInputCached(inputNum, true);
needsMemory = true;
}
if (needsMemory) {
// sanity check
if (tm == TempMode.NONE || channel.getRelativeTempMemory() <= 0) {
throw new CompilerException("Bug in compiler: Inconsistent description of input materialization.");
}
config.setRelativeInputMaterializationMemory(inputNum, channel.getRelativeTempMemory());
}
}
}
示例4: addLocalInfoFromChannelToConfig
import org.apache.flink.runtime.operators.util.TaskConfig; //導入方法依賴的package包/類
private void addLocalInfoFromChannelToConfig(Channel channel, TaskConfig config, int inputNum, boolean isBroadcastChannel) {
// serializer
if (isBroadcastChannel) {
config.setBroadcastInputSerializer(channel.getSerializer(), inputNum);
if (channel.getLocalStrategy() != LocalStrategy.NONE || (channel.getTempMode() != null && channel.getTempMode() != TempMode.NONE)) {
throw new CompilerException("Found local strategy or temp mode on a broadcast variable channel.");
} else {
return;
}
} else {
config.setInputSerializer(channel.getSerializer(), inputNum);
}
// local strategy
if (channel.getLocalStrategy() != LocalStrategy.NONE) {
config.setInputLocalStrategy(inputNum, channel.getLocalStrategy());
if (channel.getLocalStrategyComparator() != null) {
config.setInputComparator(channel.getLocalStrategyComparator(), inputNum);
}
}
assignLocalStrategyResources(channel, config, inputNum);
// materialization / caching
if (channel.getTempMode() != null) {
final TempMode tm = channel.getTempMode();
boolean needsMemory = false;
if (tm.breaksPipeline()) {
config.setInputAsynchronouslyMaterialized(inputNum, true);
needsMemory = true;
}
if (tm.isCached()) {
config.setInputCached(inputNum, true);
needsMemory = true;
}
if (needsMemory) {
// sanity check
if (tm == null || tm == TempMode.NONE || channel.getRelativeTempMemory() <= 0) {
throw new CompilerException("Bug in compiler: Inconsistent description of input materialization.");
}
config.setRelativeInputMaterializationMemory(inputNum, channel.getRelativeTempMemory());
}
}
}
示例5: createIterationHead
import org.apache.flink.runtime.operators.util.TaskConfig; //導入方法依賴的package包/類
private static AbstractJobVertex createIterationHead(JobGraph jobGraph, int numSubTasks,
TypeSerializerFactory<?> serializer,
TypeComparatorFactory<?> comparator,
TypePairComparatorFactory<?, ?> pairComparator) {
AbstractJobVertex head = JobGraphUtils.createTask(IterationHeadPactTask.class, "Join With Edges (Iteration Head)", jobGraph, numSubTasks);
TaskConfig headConfig = new TaskConfig(head.getConfiguration());
{
headConfig.setIterationId(ITERATION_ID);
// initial input / workset
headConfig.addInputToGroup(0);
headConfig.setInputSerializer(serializer, 0);
headConfig.setInputComparator(comparator, 0);
headConfig.setInputLocalStrategy(0, LocalStrategy.NONE);
headConfig.setIterationHeadPartialSolutionOrWorksetInputIndex(0);
// regular plan input (second input to the join)
headConfig.addInputToGroup(1);
headConfig.setInputSerializer(serializer, 1);
headConfig.setInputComparator(comparator, 1);
headConfig.setInputLocalStrategy(1, LocalStrategy.NONE);
headConfig.setInputCached(1, true);
headConfig.setRelativeInputMaterializationMemory(1, MEM_FRAC_PER_CONSUMER);
// initial solution set input
headConfig.addInputToGroup(2);
headConfig.setInputSerializer(serializer, 2);
headConfig.setInputComparator(comparator, 2);
headConfig.setInputLocalStrategy(2, LocalStrategy.NONE);
headConfig.setIterationHeadSolutionSetInputIndex(2);
headConfig.setSolutionSetSerializer(serializer);
headConfig.setSolutionSetComparator(comparator);
// back channel / iterations
headConfig.setIsWorksetIteration();
headConfig.setRelativeBackChannelMemory(MEM_FRAC_PER_CONSUMER);
headConfig.setRelativeSolutionSetMemory(MEM_FRAC_PER_CONSUMER );
// output into iteration
headConfig.setOutputSerializer(serializer);
headConfig.addOutputShipStrategy(ShipStrategyType.PARTITION_HASH);
headConfig.setOutputComparator(comparator, 0);
// final output
TaskConfig headFinalOutConfig = new TaskConfig(new Configuration());
headFinalOutConfig.setOutputSerializer(serializer);
headFinalOutConfig.addOutputShipStrategy(ShipStrategyType.FORWARD);
headConfig.setIterationHeadFinalOutputConfig(headFinalOutConfig);
// the sync
headConfig.setIterationHeadIndexOfSyncOutput(2);
// the driver
headConfig.setDriver(BuildSecondCachedMatchDriver.class);
headConfig.setDriverStrategy(DriverStrategy.HYBRIDHASH_BUILD_SECOND);
headConfig.setStubWrapper(
new UserCodeClassWrapper<NeighborWithComponentIDJoin>(NeighborWithComponentIDJoin.class));
headConfig.setDriverComparator(comparator, 0);
headConfig.setDriverComparator(comparator, 1);
headConfig.setDriverPairComparator(pairComparator);
headConfig.setRelativeMemoryDriver(MEM_FRAC_PER_CONSUMER);
headConfig.addIterationAggregator(
WorksetEmptyConvergenceCriterion.AGGREGATOR_NAME, new LongSumAggregator());
}
return head;
}