Skip to content

Instantly share code, notes, and snippets.

@bfabry
Created August 26, 2016 00:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bfabry/1e2c14c60aff3937d6a0245eb89c78e8 to your computer and use it in GitHub Desktop.
Save bfabry/1e2c14c60aff3937d6a0245eb89c78e8 to your computer and use it in GitHub Desktop.
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