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 LongValueComparator method compareToReference.
@Override
public int compareToReference(TypeComparator<LongValue> referencedComparator) {
LongValue otherRef = ((LongValueComparator) referencedComparator).reference;
int comp = otherRef.compareTo(reference);
return ascendingComparison ? comp : -comp;
}
use of org.apache.flink.types.LongValue in project flink by apache.
the class GenericCsvInputFormatTest method testLongLongLong.
@Test
public void testLongLongLong() {
try {
final String fileContent = "1,2,3\n3,2,1";
final FileInputSplit split = createTempFile(fileContent);
final Configuration parameters = new Configuration();
format.setFieldDelimiter(",");
format.setFieldTypesGeneric(LongValue.class, LongValue.class, LongValue.class);
format.configure(parameters);
format.open(split);
Value[] values = createLongValues(3);
values = format.nextRecord(values);
assertNotNull(values);
assertEquals(1L, ((LongValue) values[0]).getValue());
assertEquals(2L, ((LongValue) values[1]).getValue());
assertEquals(3L, ((LongValue) values[2]).getValue());
values = format.nextRecord(values);
assertNotNull(values);
assertEquals(3L, ((LongValue) values[0]).getValue());
assertEquals(2L, ((LongValue) values[1]).getValue());
assertEquals(1L, ((LongValue) values[2]).getValue());
assertNull(format.nextRecord(values));
assertTrue(format.reachedEnd());
} catch (Exception ex) {
System.err.println(ex.getMessage());
ex.printStackTrace();
fail("Test erroneous");
}
}
Aggregations