简体   繁体   English

在apache flink中使用DataSet的collect()函数的问题

[英]Problem with using collect() function of DataSet in apache flink

I am trying to calculate the AdamicAdar index of relations in a Social Media following graph.我正在尝试计算以下图表中社交媒体中的 AdamicAdar 关系指数。 I set up my Edges, Vertices, Dataset and Graph, using apache flink-gelly lirbrarie.我使用 apache flink-gelly lirbrarie 设置了我的 Edges、Vertices、Dataset 和 Graph。 Here is my code:这是我的代码:



    import org.apache.flink.api.java.ExecutionEnvironment;
    import org.apache.flink.api.java.operators.DataSource;
    import org.apache.flink.api.java.tuple.Tuple2;
    import org.apache.flink.graph.Graph;
    import org.apache.flink.graph.library.similarity.AdamicAdar;
    import org.apache.flink.types.NullValue;
    import org.apache.flink.types.StringValue;
    
    import java.util.List;
    
    public class MyMain {
    
        public static void main(String[] args) {
    
            ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
            DataSource> edgeDataSet = env.
                    readCsvFile(String.valueOf(MyMain.class.getResource("dataset/edges.csv"))).
                    types(StringValue.class, StringValue.class);
            Graph graph = Graph.fromTuple2DataSet(edgeDataSet, env);
    
            List list = null;
            try {
                list = graph.run(new AdamicAdar()).collect();
            } catch (Exception e) {
                e.printStackTrace();
            }
    
            System.out.println(list.get(0));
        }
    }

and here is the error I get:这是我得到的错误:



    Exception in thread "main" java.lang.NoSuchMethodError: org.apache.flink.configuration.ConfigUtils.decodeListFromConfig(Lorg/apache/flink/configuration/ReadableConfig;Lorg/apache/flink/configuration/ConfigOption;Lorg/apache/flink/util/function/FunctionWithException;)Ljava/util/List;
        at org.apache.flink.client.cli.ExecutionConfigAccessor.getJars(ExecutionConfigAccessor.java:75)
        at org.apache.flink.client.deployment.executors.PipelineExecutorUtils.getJobGraph(PipelineExecutorUtils.java:61)
        at org.apache.flink.client.deployment.executors.LocalExecutor.getJobGraph(LocalExecutor.java:98)
        at org.apache.flink.client.deployment.executors.LocalExecutor.execute(LocalExecutor.java:79)
        at org.apache.flink.api.java.ExecutionEnvironment.executeAsync(ExecutionEnvironment.java:962)
        at org.apache.flink.api.java.ExecutionEnvironment.execute(ExecutionEnvironment.java:878)
        at org.apache.flink.api.java.ExecutionEnvironment.execute(ExecutionEnvironment.java:862)
        at org.apache.flink.api.java.DataSet.collect(DataSet.java:413)
        at MyMain.main(MyMain.java:23)
    
    Process finished with exit code 1

Also this is a part of edges.csv file I use:这也是我使用的edges.csv文件的一部分:



    5 122
    5 156
    5 158
    5 169
    5 180
    5 187
    5 204
    5 213
    5 235
    5 315
    5 316
    6 89
    6 95
    6 147
    6 219
    6 319
    7 22

in which 5 316 means vertex number five is connected to vertex number 216 and this defines an edge.其中 5 316 表示第 5 个顶点连接到第 216 个顶点,这定义了一条边。

And here is my pom.xml file pom.xml这是我的 pom.xml 文件pom.xml

A NoSuchMethodError usually means there's a version mismatch in your dependencies. NoSuchMethodError通常意味着您的依赖项中存在版本不匹配。 Looking at your pom.xml you've got what appears to be a mixture of different versions of your Flink related libraries.查看您的pom.xml您似乎看到了 Flink 相关库的不同版本的混合。

As an aside, I also noticed that your .csv is not comma separated.顺便说.csv ,我还注意到您的.csv不是逗号分隔的。 You may want to simplify the program and verify that edgeDataset is actually a 2-Tuple and not a single value.您可能希望简化程序并验证edgeDataset实际上是一个 2-Tuple 而不是单个值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM