public override void Process(K key, Change <V> change)
        {
            LogProcessingKeyValue(key, change);
            // the original key should never be null
            if (key == null)
            {
                throw new StreamsException("Record key for the grouping KTable should not be null.");
            }

            // if the value is null, we do not need to forward its selected key-value further
            // if the selected repartition key or value is null, skip
            // forward oldPair first, to be consistent with reduce and aggregate
            if (change.OldValue != null)
            {
                KeyValuePair <K1, V1> oldPair = mapper.Apply(key, change.OldValue);
                if (oldPair.Key != null && oldPair.Value != null)
                {
                    this.Forward(oldPair.Key, new Change <V1>(oldPair.Value, default));
                }
            }

            if (change.NewValue != null)
            {
                KeyValuePair <K1, V1> newPair = mapper.Apply(key, change.NewValue);
                if (newPair.Key != null && newPair.Value != null)
                {
                    this.Forward(newPair.Key, new Change <V1>(default, newPair.Value));
예제 #2
0
        public void Apply(K key, V value)
        {
            string data = $"[{label}]: {mapper.Apply(key, value)}";

            writer.WriteLine(data);
            writer.Flush();
        }
            public ValueAndTimestamp <KeyValuePair <K1, V1> > Get(K key)
            {
                ValueAndTimestamp <V> valueAndTimestamp = parentTableGetter.Get(key);
                var v = mapper.Apply(key, valueAndTimestamp != null ? valueAndTimestamp.Value : default);

                return(ValueAndTimestamp <KeyValuePair <K1, V1> > .Make(v, valueAndTimestamp == null?context.Timestamp : valueAndTimestamp.Timestamp));
            }
        public override void Process(K key, V value)
        {
            LogProcessingKeyValue(key, value);
            KeyValuePair <K1, V1> newPair = mapper.Apply(key, value);

            Forward(newPair.Key, newPair.Value);
        }
예제 #5
0
 public override void Process(K key, V value)
 {
     LogProcessingKeyValue(key, value);
     foreach (var newPair in mapper.Apply(key, value))
     {
         Forward(newPair.Key, newPair.Value);
     }
 }
예제 #6
0
        private ProcessorGraphNode <K, V> InternalSelectKey <KR>(IKeyValueMapper <K, V, KR> mapper, string named = null)
        {
            var name = new Named(named).OrElseGenerateWithPrefix(this.builder, KEY_SELECT_NAME);

            WrappedKeyValueMapper <K, V, KeyValuePair <KR, V> > internalMapper =
                new WrappedKeyValueMapper <K, V, KeyValuePair <KR, V> >(
                    (key, value) => new KeyValuePair <KR, V>(mapper.Apply(key, value), value));

            KStreamMap <K, V, KR, V>   kStreamMap          = new KStreamMap <K, V, KR, V>(internalMapper);
            ProcessorParameters <K, V> processorParameters = new ProcessorParameters <K, V>(kStreamMap, name);

            return(new ProcessorGraphNode <K, V>(name, processorParameters));
        }
예제 #7
0
 public override void Process(K1 key, V1 value)
 {
     // If the key or value is null we don't need to proceed
     if (key == null || value == null)
     {
         log.Warn($"Skipping record due to null key or value. key=[{key}] value=[{value}] topic=[{Context.Topic}] partition=[{Context.Partition}] offset=[{Context.Offset}]");
         return;
     }
     else
     {
         K2 mappedKey = mapper.Apply(key, value);
         V2 value2    = mappedKey == null ? null : ValueAndTimestamp.GetValueOrNull(valueGetter.Get(mappedKey));
         if (leftJoin || value2 != null)
         {
             Forward(key, joiner.Apply(value, value2));
         }
     }
 }