@Override public Collection<IntervalWindow> assignWindows(AssignContext c) { // Assign each element into a window from its timestamp until gapDuration in the // future. Overlapping windows (representing elements within gapDuration of // each other) will be merged. return Arrays.asList(new IntervalWindow(c.timestamp(), gapDuration)); }
@Override public final Collection<W> assignWindows(AssignContext c) { return Arrays.asList(assignWindow(c.timestamp())); }
@Override public Collection<IntervalWindow> assignWindows(AssignContext c) { // Assign each element into a window from its timestamp until the end of // the global window. I'd rather assign to the end of time, but it appears // that any window that exceeds the global window is dropped from the output // received by PAssert. return Arrays.asList(new IntervalWindow(c.timestamp(), GlobalWindow.INSTANCE.maxTimestamp())); }
@Override public Collection<CustomWindow> assignWindows(AssignContext c) throws Exception { String element; // It loses genericity of type T but this is not a big deal for a test. // And it allows to avoid duplicating CustomWindowFn to support PCollection<KV> if (c.element() instanceof KV) { element = ((KV<Integer, String>) c.element()).getValue(); } else { element = (String) c.element(); } // put big elements in windows of 30s and small ones in windows of 5s if ("big".equals(element)) { return Collections.singletonList( new CustomWindow( c.timestamp(), c.timestamp().plus(Duration.standardSeconds(30)), true)); } else { return Collections.singletonList( new CustomWindow( c.timestamp(), c.timestamp().plus(Duration.standardSeconds(5)), false)); } }
@Override public Collection<IntervalWindow> assignWindows(AssignContext c) { return assignWindows(c.timestamp()); }