@Override public boolean equals(Object o) { if (o instanceof KeyedWindow) { KeyedWindow other = (KeyedWindow) o; return window.equals(other.window) && Objects.equals(key, other.key); } return false; }
@Override public int hashCode() { int result = window.hashCode(); result = 31 * result + (key != null ? key.hashCode() : 0); return result; }
@Override public void collect(T elem) { long stamp = Math.min(stampSupplier.get(), window.maxTimestamp() - 1); wrap.collect(Datum.of(window, elem, stamp)); }
@Override public int compareTo(KeyedWindow other) { final int compareWindowResult = this.window.compareTo(other.window); if (compareWindowResult == 0) { if (Objects.equals(key, other.key)) { return 0; } else { return 1; } } return compareWindowResult; } }
@Override @SuppressWarnings("unchecked") public int compareTo(KeyedWindow<W, K> o) { final int windowCompare = window.compareTo(o.window); if (windowCompare == 0) { return ((Comparable) key).compareTo(o.key); } return windowCompare; } }
@Override public boolean equals(Object o) { if (o instanceof KeyedWindow) { KeyedWindow other = (KeyedWindow) o; return window.equals(other.window) && Objects.equals(key, other.key); } return false; }
@Override public void collect(T elem) { long stamp = Math.min(stampSupplier.get(), window.maxTimestamp() - 1); wrap.collect(Datum.of(window, elem, stamp)); }
@Override public int hashCode() { int result = window.hashCode(); result = 31 * result + (key != null ? key.hashCode() : 0); return result; }
@Override public void deleteTimer(long stamp, Window window) { Preconditions.checkState(this.scope.window().equals(window)); scheduler.cancel(stamp, this.scope); }
@Override public Iterator<Tuple2<KeyedWindow<W, KEY>, VALUE>> call(SparkElement<?, IN> wel) { final Iterable<W> windows = windowing.assignWindowsToElement(wel); return Iterators.transform( windows.iterator(), wid -> { final long stamp = Objects.requireNonNull(wid).maxTimestamp() - 1; return new Tuple2<>( new KeyedWindow<>(wid, stamp, keyExtractor.apply(wel.getElement())), valueExtractor.apply(wel.getElement())); }); } }
@Override public int hashCode() { int result = window.hashCode(); result = 31 * result + (key != null ? key.hashCode() : 0); return result; }
if (mergeResults.isEmpty() || (resultWindow.equals(newWindow) && !mergedNewWindow)) { mapping.put(resultWindow, resultWindow);
@Override @SuppressWarnings("unchecked") public void flatMap(BatchElement wel, Collector<BatchElement<Window, Pair>> coll) throws Exception { Iterable<Window> assigned = windowing.assignWindowsToElement(wel); for (Window wid : assigned) { Object el = wel.getElement(); coll.collect(new BatchElement( wid, wid.maxTimestamp(), Pair.of(keyExtractor.apply(el), el))); } } }
@Override public int hashCode() { int result = window.hashCode(); result = 31 * result + (key != null ? key.hashCode() : 0); return result; }
@Override public void deleteTimer(long stamp, Window window) { Preconditions.checkState(this.scope.window().equals(window)); scheduler.cancel(stamp, this.scope); }
@Override @SuppressWarnings("unchecked") public void join(BatchElement<Window, Pair> first, BatchElement<Window, Pair> second, Collector<BatchElement<Window, Pair>> coll) throws Exception { if (multiValueContext == null) { multiValueContext = new MultiValueContext<>(); } final Window window = first == null ? second.getWindow() : first.getWindow(); final long maxTimestamp = Math.max( first == null ? window.maxTimestamp() - 1 : first.getTimestamp(), second == null ? window.maxTimestamp() - 1 : second.getTimestamp()); Object firstEl = first == null ? null : first.getElement().getSecond(); Object secondEl = second == null ? null : second.getElement().getSecond(); joiner.apply(firstEl, secondEl, multiValueContext); final Object key = first == null ? second.getElement().getFirst() : first.getElement().getFirst(); List<Object> values = multiValueContext.getAndResetValues(); values.forEach(val -> coll.collect(new BatchElement<>( window, maxTimestamp, Pair.of(key, val)))); } }
@Override public int hashCode() { int result = itemKey != null ? itemKey.hashCode() : 0; result = 31 * result + (itemWindow != null ? itemWindow.hashCode() : 0); result = 31 * result + (storeId != null ? storeId.hashCode() : 0); return result; } }
if (!source.equals(target.window())) { State state = wRegistry.removeWindowState(new KeyedWindow<>(source, target.key())); if (state != null) {
final long maxTimestamp = Math.max( first == null ? window.maxTimestamp() - 1 : first.getTimestamp(), second == null ? window.maxTimestamp() - 1 : second.getTimestamp()); collector.clear(); collector.setWindow(window);
@Override public int hashCode() { int result = itemKey != null ? itemKey.hashCode() : 0; result = 31 * result + (itemWindow != null ? itemWindow.hashCode() : 0); result = 31 * result + (storeId != null ? storeId.hashCode() : 0); return result; } }