flink streaming-无法解析symbol ValueState


0

我正在尝试使用flink streaming状态后端,请遵循以下指南:https://ci.apache.org/projects/flink/flink-docs-master/api/streaming/state.html,但我得到错误:无法解析符号“ValueState”。

看了一眼之后,我意识到ValueState不在我的依赖项中。相反,只有OperatorState处于org.apache.flink网站.api.common.state(燧石核)。

但是,如果我查看Github,我会在该包中看到ValueState:https://github.com/apache/flink/tree/master/flink-core/src/main/java/org/apache/flink/api/common/state

我猜我要么没有正确版本的flink来使用StateBackend,要么我有正确的版本,但是ValueState已经转移到另一个maven依赖项。

下面是我的pom.xml文件:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>test</groupId>
<artifactId>flink-streaming</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>

<name>flink-streaming</name>
<url>http://maven.apache.org</url>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<!--<flink.version>0.10.2</flink.version>-->
<flink.version>0.10.2</flink.version>
<scala.version>2.11.8</scala.version>
<scala.dependency.version>2.11</scala.dependency.version>
</properties>

<dependencies>
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-library</artifactId>
<version>${scala.version}</version>
</dependency>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-scala_${scala.dependency.version}</artifactId>
<version>${flink.version}</version>
</dependency>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-clients_${scala.dependency.version}</artifactId>
<version>${flink.version}</version>
</dependency>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-streaming-scala_${scala.dependency.version}</artifactId>
<version>${flink.version}</version>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>

    &lt;plugin&gt;
        &lt;groupId&gt;org.scala-tools&lt;/groupId&gt;
        &lt;artifactId&gt;maven-scala-plugin&lt;/artifactId&gt;
        &lt;executions&gt;
            &lt;execution&gt;
                &lt;goals&gt;
                    &lt;goal&gt;compile&lt;/goal&gt;
                    &lt;goal&gt;testCompile&lt;/goal&gt;
                &lt;/goals&gt;
            &lt;/execution&gt;
        &lt;/executions&gt;
        &lt;configuration&gt;
            &lt;jvmArgs&gt;
                &lt;jvmArg&gt;-Xms64m&lt;/jvmArg&gt;
                &lt;jvmArg&gt;-Xmx1024m&lt;/jvmArg&gt;
            &lt;/jvmArgs&gt;
        &lt;/configuration&gt;
    &lt;/plugin&gt;

&lt;/plugins&gt;

</build>

我的代码是:

import org.apache.flink.api.common.functions.RichFlatMapFunction;
import org.apache.flink.api.java.tuple.Tuple2;
import org.apache.flink.util.Collector;


public class CountWindowAverage extends RichFlatMapFunction<Tuple2<Long,Long>, Tuple2<Long,Long>> {
private transient ValueState<Tuple2<Long,Long>> sum;

@Override
public void flatMap(Tuple2&lt;Long,Long&gt; input, Collector&lt;Tuple2&lt;Long,Long&gt;&gt; out) throws Exception {

}

}

提前非常感谢您的帮助!

劳伦特。

1 答案


0

没错,Flink 0.10.x版还没有ValueState。如果您切换到至少1.0.0版,您应该可以。


我来回答

写文章

提问题

面试题