@Override public String topic() { return delegate.topic(); }
private boolean checkHighWaterMark() { Long latestOffset = this.currentNFAState.getLatestOffsetForTopic(this.context.topic()); if (latestOffset == null) latestOffset = -1L; if (this.context.offset() < latestOffset) { LOG.warn("Offset({}) is prior to the current high-water mark({}) for topic={}", this.context.offset(), latestOffset, this.context.topic()); return false; } return true; }
/** * {@inheritDoc} */ @Override public void process(K key, V value) { // If the key or value is null we don't need to proceed if (key == null || value == null) { return; } final NFA<K, V> nfa = loadNFA(this.stages, key); if (checkHighWaterMark()) { Event<K, V> event = new Event<>(key, value, context.timestamp(), context.topic(), context.partition(), context.offset()); List<Sequence<K, V>> sequences = nfa.matchPattern(event); Map<String, Long> latestOffsets = this.currentNFAState.getLatestOffsets(); latestOffsets.put(this.context.topic(), this.context.offset() + 1); this.currentNFAState = new NFAStates<>(nfa.getComputationStages(), nfa.getRuns(), latestOffsets); this.nfaStore.put(getRunned(key), this.currentNFAState); sequences.forEach(seq -> this.context.forward(key, seq)); } }
@Override public void process(final K1 key, final V1 value) { // we do join iff keys are equal, thus, if key is null we cannot join and just ignore the record // If {@code keyMapper} returns {@code null} it implies there is no match, // so ignore unless it is a left join // // we also ignore the record if value is null, because in a key-value data model a null-value indicates // an empty message (ie, there is nothing to be joined) -- this contrast SQL NULL semantics // furthermore, on left/outer joins 'null' in ValueJoiner#apply() indicates a missing record -- // thus, to be consistent and to avoid ambiguous null semantics, null values are ignored if (key == null || value == null) { LOG.warn( "Skipping record due to null key or value. key=[{}] value=[{}] topic=[{}] partition=[{}] offset=[{}]", key, value, context().topic(), context().partition(), context().offset() ); metrics.skippedRecordsSensor().record(); } else { final K2 mappedKey = keyMapper.apply(key, value); final V2 value2 = mappedKey == null ? null : valueGetter.get(mappedKey); if (leftJoin || value2 != null) { context().forward(key, joiner.apply(value, value2)); } } }