use of org.apache.flink.types.LongValue in project flink by apache.
the class TranslateTest method testTranslateGraphIds.
@Test
public void testTranslateGraphIds() throws Exception {
Graph<StringValue, LongValue, LongValue> stringIdGraph = graph.translateGraphIds(new LongValueToStringValue());
for (Vertex<StringValue, LongValue> vertex : stringIdGraph.getVertices().collect()) {
assertEquals(StringValue.class, vertex.f0.getClass());
assertEquals(LongValue.class, vertex.f1.getClass());
}
for (Edge<StringValue, LongValue> edge : stringIdGraph.getEdges().collect()) {
assertEquals(StringValue.class, edge.f0.getClass());
assertEquals(StringValue.class, edge.f1.getClass());
assertEquals(LongValue.class, edge.f2.getClass());
}
TestBaseUtils.compareResultAsText(stringIdGraph.getVertices().collect(), expectedVertexResult);
TestBaseUtils.compareResultAsText(stringIdGraph.getEdges().collect(), expectedEdgeResult);
}
use of org.apache.flink.types.LongValue in project flink by apache.
the class LongValueAddOffsetTest method testTranslation.
@Test
public void testTranslation() throws Exception {
LongValue reuse = new LongValue();
assertEquals(new LongValue(0), new LongValueAddOffset(0).translate(new LongValue(0), reuse));
assertEquals(new LongValue(3), new LongValueAddOffset(1).translate(new LongValue(2), reuse));
assertEquals(new LongValue(1), new LongValueAddOffset(-1).translate(new LongValue(2), reuse));
assertEquals(new LongValue(-1), new LongValueAddOffset(Long.MIN_VALUE).translate(new LongValue(Long.MAX_VALUE), reuse));
assertEquals(new LongValue(-1), new LongValueAddOffset(Long.MAX_VALUE).translate(new LongValue(Long.MIN_VALUE), reuse));
// underflow wraps to positive values
assertEquals(new LongValue(Long.MAX_VALUE), new LongValueAddOffset(-1).translate(new LongValue(Long.MIN_VALUE), reuse));
assertEquals(new LongValue(0), new LongValueAddOffset(Long.MIN_VALUE).translate(new LongValue(Long.MIN_VALUE), reuse));
// overflow wraps to negative values
assertEquals(new LongValue(Long.MIN_VALUE), new LongValueAddOffset(1).translate(new LongValue(Long.MAX_VALUE), reuse));
assertEquals(new LongValue(-2), new LongValueAddOffset(Long.MAX_VALUE).translate(new LongValue(Long.MAX_VALUE), reuse));
}
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, 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, 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 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());
}
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 = 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());
}
Aggregations