Search in sources :

Example 46 with LongValue

use of org.apache.flink.types.LongValue in project flink by apache.

the class TriangleListingTest method testCompleteGraph.

@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<LongValue, NullValue, NullValue>());
    Checksum checksum = new ChecksumHashCode<Result<LongValue>>().run(tl).execute();
    assertEquals(expectedCount, checksum.getCount());
}
Also used : NullValue(org.apache.flink.types.NullValue) 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.undirected.TriangleListing.Result) Test(org.junit.Test)

Example 47 with LongValue

use of org.apache.flink.types.LongValue in project flink by apache.

the class TriangleListingTest method testRMatGraph.

@Test
public void testRMatGraph() throws Exception {
    DataSet<Result<LongValue>> tl = undirectedRMatGraph.run(new TriangleListing<LongValue, NullValue, NullValue>().setSortTriangleVertices(true));
    Checksum checksum = new ChecksumHashCode<Result<LongValue>>().run(tl).execute();
    assertEquals(75049, checksum.getCount());
    assertEquals(0x00000001a5b500afL, 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.undirected.TriangleListing.Result) Test(org.junit.Test)

Example 48 with LongValue

use of org.apache.flink.types.LongValue in project flink by apache.

the class LocalClusteringCoefficientTest method testRMatGraph.

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

Example 49 with LongValue

use of org.apache.flink.types.LongValue in project flink by apache.

the class VertexMetricsTest method testWithEmptyGraph.

@Test
public void testWithEmptyGraph() throws Exception {
    Result expectedResult;
    expectedResult = new Result(0, 0, 0, 0, 0);
    Result withoutZeroDegreeVertices = new VertexMetrics<LongValue, NullValue, NullValue>().setIncludeZeroDegreeVertices(false).run(emptyGraph).execute();
    assertEquals(expectedResult, withoutZeroDegreeVertices);
    assertEquals(Float.NaN, withoutZeroDegreeVertices.getAverageDegree(), ACCURACY);
    assertEquals(Float.NaN, withoutZeroDegreeVertices.getDensity(), ACCURACY);
    expectedResult = new Result(3, 0, 0, 0, 0);
    Result withZeroDegreeVertices = new VertexMetrics<LongValue, NullValue, NullValue>().setIncludeZeroDegreeVertices(true).run(emptyGraph).execute();
    assertEquals(expectedResult, withZeroDegreeVertices);
    assertEquals(0.0f, withZeroDegreeVertices.getAverageDegree(), ACCURACY);
    assertEquals(0.0f, withZeroDegreeVertices.getDensity(), ACCURACY);
}
Also used : NullValue(org.apache.flink.types.NullValue) LongValue(org.apache.flink.types.LongValue) Result(org.apache.flink.graph.library.metric.undirected.VertexMetrics.Result) Test(org.junit.Test)

Example 50 with LongValue

use of org.apache.flink.types.LongValue in project flink by apache.

the class EventWithAggregatorsTest method testSerializationOfEventWithAggregateValues.

@Test
public void testSerializationOfEventWithAggregateValues() {
    StringValue stringValue = new StringValue("test string");
    LongValue longValue = new LongValue(68743254);
    String stringValueName = "stringValue";
    String longValueName = "longValue";
    Aggregator<StringValue> stringAgg = new TestAggregator<StringValue>(stringValue);
    Aggregator<LongValue> longAgg = new TestAggregator<LongValue>(longValue);
    Map<String, Aggregator<?>> aggMap = new HashMap<String, Aggregator<?>>();
    aggMap.put(stringValueName, stringAgg);
    aggMap.put(longValueName, longAgg);
    Set<String> allNames = new HashSet<String>();
    allNames.add(stringValueName);
    allNames.add(longValueName);
    Set<Value> allVals = new HashSet<Value>();
    allVals.add(stringValue);
    allVals.add(longValue);
    // run the serialization
    AllWorkersDoneEvent e = new AllWorkersDoneEvent(aggMap);
    IterationEventWithAggregators deserialized = pipeThroughSerialization(e);
    // verify the result
    String[] names = deserialized.getAggregatorNames();
    Value[] aggregates = deserialized.getAggregates(cl);
    Assert.assertEquals(allNames.size(), names.length);
    Assert.assertEquals(allVals.size(), aggregates.length);
    // check that all the correct names and values are returned
    for (String s : names) {
        allNames.remove(s);
    }
    for (Value v : aggregates) {
        allVals.remove(v);
    }
    Assert.assertTrue(allNames.isEmpty());
    Assert.assertTrue(allVals.isEmpty());
}
Also used : HashMap(java.util.HashMap) Aggregator(org.apache.flink.api.common.aggregators.Aggregator) LongValue(org.apache.flink.types.LongValue) LongValue(org.apache.flink.types.LongValue) Value(org.apache.flink.types.Value) StringValue(org.apache.flink.types.StringValue) StringValue(org.apache.flink.types.StringValue) HashSet(java.util.HashSet) Test(org.junit.Test)

Aggregations

LongValue (org.apache.flink.types.LongValue)50 Test (org.junit.Test)33 NullValue (org.apache.flink.types.NullValue)23 Checksum (org.apache.flink.graph.asm.dataset.ChecksumHashCode.Checksum)17 ChecksumHashCode (org.apache.flink.graph.asm.dataset.ChecksumHashCode)15 Edge (org.apache.flink.graph.Edge)13 StringValue (org.apache.flink.types.StringValue)13 ExecutionEnvironment (org.apache.flink.api.java.ExecutionEnvironment)12 Vertex (org.apache.flink.graph.Vertex)11 IntValue (org.apache.flink.types.IntValue)9 Tuple2 (org.apache.flink.api.java.tuple.Tuple2)7 JDKRandomGeneratorFactory (org.apache.flink.graph.generator.random.JDKRandomGeneratorFactory)7 NumberFormat (java.text.NumberFormat)6 JobExecutionResult (org.apache.flink.api.common.JobExecutionResult)6 Tuple3 (org.apache.flink.api.java.tuple.Tuple3)6 ParameterTool (org.apache.flink.api.java.utils.ParameterTool)6 ProgramParametrizationException (org.apache.flink.client.program.ProgramParametrizationException)6 RMatGraph (org.apache.flink.graph.generator.RMatGraph)6 Graph (org.apache.flink.graph.Graph)5 GraphCsvReader (org.apache.flink.graph.GraphCsvReader)5