/** * Serialize the given key. * * @param key the key to be serialized * @return the serialized key */ public byte[] rawKey(final K key) { try { return keySerde.serializer().serialize(topic, key); } catch (final ClassCastException e) { final String keyClass = key == null ? "unknown because key is null" : key.getClass().getName(); throw new StreamsException( String.format("A serializer (key: %s) is not compatible to the actual key type " + "(key type: %s). Change the default Serdes in StreamConfig or " + "provide correct Serdes via method parameters.", keySerializer().getClass().getName(), keyClass), e); } }
void logChange(final K key, final V value) { if (collector != null) { final Serializer<K> keySerializer = serialization.keySerializer(); final Serializer<V> valueSerializer = serialization.valueSerializer(); // Sending null headers to changelog topics (KIP-244) collector.send(this.topic, key, value, null, this.partition, context.timestamp(), keySerializer, valueSerializer); } } }
@Override public void remove(final Windowed<K> key) { bytesStore.remove(Bytes.wrap(SessionKeySchema.toBinary(key, serdes.keySerializer(), topic))); }
@Override public void put(final Windowed<K> sessionKey, final AGG aggregate) { bytesStore.put(Bytes.wrap(SessionKeySchema.toBinary(sessionKey, serdes.keySerializer(), topic)), serdes.rawValue(aggregate)); } }
private StoreChangeFlushingLogger(String storeName, ProcessorContext context, int partition, StateSerdes<K, V> serialization) { this.topic = ProcessorStateManager.storeChangelogTopic(context.applicationId(), storeName); this.context = context; this.partition = partition; this.serialization = serialization; this.collector = ((RecordCollector.Supplier) context).recordCollector(); // Twitter Added this.taskId = context.taskId(); this.keySerializer = serialization.keySerializer(); this.valueSerializer = serialization.valueSerializer(); }