Created
August 26, 2016 00:10
-
-
Save bfabry/1e2c14c60aff3937d6a0245eb89c78e8 to your computer and use it in GitHub Desktop.
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
package clojure_dataflow; | |
import com.google.cloud.dataflow.sdk.transforms.DoFnWithContext; | |
import com.google.cloud.dataflow.sdk.transforms.windowing.BoundedWindow; | |
/** | |
* This class exists because DoFn relies on overriding abstract methods, | |
* but DoFnWithContext relies on overriding and annotating abstract methods, | |
* since annotating classmethods in clojure is a pain, we made this class. | |
* To use this class, extend it using `proxy` and override the abstract methods. | |
*/ | |
public abstract class CljDoFnWithContext<InputT, OutputT> extends DoFnWithContext<InputT, OutputT> { | |
@ProcessElement | |
public void processElement(ProcessContext context, BoundedWindow window) { | |
cljProcessElement(context, window); | |
} | |
@StartBundle | |
public void startBundle(Context context) { | |
cljStartBundle(context); | |
} | |
public abstract void cljProcessElement(ProcessContext context, BoundedWindow window); | |
public abstract void cljStartBundle(Context context); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment