private IKGroupedTable <K1, V1> DoGroup <K1, V1>(IKeyValueMapper <K, V, KeyValuePair <K1, V1> > keySelector, Grouped <K1, V1> grouped) { var selectName = new Named(grouped.Named).OrElseGenerateWithPrefix(this.builder, SELECT_NAME); IKTableProcessorSupplier <K, V, KeyValuePair <K1, V1> > selectSupplier = new KTableRepartitionMap <K, V, K1, V1>(this, keySelector); var processorParameters = new TableProcessorParameters <K, V>(selectSupplier, selectName); // select the aggregate key and values (old and new), it would require parent to send old values var groupByMapNode = new TableProcessorNode <K, V, K1, V1>( selectName, processorParameters, null ); builder.AddGraphNode(this.node, groupByMapNode); this.EnableSendingOldValues(); return(new KGroupedTable <K1, V1>( selectName, grouped, this.setSourceNodes, groupByMapNode, builder)); }
private IKTable <K, VR> DoMapValues <VR>(IValueMapperWithKey <K, V, VR> mapper, string named, Materialized <K, VR, IKeyValueStore <Bytes, byte[]> > materializedInternal) { ISerDes <K> keySerde; ISerDes <VR> valueSerde; String queryableStoreName; StoreBuilder <TimestampedKeyValueStore <K, VR> > storeBuilder; if (materializedInternal != null) { // we actually do not need to generate store names at all since if it is not specified, we will not // materialize the store; but we still need to burn one index BEFORE generating the processor to keep compatibility. if (materializedInternal.StoreName == null) { builder.NewStoreName(MAPVALUES_NAME); } keySerde = materializedInternal.KeySerdes != null ? materializedInternal.KeySerdes : this.keySerdes; valueSerde = materializedInternal.ValueSerdes != null ? materializedInternal.ValueSerdes : null; queryableStoreName = materializedInternal.QueryableStoreName; // only materialize if materialized is specified and it has queryable name storeBuilder = queryableStoreName != null ? new TimestampedKeyValueStoreMaterializer <K, VR>(materializedInternal).Materialize() : null; } else { keySerde = this.keySerdes; valueSerde = null; queryableStoreName = null; storeBuilder = null; } var name = new Named(named).OrElseGenerateWithPrefix(this.builder, MAPVALUES_NAME); var processorSupplier = new KTableMapValues <K, V, VR>(this, mapper, queryableStoreName); var processorParameters = new TableProcessorParameters <K, V>(processorSupplier, name); var tableNode = new TableProcessorNode <K, V, K, VR>( name, processorParameters, storeBuilder ); builder.AddGraphNode(this.node, tableNode); // don't inherit parent value serde, since this operation may change the value type, more specifically: // we preserve the key following the order of 1) materialized, 2) parent, 3) null // we preserve the value following the order of 1) materialized, 2) null return(new KTable <K, V, VR>( name, keySerde, valueSerde, this.setSourceNodes, queryableStoreName, processorSupplier, tableNode, builder )); }
private IKTable <K, V> DoFilter(Func <K, V, bool> predicate, string named, Materialized <K, V, IKeyValueStore <Bytes, byte[]> > materializedInternal, bool filterNot) { ISerDes <K> keySerde; ISerDes <V> valueSerde; String queryableStoreName; StoreBuilder <TimestampedKeyValueStore <K, V> > storeBuilder; if (materializedInternal != null) { // we actually do not need to generate store names at all since if it is not specified, we will not // materialize the store; but we still need to burn one index BEFORE generating the processor to keep compatibility. if (materializedInternal.StoreName == null) { builder.NewStoreName(FILTER_NAME); } // we can inherit parent key and value serde if user do not provide specific overrides, more specifically: // we preserve the key following the order of 1) materialized, 2) parent keySerde = materializedInternal.KeySerdes != null ? materializedInternal.KeySerdes : this.keySerdes; // we preserve the value following the order of 1) materialized, 2) parent valueSerde = materializedInternal.ValueSerdes != null ? materializedInternal.ValueSerdes : this.valueSerdes; queryableStoreName = materializedInternal.QueryableStoreName; // only materialize if materialized is specified and it has queryable name storeBuilder = queryableStoreName != null ? (new TimestampedKeyValueStoreMaterializer <K, V>(materializedInternal)).Materialize() : null; } else { keySerde = this.keySerdes; valueSerde = this.valueSerdes; queryableStoreName = null; storeBuilder = null; } var name = new Named(named).OrElseGenerateWithPrefix(this.builder, FILTER_NAME); IProcessorSupplier <K, Change <V> > processorSupplier = new KTableFilter <K, V>(this, predicate, filterNot, queryableStoreName); var processorParameters = new TableProcessorParameters <K, V>(processorSupplier, name); var tableNode = new TableProcessorNode <K, V, K, V>( name, processorParameters, storeBuilder ); builder.AddGraphNode(this.node, tableNode); return(new KTable <K, V, V>(name, keySerde, valueSerde, this.setSourceNodes, queryableStoreName, processorSupplier, tableNode, builder)); }