Search in sources :

Example 41 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 42 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 43 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 44 with LongValue

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;
}
Also used : LongValue(org.apache.flink.types.LongValue)

Example 45 with LongValue

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");
    }
}
Also used : FileInputSplit(org.apache.flink.core.fs.FileInputSplit) Configuration(org.apache.flink.configuration.Configuration) IntValue(org.apache.flink.types.IntValue) DoubleValue(org.apache.flink.types.DoubleValue) LongValue(org.apache.flink.types.LongValue) Value(org.apache.flink.types.Value) StringValue(org.apache.flink.types.StringValue) IOException(java.io.IOException) 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