Streaming state (#7348)

This commit is contained in:
WuTao
2020-04-28 10:36:32 +08:00
committed by GitHub
parent be5235d982
commit 32c2055c99
81 changed files with 5670 additions and 20 deletions
+6 -1
View File
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- This file is auto-generated by Bazel from pom_template.xml, do not modify it. -->
<!-- This file is auto-generated by Bazel from pom_template.xml, do not modify it. -->
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
@@ -23,6 +23,11 @@
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.ray</groupId>
<artifactId>streaming-state</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>27.0.1-jre</version>
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
{auto_gen_header}
{auto_gen_header}
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
@@ -22,6 +22,11 @@
<artifactId>ray-api</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.ray</groupId>
<artifactId>streaming-state</artifactId>
<version>${project.version}</version>
</dependency>
{generated_bzl_deps}
</dependencies>
</project>
@@ -1,5 +1,14 @@
package io.ray.streaming.api.context;
import io.ray.streaming.state.backend.KeyStateBackend;
import io.ray.streaming.state.keystate.desc.ListStateDescriptor;
import io.ray.streaming.state.keystate.desc.MapStateDescriptor;
import io.ray.streaming.state.keystate.desc.ValueStateDescriptor;
import io.ray.streaming.state.keystate.state.ListState;
import io.ray.streaming.state.keystate.state.MapState;
import io.ray.streaming.state.keystate.state.ValueState;
import java.util.Map;
/**
* Encapsulate the runtime information of a streaming task.
*/
@@ -11,8 +20,23 @@ public interface RuntimeContext {
int getParallelism();
Long getBatchId();
Long getCheckpointId();
void setCheckpointId(long checkpointId);
Long getMaxBatch();
Map<String, String> getConfig();
void setCurrentKey(Object key);
KeyStateBackend getKeyStateBackend();
void setKeyStateBackend(KeyStateBackend keyStateBackend);
<T> ValueState<T> getValueState(ValueStateDescriptor<T> stateDescriptor);
<T> ListState<T> getListState(ListStateDescriptor<T> stateDescriptor);
<S, T> MapState<S, T> getMapState(MapStateDescriptor<S, T> stateDescriptor);
}
@@ -10,7 +10,6 @@ import io.ray.streaming.operator.StreamOperator;
import java.util.List;
public class SourceOperator<T> extends StreamOperator<SourceFunction<T>> {
private SourceContextImpl sourceContext;
public SourceOperator(SourceFunction<T> function) {
@@ -38,6 +37,7 @@ public class SourceOperator<T> extends StreamOperator<SourceFunction<T>> {
}
class SourceContextImpl implements SourceContext<T> {
private List<Collector> collectors;
public SourceContextImpl(List<Collector> collectors) {