use of com.github.fhuss.kafka.streams.cep.state.QueryStoreBuilders in project kafkastreams-cep by fhussonnois.
the class CEPStreamImpl method query.
/**
* {@inheritDoc}
*/
@Override
public KStream<K, Sequence<K, V>> query(String queryName, Pattern<K, V> pattern, Queried<K, V> queried) {
Objects.requireNonNull(queryName, "queryName can't be null");
Objects.requireNonNull(pattern, "pattern can't be null");
final String name = builder.newProcessorName("CEPSTREAM-QUERY-" + queryName.toUpperCase() + "-");
final ProcessorSupplier processor = () -> new CEPProcessor<>(queryName, pattern);
builder.internalTopologyBuilder.addProcessor(name, processor, this.name);
QueryStoreBuilders<K, V> storeBuilders = new QueryStoreBuilders<>(queryName, pattern);
final Serde<K> keySerde = (queried == null) ? null : queried.keySerde();
final Serde<V> valSerde = (queried == null) ? null : queried.valueSerde();
addStateStore(storeBuilders.getNFAStateStoreBuilder(keySerde, valSerde), name);
addStateStore(storeBuilders.getEventBufferStoreBuilder(keySerde, valSerde), name);
addStateStore(storeBuilders.getAggregateStateStores(), name);
return new KStreamImpl<>(builder, name, sourceNodes, false);
}
Aggregations