Search in sources :

Example 6 with Checksum

use of org.apache.flink.graph.asm.dataset.ChecksumHashCode.Checksum in project flink by apache.

the class JaccardIndexTest method testRMatGraph.

@Test
public void testRMatGraph() throws Exception {
    long vertexCount = 1 << 8;
    long edgeCount = 8 * vertexCount;
    RandomGenerableFactory<JDKRandomGenerator> rnd = new JDKRandomGeneratorFactory();
    Graph<LongValue, NullValue, NullValue> graph = new RMatGraph<>(env, rnd, vertexCount, edgeCount).generate().run(new Simplify<LongValue, NullValue, NullValue>(false));
    DataSet<Result<LongValue>> ji = graph.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());
}
Also used : JDKRandomGeneratorFactory(org.apache.flink.graph.generator.random.JDKRandomGeneratorFactory) ChecksumHashCode(org.apache.flink.graph.asm.dataset.ChecksumHashCode) Result(org.apache.flink.graph.library.similarity.JaccardIndex.Result) RMatGraph(org.apache.flink.graph.generator.RMatGraph) NullValue(org.apache.flink.types.NullValue) Checksum(org.apache.flink.graph.asm.dataset.ChecksumHashCode.Checksum) LongValue(org.apache.flink.types.LongValue) JDKRandomGenerator(org.apache.commons.math3.random.JDKRandomGenerator) Test(org.junit.Test)

Example 7 with Checksum

use of org.apache.flink.graph.asm.dataset.ChecksumHashCode.Checksum in project flink by apache.

the class TriangleListingTest method testRMatGraph.

@Test
public void testRMatGraph() throws Exception {
    DataSet<Result<LongValue>> tl = directedRMatGraph.run(new TriangleListing<LongValue, NullValue, NullValue>().setSortTriangleVertices(true));
    Checksum checksum = new ChecksumHashCode<Result<LongValue>>().run(tl).execute();
    assertEquals(75049, checksum.getCount());
    assertEquals(0x00000033111f11baL, checksum.getChecksum());
}
Also used : Checksum(org.apache.flink.graph.asm.dataset.ChecksumHashCode.Checksum) LongValue(org.apache.flink.types.LongValue) ChecksumHashCode(org.apache.flink.graph.asm.dataset.ChecksumHashCode) Result(org.apache.flink.graph.library.clustering.directed.TriangleListing.Result) Test(org.junit.Test)

Example 8 with Checksum

use of org.apache.flink.graph.asm.dataset.ChecksumHashCode.Checksum in project flink by apache.

the class ChecksumHashCode method getResult.

@Override
public Checksum getResult() {
    Checksum checksum = vertexChecksum.getResult();
    checksum.add(edgeChecksum.getResult());
    return checksum;
}
Also used : Checksum(org.apache.flink.graph.asm.dataset.ChecksumHashCode.Checksum)

Example 9 with Checksum

use of org.apache.flink.graph.asm.dataset.ChecksumHashCode.Checksum in project flink by apache.

the class VertexInDegreeTest method testWithRMatGraph.

@Test
public void testWithRMatGraph() throws Exception {
    DataSet<Vertex<LongValue, LongValue>> inDegree = directedRMatGraph.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());
}
Also used : Vertex(org.apache.flink.graph.Vertex) Checksum(org.apache.flink.graph.asm.dataset.ChecksumHashCode.Checksum) LongValue(org.apache.flink.types.LongValue) ChecksumHashCode(org.apache.flink.graph.asm.dataset.ChecksumHashCode) Test(org.junit.Test)

Example 10 with Checksum

use of org.apache.flink.graph.asm.dataset.ChecksumHashCode.Checksum in project flink by apache.

the class ChecksumHashCodeTest method testChecksumHashCode.

@Test
public void testChecksumHashCode() throws Exception {
    List<Long> list = Arrays.asList(ArrayUtils.toObject(new long[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }));
    DataSet<Long> dataset = env.fromCollection(list);
    Checksum checksum = new ChecksumHashCode<Long>().run(dataset).execute();
    assertEquals(list.size(), checksum.getCount());
    assertEquals(list.size() * (list.size() - 1) / 2, checksum.getChecksum());
}
Also used : Checksum(org.apache.flink.graph.asm.dataset.ChecksumHashCode.Checksum) Test(org.junit.Test)

Aggregations

Checksum (org.apache.flink.graph.asm.dataset.ChecksumHashCode.Checksum)20 Test (org.junit.Test)19 LongValue (org.apache.flink.types.LongValue)17 ChecksumHashCode (org.apache.flink.graph.asm.dataset.ChecksumHashCode)15 NullValue (org.apache.flink.types.NullValue)13 Edge (org.apache.flink.graph.Edge)6 Tuple2 (org.apache.flink.api.java.tuple.Tuple2)4 Vertex (org.apache.flink.graph.Vertex)4 Degrees (org.apache.flink.graph.asm.degree.annotate.directed.VertexDegrees.Degrees)4 Tuple3 (org.apache.flink.api.java.tuple.Tuple3)2 Result (org.apache.flink.graph.library.clustering.undirected.TriangleListing.Result)2 JDKRandomGenerator (org.apache.commons.math3.random.JDKRandomGenerator)1 RMatGraph (org.apache.flink.graph.generator.RMatGraph)1 JDKRandomGeneratorFactory (org.apache.flink.graph.generator.random.JDKRandomGeneratorFactory)1 Result (org.apache.flink.graph.library.clustering.directed.LocalClusteringCoefficient.Result)1 Result (org.apache.flink.graph.library.clustering.directed.TriangleListing.Result)1 Result (org.apache.flink.graph.library.clustering.undirected.LocalClusteringCoefficient.Result)1 ChecksumHashCode (org.apache.flink.graph.library.metric.ChecksumHashCode)1 Result (org.apache.flink.graph.library.similarity.JaccardIndex.Result)1