org.apache.flink.graph.asm.dataset.ChecksumHashCode.Checksum Java Examples
The following examples show how to use
org.apache.flink.graph.asm.dataset.ChecksumHashCode.Checksum.
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: EdgeTargetDegreeTest.java From flink with Apache License 2.0 | 6 votes |
@Test public void testWithRMatGraph() throws Exception { DataSet<Edge<LongValue, Tuple2<NullValue, LongValue>>> targetDegreeOnTargetId = undirectedRMatGraph(10, 16) .run(new EdgeTargetDegree<LongValue, NullValue, NullValue>() .setReduceOnSourceId(false)); Checksum checksumOnTargetId = new ChecksumHashCode<Edge<LongValue, Tuple2<NullValue, LongValue>>>() .run(targetDegreeOnTargetId) .execute(); assertEquals(20884, checksumOnTargetId.getCount()); assertEquals(0x000000019d8f0070L, checksumOnTargetId.getChecksum()); DataSet<Edge<LongValue, Tuple2<NullValue, LongValue>>> targetDegreeOnSourceId = undirectedRMatGraph(10, 16) .run(new EdgeTargetDegree<LongValue, NullValue, NullValue>() .setReduceOnSourceId(true)); Checksum checksumOnSourceId = new ChecksumHashCode<Edge<LongValue, Tuple2<NullValue, LongValue>>>() .run(targetDegreeOnSourceId) .execute(); assertEquals(checksumOnTargetId, checksumOnSourceId); }
Example #2
Source File: ChecksumHashCode.java From flink with Apache License 2.0 | 6 votes |
@Override public boolean equals(Object obj) { if (obj == null) { return false; } if (obj == this) { return true; } if (obj.getClass() != getClass()) { return false; } Checksum rhs = (Checksum) obj; return new EqualsBuilder() .append(count, rhs.count) .append(checksum, rhs.checksum) .isEquals(); }
Example #3
Source File: EdgeTargetDegreeTest.java From flink with Apache License 2.0 | 6 votes |
@Test public void testWithRMatGraph() throws Exception { DataSet<Edge<LongValue, Tuple2<NullValue, LongValue>>> targetDegreeOnTargetId = undirectedRMatGraph(10, 16) .run(new EdgeTargetDegree<LongValue, NullValue, NullValue>() .setReduceOnSourceId(false)); Checksum checksumOnTargetId = new ChecksumHashCode<Edge<LongValue, Tuple2<NullValue, LongValue>>>() .run(targetDegreeOnTargetId) .execute(); assertEquals(20884, checksumOnTargetId.getCount()); assertEquals(0x000000019d8f0070L, checksumOnTargetId.getChecksum()); DataSet<Edge<LongValue, Tuple2<NullValue, LongValue>>> targetDegreeOnSourceId = undirectedRMatGraph(10, 16) .run(new EdgeTargetDegree<LongValue, NullValue, NullValue>() .setReduceOnSourceId(true)); Checksum checksumOnSourceId = new ChecksumHashCode<Edge<LongValue, Tuple2<NullValue, LongValue>>>() .run(targetDegreeOnSourceId) .execute(); assertEquals(checksumOnTargetId, checksumOnSourceId); }
Example #4
Source File: EdgeSourceDegreeTest.java From flink with Apache License 2.0 | 6 votes |
@Test public void testWithRMatGraph() throws Exception { DataSet<Edge<LongValue, Tuple2<NullValue, LongValue>>> sourceDegreeOnSourceId = undirectedRMatGraph(10, 16) .run(new EdgeSourceDegree<LongValue, NullValue, NullValue>() .setReduceOnTargetId(false)); Checksum checksumOnSourceId = new ChecksumHashCode<Edge<LongValue, Tuple2<NullValue, LongValue>>>() .run(sourceDegreeOnSourceId) .execute(); assertEquals(20884, checksumOnSourceId.getCount()); assertEquals(0x000000019d8f0070L, checksumOnSourceId.getChecksum()); DataSet<Edge<LongValue, Tuple2<NullValue, LongValue>>> sourceDegreeOnTargetId = undirectedRMatGraph(10, 16) .run(new EdgeSourceDegree<LongValue, NullValue, NullValue>() .setReduceOnTargetId(true)); Checksum checksumOnTargetId = new ChecksumHashCode<Edge<LongValue, Tuple2<NullValue, LongValue>>>() .run(sourceDegreeOnTargetId) .execute(); assertEquals(checksumOnTargetId, checksumOnTargetId); }
Example #5
Source File: DriverBaseITCase.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
/** * Simpler variant of {@link #expectedOutput(String[], String)} * that sums the hashCode() of each line of output. * * @param parameters algorithm, input, and output arguments * @param expected expected checksum over lines of output * @throws Exception on error */ protected void expectedOutputChecksum(String[] parameters, Checksum expected) throws Exception { String output = getSystemOutput(parameters); long count = 0; long checksum = 0; for (String line : output.split(System.getProperty("line.separator"))) { if (line.length() > 0) { count++; // convert 32-bit integer to non-negative long checksum += line.hashCode() & 0xffffffffL; } } Assert.assertEquals(expected.getCount(), count); Assert.assertEquals(expected.getChecksum(), checksum); }
Example #6
Source File: CommunityDetectionTest.java From flink with Apache License 2.0 | 6 votes |
@Test public void testWithRMatGraph() throws Exception { Graph<LongValue, Long, Double> result = undirectedRMatGraph(8, 4) .mapVertices(v -> v.getId().getValue(), new TypeHint<Vertex<LongValue, Long>>(){}.getTypeInfo()) .mapEdges(e -> (double) e.getTarget().getValue() - e.getSource().getValue(), new TypeHint<Edge<LongValue, Double>>(){}.getTypeInfo()) .run(new CommunityDetection<>(10, 0.5)); Checksum checksum = new ChecksumHashCode<Vertex<LongValue, Long>>() .run(result.getVertices()) .execute(); assertEquals(184, checksum.getCount()); assertEquals(0x00000000000cdc96L, checksum.getChecksum()); }
Example #7
Source File: TriangleListingITCase.java From flink with Apache License 2.0 | 6 votes |
@Test public void testHashWithDirectedRMatGraph() throws Exception { String expected = "\n" + new Checksum(61410, 0x000077d3e5e69fa3L) + "\n\n" + "Triadic census:\n" + " 003: 1,679,209\n" + " 012: 267,130\n" + " 102: 57,972\n" + " 021d: 8,496\n" + " 021u: 8,847\n" + " 021c: 17,501\n" + " 111d: 13,223\n" + " 111u: 12,865\n" + " 030t: 1,674\n" + " 030c: 572\n" + " 201: 5,678\n" + " 120d: 1,066\n" + " 120u: 896\n" + " 120c: 2,011\n" + " 210: 2,867\n" + " 300: 1,149\n"; expectedOutput(parameters(8, "directed", "hash"), expected); }
Example #8
Source File: ChecksumHashCode.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
@Override public boolean equals(Object obj) { if (obj == null) { return false; } if (obj == this) { return true; } if (obj.getClass() != getClass()) { return false; } Checksum rhs = (Checksum) obj; return new EqualsBuilder() .append(count, rhs.count) .append(checksum, rhs.checksum) .isEquals(); }
Example #9
Source File: TriangleListingITCase.java From flink with Apache License 2.0 | 6 votes |
@Test public void testHashWithDirectedRMatGraph() throws Exception { String expected = "\n" + new Checksum(61410, 0x000077d3e5e69fa3L) + "\n\n" + "Triadic census:\n" + " 003: 1,679,209\n" + " 012: 267,130\n" + " 102: 57,972\n" + " 021d: 8,496\n" + " 021u: 8,847\n" + " 021c: 17,501\n" + " 111d: 13,223\n" + " 111u: 12,865\n" + " 030t: 1,674\n" + " 030c: 572\n" + " 201: 5,678\n" + " 120d: 1,066\n" + " 120u: 896\n" + " 120c: 2,011\n" + " 210: 2,867\n" + " 300: 1,149\n"; expectedOutput(parameters(8, "directed", "hash"), expected); }
Example #10
Source File: EdgeDegreePairTest.java From flink with Apache License 2.0 | 6 votes |
@Test public void testWithRMatGraph() throws Exception { DataSet<Edge<LongValue, Tuple3<NullValue, LongValue, LongValue>>> degreePairOnSourceId = undirectedRMatGraph(10, 16) .run(new EdgeDegreePair<LongValue, NullValue, NullValue>() .setReduceOnTargetId(false)); Checksum checksumOnSourceId = new ChecksumHashCode<Edge<LongValue, Tuple3<NullValue, LongValue, LongValue>>>() .run(degreePairOnSourceId) .execute(); assertEquals(20884, checksumOnSourceId.getCount()); assertEquals(0x00000001e051efe4L, checksumOnSourceId.getChecksum()); DataSet<Edge<LongValue, Tuple3<NullValue, LongValue, LongValue>>> degreePairOnTargetId = undirectedRMatGraph(10, 16) .run(new EdgeDegreePair<LongValue, NullValue, NullValue>() .setReduceOnTargetId(true)); Checksum checksumOnTargetId = new ChecksumHashCode<Edge<LongValue, Tuple3<NullValue, LongValue, LongValue>>>() .run(degreePairOnTargetId) .execute(); assertEquals(checksumOnSourceId, checksumOnTargetId); }
Example #11
Source File: CommunityDetectionTest.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
@Test public void testWithRMatGraph() throws Exception { Graph<LongValue, Long, Double> result = undirectedRMatGraph(8, 4) .mapVertices(v -> v.getId().getValue(), new TypeHint<Vertex<LongValue, Long>>(){}.getTypeInfo()) .mapEdges(e -> (double) e.getTarget().getValue() - e.getSource().getValue(), new TypeHint<Edge<LongValue, Double>>(){}.getTypeInfo()) .run(new CommunityDetection<>(10, 0.5)); Checksum checksum = new ChecksumHashCode<Vertex<LongValue, Long>>() .run(result.getVertices()) .execute(); assertEquals(184, checksum.getCount()); assertEquals(0x00000000000cdc96L, checksum.getChecksum()); }
Example #12
Source File: EdgeDegreePairTest.java From flink with Apache License 2.0 | 6 votes |
@Test public void testWithRMatGraph() throws Exception { DataSet<Edge<LongValue, Tuple3<NullValue, LongValue, LongValue>>> degreePairOnSourceId = undirectedRMatGraph(10, 16) .run(new EdgeDegreePair<LongValue, NullValue, NullValue>() .setReduceOnTargetId(false)); Checksum checksumOnSourceId = new ChecksumHashCode<Edge<LongValue, Tuple3<NullValue, LongValue, LongValue>>>() .run(degreePairOnSourceId) .execute(); assertEquals(20884, checksumOnSourceId.getCount()); assertEquals(0x00000001e051efe4L, checksumOnSourceId.getChecksum()); DataSet<Edge<LongValue, Tuple3<NullValue, LongValue, LongValue>>> degreePairOnTargetId = undirectedRMatGraph(10, 16) .run(new EdgeDegreePair<LongValue, NullValue, NullValue>() .setReduceOnTargetId(true)); Checksum checksumOnTargetId = new ChecksumHashCode<Edge<LongValue, Tuple3<NullValue, LongValue, LongValue>>>() .run(degreePairOnTargetId) .execute(); assertEquals(checksumOnSourceId, checksumOnTargetId); }
Example #13
Source File: CommunityDetectionTest.java From flink with Apache License 2.0 | 6 votes |
@Test public void testWithRMatGraph() throws Exception { Graph<LongValue, Long, Double> result = undirectedRMatGraph(8, 4) .mapVertices(v -> v.getId().getValue(), new TypeHint<Vertex<LongValue, Long>>(){}.getTypeInfo()) .mapEdges(e -> (double) e.getTarget().getValue() - e.getSource().getValue(), new TypeHint<Edge<LongValue, Double>>(){}.getTypeInfo()) .run(new CommunityDetection<>(10, 0.5)); Checksum checksum = new ChecksumHashCode<Vertex<LongValue, Long>>() .run(result.getVertices()) .execute(); assertEquals(184, checksum.getCount()); assertEquals(0x00000000000cdc96L, checksum.getChecksum()); }
Example #14
Source File: EdgeDegreePairTest.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
@Test public void testWithRMatGraph() throws Exception { DataSet<Edge<LongValue, Tuple3<NullValue, LongValue, LongValue>>> degreePairOnSourceId = undirectedRMatGraph(10, 16) .run(new EdgeDegreePair<LongValue, NullValue, NullValue>() .setReduceOnTargetId(false)); Checksum checksumOnSourceId = new ChecksumHashCode<Edge<LongValue, Tuple3<NullValue, LongValue, LongValue>>>() .run(degreePairOnSourceId) .execute(); assertEquals(20884, checksumOnSourceId.getCount()); assertEquals(0x00000001e051efe4L, checksumOnSourceId.getChecksum()); DataSet<Edge<LongValue, Tuple3<NullValue, LongValue, LongValue>>> degreePairOnTargetId = undirectedRMatGraph(10, 16) .run(new EdgeDegreePair<LongValue, NullValue, NullValue>() .setReduceOnTargetId(true)); Checksum checksumOnTargetId = new ChecksumHashCode<Edge<LongValue, Tuple3<NullValue, LongValue, LongValue>>>() .run(degreePairOnTargetId) .execute(); assertEquals(checksumOnSourceId, checksumOnTargetId); }
Example #15
Source File: VertexDegreeTest.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
@Test public void testWithRMatGraph() throws Exception { DataSet<Vertex<LongValue, LongValue>> degreeOnSourceId = undirectedRMatGraph(10, 16) .run(new VertexDegree<LongValue, NullValue, NullValue>() .setReduceOnTargetId(false)); Checksum checksumOnSourceId = new ChecksumHashCode<Vertex<LongValue, LongValue>>() .run(degreeOnSourceId) .execute(); assertEquals(902, checksumOnSourceId.getCount()); assertEquals(0x0000000000e1fb30L, checksumOnSourceId.getChecksum()); DataSet<Vertex<LongValue, LongValue>> degreeOnTargetId = undirectedRMatGraph(10, 16) .run(new VertexDegree<LongValue, NullValue, NullValue>() .setReduceOnTargetId(true)); Checksum checksumOnTargetId = new ChecksumHashCode<Vertex<LongValue, LongValue>>() .run(degreeOnTargetId) .execute(); assertEquals(checksumOnSourceId, checksumOnTargetId); }
Example #16
Source File: DriverBaseITCase.java From flink with Apache License 2.0 | 6 votes |
/** * Simpler variant of {@link #expectedOutput(String[], String)} * that sums the hashCode() of each line of output. * * @param parameters algorithm, input, and output arguments * @param expected expected checksum over lines of output * @throws Exception on error */ protected void expectedOutputChecksum(String[] parameters, Checksum expected) throws Exception { String output = getSystemOutput(parameters); long count = 0; long checksum = 0; for (String line : output.split(System.getProperty("line.separator"))) { if (line.length() > 0) { count++; // convert 32-bit integer to non-negative long checksum += line.hashCode() & 0xffffffffL; } } Assert.assertEquals(expected.getCount(), count); Assert.assertEquals(expected.getChecksum(), checksum); }
Example #17
Source File: EdgeSourceDegreeTest.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
@Test public void testWithRMatGraph() throws Exception { DataSet<Edge<LongValue, Tuple2<NullValue, LongValue>>> sourceDegreeOnSourceId = undirectedRMatGraph(10, 16) .run(new EdgeSourceDegree<LongValue, NullValue, NullValue>() .setReduceOnTargetId(false)); Checksum checksumOnSourceId = new ChecksumHashCode<Edge<LongValue, Tuple2<NullValue, LongValue>>>() .run(sourceDegreeOnSourceId) .execute(); assertEquals(20884, checksumOnSourceId.getCount()); assertEquals(0x000000019d8f0070L, checksumOnSourceId.getChecksum()); DataSet<Edge<LongValue, Tuple2<NullValue, LongValue>>> sourceDegreeOnTargetId = undirectedRMatGraph(10, 16) .run(new EdgeSourceDegree<LongValue, NullValue, NullValue>() .setReduceOnTargetId(true)); Checksum checksumOnTargetId = new ChecksumHashCode<Edge<LongValue, Tuple2<NullValue, LongValue>>>() .run(sourceDegreeOnTargetId) .execute(); assertEquals(checksumOnTargetId, checksumOnTargetId); }
Example #18
Source File: EdgeListITCase.java From flink with Apache License 2.0 | 5 votes |
@Test public void testPrintWithDirectedRMatGraph() throws Exception { // skip 'char' since it is not printed as a number Assume.assumeFalse(idType.equals("char") || idType.equals("nativeChar")); expectedOutputChecksum(getRMatGraphParameters("print", "directed"), new Checksum(1168, 0x0000020e35b0f35dL)); }
Example #19
Source File: VertexOutDegreeTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testWithRMatGraph() throws Exception { DataSet<Vertex<LongValue, LongValue>> outDegree = directedRMatGraph(10, 16) .run(new VertexOutDegree<LongValue, NullValue, NullValue>() .setIncludeZeroDegreeVertices(true)); Checksum checksum = new ChecksumHashCode<Vertex<LongValue, LongValue>>() .run(outDegree) .execute(); assertEquals(902, checksum.getCount()); assertEquals(0x0000000000e1d885L, checksum.getChecksum()); }
Example #20
Source File: TriangleListingTest.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Test public void testCompleteGraph() throws Exception { long expectedDegree = completeGraphVertexCount - 1; long expectedCount = completeGraphVertexCount * CombinatoricsUtils.binomialCoefficient((int) expectedDegree, 2) / 3; DataSet<Result<LongValue>> tl = completeGraph .run(new TriangleListing<>()); Checksum checksum = new ChecksumHashCode<Result<LongValue>>() .run(tl) .execute(); assertEquals(expectedCount, checksum.getCount()); }
Example #21
Source File: VertexDegreesTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testWithRMatGraph() throws Exception { DataSet<Vertex<LongValue, Degrees>> degrees = directedRMatGraph(10, 16) .run(new VertexDegrees<>()); Checksum checksum = new ChecksumHashCode<Vertex<LongValue, Degrees>>() .run(degrees) .execute(); assertEquals(902, checksum.getCount()); assertEquals(0x000001a3305dd86aL, checksum.getChecksum()); }
Example #22
Source File: EdgeSourceDegreesTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testWithRMatGraph() throws Exception { DataSet<Edge<LongValue, Tuple2<NullValue, Degrees>>> sourceDegrees = directedRMatGraph(10, 16) .run(new EdgeSourceDegrees<>()); Checksum checksum = new ChecksumHashCode<Edge<LongValue, Tuple2<NullValue, Degrees>>>() .run(sourceDegrees) .execute(); assertEquals(12009, checksum.getCount()); assertEquals(0x0000162435fde1d9L, checksum.getChecksum()); }
Example #23
Source File: TriangleListingTest.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Test public void testRMatGraph() throws Exception { DataSet<Result<LongValue>> tl = directedRMatGraph(10, 16) .run(new TriangleListing<LongValue, NullValue, NullValue>() .setSortTriangleVertices(true)); Checksum checksum = new ChecksumHashCode<Result<LongValue>>() .run(tl) .execute(); assertEquals(75049, checksum.getCount()); assertEquals(0x000092399c79299eL, checksum.getChecksum()); }
Example #24
Source File: TriangleListingITCase.java From flink with Apache License 2.0 | 5 votes |
@Test public void testHashWithUndirectedRMatGraph() throws Exception { String expected = "\n" + new Checksum(61410, 0x000077ea1798a4e0L) + "\n\n" + "Triadic census:\n" + " 03: 1,679,209\n" + " 12: 325,102\n" + " 21: 66,610\n" + " 30: 10,235\n"; expectedOutput(parameters(8, "undirected", "hash"), expected); }
Example #25
Source File: JaccardIndexTest.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Test public void testWithRMatGraph() throws Exception { DataSet<Result<LongValue>> ji = undirectedRMatGraph(8, 8) .run(new JaccardIndex<LongValue, NullValue, NullValue>() .setGroupSize(4)); Checksum checksum = new ChecksumHashCode<Result<LongValue>>() .run(ji) .execute(); assertEquals(13954, checksum.getCount()); assertEquals(0x00001b1a1f7a9d0bL, checksum.getChecksum()); }
Example #26
Source File: JaccardIndexITCase.java From flink with Apache License 2.0 | 5 votes |
@Test public void testPrintWithRMatGraph() throws Exception { // skip 'char' since it is not printed as a number Assume.assumeFalse(idType.equals("char") || idType.equals("nativeChar")); expectedOutputChecksum(parameters(8, "print"), new Checksum(39276, 0x00004c5a726220c0L)); }
Example #27
Source File: ChecksumHashCodeTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testSmallGraph() throws Exception { Graph<Long, Long, Long> graph = Graph.fromDataSet( TestGraphUtils.getLongLongVertexData(env), TestGraphUtils.getLongLongEdgeData(env), env); Checksum checksum = graph .run(new ChecksumHashCode<>()) .execute(); assertEquals(12, checksum.getCount()); assertEquals(0x4cd1, checksum.getChecksum()); }
Example #28
Source File: EdgeListITCase.java From flink with Apache License 2.0 | 5 votes |
@Test public void testPrintWithGridGraph() throws Exception { // skip 'char' since it is not printed as a number Assume.assumeFalse(idType.equals("char") || idType.equals("nativeChar")); expectedOutputChecksum(getGridGraphParameters("print"), new Checksum(130, 0x00000033237d24eeL)); }
Example #29
Source File: VertexInDegreeTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testWithRMatGraph() throws Exception { DataSet<Vertex<LongValue, LongValue>> inDegree = directedRMatGraph(10, 16) .run(new VertexInDegree<LongValue, NullValue, NullValue>() .setIncludeZeroDegreeVertices(true)); Checksum checksum = new ChecksumHashCode<Vertex<LongValue, LongValue>>() .run(inDegree) .execute(); assertEquals(902, checksum.getCount()); assertEquals(0x0000000000e1d885L, checksum.getChecksum()); }
Example #30
Source File: ChecksumHashCodeTest.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Test public void testSmallGraph() throws Exception { Graph<Long, Long, Long> graph = Graph.fromDataSet( TestGraphUtils.getLongLongVertexData(env), TestGraphUtils.getLongLongEdgeData(env), env); Checksum checksum = graph .run(new ChecksumHashCode<>()) .execute(); assertEquals(12, checksum.getCount()); assertEquals(0x4cd1, checksum.getChecksum()); }