flink-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From greghogan <...@git.apache.org>
Subject [GitHub] flink pull request #2606: [FLINK-3888] Allow custom convergence criterion in...
Date Wed, 12 Oct 2016 19:17:04 GMT
Github user greghogan commented on a diff in the pull request:

    https://github.com/apache/flink/pull/2606#discussion_r83075316
  
    --- Diff: flink-tests/src/test/java/org/apache/flink/test/iterative/aggregators/AggregatorConvergenceITCase.java
---
    @@ -137,42 +138,51 @@ public void testConnectedComponentsWithParametrizableConvergence()
{
     			fail(e.getMessage());
     		}
     	}
    +
    +	@Test
    +	public void testDeltaConnectedComponentsWithParametrizableConvergence() {
    +		try {
    +
    +			// name of the aggregator that checks for convergence
    +			final String UPDATED_ELEMENTS = "updated.elements.aggr";
    +
    +			// the iteration stops if less than this number of elements change value
    +			final long convergence_threshold = 3;
    +
    +			final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
    +
    +			DataSet<Tuple2<Long, Long>> initialSolutionSet = env.fromCollection(verticesInput);
    +			DataSet<Tuple2<Long, Long>> edges = env.fromCollection(edgesInput);
    +
    +			DeltaIteration<Tuple2<Long, Long>, Tuple2<Long, Long>> iteration
=
    +					initialSolutionSet.iterateDelta(initialSolutionSet, 10, 0);
    +
    +			// register the convergence criterion
    +			iteration.registerAggregationConvergenceCriterion(UPDATED_ELEMENTS,
    +					new LongSumAggregator(), new UpdatedElementsConvergenceCriterion(convergence_threshold));
    +
    +			DataSet<Tuple2<Long, Long>> verticesWithNewComponents = iteration.getWorkset().join(edges).where(0).equalTo(0)
    +					.with(new NeighborWithComponentIDJoin())
    +					.groupBy(0).min(1);
    +
    +			DataSet<Tuple2<Long, Long>> updatedComponentId =
    +					verticesWithNewComponents.join(iteration.getSolutionSet()).where(0).equalTo(0)
    +							.flatMap(new MinimumIdFilter(UPDATED_ELEMENTS));
    +
    +			List<Tuple2<Long, Long>> result = iteration.closeWith(updatedComponentId,
updatedComponentId).collect();
    +			Collections.sort(result, new JavaProgramTestBase.TupleComparator<Tuple2<Long,
Long>>());
    +
    +			assertEquals(expectedResult, result);
    +		}
    +		catch (Exception e) {
    --- End diff --
    
    Catching and re-throwing exceptions looks to be unnecessary.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message