Search in sources :

Example 6 with GraphCsvReader

use of org.apache.flink.graph.GraphCsvReader in project flink by apache.

the class CSV method create.

@Override
public Graph<K, NullValue, NullValue> create(ExecutionEnvironment env) throws Exception {
    GraphCsvReader reader = Graph.fromCsvReader(inputFilename.getValue(), env).ignoreCommentsEdges(commentPrefix.getValue()).lineDelimiterEdges(lineDelimiter.getValue()).fieldDelimiterEdges(fieldDelimiter.getValue());
    Graph<K, NullValue, NullValue> graph;
    switch(type.getValue()) {
        case INTEGER:
            graph = (Graph<K, NullValue, NullValue>) reader.keyType(IntValue.class);
            break;
        case LONG:
            graph = (Graph<K, NullValue, NullValue>) reader.keyType(LongValue.class);
            break;
        case STRING:
            graph = (Graph<K, NullValue, NullValue>) reader.keyType(StringValue.class);
            break;
        default:
            throw new ProgramParametrizationException("Unknown type '" + type.getValue() + "'");
    }
    return simplify.simplify(graph, parallelism.getValue().intValue());
}
Also used : GraphCsvReader(org.apache.flink.graph.GraphCsvReader) NullValue(org.apache.flink.types.NullValue) ProgramParametrizationException(org.apache.flink.client.program.ProgramParametrizationException)

Aggregations

ProgramParametrizationException (org.apache.flink.client.program.ProgramParametrizationException)6 GraphCsvReader (org.apache.flink.graph.GraphCsvReader)6 NullValue (org.apache.flink.types.NullValue)6 NumberFormat (java.text.NumberFormat)5 JobExecutionResult (org.apache.flink.api.common.JobExecutionResult)5 ExecutionEnvironment (org.apache.flink.api.java.ExecutionEnvironment)5 ParameterTool (org.apache.flink.api.java.utils.ParameterTool)5 Graph (org.apache.flink.graph.Graph)5 LongValueToUnsignedIntValue (org.apache.flink.graph.asm.translate.translators.LongValueToUnsignedIntValue)5 RMatGraph (org.apache.flink.graph.generator.RMatGraph)5 JDKRandomGeneratorFactory (org.apache.flink.graph.generator.random.JDKRandomGeneratorFactory)5 RandomGenerableFactory (org.apache.flink.graph.generator.random.RandomGenerableFactory)5 IntValue (org.apache.flink.types.IntValue)5 LongValue (org.apache.flink.types.LongValue)5 DataSet (org.apache.flink.api.java.DataSet)4 StringValue (org.apache.flink.types.StringValue)4 GraphAnalytic (org.apache.flink.graph.GraphAnalytic)3 TranslateGraphIds (org.apache.flink.graph.asm.translate.TranslateGraphIds)3 Simplify (org.apache.flink.graph.asm.simple.directed.Simplify)1 Result (org.apache.flink.graph.library.similarity.JaccardIndex.Result)1