forked from phil3k3/flink-esper
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request phil3k3#1 from phil3k3/esper-engine-serialization
Esper engine serialization
- Loading branch information
Showing
14 changed files
with
532 additions
and
157 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<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"> | ||
<parent> | ||
<artifactId>flink-esper-parent</artifactId> | ||
<groupId>at.datasciencelabs.research</groupId> | ||
<version>0.0.1-SNAPSHOT</version> | ||
</parent> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<artifactId>flink-esper-test</artifactId> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<artifactId>maven-assembly-plugin</artifactId> | ||
<configuration> | ||
<archive> | ||
<manifest> | ||
<mainClass>at.datasciencelabs.test.FlinkTestClass</mainClass> | ||
</manifest> | ||
</archive> | ||
<descriptorRefs> | ||
<descriptorRef>jar-with-dependencies</descriptorRef> | ||
</descriptorRefs> | ||
</configuration> | ||
<executions> | ||
<execution> | ||
<id>make-assembly</id> <!-- this is used for inheritance merges --> | ||
<phase>package</phase> <!-- bind to the packaging phase --> | ||
<goals> | ||
<goal>single</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>at.datasciencelabs.research</groupId> | ||
<artifactId>flink-esper</artifactId> | ||
<version>${parent.version}</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.apache.flink</groupId> | ||
<artifactId>flink-core</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.apache.flink</groupId> | ||
<artifactId>flink-streaming-java_${scala.binary.version}</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
</dependencies> | ||
</project> |
31 changes: 31 additions & 0 deletions
31
flink-esper-test/src/main/java/at/datasciencelabs/test/FlinkTestClass.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package at.datasciencelabs.test; | ||
|
||
import at.datasciencelabs.Esper; | ||
import at.datasciencelabs.EsperSelectFunction; | ||
import at.datasciencelabs.EsperStream; | ||
import com.espertech.esper.client.EventBean; | ||
import org.apache.flink.streaming.api.datastream.DataStream; | ||
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment; | ||
import org.apache.flink.streaming.api.functions.sink.PrintSinkFunction; | ||
|
||
public class FlinkTestClass { | ||
|
||
public static void main(String[] args) throws Exception { | ||
StreamExecutionEnvironment streamExecutionEnvironment = StreamExecutionEnvironment.getExecutionEnvironment(); | ||
DataStream<String> dataStream = streamExecutionEnvironment.readTextFile("file:///tmp/flink-test"); | ||
|
||
EsperStream<String> esperStream = Esper.pattern(dataStream, "select bytes from String"); | ||
|
||
DataStream<String> result = esperStream.select(new EsperSelectFunction<String>() { | ||
@Override | ||
public String select(EventBean eventBean) throws Exception { | ||
return new String((byte[]) eventBean.get("bytes")); | ||
} | ||
}); | ||
|
||
result.addSink(new PrintSinkFunction<>(true)); | ||
|
||
streamExecutionEnvironment.execute("Kafka 0.10 Example"); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<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"> | ||
<parent> | ||
<artifactId>flink-esper-parent</artifactId> | ||
<groupId>at.datasciencelabs.research</groupId> | ||
<version>0.0.1-SNAPSHOT</version> | ||
</parent> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<artifactId>flink-esper</artifactId> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>com.espertech</groupId> | ||
<artifactId>esper</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.apache.flink</groupId> | ||
<artifactId>flink-core</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.apache.flink</groupId> | ||
<artifactId>flink-streaming-java_${scala.binary.version}</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.apache.flink</groupId> | ||
<artifactId>flink-shaded-guava</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.apache.flink</groupId> | ||
<artifactId>flink-test-utils_${scala.binary.version}</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.apache.flink</groupId> | ||
<artifactId>flink-streaming-java_${scala.binary.version}</artifactId> | ||
<type>test-jar</type> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.apache.flink</groupId> | ||
<artifactId>flink-runtime_${scala.binary.version}</artifactId> | ||
<type>test-jar</type> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.apache.flink</groupId> | ||
<artifactId>flink-statebackend-rocksdb_${scala.binary.version}</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package at.datasciencelabs; | ||
|
||
import org.apache.flink.streaming.api.datastream.DataStream; | ||
|
||
public class Esper { | ||
|
||
public static <IN> EsperStream<IN> pattern(DataStream<IN> dataStream, String query) { | ||
return new EsperStream<IN>(dataStream, query); | ||
} | ||
} |
88 changes: 88 additions & 0 deletions
88
flink-esper/src/main/java/at/datasciencelabs/EsperEngineSerializer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
package at.datasciencelabs; | ||
|
||
import com.espertech.esper.client.EPServiceProvider; | ||
import org.apache.flink.api.common.typeutils.CompatibilityResult; | ||
import org.apache.flink.api.common.typeutils.TypeSerializer; | ||
import org.apache.flink.api.common.typeutils.TypeSerializerConfigSnapshot; | ||
import org.apache.flink.core.memory.DataInputView; | ||
import org.apache.flink.core.memory.DataOutputView; | ||
|
||
import java.io.IOException; | ||
|
||
public class EsperEngineSerializer extends TypeSerializer<EPServiceProvider> { | ||
|
||
@Override | ||
public boolean isImmutableType() { | ||
return false; | ||
} | ||
|
||
@Override | ||
public TypeSerializer<EPServiceProvider> duplicate() { | ||
return this; | ||
} | ||
|
||
@Override | ||
public EPServiceProvider createInstance() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public EPServiceProvider copy(EPServiceProvider from) { | ||
return null; | ||
} | ||
|
||
@Override | ||
public EPServiceProvider copy(EPServiceProvider from, EPServiceProvider reuse) { | ||
return null; | ||
} | ||
|
||
@Override | ||
public int getLength() { | ||
return -1; | ||
} | ||
|
||
@Override | ||
public void serialize(EPServiceProvider record, DataOutputView target) throws IOException { | ||
|
||
} | ||
|
||
@Override | ||
public EPServiceProvider deserialize(DataInputView source) throws IOException { | ||
return null; | ||
} | ||
|
||
@Override | ||
public EPServiceProvider deserialize(EPServiceProvider reuse, DataInputView source) throws IOException { | ||
return null; | ||
} | ||
|
||
@Override | ||
public void copy(DataInputView source, DataOutputView target) throws IOException { | ||
|
||
} | ||
|
||
@Override | ||
public boolean equals(Object obj) { | ||
return false; | ||
} | ||
|
||
@Override | ||
public boolean canEqual(Object obj) { | ||
return false; | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return 0; | ||
} | ||
|
||
@Override | ||
public TypeSerializerConfigSnapshot snapshotConfiguration() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public CompatibilityResult<EPServiceProvider> ensureCompatibility(TypeSerializerConfigSnapshot configSnapshot) { | ||
return null; | ||
} | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.