@Override protected boolean tryProcess(int ordinal, @Nonnull Object item) { return mapper.tryProcess(((TimestampedEntry<String, String>) item)); } }
/** * Factory of {@link FlatMapper}. The {@code FlatMapper} will emit items to * the ordinals identified in the array. */ @Nonnull protected final <T, R> FlatMapper<T, R> flatMapper( @Nonnull int[] ordinals, @Nonnull Function<? super T, ? extends Traverser<? extends R>> mapper ) { return new FlatMapper<>(ordinals, mapper); }
/** * Method designed to be called from one of {@code AbstractProcessor#tryProcessX()} * methods. The calling method must return this method's return * value. * * @param item the item to process * @return what the calling {@code tryProcessX()} method should return */ public boolean tryProcess(@Nonnull T item) { if (outputTraverser == null) { outputTraverser = mapper.apply(item); } if (emit()) { outputTraverser = null; return true; } return false; }
@Override protected boolean tryProcess0(@Nonnull Object item) { if (((Entry) item).getKey() instanceof SnapshotValidationRecord.SnapshotValidationKey) { // ignore the validation record return true; } Entry<SnapshotDataKey, byte[]> casted = (Entry<SnapshotDataKey, byte[]>) item; String vertexName = casted.getKey().vertexName(); FlatMapper<byte[], Object> flatMapper = vertexToFlatMapper.get(vertexName); if (flatMapper == null) { if (!vertexToFlatMapper.containsKey(vertexName)) { // log only once vertexToFlatMapper.put(vertexName, null); getLogger().warning("Data for unknown vertex found in the snapshot, ignoring. Vertex=" + vertexName); } return true; } long snapshotId = casted.getKey().snapshotId(); if (snapshotId != expectedSnapshotId) { getLogger().warning("Data for unexpected snapshot ID encountered, ignoring. Expected=" + expectedSnapshotId + ", found=" + snapshotId); return true; } return flatMapper.tryProcess(casted.getValue()); } }
@Override public boolean tryProcessWatermark(@Nonnull Watermark wm) { return wmFlatMapper.tryProcess(wm); }
@Override @SuppressWarnings("unchecked") protected boolean tryProcess(int ordinal, @Nonnull Object item) { return flatMapper.tryProcess((T) item); } }
/** * Factory of {@link FlatMapper}. The {@code FlatMapper} will emit items to * all defined output ordinals. */ @Nonnull @SuppressFBWarnings("NP_NULL_PARAM_DEREF_NONVIRTUAL") // possible spotbugs bug protected final <T, R> FlatMapper<T, R> flatMapper( @Nonnull Function<? super T, ? extends Traverser<? extends R>> mapper ) { return new FlatMapper<>(null, mapper); }
@Override public boolean tryProcessWatermark(@Nonnull Watermark wm) { currentWatermark = wm.timestamp(); assert totalWindows.get() == deadlineToKeys.values().stream().mapToInt(Set::size).sum() : "unexpected totalWindows. Expected=" + deadlineToKeys.values().stream().mapToInt(Set::size).sum() + ", actual=" + totalWindows.get(); return closedWindowFlatmapper.tryProcess(wm); }
@Override public boolean complete() { inComplete = true; return closedWindowFlatmapper.tryProcess(COMPLETING_WM); }
@Override @SuppressWarnings("unchecked") protected boolean tryProcess1(@Nonnull Object item) { return flatMapper.tryProcess((Entry<Long, String>) item); } }
@Override @SuppressWarnings("unchecked") protected boolean tryProcess(int ordinal, @Nonnull Object item) { return flatMapper.tryProcess((T) item); }