Java Code Examples for org.apache.flink.api.common.operators.base.BulkIterationBase#getMaximumNumberOfIterations()
The following examples show how to use
org.apache.flink.api.common.operators.base.BulkIterationBase#getMaximumNumberOfIterations() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BulkIterationNode.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
/** * Creates a new node for the bulk iteration. * * @param iteration The bulk iteration the node represents. */ public BulkIterationNode(BulkIterationBase<?> iteration) { super(iteration); if (iteration.getMaximumNumberOfIterations() <= 0) { throw new CompilerException("BulkIteration must have a maximum number of iterations specified."); } int numIters = iteration.getMaximumNumberOfIterations(); this.costWeight = (numIters > 0 && numIters < OptimizerNode.MAX_DYNAMIC_PATH_COST_WEIGHT) ? numIters : OptimizerNode.MAX_DYNAMIC_PATH_COST_WEIGHT; }
Example 2
Source File: BulkIterationNode.java From flink with Apache License 2.0 | 5 votes |
/** * Creates a new node for the bulk iteration. * * @param iteration The bulk iteration the node represents. */ public BulkIterationNode(BulkIterationBase<?> iteration) { super(iteration); if (iteration.getMaximumNumberOfIterations() <= 0) { throw new CompilerException("BulkIteration must have a maximum number of iterations specified."); } int numIters = iteration.getMaximumNumberOfIterations(); this.costWeight = (numIters > 0 && numIters < OptimizerNode.MAX_DYNAMIC_PATH_COST_WEIGHT) ? numIters : OptimizerNode.MAX_DYNAMIC_PATH_COST_WEIGHT; }
Example 3
Source File: BulkIterationNode.java From flink with Apache License 2.0 | 5 votes |
/** * Creates a new node for the bulk iteration. * * @param iteration The bulk iteration the node represents. */ public BulkIterationNode(BulkIterationBase<?> iteration) { super(iteration); if (iteration.getMaximumNumberOfIterations() <= 0) { throw new CompilerException("BulkIteration must have a maximum number of iterations specified."); } int numIters = iteration.getMaximumNumberOfIterations(); this.costWeight = (numIters > 0 && numIters < OptimizerNode.MAX_DYNAMIC_PATH_COST_WEIGHT) ? numIters : OptimizerNode.MAX_DYNAMIC_PATH_COST_WEIGHT; }
Example 4
Source File: CollectionExecutor.java From Flink-CEPplus with Apache License 2.0 | 4 votes |
@SuppressWarnings("unchecked") private <T> List<T> executeBulkIteration(BulkIterationBase<?> iteration) throws Exception { Operator<?> inputOp = iteration.getInput(); if (inputOp == null) { throw new InvalidProgramException("The iteration " + iteration.getName() + " has no input (initial partial solution)."); } if (iteration.getNextPartialSolution() == null) { throw new InvalidProgramException("The iteration " + iteration.getName() + " has no next partial solution defined (is not closed)."); } List<T> inputData = (List<T>) execute(inputOp); // get the operators that are iterative Set<Operator<?>> dynamics = new LinkedHashSet<Operator<?>>(); DynamicPathCollector dynCollector = new DynamicPathCollector(dynamics); iteration.getNextPartialSolution().accept(dynCollector); if (iteration.getTerminationCriterion() != null) { iteration.getTerminationCriterion().accept(dynCollector); } // register the aggregators for (AggregatorWithName<?> a : iteration.getAggregators().getAllRegisteredAggregators()) { aggregators.put(a.getName(), a.getAggregator()); } String convCriterionAggName = iteration.getAggregators().getConvergenceCriterionAggregatorName(); ConvergenceCriterion<Value> convCriterion = (ConvergenceCriterion<Value>) iteration.getAggregators().getConvergenceCriterion(); List<T> currentResult = inputData; final int maxIterations = iteration.getMaximumNumberOfIterations(); for (int superstep = 1; superstep <= maxIterations; superstep++) { // set the input to the current partial solution this.intermediateResults.put(iteration.getPartialSolution(), currentResult); // set the superstep number iterationSuperstep = superstep; // grab the current iteration result currentResult = (List<T>) execute(iteration.getNextPartialSolution(), superstep); // evaluate the termination criterion if (iteration.getTerminationCriterion() != null) { execute(iteration.getTerminationCriterion(), superstep); } // evaluate the aggregator convergence criterion if (convCriterion != null && convCriterionAggName != null) { Value v = aggregators.get(convCriterionAggName).getAggregate(); if (convCriterion.isConverged(superstep, v)) { break; } } // clear the dynamic results for (Operator<?> o : dynamics) { intermediateResults.remove(o); } // set the previous iteration's aggregates and reset the aggregators for (Map.Entry<String, Aggregator<?>> e : aggregators.entrySet()) { previousAggregates.put(e.getKey(), e.getValue().getAggregate()); e.getValue().reset(); } } previousAggregates.clear(); aggregators.clear(); return currentResult; }
Example 5
Source File: CollectionExecutor.java From flink with Apache License 2.0 | 4 votes |
@SuppressWarnings("unchecked") private <T> List<T> executeBulkIteration(BulkIterationBase<?> iteration) throws Exception { Operator<?> inputOp = iteration.getInput(); if (inputOp == null) { throw new InvalidProgramException("The iteration " + iteration.getName() + " has no input (initial partial solution)."); } if (iteration.getNextPartialSolution() == null) { throw new InvalidProgramException("The iteration " + iteration.getName() + " has no next partial solution defined (is not closed)."); } List<T> inputData = (List<T>) execute(inputOp); // get the operators that are iterative Set<Operator<?>> dynamics = new LinkedHashSet<Operator<?>>(); DynamicPathCollector dynCollector = new DynamicPathCollector(dynamics); iteration.getNextPartialSolution().accept(dynCollector); if (iteration.getTerminationCriterion() != null) { iteration.getTerminationCriterion().accept(dynCollector); } // register the aggregators for (AggregatorWithName<?> a : iteration.getAggregators().getAllRegisteredAggregators()) { aggregators.put(a.getName(), a.getAggregator()); } String convCriterionAggName = iteration.getAggregators().getConvergenceCriterionAggregatorName(); ConvergenceCriterion<Value> convCriterion = (ConvergenceCriterion<Value>) iteration.getAggregators().getConvergenceCriterion(); List<T> currentResult = inputData; final int maxIterations = iteration.getMaximumNumberOfIterations(); for (int superstep = 1; superstep <= maxIterations; superstep++) { // set the input to the current partial solution this.intermediateResults.put(iteration.getPartialSolution(), currentResult); // set the superstep number iterationSuperstep = superstep; // grab the current iteration result currentResult = (List<T>) execute(iteration.getNextPartialSolution(), superstep); // evaluate the termination criterion if (iteration.getTerminationCriterion() != null) { execute(iteration.getTerminationCriterion(), superstep); } // evaluate the aggregator convergence criterion if (convCriterion != null && convCriterionAggName != null) { Value v = aggregators.get(convCriterionAggName).getAggregate(); if (convCriterion.isConverged(superstep, v)) { break; } } // clear the dynamic results for (Operator<?> o : dynamics) { intermediateResults.remove(o); } // set the previous iteration's aggregates and reset the aggregators for (Map.Entry<String, Aggregator<?>> e : aggregators.entrySet()) { previousAggregates.put(e.getKey(), e.getValue().getAggregate()); e.getValue().reset(); } } previousAggregates.clear(); aggregators.clear(); return currentResult; }
Example 6
Source File: CollectionExecutor.java From flink with Apache License 2.0 | 4 votes |
@SuppressWarnings("unchecked") private <T> List<T> executeBulkIteration(BulkIterationBase<?> iteration) throws Exception { Operator<?> inputOp = iteration.getInput(); if (inputOp == null) { throw new InvalidProgramException("The iteration " + iteration.getName() + " has no input (initial partial solution)."); } if (iteration.getNextPartialSolution() == null) { throw new InvalidProgramException("The iteration " + iteration.getName() + " has no next partial solution defined (is not closed)."); } List<T> inputData = (List<T>) execute(inputOp); // get the operators that are iterative Set<Operator<?>> dynamics = new LinkedHashSet<Operator<?>>(); DynamicPathCollector dynCollector = new DynamicPathCollector(dynamics); iteration.getNextPartialSolution().accept(dynCollector); if (iteration.getTerminationCriterion() != null) { iteration.getTerminationCriterion().accept(dynCollector); } // register the aggregators for (AggregatorWithName<?> a : iteration.getAggregators().getAllRegisteredAggregators()) { aggregators.put(a.getName(), a.getAggregator()); } String convCriterionAggName = iteration.getAggregators().getConvergenceCriterionAggregatorName(); ConvergenceCriterion<Value> convCriterion = (ConvergenceCriterion<Value>) iteration.getAggregators().getConvergenceCriterion(); List<T> currentResult = inputData; final int maxIterations = iteration.getMaximumNumberOfIterations(); for (int superstep = 1; superstep <= maxIterations; superstep++) { // set the input to the current partial solution this.intermediateResults.put(iteration.getPartialSolution(), currentResult); // set the superstep number iterationSuperstep = superstep; // grab the current iteration result currentResult = (List<T>) execute(iteration.getNextPartialSolution(), superstep); // evaluate the termination criterion if (iteration.getTerminationCriterion() != null) { execute(iteration.getTerminationCriterion(), superstep); } // evaluate the aggregator convergence criterion if (convCriterion != null && convCriterionAggName != null) { Value v = aggregators.get(convCriterionAggName).getAggregate(); if (convCriterion.isConverged(superstep, v)) { break; } } // clear the dynamic results for (Operator<?> o : dynamics) { intermediateResults.remove(o); } // set the previous iteration's aggregates and reset the aggregators for (Map.Entry<String, Aggregator<?>> e : aggregators.entrySet()) { previousAggregates.put(e.getKey(), e.getValue().getAggregate()); e.getValue().reset(); } } previousAggregates.clear(); aggregators.clear(); return currentResult; }