新しいWindowFnを作成するには、WindowFnまたはサブクラスから継承し、さまざまな抽象メソッドをオーバーライドするだけです。
あなたのケースでは、あなたがNonMergingWindowFnから継承することができるようにあなたは、ウィンドウのマージを必要としない、とあなたのコードが
public class MyWindowFn extends NonMergingWindowFn<ElementT, IntervalWindow> {
public Collection<W> assignWindows(AssignContext c) {
return setOfWindowsElementShouldBeIn(c.element());
}
public boolean isCompatible(WindowFn other) {
return other instanceof MyWindowFn;
}
public Coder<IntervalWindow> windowCoder() {
return IntervalWindow.getCoder();
}
public W getSideInputWindow(final BoundedWindow window) {
// You may not need this if you won't ever be using PCollections windowed
// with this as side inputs. If that's the case, just throw.
// Otherwise you'll need to figure out how to map the main input windows
// into the windows generated by this WindowFn.
}
}
のようになります