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());
}
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());
}
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());
}
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);
}
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());
}
Aggregations