@Override public Iterable<TimeInterval> assignWindowsToElement(WindowedElement<?, T> input) { return Collections.singleton(new TimeInterval(0, Long.MAX_VALUE)); }
@Override public Iterable<TimeInterval> assignWindowsToElement(WindowedElement<?, T> input) { return Collections.singleton(new TimeInterval(0, Long.MAX_VALUE)); }
/** * Returns the minimal window covers both this window and the given window. */ TimeInterval cover(TimeInterval that) { return new TimeInterval( Math.min(this.startMillis, that.startMillis), Math.max(this.endMillis, that.endMillis)); }
/** * Returns the minimal window covers both this window and the given window. */ TimeInterval cover(TimeInterval that) { return new TimeInterval( Math.min(this.startMillis, that.startMillis), Math.max(this.endMillis, that.endMillis)); }
@Override protected TimeInterval computeNext() { TimeInterval window = null; if (start > elementStamp - duration) { window = new TimeInterval(start, start + duration); start -= slide; } else { endOfData(); } return window; } };
@Override protected TimeInterval computeNext() { TimeInterval window = null; if (start > elementStamp - duration) { window = new TimeInterval(start, start + duration); start -= slide; } else { endOfData(); } return window; } };
@Override public List<Triple<TimeInterval, String, String>> getUnorderedOutput() { return Arrays.asList( Triple.of(new TimeInterval(0, 3), "fi", "ha"), Triple.of(new TimeInterval(3, 6), "fa", "ho")); }
@Override public Iterable<TimeInterval> assignWindowsToElement(WindowedElement<?, T> el) { long stamp = el.getTimestamp(); long start = stamp - (stamp + durationMillis) % durationMillis; long end = start + durationMillis; return singleton(new TimeInterval(start, end)); }
@Override public List<Triple<TimeInterval, String, String>> getUnorderedOutput() { return Arrays.asList( Triple.of(new TimeInterval(0, 3), "fi", "ha"), Triple.of(new TimeInterval(3, 6), "fa", "ho")); }
@Override public Iterable<TimeInterval> assignWindowsToElement(WindowedElement<?, T> el) { long stamp = el.getTimestamp(); TimeInterval ret = new TimeInterval(stamp, stamp + gapDurationMillis); return Collections.singleton(ret); }
@SuppressWarnings("unchecked") @Override public List<Pair<TimeInterval, Integer>> getUnorderedOutput() { return Arrays.asList( Pair.of(new TimeInterval(0, 3600000), 4), Pair.of(new TimeInterval(3600000, 7200000), 3) ); } });
@Override public Iterable<TimeInterval> assignWindowsToElement(WindowedElement<?, T> el) { long stamp = el.getTimestamp(); TimeInterval ret = new TimeInterval(stamp, stamp + gapDurationMillis); return Collections.singleton(ret); }
@SuppressWarnings("unchecked") @Override public List<Pair<TimeInterval, Integer>> getUnorderedOutput() { return Arrays.asList( Pair.of(new TimeInterval(0, 3600000), 4), Pair.of(new TimeInterval(3600000, 7200000), 3) ); } });
@Override public Iterable<TimeInterval> assignWindowsToElement(WindowedElement<?, T> el) { long stamp = el.getTimestamp(); long start = stamp - (stamp + durationMillis) % durationMillis; long end = start + durationMillis; return singleton(new TimeInterval(start, end)); }
@Override public List<Triple<TimeInterval, Integer, Set<String>>> getUnorderedOutput() { return Arrays.asList( Triple.of(new TimeInterval(1, 15), 1, Sets.newHashSet( "1-four", "1-one", "1-three", "1-two")), Triple.of(new TimeInterval(10, 15), 2, Sets.newHashSet("2-two")), Triple.of(new TimeInterval(18, 27), 1, Sets.newHashSet("1-five", "1-six")), Triple.of(new TimeInterval(2, 7), 2, Sets.newHashSet("2-one")), Triple.of(new TimeInterval(20, 25), 2, Sets.newHashSet("2-three"))); }
@Override public List<Triple<TimeInterval, Integer, Set<String>>> getUnorderedOutput() { return Arrays.asList( Triple.of(new TimeInterval(1, 15), 1, Sets.newHashSet( "1-four", "1-one", "1-three", "1-two")), Triple.of(new TimeInterval(10, 15), 2, Sets.newHashSet("2-two")), Triple.of(new TimeInterval(18, 27), 1, Sets.newHashSet("1-five", "1-six")), Triple.of(new TimeInterval(2, 7), 2, Sets.newHashSet("2-one")), Triple.of(new TimeInterval(20, 25), 2, Sets.newHashSet("2-three"))); }
@Override public List<Triple<TimeInterval, String, String>> getUnorderedOutput() { TimeInterval expectedWindow = new TimeInterval(1, 14); return Arrays.asList( Triple.of(expectedWindow, "fi", "ha"), Triple.of(expectedWindow, "fi", "ho"), Triple.of(expectedWindow, "fa", "ha"), Triple.of(expectedWindow, "fa", "ho")); } });
@Override public List<Triple<TimeInterval, String, String>> getUnorderedOutput() { TimeInterval expectedWindow = new TimeInterval(1, 14); return Arrays.asList( Triple.of(expectedWindow, "fi", "ha"), Triple.of(expectedWindow, "fi", "ho"), Triple.of(expectedWindow, "fa", "ha"), Triple.of(expectedWindow, "fa", "ho")); } });
@Test public void testWindowAssignment() { Session<?> windowing = Session.of(Duration.ofMillis(10)); Iterable<TimeInterval> windows = windowing.assignWindowsToElement(new TimestampedElement<>(13)); assertEquals(1, Iterables.size(windows)); assertEquals(new TimeInterval(13, 23), Iterables.getOnlyElement(windows)); }
@Test public void testWindowAssignment() { Time<?> windowing = Time.of(Duration.ofMillis(10)); Iterable<TimeInterval> windows = windowing.assignWindowsToElement(new TimestampedElement<>(11)); assertEquals(1, Iterables.size(windows)); assertEquals(new TimeInterval(10, 20), Iterables.getOnlyElement(windows)); windows = windowing.assignWindowsToElement(new TimestampedElement<>(10)); assertEquals(1, Iterables.size(windows)); assertEquals(new TimeInterval(10, 20), Iterables.getOnlyElement(windows)); windows = windowing.assignWindowsToElement(new TimestampedElement<>(9)); assertEquals(1, Iterables.size(windows)); assertEquals(new TimeInterval(0, 10), Iterables.getOnlyElement(windows)); }