Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 4BE42200CB8 for ; Fri, 26 May 2017 21:16:15 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 4A827160B9C; Fri, 26 May 2017 19:16:15 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id ED896160BD6 for ; Fri, 26 May 2017 21:16:12 +0200 (CEST) Received: (qmail 70233 invoked by uid 500); 26 May 2017 19:16:12 -0000 Mailing-List: contact commits-help@flink.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@flink.apache.org Delivered-To: mailing list commits@flink.apache.org Received: (qmail 69948 invoked by uid 99); 26 May 2017 19:16:11 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 26 May 2017 19:16:11 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id D1D80E04F2; Fri, 26 May 2017 19:16:10 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: chesnay@apache.org To: commits@flink.apache.org Date: Fri, 26 May 2017 19:16:14 -0000 Message-Id: In-Reply-To: <1b42c15ef80a4ff6b04aea1beb9e93e1@git.apache.org> References: <1b42c15ef80a4ff6b04aea1beb9e93e1@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [05/15] flink git commit: [FLINK-6709] [gelly] Activate strict checkstyle for flink-gellies archived-at: Fri, 26 May 2017 19:16:15 -0000 http://git-wip-us.apache.org/repos/asf/flink/blob/d313ac76/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/asm/degree/annotate/directed/VertexOutDegreeTest.java ---------------------------------------------------------------------- diff --git a/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/asm/degree/annotate/directed/VertexOutDegreeTest.java b/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/asm/degree/annotate/directed/VertexOutDegreeTest.java index b72f0ef..1517f23 100644 --- a/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/asm/degree/annotate/directed/VertexOutDegreeTest.java +++ b/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/asm/degree/annotate/directed/VertexOutDegreeTest.java @@ -27,10 +27,14 @@ import org.apache.flink.test.util.TestBaseUtils; import org.apache.flink.types.IntValue; import org.apache.flink.types.LongValue; import org.apache.flink.types.NullValue; + import org.junit.Test; import static org.junit.Assert.assertEquals; +/** + * Tests for {@link VertexOutDegree}. + */ public class VertexOutDegreeTest extends AsmTestBase { http://git-wip-us.apache.org/repos/asf/flink/blob/d313ac76/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/asm/degree/annotate/undirected/EdgeDegreePairTest.java ---------------------------------------------------------------------- diff --git a/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/asm/degree/annotate/undirected/EdgeDegreePairTest.java b/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/asm/degree/annotate/undirected/EdgeDegreePairTest.java index c65ef2d..5f492e4 100644 --- a/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/asm/degree/annotate/undirected/EdgeDegreePairTest.java +++ b/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/asm/degree/annotate/undirected/EdgeDegreePairTest.java @@ -28,10 +28,14 @@ import org.apache.flink.test.util.TestBaseUtils; import org.apache.flink.types.IntValue; import org.apache.flink.types.LongValue; import org.apache.flink.types.NullValue; + import org.junit.Test; import static org.junit.Assert.assertEquals; +/** + * Tests for {@link EdgeDegreePair}. + */ public class EdgeDegreePairTest extends AsmTestBase { http://git-wip-us.apache.org/repos/asf/flink/blob/d313ac76/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/asm/degree/annotate/undirected/EdgeSourceDegreeTest.java ---------------------------------------------------------------------- diff --git a/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/asm/degree/annotate/undirected/EdgeSourceDegreeTest.java b/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/asm/degree/annotate/undirected/EdgeSourceDegreeTest.java index 2fd0b19..393220d 100644 --- a/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/asm/degree/annotate/undirected/EdgeSourceDegreeTest.java +++ b/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/asm/degree/annotate/undirected/EdgeSourceDegreeTest.java @@ -28,10 +28,14 @@ import org.apache.flink.test.util.TestBaseUtils; import org.apache.flink.types.IntValue; import org.apache.flink.types.LongValue; import org.apache.flink.types.NullValue; + import org.junit.Test; import static org.junit.Assert.assertEquals; +/** + * Tests for {@link EdgeSourceDegree}. + */ public class EdgeSourceDegreeTest extends AsmTestBase { http://git-wip-us.apache.org/repos/asf/flink/blob/d313ac76/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/asm/degree/annotate/undirected/EdgeTargetDegreeTest.java ---------------------------------------------------------------------- diff --git a/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/asm/degree/annotate/undirected/EdgeTargetDegreeTest.java b/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/asm/degree/annotate/undirected/EdgeTargetDegreeTest.java index 34aca35..782296a 100644 --- a/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/asm/degree/annotate/undirected/EdgeTargetDegreeTest.java +++ b/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/asm/degree/annotate/undirected/EdgeTargetDegreeTest.java @@ -28,10 +28,14 @@ import org.apache.flink.test.util.TestBaseUtils; import org.apache.flink.types.IntValue; import org.apache.flink.types.LongValue; import org.apache.flink.types.NullValue; + import org.junit.Test; import static org.junit.Assert.assertEquals; +/** + * Tests for {@link EdgeTargetDegree}. + */ public class EdgeTargetDegreeTest extends AsmTestBase { http://git-wip-us.apache.org/repos/asf/flink/blob/d313ac76/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/asm/degree/annotate/undirected/VertexDegreeTest.java ---------------------------------------------------------------------- diff --git a/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/asm/degree/annotate/undirected/VertexDegreeTest.java b/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/asm/degree/annotate/undirected/VertexDegreeTest.java index c157cc1..192782d 100644 --- a/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/asm/degree/annotate/undirected/VertexDegreeTest.java +++ b/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/asm/degree/annotate/undirected/VertexDegreeTest.java @@ -27,10 +27,14 @@ import org.apache.flink.test.util.TestBaseUtils; import org.apache.flink.types.IntValue; import org.apache.flink.types.LongValue; import org.apache.flink.types.NullValue; + import org.junit.Test; import static org.junit.Assert.assertEquals; +/** + * Tests for {@link VertexDegree}. + */ public class VertexDegreeTest extends AsmTestBase { http://git-wip-us.apache.org/repos/asf/flink/blob/d313ac76/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/asm/degree/filter/undirected/MaximumDegreeTest.java ---------------------------------------------------------------------- diff --git a/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/asm/degree/filter/undirected/MaximumDegreeTest.java b/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/asm/degree/filter/undirected/MaximumDegreeTest.java index f017750..f03d82c 100644 --- a/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/asm/degree/filter/undirected/MaximumDegreeTest.java +++ b/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/asm/degree/filter/undirected/MaximumDegreeTest.java @@ -26,10 +26,14 @@ import org.apache.flink.test.util.TestBaseUtils; import org.apache.flink.types.IntValue; import org.apache.flink.types.LongValue; import org.apache.flink.types.NullValue; + import org.junit.Test; import static org.junit.Assert.assertEquals; +/** + * Tests for {@link MaximumDegree}. + */ public class MaximumDegreeTest extends AsmTestBase { http://git-wip-us.apache.org/repos/asf/flink/blob/d313ac76/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/asm/simple/directed/SimplifyTest.java ---------------------------------------------------------------------- diff --git a/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/asm/simple/directed/SimplifyTest.java b/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/asm/simple/directed/SimplifyTest.java index 709317c..a3aad4b 100644 --- a/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/asm/simple/directed/SimplifyTest.java +++ b/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/asm/simple/directed/SimplifyTest.java @@ -24,12 +24,16 @@ import org.apache.flink.graph.Graph; import org.apache.flink.test.util.TestBaseUtils; import org.apache.flink.types.IntValue; import org.apache.flink.types.NullValue; + import org.junit.Before; import org.junit.Test; import java.util.LinkedList; import java.util.List; +/** + * Tests for {@link Simplify}. + */ public class SimplifyTest { protected Graph graph; http://git-wip-us.apache.org/repos/asf/flink/blob/d313ac76/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/asm/simple/undirected/SimplifyTest.java ---------------------------------------------------------------------- diff --git a/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/asm/simple/undirected/SimplifyTest.java b/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/asm/simple/undirected/SimplifyTest.java index d589000..6ff4292 100644 --- a/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/asm/simple/undirected/SimplifyTest.java +++ b/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/asm/simple/undirected/SimplifyTest.java @@ -24,12 +24,16 @@ import org.apache.flink.graph.Graph; import org.apache.flink.test.util.TestBaseUtils; import org.apache.flink.types.IntValue; import org.apache.flink.types.NullValue; + import org.junit.Before; import org.junit.Test; import java.util.LinkedList; import java.util.List; +/** + * Tests for {@link Simplify}. + */ public class SimplifyTest { protected Graph graph; http://git-wip-us.apache.org/repos/asf/flink/blob/d313ac76/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/asm/translate/TranslateTest.java ---------------------------------------------------------------------- diff --git a/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/asm/translate/TranslateTest.java b/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/asm/translate/TranslateTest.java index 7d6e3ea..dacea26 100644 --- a/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/asm/translate/TranslateTest.java +++ b/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/asm/translate/TranslateTest.java @@ -27,6 +27,7 @@ import org.apache.flink.graph.asm.translate.translators.LongValueToStringValue; import org.apache.flink.test.util.TestBaseUtils; import org.apache.flink.types.LongValue; import org.apache.flink.types.StringValue; + import org.junit.Before; import org.junit.Test; @@ -35,6 +36,9 @@ import java.util.List; import static org.junit.Assert.assertEquals; +/** + * Tests for translation of {@link Graph} IDs and values. + */ public class TranslateTest { private Graph graph; @@ -72,10 +76,10 @@ public class TranslateTest { List> vertexList = new LinkedList<>(); List> edgeList = new LinkedList<>(); - for (long l = 0 ; l < count ; l++) { + for (long l = 0; l < count; l++) { LongValue lv0 = new LongValue(l); - LongValue lv1 = new LongValue(l+1); - LongValue lv2 = new LongValue(l+2); + LongValue lv1 = new LongValue(l + 1); + LongValue lv2 = new LongValue(l + 2); vertexList.add(new Vertex<>(lv0, lv1)); edgeList.add(new Edge<>(lv0, lv1, lv2)); } http://git-wip-us.apache.org/repos/asf/flink/blob/d313ac76/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/asm/translate/translators/LongValueAddOffsetTest.java ---------------------------------------------------------------------- diff --git a/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/asm/translate/translators/LongValueAddOffsetTest.java b/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/asm/translate/translators/LongValueAddOffsetTest.java index ad63209..823de3d 100644 --- a/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/asm/translate/translators/LongValueAddOffsetTest.java +++ b/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/asm/translate/translators/LongValueAddOffsetTest.java @@ -19,10 +19,14 @@ package org.apache.flink.graph.asm.translate.translators; import org.apache.flink.types.LongValue; + import org.junit.Test; import static org.junit.Assert.assertEquals; +/** + * Tests for {@link LongValueAddOffset}. + */ public class LongValueAddOffsetTest { @Test http://git-wip-us.apache.org/repos/asf/flink/blob/d313ac76/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/asm/translate/translators/LongValueToSignedIntValueTest.java ---------------------------------------------------------------------- diff --git a/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/asm/translate/translators/LongValueToSignedIntValueTest.java b/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/asm/translate/translators/LongValueToSignedIntValueTest.java index f730adf..c1f1966 100644 --- a/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/asm/translate/translators/LongValueToSignedIntValueTest.java +++ b/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/asm/translate/translators/LongValueToSignedIntValueTest.java @@ -21,10 +21,14 @@ package org.apache.flink.graph.asm.translate.translators; import org.apache.flink.graph.asm.translate.TranslateFunction; import org.apache.flink.types.IntValue; import org.apache.flink.types.LongValue; + import org.junit.Test; import static org.junit.Assert.assertEquals; +/** + * Tests for {@link LongValueToSignedIntValue}. + */ public class LongValueToSignedIntValueTest { private TranslateFunction translator = new LongValueToSignedIntValue(); @@ -33,18 +37,18 @@ public class LongValueToSignedIntValueTest { @Test public void testTranslation() throws Exception { - assertEquals(new IntValue(Integer.MIN_VALUE), translator.translate(new LongValue((long)Integer.MIN_VALUE), reuse)); + assertEquals(new IntValue(Integer.MIN_VALUE), translator.translate(new LongValue((long) Integer.MIN_VALUE), reuse)); assertEquals(new IntValue(0), translator.translate(new LongValue(0L), reuse)); - assertEquals(new IntValue(Integer.MAX_VALUE), translator.translate(new LongValue((long)Integer.MAX_VALUE), reuse)); + assertEquals(new IntValue(Integer.MAX_VALUE), translator.translate(new LongValue((long) Integer.MAX_VALUE), reuse)); } - @Test(expected=IllegalArgumentException.class) + @Test(expected = IllegalArgumentException.class) public void testUpperOutOfRange() throws Exception { - translator.translate(new LongValue((long)Integer.MAX_VALUE + 1), reuse); + translator.translate(new LongValue((long) Integer.MAX_VALUE + 1), reuse); } - @Test(expected=IllegalArgumentException.class) + @Test(expected = IllegalArgumentException.class) public void testLowerOutOfRange() throws Exception { - translator.translate(new LongValue((long)Integer.MIN_VALUE - 1), reuse); + translator.translate(new LongValue((long) Integer.MIN_VALUE - 1), reuse); } } http://git-wip-us.apache.org/repos/asf/flink/blob/d313ac76/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/asm/translate/translators/LongValueToStringValueTest.java ---------------------------------------------------------------------- diff --git a/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/asm/translate/translators/LongValueToStringValueTest.java b/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/asm/translate/translators/LongValueToStringValueTest.java index 8980cd3..db72121 100644 --- a/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/asm/translate/translators/LongValueToStringValueTest.java +++ b/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/asm/translate/translators/LongValueToStringValueTest.java @@ -21,10 +21,14 @@ package org.apache.flink.graph.asm.translate.translators; import org.apache.flink.graph.asm.translate.TranslateFunction; import org.apache.flink.types.LongValue; import org.apache.flink.types.StringValue; + import org.junit.Test; import static org.junit.Assert.assertEquals; +/** + * Tests for {@link LongValueToStringValue}. + */ public class LongValueToStringValueTest { private TranslateFunction translator = new LongValueToStringValue(); http://git-wip-us.apache.org/repos/asf/flink/blob/d313ac76/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/asm/translate/translators/LongValueToUnsignedIntValueTest.java ---------------------------------------------------------------------- diff --git a/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/asm/translate/translators/LongValueToUnsignedIntValueTest.java b/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/asm/translate/translators/LongValueToUnsignedIntValueTest.java index ca70162..1cd51ad 100644 --- a/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/asm/translate/translators/LongValueToUnsignedIntValueTest.java +++ b/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/asm/translate/translators/LongValueToUnsignedIntValueTest.java @@ -21,10 +21,14 @@ package org.apache.flink.graph.asm.translate.translators; import org.apache.flink.graph.asm.translate.TranslateFunction; import org.apache.flink.types.IntValue; import org.apache.flink.types.LongValue; + import org.junit.Test; import static org.junit.Assert.assertEquals; +/** + * Tests for {@link LongValueToUnsignedIntValue}. + */ public class LongValueToUnsignedIntValueTest { private TranslateFunction translator = new LongValueToUnsignedIntValue(); @@ -38,12 +42,12 @@ public class LongValueToUnsignedIntValueTest { assertEquals(new IntValue(-1), translator.translate(new LongValue((1L << 32) - 1), reuse)); } - @Test(expected=IllegalArgumentException.class) + @Test(expected = IllegalArgumentException.class) public void testUpperOutOfRange() throws Exception { translator.translate(new LongValue(1L << 32), reuse); } - @Test(expected=IllegalArgumentException.class) + @Test(expected = IllegalArgumentException.class) public void testLowerOutOfRange() throws Exception { translator.translate(new LongValue(-1), reuse); } http://git-wip-us.apache.org/repos/asf/flink/blob/d313ac76/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/asm/translate/translators/ToNullValueTest.java ---------------------------------------------------------------------- diff --git a/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/asm/translate/translators/ToNullValueTest.java b/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/asm/translate/translators/ToNullValueTest.java index 6d8a8da..416c479 100644 --- a/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/asm/translate/translators/ToNullValueTest.java +++ b/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/asm/translate/translators/ToNullValueTest.java @@ -24,10 +24,14 @@ import org.apache.flink.types.IntValue; import org.apache.flink.types.LongValue; import org.apache.flink.types.NullValue; import org.apache.flink.types.StringValue; + import org.junit.Test; import static org.junit.Assert.assertEquals; +/** + * Tests for {@link ToNullValue}. + */ public class ToNullValueTest { @Test http://git-wip-us.apache.org/repos/asf/flink/blob/d313ac76/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/bipartite/BipartiteEdgeTest.java ---------------------------------------------------------------------- diff --git a/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/bipartite/BipartiteEdgeTest.java b/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/bipartite/BipartiteEdgeTest.java index ad0106b..b27ece5 100644 --- a/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/bipartite/BipartiteEdgeTest.java +++ b/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/bipartite/BipartiteEdgeTest.java @@ -18,11 +18,13 @@ package org.apache.flink.graph.bipartite; -import org.apache.flink.graph.bipartite.BipartiteEdge; import org.junit.Test; import static org.junit.Assert.assertEquals; +/** + * Tests for {@link BipartiteEdge}. + */ public class BipartiteEdgeTest { private static final int BOTTOM_ID = 0; http://git-wip-us.apache.org/repos/asf/flink/blob/d313ac76/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/bipartite/BipartiteGraphTest.java ---------------------------------------------------------------------- diff --git a/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/bipartite/BipartiteGraphTest.java b/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/bipartite/BipartiteGraphTest.java index 366cf8e..0ee6e3a 100644 --- a/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/bipartite/BipartiteGraphTest.java +++ b/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/bipartite/BipartiteGraphTest.java @@ -24,6 +24,7 @@ import org.apache.flink.api.java.tuple.Tuple2; import org.apache.flink.graph.Graph; import org.apache.flink.graph.Vertex; import org.apache.flink.test.util.TestBaseUtils; + import org.junit.Test; import java.util.Arrays; @@ -31,6 +32,9 @@ import java.util.Arrays; import static org.apache.flink.graph.generator.TestUtils.compareGraph; import static org.junit.Assert.assertEquals; +/** + * Tests for {@link BipartiteGraph}. + */ public class BipartiteGraphTest { @Test http://git-wip-us.apache.org/repos/asf/flink/blob/d313ac76/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/bipartite/ProjectionTest.java ---------------------------------------------------------------------- diff --git a/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/bipartite/ProjectionTest.java b/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/bipartite/ProjectionTest.java index 3aafe64..6301045 100644 --- a/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/bipartite/ProjectionTest.java +++ b/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/bipartite/ProjectionTest.java @@ -19,10 +19,14 @@ package org.apache.flink.graph.bipartite; import org.apache.flink.graph.Vertex; + import org.junit.Test; import static org.junit.Assert.assertEquals; +/** + * Tests for {@link Projection}. + */ public class ProjectionTest { private static final int ID = 10; http://git-wip-us.apache.org/repos/asf/flink/blob/d313ac76/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/generator/AbstractGraphTest.java ---------------------------------------------------------------------- diff --git a/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/generator/AbstractGraphTest.java b/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/generator/AbstractGraphTest.java deleted file mode 100644 index 0f65e32..0000000 --- a/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/generator/AbstractGraphTest.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.flink.graph.generator; - -import org.apache.flink.api.java.ExecutionEnvironment; -import org.junit.Before; - -public class AbstractGraphTest { - - protected ExecutionEnvironment env; - - @Before - public void setup() { - env = ExecutionEnvironment.createCollectionsEnvironment(); - } -} http://git-wip-us.apache.org/repos/asf/flink/blob/d313ac76/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/generator/CirculantGraphTest.java ---------------------------------------------------------------------- diff --git a/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/generator/CirculantGraphTest.java b/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/generator/CirculantGraphTest.java index aae88ca..b7197a4 100644 --- a/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/generator/CirculantGraphTest.java +++ b/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/generator/CirculantGraphTest.java @@ -24,14 +24,16 @@ import org.apache.flink.graph.Graph; import org.apache.flink.graph.Vertex; import org.apache.flink.types.LongValue; import org.apache.flink.types.NullValue; -import org.junit.Rule; + import org.junit.Test; -import org.junit.rules.ExpectedException; import static org.junit.Assert.assertEquals; +/** + * Tests for {@link CirculantGraph}. + */ public class CirculantGraphTest -extends AbstractGraphTest { +extends GraphGeneratorTestBase { @Test public void testGraph() http://git-wip-us.apache.org/repos/asf/flink/blob/d313ac76/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/generator/CompleteGraphTest.java ---------------------------------------------------------------------- diff --git a/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/generator/CompleteGraphTest.java b/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/generator/CompleteGraphTest.java index cb06da5..1791f2e 100644 --- a/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/generator/CompleteGraphTest.java +++ b/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/generator/CompleteGraphTest.java @@ -24,12 +24,16 @@ import org.apache.flink.graph.Graph; import org.apache.flink.graph.Vertex; import org.apache.flink.types.LongValue; import org.apache.flink.types.NullValue; + import org.junit.Test; import static org.junit.Assert.assertEquals; +/** + * Tests for {@link CompleteGraph}. + */ public class CompleteGraphTest -extends AbstractGraphTest { +extends GraphGeneratorTestBase { @Test public void testGraph() @@ -54,7 +58,7 @@ extends AbstractGraphTest { .generate(); assertEquals(vertexCount, graph.numberOfVertices()); - assertEquals(vertexCount*(vertexCount-1), graph.numberOfEdges()); + assertEquals(vertexCount * (vertexCount - 1), graph.numberOfEdges()); long minInDegree = graph.inDegrees().min(1).collect().get(0).f1.getValue(); long minOutDegree = graph.outDegrees().min(1).collect().get(0).f1.getValue(); http://git-wip-us.apache.org/repos/asf/flink/blob/d313ac76/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/generator/CycleGraphTest.java ---------------------------------------------------------------------- diff --git a/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/generator/CycleGraphTest.java b/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/generator/CycleGraphTest.java index be56f56..e4e2960 100644 --- a/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/generator/CycleGraphTest.java +++ b/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/generator/CycleGraphTest.java @@ -24,12 +24,16 @@ import org.apache.flink.graph.Graph; import org.apache.flink.graph.Vertex; import org.apache.flink.types.LongValue; import org.apache.flink.types.NullValue; + import org.junit.Test; import static org.junit.Assert.assertEquals; +/** + * Tests for {@link CycleGraph}. + */ public class CycleGraphTest -extends AbstractGraphTest { +extends GraphGeneratorTestBase { @Test public void testGraph() http://git-wip-us.apache.org/repos/asf/flink/blob/d313ac76/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/generator/EchoGraphTest.java ---------------------------------------------------------------------- diff --git a/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/generator/EchoGraphTest.java b/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/generator/EchoGraphTest.java index 777b576..fc64d62 100644 --- a/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/generator/EchoGraphTest.java +++ b/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/generator/EchoGraphTest.java @@ -24,14 +24,18 @@ import org.apache.flink.graph.Graph; import org.apache.flink.graph.Vertex; import org.apache.flink.types.LongValue; import org.apache.flink.types.NullValue; + import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import static org.junit.Assert.assertEquals; +/** + * Tests for {@link EchoGraph}. + */ public class EchoGraphTest -extends AbstractGraphTest { +extends GraphGeneratorTestBase { @Rule public ExpectedException thrown = ExpectedException.none(); http://git-wip-us.apache.org/repos/asf/flink/blob/d313ac76/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/generator/EmptyGraphTest.java ---------------------------------------------------------------------- diff --git a/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/generator/EmptyGraphTest.java b/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/generator/EmptyGraphTest.java index c039607..939d871 100644 --- a/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/generator/EmptyGraphTest.java +++ b/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/generator/EmptyGraphTest.java @@ -24,12 +24,16 @@ import org.apache.flink.graph.Graph; import org.apache.flink.graph.Vertex; import org.apache.flink.types.LongValue; import org.apache.flink.types.NullValue; + import org.junit.Test; import static org.junit.Assert.assertEquals; +/** + * Tests for {@link EmptyGraph}. + */ public class EmptyGraphTest -extends AbstractGraphTest { +extends GraphGeneratorTestBase { @Test public void testGraph() http://git-wip-us.apache.org/repos/asf/flink/blob/d313ac76/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/generator/GraphGeneratorTestBase.java ---------------------------------------------------------------------- diff --git a/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/generator/GraphGeneratorTestBase.java b/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/generator/GraphGeneratorTestBase.java new file mode 100644 index 0000000..85a9ef0 --- /dev/null +++ b/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/generator/GraphGeneratorTestBase.java @@ -0,0 +1,36 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.flink.graph.generator; + +import org.apache.flink.api.java.ExecutionEnvironment; + +import org.junit.Before; + +/** + * Base class for graph generator tests. + */ +public abstract class GraphGeneratorTestBase { + + protected ExecutionEnvironment env; + + @Before + public void setup() { + env = ExecutionEnvironment.createCollectionsEnvironment(); + } +} http://git-wip-us.apache.org/repos/asf/flink/blob/d313ac76/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/generator/GridGraphTest.java ---------------------------------------------------------------------- diff --git a/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/generator/GridGraphTest.java b/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/generator/GridGraphTest.java index 6a01a34..c40d456 100644 --- a/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/generator/GridGraphTest.java +++ b/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/generator/GridGraphTest.java @@ -24,12 +24,16 @@ import org.apache.flink.graph.Graph; import org.apache.flink.graph.Vertex; import org.apache.flink.types.LongValue; import org.apache.flink.types.NullValue; + import org.junit.Test; import static org.junit.Assert.assertEquals; +/** + * Tests for {@link GridGraph}. + */ public class GridGraphTest -extends AbstractGraphTest { +extends GraphGeneratorTestBase { @Test public void testGraph() @@ -60,8 +64,8 @@ extends AbstractGraphTest { // Each vertex is the source of one edge in the first dimension of size 2, // and the source of two edges in each dimension of size greater than 2. - assertEquals(2*3*5*7, graph.numberOfVertices()); - assertEquals(7 * 2*3*5*7, graph.numberOfEdges()); + assertEquals(2 * 3 * 5 * 7, graph.numberOfVertices()); + assertEquals(7 * 2 * 3 * 5 * 7, graph.numberOfEdges()); long minInDegree = graph.inDegrees().min(1).collect().get(0).f1.getValue(); long minOutDegree = graph.outDegrees().min(1).collect().get(0).f1.getValue(); http://git-wip-us.apache.org/repos/asf/flink/blob/d313ac76/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/generator/HypercubeGraphTest.java ---------------------------------------------------------------------- diff --git a/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/generator/HypercubeGraphTest.java b/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/generator/HypercubeGraphTest.java index 49b0ba7..05f84cd 100644 --- a/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/generator/HypercubeGraphTest.java +++ b/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/generator/HypercubeGraphTest.java @@ -24,12 +24,16 @@ import org.apache.flink.graph.Graph; import org.apache.flink.graph.Vertex; import org.apache.flink.types.LongValue; import org.apache.flink.types.NullValue; + import org.junit.Test; import static org.junit.Assert.assertEquals; +/** + * Tests for {@link HypercubeGraph}. + */ public class HypercubeGraphTest -extends AbstractGraphTest { +extends GraphGeneratorTestBase { @Test public void testGraph() http://git-wip-us.apache.org/repos/asf/flink/blob/d313ac76/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/generator/PathGraphTest.java ---------------------------------------------------------------------- diff --git a/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/generator/PathGraphTest.java b/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/generator/PathGraphTest.java index b5c7cd3..19b0f25 100644 --- a/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/generator/PathGraphTest.java +++ b/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/generator/PathGraphTest.java @@ -24,12 +24,16 @@ import org.apache.flink.graph.Graph; import org.apache.flink.graph.Vertex; import org.apache.flink.types.LongValue; import org.apache.flink.types.NullValue; + import org.junit.Test; import static org.junit.Assert.assertEquals; +/** + * Tests for {@link PathGraph}. + */ public class PathGraphTest -extends AbstractGraphTest { +extends GraphGeneratorTestBase { @Test public void testGraph() http://git-wip-us.apache.org/repos/asf/flink/blob/d313ac76/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/generator/RMatGraphTest.java ---------------------------------------------------------------------- diff --git a/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/generator/RMatGraphTest.java b/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/generator/RMatGraphTest.java index 2cda69a..920fc4e 100644 --- a/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/generator/RMatGraphTest.java +++ b/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/generator/RMatGraphTest.java @@ -18,7 +18,6 @@ package org.apache.flink.graph.generator; -import org.apache.commons.math3.random.JDKRandomGenerator; import org.apache.flink.api.java.io.DiscardingOutputFormat; import org.apache.flink.graph.Edge; import org.apache.flink.graph.Graph; @@ -27,13 +26,18 @@ import org.apache.flink.graph.generator.random.JDKRandomGeneratorFactory; import org.apache.flink.graph.generator.random.RandomGenerableFactory; import org.apache.flink.types.LongValue; import org.apache.flink.types.NullValue; + +import org.apache.commons.math3.random.JDKRandomGenerator; import org.junit.Test; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; +/** + * Tests for {@link RMatGraph}. + */ public class RMatGraphTest -extends AbstractGraphTest { +extends GraphGeneratorTestBase { @Test public void testGraphMetrics() http://git-wip-us.apache.org/repos/asf/flink/blob/d313ac76/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/generator/SingletonEdgeGraphTest.java ---------------------------------------------------------------------- diff --git a/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/generator/SingletonEdgeGraphTest.java b/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/generator/SingletonEdgeGraphTest.java index 5e9a79a..045354d 100644 --- a/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/generator/SingletonEdgeGraphTest.java +++ b/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/generator/SingletonEdgeGraphTest.java @@ -24,12 +24,16 @@ import org.apache.flink.graph.Graph; import org.apache.flink.graph.Vertex; import org.apache.flink.types.LongValue; import org.apache.flink.types.NullValue; + import org.junit.Test; import static org.junit.Assert.assertEquals; +/** + * Tests for {@link SingletonEdgeGraph}. + */ public class SingletonEdgeGraphTest -extends AbstractGraphTest { +extends GraphGeneratorTestBase { @Test public void testGraph() http://git-wip-us.apache.org/repos/asf/flink/blob/d313ac76/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/generator/StarGraphTest.java ---------------------------------------------------------------------- diff --git a/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/generator/StarGraphTest.java b/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/generator/StarGraphTest.java index 4ccb804..ee9df74 100644 --- a/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/generator/StarGraphTest.java +++ b/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/generator/StarGraphTest.java @@ -24,12 +24,16 @@ import org.apache.flink.graph.Graph; import org.apache.flink.graph.Vertex; import org.apache.flink.types.LongValue; import org.apache.flink.types.NullValue; + import org.junit.Test; import static org.junit.Assert.assertEquals; +/** + * Tests for {@link StarGraph}. + */ public class StarGraphTest -extends AbstractGraphTest { +extends GraphGeneratorTestBase { @Test public void testGraph() http://git-wip-us.apache.org/repos/asf/flink/blob/d313ac76/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/generator/TestUtils.java ---------------------------------------------------------------------- diff --git a/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/generator/TestUtils.java b/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/generator/TestUtils.java index 23ad31c..fd099c0 100644 --- a/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/generator/TestUtils.java +++ b/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/generator/TestUtils.java @@ -35,8 +35,13 @@ import java.util.List; import static org.junit.Assert.assertTrue; +/** + * Utility methods for testing graph algorithms. + */ public final class TestUtils { + private TestUtils() {} + /** * Compare graph vertices and edges against expected values. * http://git-wip-us.apache.org/repos/asf/flink/blob/d313ac76/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/gsa/GSACompilerTest.java ---------------------------------------------------------------------- diff --git a/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/gsa/GSACompilerTest.java b/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/gsa/GSACompilerTest.java index cd677b6..70a2d15 100644 --- a/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/gsa/GSACompilerTest.java +++ b/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/gsa/GSACompilerTest.java @@ -18,10 +18,6 @@ package org.apache.flink.graph.gsa; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - import org.apache.flink.api.common.Plan; import org.apache.flink.api.common.functions.MapFunction; import org.apache.flink.api.common.operators.util.FieldList; @@ -43,75 +39,75 @@ import org.apache.flink.optimizer.plan.WorksetIterationPlanNode; import org.apache.flink.optimizer.util.CompilerTestBase; import org.apache.flink.runtime.operators.shipping.ShipStrategyType; import org.apache.flink.types.NullValue; + import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +/** + * Validate compiled {@link GatherSumApplyIteration} programs. + */ public class GSACompilerTest extends CompilerTestBase { private static final long serialVersionUID = 1L; @Test public void testGSACompiler() { - try { - ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); - env.setParallelism(DEFAULT_PARALLELISM); - // compose test program - { - DataSet> edges = env.fromElements(new Tuple3<>( - 1L, 2L, NullValue.getInstance())).map(new Tuple3ToEdgeMap()); - - Graph graph = Graph.fromDataSet(edges, new InitVertices(), env); - - DataSet> result = graph.runGatherSumApplyIteration( - new GatherNeighborIds(), new SelectMinId(), - new UpdateComponentId(), 100).getVertices(); - - result.output(new DiscardingOutputFormat>()); - } - - Plan p = env.createProgramPlan("GSA Connected Components"); - OptimizedPlan op = compileNoStats(p); - - // check the sink - SinkPlanNode sink = op.getDataSinks().iterator().next(); - assertEquals(ShipStrategyType.FORWARD, sink.getInput().getShipStrategy()); - assertEquals(DEFAULT_PARALLELISM, sink.getParallelism()); - assertEquals(PartitioningProperty.HASH_PARTITIONED, sink.getGlobalProperties().getPartitioning()); - - // check the iteration - WorksetIterationPlanNode iteration = (WorksetIterationPlanNode) sink.getInput().getSource(); - assertEquals(DEFAULT_PARALLELISM, iteration.getParallelism()); - - // check the solution set join and the delta - PlanNode ssDelta = iteration.getSolutionSetDeltaPlanNode(); - assertTrue(ssDelta instanceof DualInputPlanNode); // this is only true if the update function preserves the partitioning - - DualInputPlanNode ssJoin = (DualInputPlanNode) ssDelta; - assertEquals(DEFAULT_PARALLELISM, ssJoin.getParallelism()); - assertEquals(ShipStrategyType.PARTITION_HASH, ssJoin.getInput1().getShipStrategy()); - assertEquals(new FieldList(0), ssJoin.getInput1().getShipStrategyKeys()); - - // check the workset set join - SingleInputPlanNode sumReducer = (SingleInputPlanNode) ssJoin.getInput1().getSource(); - SingleInputPlanNode gatherMapper = (SingleInputPlanNode) sumReducer.getInput().getSource(); - DualInputPlanNode edgeJoin = (DualInputPlanNode) gatherMapper.getInput().getSource(); - assertEquals(DEFAULT_PARALLELISM, edgeJoin.getParallelism()); - // input1 is the workset - assertEquals(ShipStrategyType.FORWARD, edgeJoin.getInput1().getShipStrategy()); - // input2 is the edges - assertEquals(ShipStrategyType.PARTITION_HASH, edgeJoin.getInput2().getShipStrategy()); - assertTrue(edgeJoin.getInput2().getTempMode().isCached()); - - assertEquals(new FieldList(0), edgeJoin.getInput2().getShipStrategyKeys()); - } - catch (Exception e) { - System.err.println(e.getMessage()); - e.printStackTrace(); - fail(e.getMessage()); - } + ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); + env.setParallelism(DEFAULT_PARALLELISM); + + // compose test program + + DataSet> edges = env.fromElements(new Tuple3<>( + 1L, 2L, NullValue.getInstance())).map(new Tuple3ToEdgeMap()); + + Graph graph = Graph.fromDataSet(edges, new InitVertices(), env); + + DataSet> result = graph.runGatherSumApplyIteration( + new GatherNeighborIds(), new SelectMinId(), + new UpdateComponentId(), 100).getVertices(); + + result.output(new DiscardingOutputFormat>()); + + Plan p = env.createProgramPlan("GSA Connected Components"); + OptimizedPlan op = compileNoStats(p); + + // check the sink + SinkPlanNode sink = op.getDataSinks().iterator().next(); + assertEquals(ShipStrategyType.FORWARD, sink.getInput().getShipStrategy()); + assertEquals(DEFAULT_PARALLELISM, sink.getParallelism()); + assertEquals(PartitioningProperty.HASH_PARTITIONED, sink.getGlobalProperties().getPartitioning()); + + // check the iteration + WorksetIterationPlanNode iteration = (WorksetIterationPlanNode) sink.getInput().getSource(); + assertEquals(DEFAULT_PARALLELISM, iteration.getParallelism()); + + // check the solution set join and the delta + PlanNode ssDelta = iteration.getSolutionSetDeltaPlanNode(); + assertTrue(ssDelta instanceof DualInputPlanNode); // this is only true if the update function preserves the partitioning + + DualInputPlanNode ssJoin = (DualInputPlanNode) ssDelta; + assertEquals(DEFAULT_PARALLELISM, ssJoin.getParallelism()); + assertEquals(ShipStrategyType.PARTITION_HASH, ssJoin.getInput1().getShipStrategy()); + assertEquals(new FieldList(0), ssJoin.getInput1().getShipStrategyKeys()); + + // check the workset set join + SingleInputPlanNode sumReducer = (SingleInputPlanNode) ssJoin.getInput1().getSource(); + SingleInputPlanNode gatherMapper = (SingleInputPlanNode) sumReducer.getInput().getSource(); + DualInputPlanNode edgeJoin = (DualInputPlanNode) gatherMapper.getInput().getSource(); + assertEquals(DEFAULT_PARALLELISM, edgeJoin.getParallelism()); + // input1 is the workset + assertEquals(ShipStrategyType.FORWARD, edgeJoin.getInput1().getShipStrategy()); + // input2 is the edges + assertEquals(ShipStrategyType.PARTITION_HASH, edgeJoin.getInput2().getShipStrategy()); + assertTrue(edgeJoin.getInput2().getTempMode().isCached()); + + assertEquals(new FieldList(0), edgeJoin.getInput2().getShipStrategyKeys()); } @SuppressWarnings("serial") - private static final class InitVertices implements MapFunction { + private static final class InitVertices implements MapFunction { public Long map(Long vertexId) { return vertexId; http://git-wip-us.apache.org/repos/asf/flink/blob/d313ac76/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/gsa/GSATranslationTest.java ---------------------------------------------------------------------- diff --git a/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/gsa/GSATranslationTest.java b/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/gsa/GSATranslationTest.java index 2deebcb..0dfbcb7 100644 --- a/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/gsa/GSATranslationTest.java +++ b/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/gsa/GSATranslationTest.java @@ -18,11 +18,6 @@ package org.apache.flink.graph.gsa; -import static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - import org.apache.flink.api.common.aggregators.LongSumAggregator; import org.apache.flink.api.common.functions.MapFunction; import org.apache.flink.api.java.DataSet; @@ -38,98 +33,95 @@ import org.apache.flink.graph.Graph; import org.apache.flink.graph.Vertex; import org.apache.flink.graph.utils.Tuple3ToEdgeMap; import org.apache.flink.types.NullValue; + import org.junit.Test; +import static org.junit.Assert.assertArrayEquals; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +/** + * Test the creation of a {@link GatherSumApplyIteration} program. + */ public class GSATranslationTest { + private static final String ITERATION_NAME = "Test Name"; + + private static final String AGGREGATOR_NAME = "AggregatorName"; + + private static final String BC_SET_GATHER_NAME = "gather messages"; + + private static final String BC_SET_SUM_NAME = "sum updates"; + + private static final String BC_SET_APLLY_NAME = "apply updates"; + + private static final int NUM_ITERATIONS = 13; + + private static final int ITERATION_parallelism = 77; + @Test public void testTranslation() { - try { - final String ITERATION_NAME = "Test Name"; - - final String AGGREGATOR_NAME = "AggregatorName"; - - final String BC_SET_GATHER_NAME = "gather messages"; - - final String BC_SET_SUM_NAME = "sum updates"; - - final String BC_SET_APLLY_NAME = "apply updates"; - - final int NUM_ITERATIONS = 13; - - final int ITERATION_parallelism = 77; - - - ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); - - DataSet bcGather = env.fromElements(1L); - DataSet bcSum = env.fromElements(1L); - DataSet bcApply = env.fromElements(1L); - - DataSet> result; - - // ------------ construct the test program ------------------ - { - - DataSet> edges = env.fromElements(new Tuple3<>( - 1L, 2L, NullValue.getInstance())).map(new Tuple3ToEdgeMap()); - - Graph graph = Graph.fromDataSet(edges, new InitVertices(), env); - - GSAConfiguration parameters = new GSAConfiguration(); - - parameters.registerAggregator(AGGREGATOR_NAME, new LongSumAggregator()); - parameters.setName(ITERATION_NAME); - parameters.setParallelism(ITERATION_parallelism); - parameters.addBroadcastSetForGatherFunction(BC_SET_GATHER_NAME, bcGather); - parameters.addBroadcastSetForSumFunction(BC_SET_SUM_NAME, bcSum); - parameters.addBroadcastSetForApplyFunction(BC_SET_APLLY_NAME, bcApply); - - result = graph.runGatherSumApplyIteration( - new GatherNeighborIds(), new SelectMinId(), - new UpdateComponentId(), NUM_ITERATIONS, parameters).getVertices(); - - result.output(new DiscardingOutputFormat>()); - } - - - // ------------- validate the java program ---------------- - - assertTrue(result instanceof DeltaIterationResultSet); - - DeltaIterationResultSet resultSet = (DeltaIterationResultSet) result; - DeltaIteration iteration = resultSet.getIterationHead(); - - // check the basic iteration properties - assertEquals(NUM_ITERATIONS, resultSet.getMaxIterations()); - assertArrayEquals(new int[] {0}, resultSet.getKeyPositions()); - assertEquals(ITERATION_parallelism, iteration.getParallelism()); - assertEquals(ITERATION_NAME, iteration.getName()); - - assertEquals(AGGREGATOR_NAME, iteration.getAggregators().getAllRegisteredAggregators().iterator().next().getName()); - - // validate that the semantic properties are set as they should - TwoInputUdfOperator solutionSetJoin = (TwoInputUdfOperator) resultSet.getNextWorkset(); - assertTrue(solutionSetJoin.getSemanticProperties().getForwardingTargetFields(0, 0).contains(0)); - assertTrue(solutionSetJoin.getSemanticProperties().getForwardingTargetFields(1, 0).contains(0)); - - SingleInputUdfOperator sumReduce = (SingleInputUdfOperator) solutionSetJoin.getInput1(); - SingleInputUdfOperator gatherMap = (SingleInputUdfOperator) sumReduce.getInput(); - - // validate that the broadcast sets are forwarded - assertEquals(bcGather, gatherMap.getBroadcastSets().get(BC_SET_GATHER_NAME)); - assertEquals(bcSum, sumReduce.getBroadcastSets().get(BC_SET_SUM_NAME)); - assertEquals(bcApply, solutionSetJoin.getBroadcastSets().get(BC_SET_APLLY_NAME)); - } - catch (Exception e) { - System.err.println(e.getMessage()); - e.printStackTrace(); - fail(e.getMessage()); - } + ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); + + DataSet bcGather = env.fromElements(1L); + DataSet bcSum = env.fromElements(1L); + DataSet bcApply = env.fromElements(1L); + + DataSet> result; + + // ------------ construct the test program ------------------ + + DataSet> edges = env.fromElements(new Tuple3<>( + 1L, 2L, NullValue.getInstance())).map(new Tuple3ToEdgeMap()); + + Graph graph = Graph.fromDataSet(edges, new InitVertices(), env); + + GSAConfiguration parameters = new GSAConfiguration(); + + parameters.registerAggregator(AGGREGATOR_NAME, new LongSumAggregator()); + parameters.setName(ITERATION_NAME); + parameters.setParallelism(ITERATION_parallelism); + parameters.addBroadcastSetForGatherFunction(BC_SET_GATHER_NAME, bcGather); + parameters.addBroadcastSetForSumFunction(BC_SET_SUM_NAME, bcSum); + parameters.addBroadcastSetForApplyFunction(BC_SET_APLLY_NAME, bcApply); + + result = graph.runGatherSumApplyIteration( + new GatherNeighborIds(), new SelectMinId(), + new UpdateComponentId(), NUM_ITERATIONS, parameters).getVertices(); + + result.output(new DiscardingOutputFormat>()); + + // ------------- validate the java program ---------------- + + assertTrue(result instanceof DeltaIterationResultSet); + + DeltaIterationResultSet resultSet = (DeltaIterationResultSet) result; + DeltaIteration iteration = resultSet.getIterationHead(); + + // check the basic iteration properties + assertEquals(NUM_ITERATIONS, resultSet.getMaxIterations()); + assertArrayEquals(new int[]{0}, resultSet.getKeyPositions()); + assertEquals(ITERATION_parallelism, iteration.getParallelism()); + assertEquals(ITERATION_NAME, iteration.getName()); + + assertEquals(AGGREGATOR_NAME, iteration.getAggregators().getAllRegisteredAggregators().iterator().next().getName()); + + // validate that the semantic properties are set as they should + TwoInputUdfOperator solutionSetJoin = (TwoInputUdfOperator) resultSet.getNextWorkset(); + assertTrue(solutionSetJoin.getSemanticProperties().getForwardingTargetFields(0, 0).contains(0)); + assertTrue(solutionSetJoin.getSemanticProperties().getForwardingTargetFields(1, 0).contains(0)); + + SingleInputUdfOperator sumReduce = (SingleInputUdfOperator) solutionSetJoin.getInput1(); + SingleInputUdfOperator gatherMap = (SingleInputUdfOperator) sumReduce.getInput(); + + // validate that the broadcast sets are forwarded + assertEquals(bcGather, gatherMap.getBroadcastSets().get(BC_SET_GATHER_NAME)); + assertEquals(bcSum, sumReduce.getBroadcastSets().get(BC_SET_SUM_NAME)); + assertEquals(bcApply, solutionSetJoin.getBroadcastSets().get(BC_SET_APLLY_NAME)); } @SuppressWarnings("serial") - private static final class InitVertices implements MapFunction { + private static final class InitVertices implements MapFunction { public Long map(Long vertexId) { return vertexId; http://git-wip-us.apache.org/repos/asf/flink/blob/d313ac76/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/library/ConnectedComponentsWithRandomisedEdgesITCase.java ---------------------------------------------------------------------- diff --git a/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/library/ConnectedComponentsWithRandomisedEdgesITCase.java b/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/library/ConnectedComponentsWithRandomisedEdgesITCase.java index b602fe6..3e76005 100644 --- a/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/library/ConnectedComponentsWithRandomisedEdgesITCase.java +++ b/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/library/ConnectedComponentsWithRandomisedEdgesITCase.java @@ -31,6 +31,9 @@ import org.apache.flink.types.NullValue; import java.io.BufferedReader; +/** + * Test {@link ConnectedComponents} with a randomly generated graph. + */ @SuppressWarnings("serial") public class ConnectedComponentsWithRandomisedEdgesITCase extends JavaProgramTestBase { @@ -67,7 +70,7 @@ public class ConnectedComponentsWithRandomisedEdgesITCase extends JavaProgramTes /** * A map function that takes a Long value and creates a 2-tuple out of it: - *
(Long value) -> (value, value)
+ *
(Long value) -> (value, value)
. */ public static final class IdAssigner implements MapFunction> { @Override @@ -83,7 +86,7 @@ public class ConnectedComponentsWithRandomisedEdgesITCase extends JavaProgramTes } } - public static final class EdgeParser extends RichMapFunction> { + private static final class EdgeParser extends RichMapFunction> { public Edge map(String value) { String[] nums = value.split(" "); return new Edge<>(Long.parseLong(nums[0]), Long.parseLong(nums[1]), http://git-wip-us.apache.org/repos/asf/flink/blob/d313ac76/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/library/clustering/directed/AverageClusteringCoefficientTest.java ---------------------------------------------------------------------- diff --git a/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/library/clustering/directed/AverageClusteringCoefficientTest.java b/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/library/clustering/directed/AverageClusteringCoefficientTest.java index db0a8a1..6474199 100644 --- a/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/library/clustering/directed/AverageClusteringCoefficientTest.java +++ b/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/library/clustering/directed/AverageClusteringCoefficientTest.java @@ -23,10 +23,14 @@ import org.apache.flink.graph.library.clustering.directed.AverageClusteringCoeff import org.apache.flink.types.IntValue; import org.apache.flink.types.LongValue; import org.apache.flink.types.NullValue; + import org.junit.Test; import static org.junit.Assert.assertEquals; +/** + * Tests for {@link AverageClusteringCoefficient}. + */ public class AverageClusteringCoefficientTest extends AsmTestBase { @@ -34,7 +38,7 @@ extends AsmTestBase { public void testWithSimpleGraph() throws Exception { // see results in LocalClusteringCoefficientTest.testSimpleGraph - Result expectedResult = new Result(6, 1.0/2 + 2.0/6 + 2.0/6 + 1.0/12); + Result expectedResult = new Result(6, 1.0 / 2 + 2.0 / 6 + 2.0 / 6 + 1.0 / 12); Result averageClusteringCoefficient = new AverageClusteringCoefficient() .run(directedSimpleGraph) http://git-wip-us.apache.org/repos/asf/flink/blob/d313ac76/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/library/clustering/directed/GlobalClusteringCoefficientTest.java ---------------------------------------------------------------------- diff --git a/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/library/clustering/directed/GlobalClusteringCoefficientTest.java b/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/library/clustering/directed/GlobalClusteringCoefficientTest.java index 50006fc..d74948a 100644 --- a/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/library/clustering/directed/GlobalClusteringCoefficientTest.java +++ b/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/library/clustering/directed/GlobalClusteringCoefficientTest.java @@ -18,16 +18,20 @@ package org.apache.flink.graph.library.clustering.directed; -import org.apache.commons.math3.util.CombinatoricsUtils; import org.apache.flink.graph.asm.AsmTestBase; import org.apache.flink.graph.library.clustering.directed.GlobalClusteringCoefficient.Result; import org.apache.flink.types.IntValue; import org.apache.flink.types.LongValue; import org.apache.flink.types.NullValue; + +import org.apache.commons.math3.util.CombinatoricsUtils; import org.junit.Test; import static org.junit.Assert.assertEquals; +/** + * Tests for {@link GlobalClusteringCoefficient}. + */ public class GlobalClusteringCoefficientTest extends AsmTestBase { @@ -47,7 +51,7 @@ extends AsmTestBase { public void testWithCompleteGraph() throws Exception { long expectedDegree = completeGraphVertexCount - 1; - long expectedCount = completeGraphVertexCount * CombinatoricsUtils.binomialCoefficient((int)expectedDegree, 2); + long expectedCount = completeGraphVertexCount * CombinatoricsUtils.binomialCoefficient((int) expectedDegree, 2); Result expectedResult = new Result(expectedCount, expectedCount); http://git-wip-us.apache.org/repos/asf/flink/blob/d313ac76/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/library/clustering/directed/LocalClusteringCoefficientTest.java ---------------------------------------------------------------------- diff --git a/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/library/clustering/directed/LocalClusteringCoefficientTest.java b/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/library/clustering/directed/LocalClusteringCoefficientTest.java index f1dd57b..a0aba65 100644 --- a/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/library/clustering/directed/LocalClusteringCoefficientTest.java +++ b/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/library/clustering/directed/LocalClusteringCoefficientTest.java @@ -18,7 +18,6 @@ package org.apache.flink.graph.library.clustering.directed; -import org.apache.commons.math3.util.CombinatoricsUtils; import org.apache.flink.api.java.DataSet; import org.apache.flink.graph.asm.AsmTestBase; import org.apache.flink.graph.asm.dataset.ChecksumHashCode.Checksum; @@ -27,12 +26,17 @@ import org.apache.flink.test.util.TestBaseUtils; import org.apache.flink.types.IntValue; import org.apache.flink.types.LongValue; import org.apache.flink.types.NullValue; + +import org.apache.commons.math3.util.CombinatoricsUtils; import org.junit.Test; import java.util.List; import static org.junit.Assert.assertEquals; +/** + * Tests for {@link LocalClusteringCoefficient}. + */ public class LocalClusteringCoefficientTest extends AsmTestBase { @@ -57,7 +61,7 @@ extends AsmTestBase { public void testCompleteGraph() throws Exception { long expectedDegree = completeGraphVertexCount - 1; - long expectedTriangleCount = 2 * CombinatoricsUtils.binomialCoefficient((int)expectedDegree, 2); + long expectedTriangleCount = 2 * CombinatoricsUtils.binomialCoefficient((int) expectedDegree, 2); DataSet> cc = completeGraph .run(new LocalClusteringCoefficient()); http://git-wip-us.apache.org/repos/asf/flink/blob/d313ac76/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/library/clustering/directed/TriadicCensusTest.java ---------------------------------------------------------------------- diff --git a/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/library/clustering/directed/TriadicCensusTest.java b/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/library/clustering/directed/TriadicCensusTest.java index a4d1560..68d5d9d 100644 --- a/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/library/clustering/directed/TriadicCensusTest.java +++ b/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/library/clustering/directed/TriadicCensusTest.java @@ -18,16 +18,20 @@ package org.apache.flink.graph.library.clustering.directed; -import org.apache.commons.math3.util.CombinatoricsUtils; import org.apache.flink.graph.asm.AsmTestBase; import org.apache.flink.graph.library.clustering.directed.TriadicCensus.Result; import org.apache.flink.types.IntValue; import org.apache.flink.types.LongValue; import org.apache.flink.types.NullValue; + +import org.apache.commons.math3.util.CombinatoricsUtils; import org.junit.Test; import static org.junit.Assert.assertEquals; +/** + * Tests for {@link TriadicCensus}. + */ public class TriadicCensusTest extends AsmTestBase { @@ -59,7 +63,7 @@ extends AsmTestBase { public void testWithCompleteGraph() throws Exception { long expectedDegree = completeGraphVertexCount - 1; - long expectedCount = completeGraphVertexCount * CombinatoricsUtils.binomialCoefficient((int)expectedDegree, 2) / 3; + long expectedCount = completeGraphVertexCount * CombinatoricsUtils.binomialCoefficient((int) expectedDegree, 2) / 3; Result expectedResult = new Result(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, expectedCount); http://git-wip-us.apache.org/repos/asf/flink/blob/d313ac76/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/library/clustering/directed/TriangleListingTest.java ---------------------------------------------------------------------- diff --git a/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/library/clustering/directed/TriangleListingTest.java b/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/library/clustering/directed/TriangleListingTest.java index 3999959..9eacb58 100644 --- a/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/library/clustering/directed/TriangleListingTest.java +++ b/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/library/clustering/directed/TriangleListingTest.java @@ -18,7 +18,6 @@ package org.apache.flink.graph.library.clustering.directed; -import org.apache.commons.math3.util.CombinatoricsUtils; import org.apache.flink.api.java.DataSet; import org.apache.flink.graph.asm.AsmTestBase; import org.apache.flink.graph.asm.dataset.ChecksumHashCode; @@ -28,12 +27,17 @@ import org.apache.flink.test.util.TestBaseUtils; import org.apache.flink.types.IntValue; import org.apache.flink.types.LongValue; import org.apache.flink.types.NullValue; + +import org.apache.commons.math3.util.CombinatoricsUtils; import org.junit.Test; import java.util.List; import static org.junit.Assert.assertEquals; +/** + * Tests for {@link TriangleListing}. + */ public class TriangleListingTest extends AsmTestBase { @@ -55,7 +59,7 @@ extends AsmTestBase { public void testCompleteGraph() throws Exception { long expectedDegree = completeGraphVertexCount - 1; - long expectedCount = completeGraphVertexCount * CombinatoricsUtils.binomialCoefficient((int)expectedDegree, 2) / 3; + long expectedCount = completeGraphVertexCount * CombinatoricsUtils.binomialCoefficient((int) expectedDegree, 2) / 3; DataSet> tl = completeGraph .run(new TriangleListing()); http://git-wip-us.apache.org/repos/asf/flink/blob/d313ac76/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/library/clustering/undirected/AverageClusteringCoefficientTest.java ---------------------------------------------------------------------- diff --git a/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/library/clustering/undirected/AverageClusteringCoefficientTest.java b/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/library/clustering/undirected/AverageClusteringCoefficientTest.java index ee34ac6..0835169 100644 --- a/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/library/clustering/undirected/AverageClusteringCoefficientTest.java +++ b/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/library/clustering/undirected/AverageClusteringCoefficientTest.java @@ -23,10 +23,14 @@ import org.apache.flink.graph.library.clustering.undirected.AverageClusteringCoe import org.apache.flink.types.IntValue; import org.apache.flink.types.LongValue; import org.apache.flink.types.NullValue; + import org.junit.Test; import static org.junit.Assert.assertEquals; +/** + * Tests for {@link AverageClusteringCoefficient}. + */ public class AverageClusteringCoefficientTest extends AsmTestBase { @@ -34,7 +38,7 @@ extends AsmTestBase { public void testWithSimpleGraph() throws Exception { // see results in LocalClusteringCoefficientTest.testSimpleGraph - Result expectedResult = new Result(6, 1.0/1 + 2.0/3 + 2.0/3 + 1.0/6); + Result expectedResult = new Result(6, 1.0 / 1 + 2.0 / 3 + 2.0 / 3 + 1.0 / 6); Result averageClusteringCoefficient = new AverageClusteringCoefficient() .run(undirectedSimpleGraph) http://git-wip-us.apache.org/repos/asf/flink/blob/d313ac76/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/library/clustering/undirected/GlobalClusteringCoefficientTest.java ---------------------------------------------------------------------- diff --git a/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/library/clustering/undirected/GlobalClusteringCoefficientTest.java b/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/library/clustering/undirected/GlobalClusteringCoefficientTest.java index 1a73ce1..d9b0ab5 100644 --- a/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/library/clustering/undirected/GlobalClusteringCoefficientTest.java +++ b/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/library/clustering/undirected/GlobalClusteringCoefficientTest.java @@ -18,16 +18,20 @@ package org.apache.flink.graph.library.clustering.undirected; -import org.apache.commons.math3.util.CombinatoricsUtils; import org.apache.flink.graph.asm.AsmTestBase; import org.apache.flink.graph.library.clustering.undirected.GlobalClusteringCoefficient.Result; import org.apache.flink.types.IntValue; import org.apache.flink.types.LongValue; import org.apache.flink.types.NullValue; + +import org.apache.commons.math3.util.CombinatoricsUtils; import org.junit.Test; import static org.junit.Assert.assertEquals; +/** + * Tests for {@link GlobalClusteringCoefficient}. + */ public class GlobalClusteringCoefficientTest extends AsmTestBase { @@ -47,7 +51,7 @@ extends AsmTestBase { public void testWithCompleteGraph() throws Exception { long expectedDegree = completeGraphVertexCount - 1; - long expectedCount = completeGraphVertexCount * CombinatoricsUtils.binomialCoefficient((int)expectedDegree, 2); + long expectedCount = completeGraphVertexCount * CombinatoricsUtils.binomialCoefficient((int) expectedDegree, 2); Result expectedResult = new Result(expectedCount, expectedCount); http://git-wip-us.apache.org/repos/asf/flink/blob/d313ac76/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/library/clustering/undirected/LocalClusteringCoefficientTest.java ---------------------------------------------------------------------- diff --git a/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/library/clustering/undirected/LocalClusteringCoefficientTest.java b/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/library/clustering/undirected/LocalClusteringCoefficientTest.java index 2775a00..e00669b 100644 --- a/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/library/clustering/undirected/LocalClusteringCoefficientTest.java +++ b/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/library/clustering/undirected/LocalClusteringCoefficientTest.java @@ -18,7 +18,6 @@ package org.apache.flink.graph.library.clustering.undirected; -import org.apache.commons.math3.util.CombinatoricsUtils; import org.apache.flink.api.java.DataSet; import org.apache.flink.graph.asm.AsmTestBase; import org.apache.flink.graph.asm.dataset.ChecksumHashCode; @@ -28,12 +27,17 @@ import org.apache.flink.test.util.TestBaseUtils; import org.apache.flink.types.IntValue; import org.apache.flink.types.LongValue; import org.apache.flink.types.NullValue; + +import org.apache.commons.math3.util.CombinatoricsUtils; import org.junit.Test; import java.util.List; import static org.junit.Assert.assertEquals; +/** + * Tests for {@link LocalClusteringCoefficient}. + */ public class LocalClusteringCoefficientTest extends AsmTestBase { @@ -58,7 +62,7 @@ extends AsmTestBase { public void testCompleteGraph() throws Exception { long expectedDegree = completeGraphVertexCount - 1; - long expectedTriangleCount = CombinatoricsUtils.binomialCoefficient((int)expectedDegree, 2); + long expectedTriangleCount = CombinatoricsUtils.binomialCoefficient((int) expectedDegree, 2); DataSet> cc = completeGraph .run(new LocalClusteringCoefficient()); http://git-wip-us.apache.org/repos/asf/flink/blob/d313ac76/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/library/clustering/undirected/TriadicCensusTest.java ---------------------------------------------------------------------- diff --git a/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/library/clustering/undirected/TriadicCensusTest.java b/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/library/clustering/undirected/TriadicCensusTest.java index 87b4824..38cf981 100644 --- a/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/library/clustering/undirected/TriadicCensusTest.java +++ b/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/library/clustering/undirected/TriadicCensusTest.java @@ -18,16 +18,20 @@ package org.apache.flink.graph.library.clustering.undirected; -import org.apache.commons.math3.util.CombinatoricsUtils; import org.apache.flink.graph.asm.AsmTestBase; import org.apache.flink.graph.library.clustering.undirected.TriadicCensus.Result; import org.apache.flink.types.IntValue; import org.apache.flink.types.LongValue; import org.apache.flink.types.NullValue; + +import org.apache.commons.math3.util.CombinatoricsUtils; import org.junit.Test; import static org.junit.Assert.assertEquals; +/** + * Tests for {@link TriadicCensus}. + */ public class TriadicCensusTest extends AsmTestBase { @@ -47,7 +51,7 @@ extends AsmTestBase { public void testWithCompleteGraph() throws Exception { long expectedDegree = completeGraphVertexCount - 1; - long expectedCount = completeGraphVertexCount * CombinatoricsUtils.binomialCoefficient((int)expectedDegree, 2) / 3; + long expectedCount = completeGraphVertexCount * CombinatoricsUtils.binomialCoefficient((int) expectedDegree, 2) / 3; Result expectedResult = new Result(0, 0, 0, expectedCount); http://git-wip-us.apache.org/repos/asf/flink/blob/d313ac76/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/library/clustering/undirected/TriangleListingTest.java ---------------------------------------------------------------------- diff --git a/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/library/clustering/undirected/TriangleListingTest.java b/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/library/clustering/undirected/TriangleListingTest.java index afbd740..ed9e4c2 100644 --- a/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/library/clustering/undirected/TriangleListingTest.java +++ b/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/library/clustering/undirected/TriangleListingTest.java @@ -18,7 +18,6 @@ package org.apache.flink.graph.library.clustering.undirected; -import org.apache.commons.math3.util.CombinatoricsUtils; import org.apache.flink.api.java.DataSet; import org.apache.flink.graph.asm.AsmTestBase; import org.apache.flink.graph.asm.dataset.ChecksumHashCode; @@ -28,10 +27,15 @@ import org.apache.flink.test.util.TestBaseUtils; import org.apache.flink.types.IntValue; import org.apache.flink.types.LongValue; import org.apache.flink.types.NullValue; + +import org.apache.commons.math3.util.CombinatoricsUtils; import org.junit.Test; import static org.junit.Assert.assertEquals; +/** + * Tests for {@link TriangleListing}. + */ public class TriangleListingTest extends AsmTestBase { @@ -53,7 +57,7 @@ extends AsmTestBase { public void testCompleteGraph() throws Exception { long expectedDegree = completeGraphVertexCount - 1; - long expectedCount = completeGraphVertexCount * CombinatoricsUtils.binomialCoefficient((int)expectedDegree, 2) / 3; + long expectedCount = completeGraphVertexCount * CombinatoricsUtils.binomialCoefficient((int) expectedDegree, 2) / 3; DataSet> tl = completeGraph .run(new TriangleListing()); http://git-wip-us.apache.org/repos/asf/flink/blob/d313ac76/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/library/link_analysis/HITSTest.java ---------------------------------------------------------------------- diff --git a/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/library/link_analysis/HITSTest.java b/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/library/link_analysis/HITSTest.java deleted file mode 100644 index 03334da..0000000 --- a/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/library/link_analysis/HITSTest.java +++ /dev/null @@ -1,144 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.flink.graph.library.link_analysis; - -import org.apache.flink.api.java.DataSet; -import org.apache.flink.api.java.tuple.Tuple2; -import org.apache.flink.graph.asm.AsmTestBase; -import org.apache.flink.graph.asm.dataset.Collect; -import org.apache.flink.graph.library.link_analysis.HITS.Result; -import org.apache.flink.types.IntValue; -import org.apache.flink.types.LongValue; -import org.apache.flink.types.NullValue; -import org.junit.Test; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import static org.junit.Assert.assertEquals; - -public class HITSTest -extends AsmTestBase { - - /* - * This test result can be verified with the following Python script. - - import math - import networkx as nx - - graph=nx.read_edgelist('directedSimpleGraph.csv', delimiter=',', create_using=nx.DiGraph()) - hits=nx.algorithms.link_analysis.hits(graph) - - hubbiness_norm=math.sqrt(sum(v*v for v in hits[0].values())) - authority_norm=math.sqrt(sum(v*v for v in hits[1].values())) - - for key in sorted(hits[0]): - print('{}: {}, {}'.format(key, hits[0][key]/hubbiness_norm, hits[1][key]/authority_norm)) - */ - @Test - public void testWithSimpleGraph() - throws Exception { - DataSet> hits = new HITS(20) - .run(directedSimpleGraph); - - List> expectedResults = new ArrayList<>(); - expectedResults.add(Tuple2.of(0.544643396306, 0.0)); - expectedResults.add(Tuple2.of(0.0, 0.836329395866)); - expectedResults.add(Tuple2.of(0.607227031134, 0.268492526138)); - expectedResults.add(Tuple2.of(0.544643396306, 0.395444899355)); - expectedResults.add(Tuple2.of(0.0, 0.268492526138)); - expectedResults.add(Tuple2.of(0.194942233447, 0.0)); - - for (Result result : hits.collect()) { - int id = result.f0.getValue(); - assertEquals(expectedResults.get(id).f0, result.getHubScore().getValue(), 0.000001); - assertEquals(expectedResults.get(id).f1, result.getAuthorityScore().getValue(), 0.000001); - } - } - - @Test - public void testWithCompleteGraph() - throws Exception { - double expectedScore = 1.0 / Math.sqrt(completeGraphVertexCount); - - DataSet> hits = new HITS(0.000001) - .run(completeGraph); - - List> results = hits.collect(); - - assertEquals(completeGraphVertexCount, results.size()); - - for (Result result : results) { - assertEquals(expectedScore, result.getHubScore().getValue(), 0.000001); - assertEquals(expectedScore, result.getAuthorityScore().getValue(), 0.000001); - } - } - - /* - * This test result can be verified with the following Python script. - - import math - import networkx as nx - - graph=nx.read_edgelist('directedRMatGraph.csv', delimiter=',', create_using=nx.DiGraph()) - hits=nx.algorithms.link_analysis.hits(graph) - - hubbiness_norm=math.sqrt(sum(v*v for v in hits[0].values())) - authority_norm=math.sqrt(sum(v*v for v in hits[1].values())) - - for key in [0, 1, 2, 8, 13, 29, 109, 394, 652, 1020]: - print('{}: {}, {}'.format(key, hits[0][str(key)]/hubbiness_norm, hits[1][str(key)]/authority_norm)) - */ - @Test - public void testWithRMatGraph() - throws Exception { - DataSet> hits = directedRMatGraph(10, 16) - .run(new HITS(0.000001)); - - Map> results = new HashMap<>(); - for (Result result : new Collect>().run(hits).execute()) { - results.put(result.f0.getValue(), result); - } - - assertEquals(902, results.size()); - - Map> expectedResults = new HashMap<>(); - // a pseudo-random selection of results, both high and low - expectedResults.put(0L, Tuple2.of(0.231077034747, 0.238110214937)); - expectedResults.put(1L, Tuple2.of(0.162364053933, 0.169679504287)); - expectedResults.put(2L, Tuple2.of(0.162412612499, 0.161015667261)); - expectedResults.put(8L, Tuple2.of(0.167064641724, 0.158592966505)); - expectedResults.put(13L, Tuple2.of(0.041915595624, 0.0407091625629)); - expectedResults.put(29L, Tuple2.of(0.0102017346511, 0.0146218045999)); - expectedResults.put(109L, Tuple2.of(0.00190531000389, 0.00481944993023)); - expectedResults.put(394L, Tuple2.of(0.0122287016161, 0.0147987969538)); - expectedResults.put(652L, Tuple2.of(0.010966659242, 0.0113713306749)); - expectedResults.put(1020L, Tuple2.of(0.0, 0.000326973732127)); - - for (Map.Entry> expected : expectedResults.entrySet()) { - double hubScore = results.get(expected.getKey()).getHubScore().getValue(); - double authorityScore = results.get(expected.getKey()).getAuthorityScore().getValue(); - - assertEquals(expected.getValue().f0, hubScore, 0.00001); - assertEquals(expected.getValue().f1, authorityScore, 0.00001); - } - } -} http://git-wip-us.apache.org/repos/asf/flink/blob/d313ac76/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/library/link_analysis/PageRankTest.java ---------------------------------------------------------------------- diff --git a/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/library/link_analysis/PageRankTest.java b/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/library/link_analysis/PageRankTest.java deleted file mode 100644 index fc7e485..0000000 --- a/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/library/link_analysis/PageRankTest.java +++ /dev/null @@ -1,135 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.flink.graph.library.link_analysis; - -import org.apache.flink.api.java.DataSet; -import org.apache.flink.api.java.tuple.Tuple2; -import org.apache.flink.graph.asm.AsmTestBase; -import org.apache.flink.graph.asm.dataset.Collect; -import org.apache.flink.graph.library.link_analysis.PageRank.Result; -import org.apache.flink.types.DoubleValue; -import org.apache.flink.types.IntValue; -import org.apache.flink.types.LongValue; -import org.apache.flink.types.NullValue; -import org.junit.Test; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import static org.junit.Assert.assertEquals; - -public class PageRankTest -extends AsmTestBase { - - private static final double DAMPING_FACTOR = 0.85; - - /* - * This test result can be verified with the following Python script. - - import networkx as nx - - graph=nx.read_edgelist('directedSimpleGraph.csv', delimiter=',', create_using=nx.DiGraph()) - pagerank=nx.algorithms.link_analysis.pagerank(graph) - - for key in sorted(pagerank): - print('{}: {}'.format(key, pagerank[key])) - */ - @Test - public void testWithSimpleGraph() - throws Exception { - DataSet> pr = new PageRank(DAMPING_FACTOR, 10) - .run(directedSimpleGraph); - - List expectedResults = new ArrayList<>(); - expectedResults.add(0.09091296131286301); - expectedResults.add(0.27951855944178117); - expectedResults.add(0.12956847924535586); - expectedResults.add(0.22329643739217675); - expectedResults.add(0.18579060129496028); - expectedResults.add(0.09091296131286301); - - for (Tuple2 result : pr.collect()) { - int id = result.f0.getValue(); - assertEquals(expectedResults.get(id), result.f1.getValue(), 0.000001); - } - } - - @Test - public void testWithCompleteGraph() - throws Exception { - double expectedScore = 1.0 / completeGraphVertexCount; - - DataSet> pr = new PageRank(DAMPING_FACTOR, 0.000001) - .run(completeGraph); - - List> results = pr.collect(); - - assertEquals(completeGraphVertexCount, results.size()); - - for (Tuple2 result : results) { - assertEquals(expectedScore, result.f1.getValue(), 0.000001); - } - } - - /* - * This test result can be verified with the following Python script. - - import networkx as nx - - graph=nx.read_edgelist('directedRMatGraph.csv', delimiter=',', create_using=nx.DiGraph()) - pagerank=nx.algorithms.link_analysis.pagerank(graph) - - for key in [0, 1, 2, 8, 13, 29, 109, 394, 652, 1020]: - print('{}: {}'.format(key, pagerank[str(key)])) - */ - @Test - public void testWithRMatGraph() - throws Exception { - DataSet> pr = new PageRank(DAMPING_FACTOR, 0.000001) - .run(directedRMatGraph(10, 16)); - - Map> results = new HashMap<>(); - for (Result result : new Collect>().run(pr).execute()) { - results.put(result.getVertexId0().getValue(), result); - } - - assertEquals(902, results.size()); - - Map expectedResults = new HashMap<>(); - // a pseudo-random selection of results, both high and low - expectedResults.put(0L, 0.027111807822); - expectedResults.put(1L, 0.0132842310382); - expectedResults.put(2L, 0.0121818392504); - expectedResults.put(8L, 0.0115916809743); - expectedResults.put(13L, 0.00183249490033); - expectedResults.put(29L, 0.000848095047082); - expectedResults.put(109L, 0.000308507844048); - expectedResults.put(394L, 0.000828743280246); - expectedResults.put(652L, 0.000684102931253); - expectedResults.put(1020L, 0.000250487135148); - - for (Map.Entry expected : expectedResults.entrySet()) { - double value = results.get(expected.getKey()).getPageRankScore().getValue(); - - assertEquals(expected.getValue(), value, 0.00001); - } - } -}