From 7fa85666accbd42b2dff6e426831463f8cca07ec Mon Sep 17 00:00:00 2001 From: masesdevelopers <94312179+masesdevelopers@users.noreply.github.com> Date: Mon, 11 Dec 2023 03:23:03 +0100 Subject: [PATCH 01/18] Temp commit --- .../kafka/streams/processor/Punctuator.java | 35 ++ .../Specific/Streams/KNetClientSupplier.cs | 120 +++++++ src/net/KNet/Specific/Streams/KNetStreams.cs | 146 ++++++++ src/net/KNet/Specific/Streams/KNetTopology.cs | 337 ++++++++++++++++++ .../Processor/KNetStreamPartitioner.cs | 70 ++++ 5 files changed, 708 insertions(+) create mode 100644 src/jvm/knet/src/main/java/org/mases/knet/generated/org/apache/kafka/streams/processor/Punctuator.java create mode 100644 src/net/KNet/Specific/Streams/KNetClientSupplier.cs create mode 100644 src/net/KNet/Specific/Streams/KNetStreams.cs create mode 100644 src/net/KNet/Specific/Streams/KNetTopology.cs create mode 100644 src/net/KNet/Specific/Streams/Processor/KNetStreamPartitioner.cs diff --git a/src/jvm/knet/src/main/java/org/mases/knet/generated/org/apache/kafka/streams/processor/Punctuator.java b/src/jvm/knet/src/main/java/org/mases/knet/generated/org/apache/kafka/streams/processor/Punctuator.java new file mode 100644 index 0000000000..e06bc56ef3 --- /dev/null +++ b/src/jvm/knet/src/main/java/org/mases/knet/generated/org/apache/kafka/streams/processor/Punctuator.java @@ -0,0 +1,35 @@ +/* + * Copyright 2023 MASES s.r.l. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Refer to LICENSE for more information. + */ + +/* +* This file is generated by MASES.JNetReflector (ver. 2.1.0.0) +*/ + +package org.mases.knet.generated.org.apache.kafka.streams.processor; + +public final class Punctuator extends org.mases.jcobridge.JCListener implements org.apache.kafka.streams.processor.Punctuator { + public Punctuator(String key) throws org.mases.jcobridge.JCNativeException { + super(key); + } + + //@Override + public void punctuate(long arg0) { + raiseEvent("punctuate", arg0); + } + +} \ No newline at end of file diff --git a/src/net/KNet/Specific/Streams/KNetClientSupplier.cs b/src/net/KNet/Specific/Streams/KNetClientSupplier.cs new file mode 100644 index 0000000000..ee27a160f8 --- /dev/null +++ b/src/net/KNet/Specific/Streams/KNetClientSupplier.cs @@ -0,0 +1,120 @@ +/* +* Copyright 2023 MASES s.r.l. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +* Refer to LICENSE for more information. +*/ + +using Java.Util; +using MASES.KNet.Consumer; +using MASES.KNet.Producer; +using MASES.KNet.Serialization; +using Org.Apache.Kafka.Clients.Admin; +using Org.Apache.Kafka.Clients.Consumer; +using Org.Apache.Kafka.Clients.Producer; +using Org.Apache.Kafka.Streams; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MASES.KNet.Specific.Streams +{ + /// + /// KNet implementation of + /// + public class KNetClientSupplier : KafkaClientSupplier + { + private readonly System.Collections.Generic.List _admins = new System.Collections.Generic.List(); + private readonly System.Collections.Generic.List> _consumers = new System.Collections.Generic.List>(); + private readonly System.Collections.Generic.List> _producers = new System.Collections.Generic.List>(); + /// + /// Default initializer + /// + public KNetClientSupplier() + { + } + /// + public override Org.Apache.Kafka.Clients.Admin.Admin GetAdmin(Map arg0) + { + var admin = AdminClient.Create(arg0); + _admins.Add(admin); + return admin; + } + /// + public override Consumer GetConsumer(Map arg0) + { + Properties properties = new(); + properties.PutAll(arg0); + + var consumer = new KNetConsumer(properties); + _consumers.Add(consumer); + return consumer; + } + /// + public override Consumer GetGlobalConsumer(Map arg0) + { + Properties properties = new(); + properties.PutAll(arg0); + + var consumer = new KNetConsumer(properties); + _consumers.Add(consumer); + return consumer; + } + /// + public override Producer GetProducer(Map arg0) + { + Properties properties = new(); + properties.PutAll(arg0); + + var producer = new KNetProducer(properties); + _producers.Add(producer); + return producer; + } + /// + public override Consumer GetRestoreConsumer(Map arg0) + { + Properties properties = new(); + properties.PutAll(arg0); + + var consumer = new KNetConsumer(properties); + _consumers.Add(consumer); + return consumer; + } + /// + public override void Dispose() + { + foreach (var item in _admins) + { + item?.Dispose(); + } + _admins.Clear(); + + foreach (var item in _consumers) + { + item?.Dispose(); + } + _consumers.Clear(); + + foreach (var item in _producers) + { + item?.Dispose(); + } + _producers.Clear(); + + base.Dispose(); + } + } +} diff --git a/src/net/KNet/Specific/Streams/KNetStreams.cs b/src/net/KNet/Specific/Streams/KNetStreams.cs new file mode 100644 index 0000000000..7eaa19bf75 --- /dev/null +++ b/src/net/KNet/Specific/Streams/KNetStreams.cs @@ -0,0 +1,146 @@ +/* +* Copyright 2023 MASES s.r.l. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +* Refer to LICENSE for more information. +*/ + +using Java.Util; +using MASES.KNet.Consumer; +using MASES.KNet.Producer; +using MASES.KNet.Serialization; +using MASES.KNet.Specific.Streams.Processor; +using Org.Apache.Kafka.Clients.Admin; +using Org.Apache.Kafka.Clients.Consumer; +using Org.Apache.Kafka.Clients.Producer; +using Org.Apache.Kafka.Streams; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MASES.KNet.Specific.Streams +{ + /// + /// KNet extension of + /// + public class KNetStreams : KafkaStreams + { + #region Constructors + /// + public KNetStreams() : base() { } + /// + public KNetStreams(params object[] args) : base(args) { } + /// + /// KNet override of + /// + /// + /// + /// + public KNetStreams(KNetTopology arg0, Java.Util.Properties arg1, Org.Apache.Kafka.Common.Utils.Time arg2) + : base(arg0, arg1, arg2) + { + } + /// + /// KNet override of + /// + /// + /// + /// + /// + public KNetStreams(KNetTopology arg0, Java.Util.Properties arg1, KNetClientSupplier arg2, Org.Apache.Kafka.Common.Utils.Time arg3) + : base(arg0, arg1, arg2, arg3) + { + } + /// + /// KNet override of + /// + /// + /// + /// + public KNetStreams(KNetTopology arg0, Java.Util.Properties arg1, KNetClientSupplier arg2) + : base(arg0, arg1, arg2) + { + } + /// + /// KNet override of + /// + /// + /// + public KNetStreams(KNetTopology arg0, Java.Util.Properties arg1) + : base(arg0, arg1) + { + } + /// + /// KNet override of + /// + /// + /// + /// + public KNetStreams(KNetTopology arg0, Org.Apache.Kafka.Streams.StreamsConfig arg1, Org.Apache.Kafka.Common.Utils.Time arg2) + : base(arg0, arg1, arg2) + { + } + /// + /// KNet override of + /// + /// + /// + /// + public KNetStreams(KNetTopology arg0, Org.Apache.Kafka.Streams.StreamsConfig arg1, KNetClientSupplier arg2) + : base(arg0, arg1, arg2) + { + } + /// + /// KNet override of + /// + /// + /// + public KNetStreams(KNetTopology arg0, Org.Apache.Kafka.Streams.StreamsConfig arg1) + : base(arg0, arg1) + { + } + + #endregion + + #region Instance methods + /// + /// KNet override of + /// + /// + /// + /// + /// + /// + public Org.Apache.Kafka.Streams.KeyQueryMetadata QueryMetadataForKey(string arg0, TKey arg1, IKNetSerializer arg2) + { + return QueryMetadataForKey(arg0, arg2.Serialize(null, arg1), arg2.KafkaSerializer); + } + /// + /// KNet override of + /// + /// + /// + /// + /// The key type + /// + public Org.Apache.Kafka.Streams.KeyQueryMetadata QueryMetadataForKey(string arg0, TKey arg1, KNetStreamPartitioner arg2) + { + return IExecute("queryMetadataForKey", arg0, arg2.KeySerializer.Serialize(null, arg1), arg2); + } + + #endregion + } +} diff --git a/src/net/KNet/Specific/Streams/KNetTopology.cs b/src/net/KNet/Specific/Streams/KNetTopology.cs new file mode 100644 index 0000000000..5eb259d04d --- /dev/null +++ b/src/net/KNet/Specific/Streams/KNetTopology.cs @@ -0,0 +1,337 @@ +/* +* Copyright 2023 MASES s.r.l. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +* Refer to LICENSE for more information. +*/ + +using Org.Apache.Kafka.Streams; + +namespace MASES.KNet.Specific.Streams +{ + /// + /// KNet implementation of + /// + public class KNetTopology : Topology + { + #region Constructors + /// + public KNetTopology() : base() { } + /// + public KNetTopology(params object[] args) : base(args) { } + + /// + /// KNet override of + /// + /// + public KNetTopology(Org.Apache.Kafka.Streams.TopologyConfig arg0) + : base(arg0) + { + } + #endregion + + #region Instance methods + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public Org.Apache.Kafka.Streams.Topology AddSink(string arg0, string arg1, Org.Apache.Kafka.Common.Serialization.Serializer arg2, Org.Apache.Kafka.Common.Serialization.Serializer arg3, params string[] arg4) + { + if (arg4.Length == 0) return IExecute("addSink", arg0, arg1, arg2, arg3); else return IExecute("addSink", arg0, arg1, arg2, arg3, arg4); + } + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public Org.Apache.Kafka.Streams.Topology AddSink(string arg0, string arg1, Org.Apache.Kafka.Common.Serialization.Serializer arg2, Org.Apache.Kafka.Common.Serialization.Serializer arg3, Org.Apache.Kafka.Streams.Processor.StreamPartitioner arg4, params string[] arg5) where Arg4objectSuperK : K where Arg4objectSuperV : V + { + if (arg5.Length == 0) return IExecute("addSink", arg0, arg1, arg2, arg3, arg4); else return IExecute("addSink", arg0, arg1, arg2, arg3, arg4, arg5); + } + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public Org.Apache.Kafka.Streams.Topology AddSink(string arg0, string arg1, Org.Apache.Kafka.Streams.Processor.StreamPartitioner arg2, params string[] arg3) where Arg2objectSuperK : K where Arg2objectSuperV : V + { + if (arg3.Length == 0) return IExecute("addSink", arg0, arg1, arg2); else return IExecute("addSink", arg0, arg1, arg2, arg3); + } + /// + /// + /// + /// + /// + /// + /// + /// + /// + public Org.Apache.Kafka.Streams.Topology AddSink(string arg0, Org.Apache.Kafka.Streams.Processor.TopicNameExtractor arg1, params string[] arg2) + { + if (arg2.Length == 0) return IExecute("addSink", arg0, arg1); else return IExecute("addSink", arg0, arg1, arg2); + } + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public Org.Apache.Kafka.Streams.Topology AddSink(string arg0, Org.Apache.Kafka.Streams.Processor.TopicNameExtractor arg1, Org.Apache.Kafka.Common.Serialization.Serializer arg2, Org.Apache.Kafka.Common.Serialization.Serializer arg3, params string[] arg4) + { + if (arg4.Length == 0) return IExecute("addSink", arg0, arg1, arg2, arg3); else return IExecute("addSink", arg0, arg1, arg2, arg3, arg4); + } + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public Org.Apache.Kafka.Streams.Topology AddSink(string arg0, Org.Apache.Kafka.Streams.Processor.TopicNameExtractor arg1, Org.Apache.Kafka.Common.Serialization.Serializer arg2, Org.Apache.Kafka.Common.Serialization.Serializer arg3, Org.Apache.Kafka.Streams.Processor.StreamPartitioner arg4, params string[] arg5) where Arg4objectSuperK : K where Arg4objectSuperV : V + { + if (arg5.Length == 0) return IExecute("addSink", arg0, arg1, arg2, arg3, arg4); else return IExecute("addSink", arg0, arg1, arg2, arg3, arg4, arg5); + } + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public Org.Apache.Kafka.Streams.Topology AddSink(string arg0, Org.Apache.Kafka.Streams.Processor.TopicNameExtractor arg1, Org.Apache.Kafka.Streams.Processor.StreamPartitioner arg2, params string[] arg3) where Arg2objectSuperK : K where Arg2objectSuperV : V + { + if (arg3.Length == 0) return IExecute("addSink", arg0, arg1, arg2); else return IExecute("addSink", arg0, arg1, arg2, arg3); + } + /// + /// + /// + /// + /// + /// + /// + public Org.Apache.Kafka.Streams.Topology AddSink(string arg0, string arg1, params string[] arg2) + { + if (arg2.Length == 0) return IExecute("addSink", arg0, arg1); else return IExecute("addSink", arg0, arg1, arg2); + } + /// + /// + /// + /// + /// + /// + public Org.Apache.Kafka.Streams.Topology AddSource(string arg0, params string[] arg1) + { + if (arg1.Length == 0) return IExecute("addSource", arg0); else return IExecute("addSource", arg0, arg1); + } + /// + /// + /// + /// + /// + /// + public Org.Apache.Kafka.Streams.Topology AddSource(string arg0, Java.Util.Regex.Pattern arg1) + { + return IExecute("addSource", arg0, arg1); + } + /// + /// + /// + /// + /// + /// + /// + /// + public Org.Apache.Kafka.Streams.Topology AddSource(string arg0, Org.Apache.Kafka.Common.Serialization.Deserializer arg1, Org.Apache.Kafka.Common.Serialization.Deserializer arg2, params string[] arg3) + { + if (arg3.Length == 0) return IExecute("addSource", arg0, arg1, arg2); else return IExecute("addSource", arg0, arg1, arg2, arg3); + } + /// + /// + /// + /// + /// + /// + /// + /// + public Org.Apache.Kafka.Streams.Topology AddSource(string arg0, Org.Apache.Kafka.Common.Serialization.Deserializer arg1, Org.Apache.Kafka.Common.Serialization.Deserializer arg2, Java.Util.Regex.Pattern arg3) + { + return IExecute("addSource", arg0, arg1, arg2, arg3); + } + /// + /// + /// + /// + /// + /// + /// + public Org.Apache.Kafka.Streams.Topology AddSource(Org.Apache.Kafka.Streams.Processor.TimestampExtractor arg0, string arg1, params string[] arg2) + { + if (arg2.Length == 0) return IExecute("addSource", arg0, arg1); else return IExecute("addSource", arg0, arg1, arg2); + } + /// + /// + /// + /// + /// + /// + /// + public Org.Apache.Kafka.Streams.Topology AddSource(Org.Apache.Kafka.Streams.Processor.TimestampExtractor arg0, string arg1, Java.Util.Regex.Pattern arg2) + { + return IExecute("addSource", arg0, arg1, arg2); + } + /// + /// + /// + /// + /// + /// + /// + public Org.Apache.Kafka.Streams.Topology AddSource(Org.Apache.Kafka.Streams.Topology.AutoOffsetReset arg0, string arg1, params string[] arg2) + { + if (arg2.Length == 0) return IExecute("addSource", arg0, arg1); else return IExecute("addSource", arg0, arg1, arg2); + } + /// + /// + /// + /// + /// + /// + /// + public Org.Apache.Kafka.Streams.Topology AddSource(Org.Apache.Kafka.Streams.Topology.AutoOffsetReset arg0, string arg1, Java.Util.Regex.Pattern arg2) + { + return IExecute("addSource", arg0, arg1, arg2); + } + /// + /// + /// + /// + /// + /// + /// + /// + /// + public Org.Apache.Kafka.Streams.Topology AddSource(Org.Apache.Kafka.Streams.Topology.AutoOffsetReset arg0, string arg1, Org.Apache.Kafka.Common.Serialization.Deserializer arg2, Org.Apache.Kafka.Common.Serialization.Deserializer arg3, params string[] arg4) + { + if (arg4.Length == 0) return IExecute("addSource", arg0, arg1, arg2, arg3); else return IExecute("addSource", arg0, arg1, arg2, arg3, arg4); + } + /// + /// + /// + /// + /// + /// + /// + /// + /// + public Org.Apache.Kafka.Streams.Topology AddSource(Org.Apache.Kafka.Streams.Topology.AutoOffsetReset arg0, string arg1, Org.Apache.Kafka.Common.Serialization.Deserializer arg2, Org.Apache.Kafka.Common.Serialization.Deserializer arg3, Java.Util.Regex.Pattern arg4) + { + return IExecute("addSource", arg0, arg1, arg2, arg3, arg4); + } + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public Org.Apache.Kafka.Streams.Topology AddSource(Org.Apache.Kafka.Streams.Topology.AutoOffsetReset arg0, string arg1, Org.Apache.Kafka.Streams.Processor.TimestampExtractor arg2, Org.Apache.Kafka.Common.Serialization.Deserializer arg3, Org.Apache.Kafka.Common.Serialization.Deserializer arg4, params string[] arg5) + { + if (arg5.Length == 0) return IExecute("addSource", arg0, arg1, arg2, arg3, arg4); else return IExecute("addSource", arg0, arg1, arg2, arg3, arg4, arg5); + } + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public Org.Apache.Kafka.Streams.Topology AddSource(Org.Apache.Kafka.Streams.Topology.AutoOffsetReset arg0, string arg1, Org.Apache.Kafka.Streams.Processor.TimestampExtractor arg2, Org.Apache.Kafka.Common.Serialization.Deserializer arg3, Org.Apache.Kafka.Common.Serialization.Deserializer arg4, Java.Util.Regex.Pattern arg5) + { + return IExecute("addSource", arg0, arg1, arg2, arg3, arg4, arg5); + } + /// + /// + /// + /// + /// + /// + /// + /// + public Org.Apache.Kafka.Streams.Topology AddSource(Org.Apache.Kafka.Streams.Topology.AutoOffsetReset arg0, Org.Apache.Kafka.Streams.Processor.TimestampExtractor arg1, string arg2, params string[] arg3) + { + if (arg3.Length == 0) return IExecute("addSource", arg0, arg1, arg2); else return IExecute("addSource", arg0, arg1, arg2, arg3); + } + /// + /// + /// + /// + /// + /// + /// + /// + public Org.Apache.Kafka.Streams.Topology AddSource(Org.Apache.Kafka.Streams.Topology.AutoOffsetReset arg0, Org.Apache.Kafka.Streams.Processor.TimestampExtractor arg1, string arg2, Java.Util.Regex.Pattern arg3) + { + return IExecute("addSource", arg0, arg1, arg2, arg3); + } + + + #endregion + } +} diff --git a/src/net/KNet/Specific/Streams/Processor/KNetStreamPartitioner.cs b/src/net/KNet/Specific/Streams/Processor/KNetStreamPartitioner.cs new file mode 100644 index 0000000000..4dbdb02cc6 --- /dev/null +++ b/src/net/KNet/Specific/Streams/Processor/KNetStreamPartitioner.cs @@ -0,0 +1,70 @@ +/* +* Copyright 2023 MASES s.r.l. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +* Refer to LICENSE for more information. +*/ + +using Java.Lang; +using Java.Util; +using MASES.KNet.Serialization; +using Org.Apache.Kafka.Streams.Processor; + +namespace MASES.KNet.Specific.Streams.Processor +{ + /// + /// KNet implementation of + /// + /// The key type + /// The value type + public class KNetStreamPartitioner : StreamPartitioner + { + IKNetSerDes _keySerializer; + IKNetSerDes _valueSerializer; + /// + /// Default initializer + /// + public KNetStreamPartitioner(IKNetSerDes keySerializer, IKNetSerDes valueSerializer) : base() + { + _keySerializer = keySerializer; + _valueSerializer = valueSerializer; + } + /// + /// The associated to + /// + public IKNetSerDes KeySerializer => _keySerializer; + /// + /// The associated to + /// + public IKNetSerDes ValueSerializer => _valueSerializer; + + /// + public sealed override Optional> Partitions(string arg0, byte[] arg1, byte[] arg2, int arg3) + { + return Partitions(arg0, _keySerializer.Deserialize(arg0, arg1), _valueSerializer.Deserialize(arg0, arg2), arg3); + } + /// + /// KNet override of + /// + /// The topic name this record is sent to + /// The key of the record + /// The value of the record + /// The total number of partitions + /// An of of s between 0 and numPartitions-1, Empty optional means using default partitioner of an empty set means the record won't be sent to any partitions i.e drop it. Optional of Set of integers means the partitions to which the record should be sent to. + public virtual Optional> Partitions(string arg0, TKey arg1, TValue arg2, int arg3) + { + return Optional>.Empty(); + } + } +} From 9c76eb404ef00425ada4082bcf7460d554c9e7df Mon Sep 17 00:00:00 2001 From: masesdevelopers <94312179+masesdevelopers@users.noreply.github.com> Date: Mon, 11 Dec 2023 15:57:03 +0100 Subject: [PATCH 02/18] Removed unused Java classes, added specific implementation of Predicate --- .../serialization/DeserializerImpl.java | 43 ---------- .../common/serialization/SerializerImpl.java | 41 ---------- .../consumer/ConsumerInterceptorImpl.java | 53 ------------ .../ConsumerRebalanceListenerImpl.java | 39 --------- .../consumer/OffsetCommitCallbackImpl.java | 36 -------- .../knet/clients/producer/CallbackImpl.java | 33 -------- .../common/metrics/MetricsReporterImpl.java | 82 ------------------- .../knet/streams/KafkaClientSupplierImpl.java | 68 --------------- .../mases/knet/streams/StateListenerImpl.java | 33 -------- .../StreamsUncaughtExceptionHandlerImpl.java | 35 -------- .../knet/streams/kstream/AggregatorImpl.java | 35 -------- .../streams/kstream/ForeachActionImpl.java | 33 -------- .../knet/streams/kstream/InitializerImpl.java | 35 -------- ...{PredicateImpl.java => KNetPredicate.java} | 32 ++++++-- .../streams/kstream/KeyValueMapperImpl.java | 35 -------- .../knet/streams/kstream/MergerImpl.java | 35 -------- .../knet/streams/kstream/ReducerImpl.java | 35 -------- .../knet/streams/kstream/ValueJoinerImpl.java | 35 -------- .../kstream/ValueJoinerWithKeyImpl.java | 35 -------- .../knet/streams/kstream/ValueMapperImpl.java | 35 -------- .../kstream/ValueMapperWithKeyImpl.java | 35 -------- .../knet/streams/processor/ProcessorImpl.java | 42 ---------- .../processor/StateRestoreCallbackImpl.java | 33 -------- .../processor/StateRestoreListenerImpl.java | 52 ------------ .../processor/StreamPartitionerImpl.java | 49 ----------- .../processor/TimestampExtractorImpl.java | 37 --------- .../processor/TopicNameExtractorImpl.java | 36 -------- .../processor/api/FixedKeyProcessorImpl.java | 43 ---------- .../streams/processor/api/ProcessorImpl.java | 43 ---------- .../streams/KafkaClientSupplierImplTest.java | 18 ---- .../knet/streams/StateListenerImplTest.java | 18 ---- .../Specific/Streams/Kstream/KNetPredicate.cs | 70 ++++++++++++++++ 32 files changed, 95 insertions(+), 1189 deletions(-) delete mode 100644 src/jvm/knet/src/main/java/org/mases/knet/clients/common/serialization/DeserializerImpl.java delete mode 100644 src/jvm/knet/src/main/java/org/mases/knet/clients/common/serialization/SerializerImpl.java delete mode 100644 src/jvm/knet/src/main/java/org/mases/knet/clients/consumer/ConsumerInterceptorImpl.java delete mode 100644 src/jvm/knet/src/main/java/org/mases/knet/clients/consumer/ConsumerRebalanceListenerImpl.java delete mode 100644 src/jvm/knet/src/main/java/org/mases/knet/clients/consumer/OffsetCommitCallbackImpl.java delete mode 100644 src/jvm/knet/src/main/java/org/mases/knet/clients/producer/CallbackImpl.java delete mode 100644 src/jvm/knet/src/main/java/org/mases/knet/common/metrics/MetricsReporterImpl.java delete mode 100644 src/jvm/knet/src/main/java/org/mases/knet/streams/KafkaClientSupplierImpl.java delete mode 100644 src/jvm/knet/src/main/java/org/mases/knet/streams/StateListenerImpl.java delete mode 100644 src/jvm/knet/src/main/java/org/mases/knet/streams/errors/StreamsUncaughtExceptionHandlerImpl.java delete mode 100644 src/jvm/knet/src/main/java/org/mases/knet/streams/kstream/AggregatorImpl.java delete mode 100644 src/jvm/knet/src/main/java/org/mases/knet/streams/kstream/ForeachActionImpl.java delete mode 100644 src/jvm/knet/src/main/java/org/mases/knet/streams/kstream/InitializerImpl.java rename src/jvm/knet/src/main/java/org/mases/knet/streams/kstream/{PredicateImpl.java => KNetPredicate.java} (50%) delete mode 100644 src/jvm/knet/src/main/java/org/mases/knet/streams/kstream/KeyValueMapperImpl.java delete mode 100644 src/jvm/knet/src/main/java/org/mases/knet/streams/kstream/MergerImpl.java delete mode 100644 src/jvm/knet/src/main/java/org/mases/knet/streams/kstream/ReducerImpl.java delete mode 100644 src/jvm/knet/src/main/java/org/mases/knet/streams/kstream/ValueJoinerImpl.java delete mode 100644 src/jvm/knet/src/main/java/org/mases/knet/streams/kstream/ValueJoinerWithKeyImpl.java delete mode 100644 src/jvm/knet/src/main/java/org/mases/knet/streams/kstream/ValueMapperImpl.java delete mode 100644 src/jvm/knet/src/main/java/org/mases/knet/streams/kstream/ValueMapperWithKeyImpl.java delete mode 100644 src/jvm/knet/src/main/java/org/mases/knet/streams/processor/ProcessorImpl.java delete mode 100644 src/jvm/knet/src/main/java/org/mases/knet/streams/processor/StateRestoreCallbackImpl.java delete mode 100644 src/jvm/knet/src/main/java/org/mases/knet/streams/processor/StateRestoreListenerImpl.java delete mode 100644 src/jvm/knet/src/main/java/org/mases/knet/streams/processor/StreamPartitionerImpl.java delete mode 100644 src/jvm/knet/src/main/java/org/mases/knet/streams/processor/TimestampExtractorImpl.java delete mode 100644 src/jvm/knet/src/main/java/org/mases/knet/streams/processor/TopicNameExtractorImpl.java delete mode 100644 src/jvm/knet/src/main/java/org/mases/knet/streams/processor/api/FixedKeyProcessorImpl.java delete mode 100644 src/jvm/knet/src/main/java/org/mases/knet/streams/processor/api/ProcessorImpl.java delete mode 100644 src/jvm/knet/src/test/java/org/mases/knet/streams/KafkaClientSupplierImplTest.java delete mode 100644 src/jvm/knet/src/test/java/org/mases/knet/streams/StateListenerImplTest.java create mode 100644 src/net/KNet/Specific/Streams/Kstream/KNetPredicate.cs diff --git a/src/jvm/knet/src/main/java/org/mases/knet/clients/common/serialization/DeserializerImpl.java b/src/jvm/knet/src/main/java/org/mases/knet/clients/common/serialization/DeserializerImpl.java deleted file mode 100644 index 3f751f4801..0000000000 --- a/src/jvm/knet/src/main/java/org/mases/knet/clients/common/serialization/DeserializerImpl.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright 2023 MASES s.r.l. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Refer to LICENSE for more information. - */ - -package org.mases.knet.clients.common.serialization; - -import org.apache.kafka.common.header.Headers; -import org.apache.kafka.common.serialization.Deserializer; -import org.mases.jcobridge.*; - -import java.util.Map; - -public final class DeserializerImpl extends JCListener implements Deserializer { - public DeserializerImpl(String key) throws JCNativeException { - super(key); - } - - public Object deserialize(String topic, byte[] data) { - raiseEvent("deserialize", topic, null, data); - Object retVal = getReturnData(); - return retVal; - } - - public Object deserialize(String topic, Headers headers, byte[] data) { - raiseEvent("deserializeWithHeaders", topic, headers, data); - Object retVal = getReturnData(); - return retVal; - } -} \ No newline at end of file diff --git a/src/jvm/knet/src/main/java/org/mases/knet/clients/common/serialization/SerializerImpl.java b/src/jvm/knet/src/main/java/org/mases/knet/clients/common/serialization/SerializerImpl.java deleted file mode 100644 index 3a78dddda2..0000000000 --- a/src/jvm/knet/src/main/java/org/mases/knet/clients/common/serialization/SerializerImpl.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright 2023 MASES s.r.l. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Refer to LICENSE for more information. - */ - -package org.mases.knet.clients.common.serialization; - -import org.apache.kafka.common.header.Headers; -import org.apache.kafka.common.serialization.Serializer; -import org.mases.jcobridge.*; - -public final class SerializerImpl extends JCListener implements Serializer { - public SerializerImpl(String key) throws JCNativeException { - super(key); - } - - public byte[] serialize(String topic, Object data) { - raiseEvent("serialize", topic, data); - Object retVal = getReturnData(); - return (byte[])retVal; - } - - public byte[] serialize(String topic, Headers headers, Object data) { - raiseEvent("serializeWithHeaders", topic, headers, data); - Object retVal = getReturnData(); - return (byte[])retVal; - } -} \ No newline at end of file diff --git a/src/jvm/knet/src/main/java/org/mases/knet/clients/consumer/ConsumerInterceptorImpl.java b/src/jvm/knet/src/main/java/org/mases/knet/clients/consumer/ConsumerInterceptorImpl.java deleted file mode 100644 index 2617548318..0000000000 --- a/src/jvm/knet/src/main/java/org/mases/knet/clients/consumer/ConsumerInterceptorImpl.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright 2023 MASES s.r.l. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Refer to LICENSE for more information. - */ - -package org.mases.knet.clients.consumer; - -import org.apache.kafka.clients.consumer.ConsumerInterceptor; -import org.apache.kafka.clients.consumer.ConsumerRecords; -import org.mases.jcobridge.*; - -import java.util.Map; - -public final class ConsumerInterceptorImpl extends JCListener implements ConsumerInterceptor { - public ConsumerInterceptorImpl(String key) throws JCNativeException { - super(key); - } - - @Override - public void configure(Map configs) { - raiseEvent("configure", configs); - } - - @Override - public ConsumerRecords onConsume(ConsumerRecords records) { - raiseEvent("onConsume", records); - Object retVal = getReturnData(); - return (ConsumerRecords) retVal; - } - - @Override - public void onCommit(Map offsets) { - raiseEvent("onCommit", offsets); - } - - @Override - public void close() { - raiseEvent("close"); - } -} diff --git a/src/jvm/knet/src/main/java/org/mases/knet/clients/consumer/ConsumerRebalanceListenerImpl.java b/src/jvm/knet/src/main/java/org/mases/knet/clients/consumer/ConsumerRebalanceListenerImpl.java deleted file mode 100644 index b2d5bafca9..0000000000 --- a/src/jvm/knet/src/main/java/org/mases/knet/clients/consumer/ConsumerRebalanceListenerImpl.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright 2023 MASES s.r.l. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Refer to LICENSE for more information. - */ - -package org.mases.knet.clients.consumer; - -import org.apache.kafka.clients.consumer.ConsumerRebalanceListener; -import org.apache.kafka.common.TopicPartition; -import org.mases.jcobridge.*; - -import java.util.Collection; - -public final class ConsumerRebalanceListenerImpl extends JCListener implements ConsumerRebalanceListener { - public ConsumerRebalanceListenerImpl(String key) throws JCNativeException { - super(key); - } - - public void onPartitionsRevoked(Collection partitions) { - raiseEvent("onPartitionsRevoked", partitions); - } - - public void onPartitionsAssigned(Collection partitions) { - raiseEvent("onPartitionsAssigned", partitions); - } -} diff --git a/src/jvm/knet/src/main/java/org/mases/knet/clients/consumer/OffsetCommitCallbackImpl.java b/src/jvm/knet/src/main/java/org/mases/knet/clients/consumer/OffsetCommitCallbackImpl.java deleted file mode 100644 index 28b2116a65..0000000000 --- a/src/jvm/knet/src/main/java/org/mases/knet/clients/consumer/OffsetCommitCallbackImpl.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2023 MASES s.r.l. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Refer to LICENSE for more information. - */ - -package org.mases.knet.clients.consumer; - -import org.apache.kafka.clients.consumer.OffsetAndMetadata; -import org.apache.kafka.clients.consumer.OffsetCommitCallback; -import org.apache.kafka.common.TopicPartition; -import org.mases.jcobridge.*; - -import java.util.Map; - -public final class OffsetCommitCallbackImpl extends JCListener implements OffsetCommitCallback { - public OffsetCommitCallbackImpl(String key) throws JCNativeException { - super(key); - } - - public void onComplete(Map offsets, Exception exception) { - raiseEvent("onComplete", offsets, exception); - } -} diff --git a/src/jvm/knet/src/main/java/org/mases/knet/clients/producer/CallbackImpl.java b/src/jvm/knet/src/main/java/org/mases/knet/clients/producer/CallbackImpl.java deleted file mode 100644 index 92116b6fd5..0000000000 --- a/src/jvm/knet/src/main/java/org/mases/knet/clients/producer/CallbackImpl.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright 2023 MASES s.r.l. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Refer to LICENSE for more information. - */ - -package org.mases.knet.clients.producer; - -import org.apache.kafka.clients.producer.Callback; -import org.mases.jcobridge.*; - -public final class CallbackImpl extends JCListener implements Callback { - public CallbackImpl(String key) throws JCNativeException { - super(key); - } - - @Override - public void onCompletion(org.apache.kafka.clients.producer.RecordMetadata metadata, Exception exception) { - raiseEvent("onCompletion", metadata, exception); - } -} \ No newline at end of file diff --git a/src/jvm/knet/src/main/java/org/mases/knet/common/metrics/MetricsReporterImpl.java b/src/jvm/knet/src/main/java/org/mases/knet/common/metrics/MetricsReporterImpl.java deleted file mode 100644 index 7a2a493022..0000000000 --- a/src/jvm/knet/src/main/java/org/mases/knet/common/metrics/MetricsReporterImpl.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright 2023 MASES s.r.l. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Refer to LICENSE for more information. - */ - -package org.mases.knet.common.metrics; - -import org.apache.kafka.common.config.ConfigException; -import org.apache.kafka.common.metrics.KafkaMetric; -import org.apache.kafka.common.metrics.MetricsContext; -import org.apache.kafka.common.metrics.MetricsReporter; -import org.mases.jcobridge.*; - -import java.util.List; -import java.util.Map; -import java.util.Set; - -public final class MetricsReporterImpl extends JCListener implements MetricsReporter { - public MetricsReporterImpl(String key) throws JCNativeException { - super(key); - } - - @Override - public void init(List metrics) { - raiseEvent("init", metrics); - } - - @Override - public void metricChange(KafkaMetric metric) { - raiseEvent("metricChange", metric); - } - - @Override - public void metricRemoval(KafkaMetric metric) { - raiseEvent("metricRemoval", metric); - } - - @Override - public void close() { - raiseEvent("close"); - } - - @Override - public Set reconfigurableConfigs() { - raiseEvent("reconfigurableConfigs"); - Object retVal = getReturnData(); - return (Set) retVal; - } - - @Override - public void configure(Map configs) { - raiseEvent("configure", configs); - } - - @Override - public void reconfigure(Map configs) { - raiseEvent("reconfigure", configs); - } - - @Override - public void validateReconfiguration(Map configs) throws ConfigException { - raiseEvent("validateReconfiguration", configs); - } - - @Override - public void contextChange(MetricsContext metricsContext) { - raiseEvent("contextChange", metricsContext); - } -} \ No newline at end of file diff --git a/src/jvm/knet/src/main/java/org/mases/knet/streams/KafkaClientSupplierImpl.java b/src/jvm/knet/src/main/java/org/mases/knet/streams/KafkaClientSupplierImpl.java deleted file mode 100644 index b9c6850b8b..0000000000 --- a/src/jvm/knet/src/main/java/org/mases/knet/streams/KafkaClientSupplierImpl.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright 2023 MASES s.r.l. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Refer to LICENSE for more information. - */ - -package org.mases.knet.streams; - -import org.apache.kafka.clients.admin.Admin; -import org.apache.kafka.clients.consumer.Consumer; -import org.apache.kafka.clients.producer.Producer; -import org.apache.kafka.streams.KafkaClientSupplier; -import org.mases.jcobridge.*; - -import java.util.Map; - -public final class KafkaClientSupplierImpl extends JCListener implements KafkaClientSupplier { - public KafkaClientSupplierImpl(String key) throws JCNativeException { - super(key); - } - - @Override - public Admin getAdmin(final Map config) { - raiseEvent("getAdmin", config); - Object retVal = getReturnData(); - return (Admin) retVal; - } - - @Override - public Producer getProducer(final Map config) { - raiseEvent("getProducer", config); - Object retVal = getReturnData(); - return (Producer) retVal; - } - - @Override - public Consumer getConsumer(final Map config) { - raiseEvent("getConsumer", config); - Object retVal = getReturnData(); - return (Consumer) retVal; - } - - @Override - public Consumer getRestoreConsumer(final Map config) { - raiseEvent("getRestoreConsumer", config); - Object retVal = getReturnData(); - return (Consumer) retVal; - } - - @Override - public Consumer getGlobalConsumer(final Map config) { - raiseEvent("getGlobalConsumer", config); - Object retVal = getReturnData(); - return (Consumer) retVal; - } -} \ No newline at end of file diff --git a/src/jvm/knet/src/main/java/org/mases/knet/streams/StateListenerImpl.java b/src/jvm/knet/src/main/java/org/mases/knet/streams/StateListenerImpl.java deleted file mode 100644 index f6fa0711c0..0000000000 --- a/src/jvm/knet/src/main/java/org/mases/knet/streams/StateListenerImpl.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright 2023 MASES s.r.l. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Refer to LICENSE for more information. - */ - -package org.mases.knet.streams; - -import org.apache.kafka.streams.KafkaStreams; -import org.mases.jcobridge.*; - -public final class StateListenerImpl extends JCListener implements KafkaStreams.StateListener { - public StateListenerImpl(String key) throws JCNativeException { - super(key); - } - - @Override - public void onChange(final KafkaStreams.State newState, KafkaStreams.State oldState) { - raiseEvent("onChange", newState, oldState); - } -} \ No newline at end of file diff --git a/src/jvm/knet/src/main/java/org/mases/knet/streams/errors/StreamsUncaughtExceptionHandlerImpl.java b/src/jvm/knet/src/main/java/org/mases/knet/streams/errors/StreamsUncaughtExceptionHandlerImpl.java deleted file mode 100644 index 895a731d63..0000000000 --- a/src/jvm/knet/src/main/java/org/mases/knet/streams/errors/StreamsUncaughtExceptionHandlerImpl.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright 2023 MASES s.r.l. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Refer to LICENSE for more information. - */ - -package org.mases.knet.streams.errors; - -import org.apache.kafka.streams.errors.StreamsUncaughtExceptionHandler; -import org.mases.jcobridge.*; - -public final class StreamsUncaughtExceptionHandlerImpl extends JCListener implements StreamsUncaughtExceptionHandler { - public StreamsUncaughtExceptionHandlerImpl(String key) throws JCNativeException { - super(key); - } - - @Override - public StreamThreadExceptionResponse handle(final Throwable exception) { - raiseEvent("handle", exception); - Object retVal = getReturnData(); - return StreamThreadExceptionResponse.valueOf((String) retVal); - } -} diff --git a/src/jvm/knet/src/main/java/org/mases/knet/streams/kstream/AggregatorImpl.java b/src/jvm/knet/src/main/java/org/mases/knet/streams/kstream/AggregatorImpl.java deleted file mode 100644 index 3d3245ecf5..0000000000 --- a/src/jvm/knet/src/main/java/org/mases/knet/streams/kstream/AggregatorImpl.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright 2023 MASES s.r.l. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Refer to LICENSE for more information. - */ - -package org.mases.knet.streams.kstream; - -import org.apache.kafka.streams.kstream.Aggregator; -import org.mases.jcobridge.*; - -public final class AggregatorImpl extends JCListener implements Aggregator { - public AggregatorImpl(String key) throws JCNativeException { - super(key); - } - - @Override - public Object apply(Object key, Object value, Object aggregate) { - raiseEvent("apply", key, value, aggregate); - Object retVal = getReturnData(); - return retVal; - } -} diff --git a/src/jvm/knet/src/main/java/org/mases/knet/streams/kstream/ForeachActionImpl.java b/src/jvm/knet/src/main/java/org/mases/knet/streams/kstream/ForeachActionImpl.java deleted file mode 100644 index 4131c6a0c1..0000000000 --- a/src/jvm/knet/src/main/java/org/mases/knet/streams/kstream/ForeachActionImpl.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright 2023 MASES s.r.l. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Refer to LICENSE for more information. - */ - -package org.mases.knet.streams.kstream; - -import org.apache.kafka.streams.kstream.ForeachAction; -import org.mases.jcobridge.*; - -public final class ForeachActionImpl extends JCListener implements ForeachAction { - public ForeachActionImpl(String key) throws JCNativeException { - super(key); - } - - @Override - public void apply(Object key, Object value) { - raiseEvent("apply", key, value); - } -} diff --git a/src/jvm/knet/src/main/java/org/mases/knet/streams/kstream/InitializerImpl.java b/src/jvm/knet/src/main/java/org/mases/knet/streams/kstream/InitializerImpl.java deleted file mode 100644 index 84dcadcb4e..0000000000 --- a/src/jvm/knet/src/main/java/org/mases/knet/streams/kstream/InitializerImpl.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright 2023 MASES s.r.l. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Refer to LICENSE for more information. - */ - -package org.mases.knet.streams.kstream; - -import org.apache.kafka.streams.kstream.Initializer; -import org.mases.jcobridge.*; - -public final class InitializerImpl extends JCListener implements Initializer { - public InitializerImpl(String key) throws JCNativeException { - super(key); - } - - @Override - public Object apply() { - raiseEvent("apply"); - Object retVal = getReturnData(); - return retVal; - } -} diff --git a/src/jvm/knet/src/main/java/org/mases/knet/streams/kstream/PredicateImpl.java b/src/jvm/knet/src/main/java/org/mases/knet/streams/kstream/KNetPredicate.java similarity index 50% rename from src/jvm/knet/src/main/java/org/mases/knet/streams/kstream/PredicateImpl.java rename to src/jvm/knet/src/main/java/org/mases/knet/streams/kstream/KNetPredicate.java index d0d07602df..70d0570220 100644 --- a/src/jvm/knet/src/main/java/org/mases/knet/streams/kstream/PredicateImpl.java +++ b/src/jvm/knet/src/main/java/org/mases/knet/streams/kstream/KNetPredicate.java @@ -21,15 +21,33 @@ import org.apache.kafka.streams.kstream.Predicate; import org.mases.jcobridge.*; -public final class PredicateImpl extends JCListener implements Predicate { - public PredicateImpl(String key) throws JCNativeException { - super(key); +import java.util.Arrays; + +public final class KNetPredicate implements Predicate { + Boolean _isKey = null; + byte[] _key = null; + byte[] _value = null; + + public KNetPredicate(byte[] keyOrValue, boolean isKey) { + _isKey = isKey; + _key = keyOrValue; + } + + public KNetPredicate(byte[] keyOrValue, byte[] value) { + _key = keyOrValue; + _value = value; } @Override - public boolean test(Object e1, Object e2) { - raiseEvent("test", e1, e2); - Object retVal = getReturnData(); - return (boolean) retVal; + public boolean test(byte[] bytes, byte[] bytes2) { + if (_isKey != null) { + if (_isKey == true) { + return Arrays.equals(bytes, _key); + } else { + return Arrays.equals(bytes2, _value); + } + } else { + return Arrays.equals(bytes, _key) && Arrays.equals(bytes2, _value); + } } } diff --git a/src/jvm/knet/src/main/java/org/mases/knet/streams/kstream/KeyValueMapperImpl.java b/src/jvm/knet/src/main/java/org/mases/knet/streams/kstream/KeyValueMapperImpl.java deleted file mode 100644 index 9f9bcdde19..0000000000 --- a/src/jvm/knet/src/main/java/org/mases/knet/streams/kstream/KeyValueMapperImpl.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright 2023 MASES s.r.l. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Refer to LICENSE for more information. - */ - -package org.mases.knet.streams.kstream; - -import org.apache.kafka.streams.kstream.KeyValueMapper; -import org.mases.jcobridge.*; - -public final class KeyValueMapperImpl extends JCListener implements KeyValueMapper { - public KeyValueMapperImpl(String key) throws JCNativeException { - super(key); - } - - @Override - public Object apply(Object key, Object value) { - raiseEvent("apply", key, value); - Object retVal = getReturnData(); - return retVal; - } -} diff --git a/src/jvm/knet/src/main/java/org/mases/knet/streams/kstream/MergerImpl.java b/src/jvm/knet/src/main/java/org/mases/knet/streams/kstream/MergerImpl.java deleted file mode 100644 index 3eaefd55a3..0000000000 --- a/src/jvm/knet/src/main/java/org/mases/knet/streams/kstream/MergerImpl.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright 2023 MASES s.r.l. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Refer to LICENSE for more information. - */ - -package org.mases.knet.streams.kstream; - -import org.apache.kafka.streams.kstream.Aggregator; -import org.mases.jcobridge.*; - -public final class MergerImpl extends JCListener implements Aggregator { - public MergerImpl(String key) throws JCNativeException { - super(key); - } - - @Override - public Object apply(final Object aggKey, final Object aggOne, final Object aggTwo) { - raiseEvent("apply", aggKey, aggOne, aggTwo); - Object retVal = getReturnData(); - return retVal; - } -} diff --git a/src/jvm/knet/src/main/java/org/mases/knet/streams/kstream/ReducerImpl.java b/src/jvm/knet/src/main/java/org/mases/knet/streams/kstream/ReducerImpl.java deleted file mode 100644 index 1cb6ebb96a..0000000000 --- a/src/jvm/knet/src/main/java/org/mases/knet/streams/kstream/ReducerImpl.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright 2023 MASES s.r.l. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Refer to LICENSE for more information. - */ - -package org.mases.knet.streams.kstream; - -import org.apache.kafka.streams.kstream.Reducer; -import org.mases.jcobridge.*; - -public final class ReducerImpl extends JCListener implements Reducer { - public ReducerImpl(String key) throws JCNativeException { - super(key); - } - - @Override - public Object apply(Object key, Object value) { - raiseEvent("apply", key, value); - Object retVal = getReturnData(); - return retVal; - } -} diff --git a/src/jvm/knet/src/main/java/org/mases/knet/streams/kstream/ValueJoinerImpl.java b/src/jvm/knet/src/main/java/org/mases/knet/streams/kstream/ValueJoinerImpl.java deleted file mode 100644 index 5cc2ca3b55..0000000000 --- a/src/jvm/knet/src/main/java/org/mases/knet/streams/kstream/ValueJoinerImpl.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright 2023 MASES s.r.l. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Refer to LICENSE for more information. - */ - -package org.mases.knet.streams.kstream; - -import org.apache.kafka.streams.kstream.ValueJoiner; -import org.mases.jcobridge.*; - -public final class ValueJoinerImpl extends JCListener implements ValueJoiner { - public ValueJoinerImpl(String key) throws JCNativeException { - super(key); - } - - @Override - public Object apply(final Object value1, final Object value2) { - raiseEvent("apply", value1, value2); - Object retVal = getReturnData(); - return retVal; - } -} diff --git a/src/jvm/knet/src/main/java/org/mases/knet/streams/kstream/ValueJoinerWithKeyImpl.java b/src/jvm/knet/src/main/java/org/mases/knet/streams/kstream/ValueJoinerWithKeyImpl.java deleted file mode 100644 index 0cbe41e9fd..0000000000 --- a/src/jvm/knet/src/main/java/org/mases/knet/streams/kstream/ValueJoinerWithKeyImpl.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright 2023 MASES s.r.l. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Refer to LICENSE for more information. - */ - -package org.mases.knet.streams.kstream; - -import org.apache.kafka.streams.kstream.ValueJoinerWithKey; -import org.mases.jcobridge.*; - -public final class ValueJoinerWithKeyImpl extends JCListener implements ValueJoinerWithKey { - public ValueJoinerWithKeyImpl(String key) throws JCNativeException { - super(key); - } - - @Override - public Object apply(final Object readOnlyKey, final Object value1, final Object value2) { - raiseEvent("apply", readOnlyKey, value1, value2); - Object retVal = getReturnData(); - return retVal; - } -} diff --git a/src/jvm/knet/src/main/java/org/mases/knet/streams/kstream/ValueMapperImpl.java b/src/jvm/knet/src/main/java/org/mases/knet/streams/kstream/ValueMapperImpl.java deleted file mode 100644 index 7ed29df68a..0000000000 --- a/src/jvm/knet/src/main/java/org/mases/knet/streams/kstream/ValueMapperImpl.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright 2023 MASES s.r.l. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Refer to LICENSE for more information. - */ - -package org.mases.knet.streams.kstream; - -import org.apache.kafka.streams.kstream.ValueMapper; -import org.mases.jcobridge.*; - -public final class ValueMapperImpl extends JCListener implements ValueMapper { - public ValueMapperImpl(String key) throws JCNativeException { - super(key); - } - - @Override - public Object apply(Object key) { - raiseEvent("apply", key); - Object retVal = getReturnData(); - return retVal; - } -} diff --git a/src/jvm/knet/src/main/java/org/mases/knet/streams/kstream/ValueMapperWithKeyImpl.java b/src/jvm/knet/src/main/java/org/mases/knet/streams/kstream/ValueMapperWithKeyImpl.java deleted file mode 100644 index 302c738f3a..0000000000 --- a/src/jvm/knet/src/main/java/org/mases/knet/streams/kstream/ValueMapperWithKeyImpl.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright 2023 MASES s.r.l. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Refer to LICENSE for more information. - */ - -package org.mases.knet.streams.kstream; - -import org.apache.kafka.streams.kstream.ValueMapperWithKey; -import org.mases.jcobridge.*; - -public final class ValueMapperWithKeyImpl extends JCListener implements ValueMapperWithKey { - public ValueMapperWithKeyImpl(String key) throws JCNativeException { - super(key); - } - - @Override - public Object apply(Object readOnlyKey, Object value) { - raiseEvent("apply", readOnlyKey, value); - Object retVal = getReturnData(); - return retVal; - } -} diff --git a/src/jvm/knet/src/main/java/org/mases/knet/streams/processor/ProcessorImpl.java b/src/jvm/knet/src/main/java/org/mases/knet/streams/processor/ProcessorImpl.java deleted file mode 100644 index c0445b3201..0000000000 --- a/src/jvm/knet/src/main/java/org/mases/knet/streams/processor/ProcessorImpl.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright 2023 MASES s.r.l. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Refer to LICENSE for more information. - */ - -package org.mases.knet.streams.processor; - -import org.apache.kafka.streams.processor.Processor; -import org.apache.kafka.streams.processor.ProcessorContext; -import org.mases.jcobridge.*; - -public final class ProcessorImpl extends JCListener implements Processor { - public ProcessorImpl(String key) throws JCNativeException { - super(key); - } - - @Override - public void init(ProcessorContext context) { - raiseEvent("init", context); - } - @Override - public void process(Object key, Object value) { - raiseEvent("process", key, value); - } - @Override - public void close() { - raiseEvent("close"); - } -} diff --git a/src/jvm/knet/src/main/java/org/mases/knet/streams/processor/StateRestoreCallbackImpl.java b/src/jvm/knet/src/main/java/org/mases/knet/streams/processor/StateRestoreCallbackImpl.java deleted file mode 100644 index 9adec6378f..0000000000 --- a/src/jvm/knet/src/main/java/org/mases/knet/streams/processor/StateRestoreCallbackImpl.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright 2023 MASES s.r.l. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Refer to LICENSE for more information. - */ - -package org.mases.knet.streams.processor; - -import org.apache.kafka.streams.processor.StateRestoreCallback; -import org.mases.jcobridge.*; - -public final class StateRestoreCallbackImpl extends JCListener implements StateRestoreCallback { - public StateRestoreCallbackImpl(String key) throws JCNativeException { - super(key); - } - - @Override - public void restore(byte[] key, byte[] value) { - raiseEvent("restore", key, value); - } -} diff --git a/src/jvm/knet/src/main/java/org/mases/knet/streams/processor/StateRestoreListenerImpl.java b/src/jvm/knet/src/main/java/org/mases/knet/streams/processor/StateRestoreListenerImpl.java deleted file mode 100644 index 19107aec5a..0000000000 --- a/src/jvm/knet/src/main/java/org/mases/knet/streams/processor/StateRestoreListenerImpl.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright 2023 MASES s.r.l. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Refer to LICENSE for more information. - */ - -package org.mases.knet.streams.processor; - -import org.apache.kafka.common.TopicPartition; -import org.apache.kafka.streams.processor.StateRestoreListener; -import org.mases.jcobridge.*; - -public final class StateRestoreListenerImpl extends JCListener implements StateRestoreListener { - public StateRestoreListenerImpl(String key) throws JCNativeException { - super(key); - } - - @Override - public void onRestoreStart(final TopicPartition topicPartition, - final String storeName, - final long startingOffset, - final long endingOffset) { - raiseEvent("onBatchRestored", topicPartition, storeName, startingOffset, endingOffset); - } - - @Override - public void onBatchRestored(final TopicPartition topicPartition, - final String storeName, - final long batchEndOffset, - final long numRestored) { - raiseEvent("onBatchRestored", topicPartition, storeName, batchEndOffset, numRestored); - } - - @Override - public void onRestoreEnd(final TopicPartition topicPartition, - final String storeName, - final long totalRestored) { - raiseEvent("onRestoreEnd", topicPartition, storeName, totalRestored); - } -} diff --git a/src/jvm/knet/src/main/java/org/mases/knet/streams/processor/StreamPartitionerImpl.java b/src/jvm/knet/src/main/java/org/mases/knet/streams/processor/StreamPartitionerImpl.java deleted file mode 100644 index 3cc033c112..0000000000 --- a/src/jvm/knet/src/main/java/org/mases/knet/streams/processor/StreamPartitionerImpl.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright 2023 MASES s.r.l. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Refer to LICENSE for more information. - */ - -package org.mases.knet.streams.processor; - -import org.apache.kafka.streams.processor.StreamPartitioner; -import org.mases.jcobridge.*; - -import java.util.Optional; -import java.util.Set; - -public final class StreamPartitionerImpl extends JCListener implements StreamPartitioner { - public StreamPartitionerImpl(String key) throws JCNativeException { - super(key); - } - - @Override - public Integer partition(String topic, Object key, Object value, int numPartitions) { - raiseEvent("partition", topic, key, value, numPartitions); - Object retVal = getReturnData(); - int ret = (int) retVal; - if (ret == -1) return null; - return (int) retVal; - } - - @Override - public Optional> partitions(String topic, Object key, Object value, int numPartitions) { - raiseEvent("partitions", topic, key, value, numPartitions); - Object retVal = getReturnData(); - int ret = (int) retVal; - if (ret == -1) return null; - return (Optional>) retVal; - } -} diff --git a/src/jvm/knet/src/main/java/org/mases/knet/streams/processor/TimestampExtractorImpl.java b/src/jvm/knet/src/main/java/org/mases/knet/streams/processor/TimestampExtractorImpl.java deleted file mode 100644 index 5b3f5f838f..0000000000 --- a/src/jvm/knet/src/main/java/org/mases/knet/streams/processor/TimestampExtractorImpl.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright 2023 MASES s.r.l. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Refer to LICENSE for more information. - */ - -package org.mases.knet.streams.processor; - -import org.apache.kafka.streams.processor.TimestampExtractor; -import org.apache.kafka.clients.consumer.ConsumerRecord; -import org.mases.jcobridge.*; - -public final class TimestampExtractorImpl extends JCListener implements TimestampExtractor { - public TimestampExtractorImpl(String key) throws JCNativeException { - super(key); - } - - @Override - public long extract(ConsumerRecord record, long partitionTime) { - raiseEvent("extract", record, partitionTime); - Object retVal = getReturnData(); - long ret = (long)retVal; - return ret; - } -} diff --git a/src/jvm/knet/src/main/java/org/mases/knet/streams/processor/TopicNameExtractorImpl.java b/src/jvm/knet/src/main/java/org/mases/knet/streams/processor/TopicNameExtractorImpl.java deleted file mode 100644 index bdf20ec0ff..0000000000 --- a/src/jvm/knet/src/main/java/org/mases/knet/streams/processor/TopicNameExtractorImpl.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2023 MASES s.r.l. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Refer to LICENSE for more information. - */ - -package org.mases.knet.streams.processor; - -import org.apache.kafka.streams.processor.RecordContext; -import org.apache.kafka.streams.processor.TopicNameExtractor; -import org.mases.jcobridge.*; - -public final class TopicNameExtractorImpl extends JCListener implements TopicNameExtractor { - public TopicNameExtractorImpl(String key) throws JCNativeException { - super(key); - } - - @Override - public String extract(final Object key, final Object value, final RecordContext recordContext) { - raiseEvent("extract", key, value, recordContext); - Object retVal = getReturnData(); - return (String)retVal; - } -} diff --git a/src/jvm/knet/src/main/java/org/mases/knet/streams/processor/api/FixedKeyProcessorImpl.java b/src/jvm/knet/src/main/java/org/mases/knet/streams/processor/api/FixedKeyProcessorImpl.java deleted file mode 100644 index 378492731d..0000000000 --- a/src/jvm/knet/src/main/java/org/mases/knet/streams/processor/api/FixedKeyProcessorImpl.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright 2023 MASES s.r.l. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Refer to LICENSE for more information. - */ - -package org.mases.knet.streams.processor.api; - -import org.apache.kafka.streams.processor.api.FixedKeyProcessor; -import org.apache.kafka.streams.processor.api.FixedKeyProcessorContext; -import org.apache.kafka.streams.processor.api.FixedKeyRecord; -import org.mases.jcobridge.*; - -public final class FixedKeyProcessorImpl extends JCListener implements FixedKeyProcessor { - public FixedKeyProcessorImpl(String key) throws JCNativeException { - super(key); - } - - @Override - public void init(FixedKeyProcessorContext context) { - raiseEvent("init", context); - } - @Override - public void process(FixedKeyRecord record) { - raiseEvent("process", record); - } - @Override - public void close() { - raiseEvent("close"); - } -} diff --git a/src/jvm/knet/src/main/java/org/mases/knet/streams/processor/api/ProcessorImpl.java b/src/jvm/knet/src/main/java/org/mases/knet/streams/processor/api/ProcessorImpl.java deleted file mode 100644 index 085329aeb7..0000000000 --- a/src/jvm/knet/src/main/java/org/mases/knet/streams/processor/api/ProcessorImpl.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright 2023 MASES s.r.l. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Refer to LICENSE for more information. - */ - -package org.mases.knet.streams.processor.api; - -import org.apache.kafka.streams.processor.api.Processor; -import org.apache.kafka.streams.processor.api.ProcessorContext; -import org.apache.kafka.streams.processor.api.Record; -import org.mases.jcobridge.*; - -public final class ProcessorImpl extends JCListener implements Processor { - public ProcessorImpl(String key) throws JCNativeException { - super(key); - } - - @Override - public void init(ProcessorContext context) { - raiseEvent("init", context); - } - @Override - public void process(Record record) { - raiseEvent("process", record); - } - @Override - public void close() { - raiseEvent("close"); - } -} diff --git a/src/jvm/knet/src/test/java/org/mases/knet/streams/KafkaClientSupplierImplTest.java b/src/jvm/knet/src/test/java/org/mases/knet/streams/KafkaClientSupplierImplTest.java deleted file mode 100644 index ebf330150b..0000000000 --- a/src/jvm/knet/src/test/java/org/mases/knet/streams/KafkaClientSupplierImplTest.java +++ /dev/null @@ -1,18 +0,0 @@ -package org.mases.knet.streams; - -import org.junit.Test; - -import static org.junit.Assert.assertTrue; - -/** - * Unit test for simple App. - */ -public class KafkaClientSupplierImplTest { - /** - * Rigorous Test :-) - */ - @Test - public void shouldAnswerWithTrue() { - assertTrue(true); - } -} \ No newline at end of file diff --git a/src/jvm/knet/src/test/java/org/mases/knet/streams/StateListenerImplTest.java b/src/jvm/knet/src/test/java/org/mases/knet/streams/StateListenerImplTest.java deleted file mode 100644 index 7f0f7c3663..0000000000 --- a/src/jvm/knet/src/test/java/org/mases/knet/streams/StateListenerImplTest.java +++ /dev/null @@ -1,18 +0,0 @@ -package org.mases.knet.streams; - -import org.junit.Test; - -import static org.junit.Assert.assertTrue; - -/** - * Unit test for simple App. - */ -public class StateListenerImplTest { - /** - * Rigorous Test :-) - */ - @Test - public void shouldAnswerWithTrue() { - assertTrue(true); - } -} \ No newline at end of file diff --git a/src/net/KNet/Specific/Streams/Kstream/KNetPredicate.cs b/src/net/KNet/Specific/Streams/Kstream/KNetPredicate.cs new file mode 100644 index 0000000000..8807f83ca7 --- /dev/null +++ b/src/net/KNet/Specific/Streams/Kstream/KNetPredicate.cs @@ -0,0 +1,70 @@ +/* +* Copyright 2023 MASES s.r.l. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +* Refer to LICENSE for more information. +*/ + +using Java.Security; +using MASES.JCOBridge.C2JBridge; +using Org.Apache.Kafka.Streams.Kstream; +using System; + +namespace MASES.KNet.Specific.Streams.Kstream +{ + /// + /// KNet extension of + /// + public class KNetPredicate : JVMBridgeBase + { + /// + /// + /// + public override string BridgeClassName => "org.mases.knet.streams.kstream.KNetPredicate"; + /// + /// Converter from to + /// + public static implicit operator Predicate(KNetPredicate t) => t.Cast(); + /// + /// Converter from to + /// + public static implicit operator Predicate(KNetPredicate t) => t.Cast>(); + /// + /// Default constructor: even if the corresponding Java class does not have one, it is mandatory for JCOBridge + /// + public KNetPredicate() { } + /// + /// Generic constructor: it is useful for JCOBridge when there is a derived class which needs to pass arguments to the highest JVMBridgeBase class + /// + public KNetPredicate(params object[] args) : base(args) { } + /// + /// Initialize a new for key or value comparison + /// + /// The key, or value, to use in comparison + /// if represent a key, otherwise + public KNetPredicate(byte[] keyOrValue, bool isKey) + : base(keyOrValue, isKey) + { + } + /// + /// Initialize a new for both key and value comparison + /// + /// The key to use in comparison + /// The value to use in comparison + /// Both and shall be equal to input parameters of to return + public KNetPredicate(byte[] key, byte[] value) : base(key, value) + { + } + } +} From 238ecd5dbfa91b9da197c6ac9212845962e72c54 Mon Sep 17 00:00:00 2001 From: masesdevelopers <94312179+masesdevelopers@users.noreply.github.com> Date: Wed, 13 Dec 2023 18:44:18 +0100 Subject: [PATCH 03/18] Added Stores and StoresDefault methods to suppliers --- .../streams/kstream/TransformerSupplier.java | 15 +++++ .../kstream/ValueTransformerSupplier.java | 14 +++++ .../ValueTransformerWithKeySupplier.java | 15 +++++ .../api/FixedKeyProcessorSupplier.java | 15 +++++ .../processor/api/ProcessorSupplier.java | 15 +++++ .../Streams/KStream/TransformerSupplier.cs | 59 ++++++++++++++---- .../KStream/ValueTransformerSupplier.cs | 59 ++++++++++++++---- .../ValueTransformerWithKeySupplier.cs | 59 ++++++++++++++---- .../Api/FixedKeyProcessorSupplier.cs | 62 +++++++++++++++---- .../Processor/Api/ProcessorSupplier.cs | 60 ++++++++++++++---- 10 files changed, 311 insertions(+), 62 deletions(-) diff --git a/src/jvm/knet/src/main/java/org/mases/knet/streams/kstream/TransformerSupplier.java b/src/jvm/knet/src/main/java/org/mases/knet/streams/kstream/TransformerSupplier.java index b6ca2c57d0..1b88a13f56 100644 --- a/src/jvm/knet/src/main/java/org/mases/knet/streams/kstream/TransformerSupplier.java +++ b/src/jvm/knet/src/main/java/org/mases/knet/streams/kstream/TransformerSupplier.java @@ -18,11 +18,26 @@ package org.mases.knet.streams.kstream; +import org.apache.kafka.streams.state.StoreBuilder; +import org.mases.knet.streams.processor.api.FixedKeyProcessorSupplier; + +import java.util.Set; + public final class TransformerSupplier extends org.mases.jcobridge.JCListener implements org.apache.kafka.streams.kstream.TransformerSupplier { public TransformerSupplier(String key) throws org.mases.jcobridge.JCNativeException { super(key); } + public Set> storesDefault() { + return org.apache.kafka.streams.kstream.TransformerSupplier.super.stores(); + } + + @Override + public Set> stores() { + raiseEvent("stores"); + Object retVal = getReturnData(); + return (Set>) retVal; + } @Override public org.apache.kafka.streams.kstream.Transformer get() { raiseEvent("get"); diff --git a/src/jvm/knet/src/main/java/org/mases/knet/streams/kstream/ValueTransformerSupplier.java b/src/jvm/knet/src/main/java/org/mases/knet/streams/kstream/ValueTransformerSupplier.java index 3f0cf4484d..d71ea5fb42 100644 --- a/src/jvm/knet/src/main/java/org/mases/knet/streams/kstream/ValueTransformerSupplier.java +++ b/src/jvm/knet/src/main/java/org/mases/knet/streams/kstream/ValueTransformerSupplier.java @@ -18,11 +18,25 @@ package org.mases.knet.streams.kstream; +import org.apache.kafka.streams.state.StoreBuilder; + +import java.util.Set; + public final class ValueTransformerSupplier extends org.mases.jcobridge.JCListener implements org.apache.kafka.streams.kstream.ValueTransformerSupplier { public ValueTransformerSupplier(String key) throws org.mases.jcobridge.JCNativeException { super(key); } + public Set> storesDefault() { + return org.apache.kafka.streams.kstream.ValueTransformerSupplier.super.stores(); + } + + @Override + public Set> stores() { + raiseEvent("stores"); + Object retVal = getReturnData(); + return (Set>) retVal; + } @Override public org.apache.kafka.streams.kstream.ValueTransformer get() { raiseEvent("get"); diff --git a/src/jvm/knet/src/main/java/org/mases/knet/streams/kstream/ValueTransformerWithKeySupplier.java b/src/jvm/knet/src/main/java/org/mases/knet/streams/kstream/ValueTransformerWithKeySupplier.java index 70f089b765..7efeb4f675 100644 --- a/src/jvm/knet/src/main/java/org/mases/knet/streams/kstream/ValueTransformerWithKeySupplier.java +++ b/src/jvm/knet/src/main/java/org/mases/knet/streams/kstream/ValueTransformerWithKeySupplier.java @@ -18,11 +18,26 @@ package org.mases.knet.streams.kstream; +import org.apache.kafka.streams.state.StoreBuilder; + +import java.util.Set; + public final class ValueTransformerWithKeySupplier extends org.mases.jcobridge.JCListener implements org.apache.kafka.streams.kstream.ValueTransformerWithKeySupplier { public ValueTransformerWithKeySupplier(String key) throws org.mases.jcobridge.JCNativeException { super(key); } + public Set> storesDefault() { + return org.apache.kafka.streams.kstream.ValueTransformerWithKeySupplier.super.stores(); + } + + @Override + public Set> stores() { + raiseEvent("stores"); + Object retVal = getReturnData(); + return (Set>) retVal; + } + @Override public org.apache.kafka.streams.kstream.ValueTransformerWithKey get() { raiseEvent("get"); diff --git a/src/jvm/knet/src/main/java/org/mases/knet/streams/processor/api/FixedKeyProcessorSupplier.java b/src/jvm/knet/src/main/java/org/mases/knet/streams/processor/api/FixedKeyProcessorSupplier.java index c37a239a37..1def663cec 100644 --- a/src/jvm/knet/src/main/java/org/mases/knet/streams/processor/api/FixedKeyProcessorSupplier.java +++ b/src/jvm/knet/src/main/java/org/mases/knet/streams/processor/api/FixedKeyProcessorSupplier.java @@ -18,11 +18,26 @@ package org.mases.knet.streams.processor.api; +import org.apache.kafka.streams.state.StoreBuilder; + +import java.util.Set; + public final class FixedKeyProcessorSupplier extends org.mases.jcobridge.JCListener implements org.apache.kafka.streams.processor.api.FixedKeyProcessorSupplier { public FixedKeyProcessorSupplier(String key) throws org.mases.jcobridge.JCNativeException { super(key); } + public Set> storesDefault() { + return org.apache.kafka.streams.processor.api.FixedKeyProcessorSupplier.super.stores(); + } + + @Override + public Set> stores() { + raiseEvent("stores"); + Object retVal = getReturnData(); + return (Set>) retVal; + } + @Override public org.apache.kafka.streams.processor.api.FixedKeyProcessor get() { raiseEvent("get"); diff --git a/src/jvm/knet/src/main/java/org/mases/knet/streams/processor/api/ProcessorSupplier.java b/src/jvm/knet/src/main/java/org/mases/knet/streams/processor/api/ProcessorSupplier.java index f7e217c585..f4fe7aed35 100644 --- a/src/jvm/knet/src/main/java/org/mases/knet/streams/processor/api/ProcessorSupplier.java +++ b/src/jvm/knet/src/main/java/org/mases/knet/streams/processor/api/ProcessorSupplier.java @@ -18,11 +18,26 @@ package org.mases.knet.streams.processor.api; +import org.apache.kafka.streams.state.StoreBuilder; + +import java.util.Set; + public final class ProcessorSupplier extends org.mases.jcobridge.JCListener implements org.apache.kafka.streams.processor.api.ProcessorSupplier { public ProcessorSupplier(String key) throws org.mases.jcobridge.JCNativeException { super(key); } + public Set> storesDefault() { + return org.apache.kafka.streams.processor.api.ProcessorSupplier.super.stores(); + } + + @Override + public Set> stores() { + raiseEvent("stores"); + Object retVal = getReturnData(); + return (Set>) retVal; + } + @Override public org.apache.kafka.streams.processor.api.Processor get() { raiseEvent("get"); diff --git a/src/net/KNet/Developed/Org/Apache/Kafka/Streams/KStream/TransformerSupplier.cs b/src/net/KNet/Developed/Org/Apache/Kafka/Streams/KStream/TransformerSupplier.cs index 1394d77ec5..59e956909b 100644 --- a/src/net/KNet/Developed/Org/Apache/Kafka/Streams/KStream/TransformerSupplier.cs +++ b/src/net/KNet/Developed/Org/Apache/Kafka/Streams/KStream/TransformerSupplier.cs @@ -23,7 +23,7 @@ namespace Org.Apache.Kafka.Streams.Kstream { #region ITransformerSupplier /// - /// .NET interface for + /// .NET interface for /// public partial interface ITransformerSupplier { @@ -41,7 +41,7 @@ public partial interface ITransformerSupplier #region TransformerSupplier /// - /// + /// /// public partial class TransformerSupplier : JVMBridgeListener, Org.Apache.Kafka.Streams.Kstream.ITransformerSupplier, Org.Apache.Kafka.Streams.Processor.IConnectedStoreProvider, Java.Util.Function.ISupplier> { @@ -68,29 +68,31 @@ public partial class TransformerSupplier : JVMBridgeListener, Org.Apach /// protected virtual void InitializeHandlers() { - AddEventHandler("get", new System.EventHandler>(GetEventHandler)); OnGet = Get; + AddEventHandler("get", new System.EventHandler>(GetEventHandler)); + AddEventHandler("stores", new System.EventHandler>(StoresEventHandler)); } /// - /// Handler for + /// Handler for /// - public System.Action OnInit { get; set; } + public System.Action OnInit { get; set; } = null; /// - /// Handler for + /// Handler for /// - public System.Func OnTransform { get; set; } + public System.Func OnTransform { get; set; } = null; /// - /// Handler for + /// Handler for /// - public System.Func> OnGet { get; set; } + public System.Func> OnGet { get; set; } = null; void GetEventHandler(object sender, CLRListenerEventArgs data) { - if (OnGet != null) + var methodToExecute = (OnGet != null) ? OnGet : Get; + if (methodToExecute != null) { - var executionResult = OnGet.Invoke(); + var executionResult = methodToExecute.Invoke(); executionResult.OnClose = () => { lock (m_list) @@ -108,7 +110,7 @@ void GetEventHandler(object sender, CLRListenerEventArgs data) } /// - /// + /// /// /// public virtual Org.Apache.Kafka.Streams.Kstream.Transformer Get() @@ -120,6 +122,39 @@ public virtual Org.Apache.Kafka.Streams.Kstream.Transformer Get() }; } + /// + /// + /// + /// of + /// The method invokes the default implementation in the JVM interface + public Java.Util.Set StoresDefault() + { + return IExecute>("storesDefault"); + } + + /// + /// Handler for + /// + /// If has a value it takes precedence over corresponding class method + public System.Func> OnStores { get; set; } = null; + + void StoresEventHandler(object sender, CLRListenerEventArgs data) + { + var methodToExecute = (OnStores != null) ? OnStores : Stores; + var executionResult = methodToExecute(); + data.SetReturnValue(executionResult); + } + + /// + /// + /// + /// of + /// The method invokes the default implementation in the JVM interface using ; override the method to implement a different behavior + public virtual Java.Util.Set Stores() + { + return StoresDefault(); + } + #endregion } #endregion diff --git a/src/net/KNet/Developed/Org/Apache/Kafka/Streams/KStream/ValueTransformerSupplier.cs b/src/net/KNet/Developed/Org/Apache/Kafka/Streams/KStream/ValueTransformerSupplier.cs index ae76835965..3b8a29d8fc 100644 --- a/src/net/KNet/Developed/Org/Apache/Kafka/Streams/KStream/ValueTransformerSupplier.cs +++ b/src/net/KNet/Developed/Org/Apache/Kafka/Streams/KStream/ValueTransformerSupplier.cs @@ -23,7 +23,7 @@ namespace Org.Apache.Kafka.Streams.Kstream { #region IValueTransformerSupplier /// - /// .NET interface for + /// .NET interface for /// public partial interface IValueTransformerSupplier { @@ -41,7 +41,7 @@ public partial interface IValueTransformerSupplier #region ValueTransformerSupplier /// - /// + /// /// public partial class ValueTransformerSupplier : JVMBridgeListener, Org.Apache.Kafka.Streams.Kstream.IValueTransformerSupplier { @@ -68,29 +68,31 @@ public partial class ValueTransformerSupplier : JVMBridgeListener, Org.Ap /// protected virtual void InitializeHandlers() { - AddEventHandler("get", new System.EventHandler>(GetEventHandler)); OnGet = Get; + AddEventHandler("get", new System.EventHandler>(GetEventHandler)); + AddEventHandler("stores", new System.EventHandler>(StoresEventHandler)); } /// - /// Handler for + /// Handler for /// - public System.Action OnInit { get; set; } + public System.Action OnInit { get; set; } = null; /// - /// Handler for + /// Handler for /// - public System.Func OnTransform { get; set; } + public System.Func OnTransform { get; set; } = null; /// - /// Handler for + /// Handler for /// - public System.Func> OnGet { get; set; } + public System.Func> OnGet { get; set; } = null; void GetEventHandler(object sender, CLRListenerEventArgs data) { - if (OnGet != null) + var methodToExecute = (OnGet != null) ? OnGet : Get; + if (methodToExecute != null) { - var executionResult = OnGet.Invoke(); + var executionResult = methodToExecute.Invoke(); executionResult.OnClose = () => { lock (m_list) @@ -108,7 +110,7 @@ void GetEventHandler(object sender, CLRListenerEventArgs data) } /// - /// + /// /// /// public virtual Org.Apache.Kafka.Streams.Kstream.ValueTransformer Get() @@ -120,6 +122,39 @@ public virtual Org.Apache.Kafka.Streams.Kstream.ValueTransformer Get() }; } + /// + /// + /// + /// of + /// The method invokes the default implementation in the JVM interface + public Java.Util.Set StoresDefault() + { + return IExecute>("storesDefault"); + } + + /// + /// Handler for + /// + /// If has a value it takes precedence over corresponding class method + public System.Func> OnStores { get; set; } = null; + + void StoresEventHandler(object sender, CLRListenerEventArgs data) + { + var methodToExecute = (OnStores != null) ? OnStores : Stores; + var executionResult = methodToExecute(); + data.SetReturnValue(executionResult); + } + + /// + /// + /// + /// of + /// The method invokes the default implementation in the JVM interface using ; override the method to implement a different behavior + public virtual Java.Util.Set Stores() + { + return StoresDefault(); + } + #endregion } #endregion diff --git a/src/net/KNet/Developed/Org/Apache/Kafka/Streams/KStream/ValueTransformerWithKeySupplier.cs b/src/net/KNet/Developed/Org/Apache/Kafka/Streams/KStream/ValueTransformerWithKeySupplier.cs index c0c9374829..d98abbcee0 100644 --- a/src/net/KNet/Developed/Org/Apache/Kafka/Streams/KStream/ValueTransformerWithKeySupplier.cs +++ b/src/net/KNet/Developed/Org/Apache/Kafka/Streams/KStream/ValueTransformerWithKeySupplier.cs @@ -23,7 +23,7 @@ namespace Org.Apache.Kafka.Streams.Kstream { #region IValueTransformerWithKeySupplier /// - /// .NET interface for + /// .NET interface for /// public partial interface IValueTransformerWithKeySupplier { @@ -35,7 +35,7 @@ public partial interface IValueTransformerWithKeySupplier #region ValueTransformerWithKeySupplier /// - /// + /// /// public partial class ValueTransformerWithKeySupplier : JVMBridgeListener, Org.Apache.Kafka.Streams.Kstream.IValueTransformerWithKeySupplier, Org.Apache.Kafka.Streams.Processor.IConnectedStoreProvider, Java.Util.Function.ISupplier> { @@ -62,29 +62,31 @@ public partial class ValueTransformerWithKeySupplier : JVMBridgeListen /// protected virtual void InitializeHandlers() { - AddEventHandler("get", new System.EventHandler>(GetEventHandler)); OnGet = Get; + AddEventHandler("get", new System.EventHandler>(GetEventHandler)); + AddEventHandler("stores", new System.EventHandler>(StoresEventHandler)); } /// - /// Handler for + /// Handler for /// - public System.Action OnInit { get; set; } + public System.Action OnInit { get; set; } = null; /// - /// Handler for + /// Handler for /// - public System.Func OnTransform { get; set; } + public System.Func OnTransform { get; set; } = null; /// - /// Handler for + /// Handler for /// - public System.Func> OnGet { get; set; } + public System.Func> OnGet { get; set; } = null; void GetEventHandler(object sender, CLRListenerEventArgs data) { - if (OnGet != null) + var methodToExecute = (OnGet != null) ? OnGet : Get; + if (methodToExecute != null) { - var executionResult = OnGet.Invoke(); + var executionResult = methodToExecute.Invoke(); executionResult.OnClose = () => { lock (m_list) @@ -102,7 +104,7 @@ void GetEventHandler(object sender, CLRListenerEventArgs data) } /// - /// + /// /// /// public virtual Org.Apache.Kafka.Streams.Kstream.ValueTransformerWithKey Get() @@ -114,6 +116,39 @@ public virtual Org.Apache.Kafka.Streams.Kstream.ValueTransformerWithKey + /// + /// + /// of + /// The method invokes the default implementation in the JVM interface + public Java.Util.Set StoresDefault() + { + return IExecute>("storesDefault"); + } + + /// + /// Handler for + /// + /// If has a value it takes precedence over corresponding class method + public System.Func> OnStores { get; set; } = null; + + void StoresEventHandler(object sender, CLRListenerEventArgs data) + { + var methodToExecute = (OnStores != null) ? OnStores : Stores; + var executionResult = methodToExecute(); + data.SetReturnValue(executionResult); + } + + /// + /// + /// + /// of + /// The method invokes the default implementation in the JVM interface using ; override the method to implement a different behavior + public virtual Java.Util.Set Stores() + { + return StoresDefault(); + } + #endregion } #endregion diff --git a/src/net/KNet/Developed/Org/Apache/Kafka/Streams/Processor/Api/FixedKeyProcessorSupplier.cs b/src/net/KNet/Developed/Org/Apache/Kafka/Streams/Processor/Api/FixedKeyProcessorSupplier.cs index 0d85f8846a..e3abc67fc4 100644 --- a/src/net/KNet/Developed/Org/Apache/Kafka/Streams/Processor/Api/FixedKeyProcessorSupplier.cs +++ b/src/net/KNet/Developed/Org/Apache/Kafka/Streams/Processor/Api/FixedKeyProcessorSupplier.cs @@ -18,7 +18,7 @@ /* * This file is generated by MASES.JNetReflector (ver. 1.5.5.0) -* using kafka-streams-3.4.0.jar as reference +* using kafka-streams-3.6.1.jar as reference */ using MASES.JCOBridge.C2JBridge; @@ -28,7 +28,7 @@ namespace Org.Apache.Kafka.Streams.Processor.Api { #region IFixedKeyProcessorSupplier /// - /// .NET interface for + /// .NET interface for /// public partial interface IFixedKeyProcessorSupplier { @@ -46,7 +46,7 @@ public partial interface IFixedKeyProcessorSupplier #region FixedKeyProcessorSupplier /// - /// + /// /// public partial class FixedKeyProcessorSupplier : JVMBridgeListener, Org.Apache.Kafka.Streams.Processor.Api.IFixedKeyProcessorSupplier, Org.Apache.Kafka.Streams.Processor.IConnectedStoreProvider, Java.Util.Function.ISupplier> { @@ -73,29 +73,31 @@ public partial class FixedKeyProcessorSupplier : JVMBridgeListen /// protected virtual void InitializeHandlers() { - AddEventHandler("get", new System.EventHandler>(GetEventHandler)); OnGet = Get; + AddEventHandler("get", new System.EventHandler>(GetEventHandler)); + AddEventHandler("stores", new System.EventHandler>(StoresEventHandler)); } /// - /// Handler for + /// Handler for /// - public System.Action> OnInit { get; set; } + public System.Action> OnInit { get; set; } = null; /// - /// Handler for + /// Handler for /// - public System.Action> OnProcess { get; set; } + public System.Action> OnProcess { get; set; } = null; /// - /// Handler for + /// Handler for /// - public System.Func> OnGet { get; set; } + public System.Func> OnGet { get; set; } = null; void GetEventHandler(object sender, CLRListenerEventArgs data) { - if (OnGet != null) + var methodToExecute = (OnGet != null) ? OnGet : Get; + if (methodToExecute != null) { - var executionResult = OnGet.Invoke(); + var executionResult = methodToExecute.Invoke(); executionResult.OnClose = () => { lock (m_list) @@ -113,7 +115,7 @@ void GetEventHandler(object sender, CLRListenerEventArgs data) } /// - /// + /// /// /// public virtual Org.Apache.Kafka.Streams.Processor.Api.FixedKeyProcessor Get() @@ -125,6 +127,40 @@ public virtual Org.Apache.Kafka.Streams.Processor.Api.FixedKeyProcessor + /// + /// + /// of + /// The method invokes the default implementation in the JVM interface + public Java.Util.Set StoresDefault() + { + return IExecute>("storesDefault"); + } + + /// + /// Handler for + /// + /// If has a value it takes precedence over corresponding class method + public System.Func> OnStores { get; set; } = null; + + void StoresEventHandler(object sender, CLRListenerEventArgs data) + { + var methodToExecute = (OnStores != null) ? OnStores : Stores; + var executionResult = methodToExecute(); + data.SetReturnValue(executionResult); + } + + /// + /// + /// + /// of + /// The method invokes the default implementation in the JVM interface using ; override the method to implement a different behavior + public virtual Java.Util.Set Stores() + { + return StoresDefault(); + } + #endregion } #endregion diff --git a/src/net/KNet/Developed/Org/Apache/Kafka/Streams/Processor/Api/ProcessorSupplier.cs b/src/net/KNet/Developed/Org/Apache/Kafka/Streams/Processor/Api/ProcessorSupplier.cs index 1473997c42..64d983794a 100644 --- a/src/net/KNet/Developed/Org/Apache/Kafka/Streams/Processor/Api/ProcessorSupplier.cs +++ b/src/net/KNet/Developed/Org/Apache/Kafka/Streams/Processor/Api/ProcessorSupplier.cs @@ -23,7 +23,7 @@ namespace Org.Apache.Kafka.Streams.Processor.Api { #region IProcessorSupplier /// - /// .NET interface for + /// .NET interface for /// public partial interface IProcessorSupplier { @@ -41,7 +41,7 @@ public partial interface IProcessorSupplier #region ProcessorSupplier /// - /// + /// /// public partial class ProcessorSupplier : JVMBridgeListener, Org.Apache.Kafka.Streams.Processor.Api.IProcessorSupplier, Org.Apache.Kafka.Streams.Processor.IConnectedStoreProvider, Java.Util.Function.ISupplier> { @@ -68,29 +68,31 @@ public partial class ProcessorSupplier : JVMBridgeListener /// protected virtual void InitializeHandlers() { - AddEventHandler("get", new System.EventHandler>(GetEventHandler)); OnGet = Get; + AddEventHandler("get", new System.EventHandler>(GetEventHandler)); + AddEventHandler("stores", new System.EventHandler>(StoresEventHandler)); } /// - /// Handler for + /// Handler for /// - public System.Action> OnInit { get; set; } + public System.Action> OnInit { get; set; } = null; /// - /// Handler for + /// Handler for /// - public System.Action> OnProcess { get; set; } + public System.Action> OnProcess { get; set; } = null; /// - /// Handler for + /// Handler for /// - public System.Func> OnGet { get; set; } + public System.Func> OnGet { get; set; } = null; void GetEventHandler(object sender, CLRListenerEventArgs data) { - if (OnGet != null) + var methodToExecute = (OnGet != null) ? OnGet : Get; + if (methodToExecute != null) { - var executionResult = OnGet.Invoke(); + var executionResult = methodToExecute.Invoke(); executionResult.OnClose = () => { lock (m_list) @@ -107,9 +109,8 @@ void GetEventHandler(object sender, CLRListenerEventArgs data) } } - /// - /// + /// /// /// public virtual Org.Apache.Kafka.Streams.Processor.Api.Processor Get() @@ -121,6 +122,39 @@ public virtual Org.Apache.Kafka.Streams.Processor.Api.Processor + /// + /// + /// of + /// The method invokes the default implementation in the JVM interface + public Java.Util.Set StoresDefault() + { + return IExecute>("storesDefault"); + } + + /// + /// Handler for + /// + /// If has a value it takes precedence over corresponding class method + public System.Func> OnStores { get; set; } = null; + + void StoresEventHandler(object sender, CLRListenerEventArgs data) + { + var methodToExecute = (OnStores != null) ? OnStores : Stores; + var executionResult = methodToExecute(); + data.SetReturnValue(executionResult); + } + + /// + /// + /// + /// of + /// The method invokes the default implementation in the JVM interface using ; override the method to implement a different behavior + public virtual Java.Util.Set Stores() + { + return StoresDefault(); + } + #endregion } #endregion From e4db2533752bd5d4c6c5158af53f2f2a0aa9f553 Mon Sep 17 00:00:00 2001 From: masesdevelopers <94312179+masesdevelopers@users.noreply.github.com> Date: Mon, 18 Dec 2023 01:47:02 +0100 Subject: [PATCH 04/18] Temporary commit --- .../Specific/Consumer/KNetConsumerCallback.cs | 2 +- .../KNet/Specific/Serialization/KNetSerDes.cs | 68 +++-- .../Specific/Streams/KNetStreamBuilder.cs | 253 ++++++++++++++++++ .../Streams/Kstream/KNetTimestampExtractor.cs | 72 +++++ .../Processor/KNetStreamPartitioner.cs | 9 +- tests/KNetTest/Program.cs | 2 +- tests/KNetTestStreams/Program.cs | 6 +- 7 files changed, 391 insertions(+), 21 deletions(-) create mode 100644 src/net/KNet/Specific/Streams/KNetStreamBuilder.cs create mode 100644 src/net/KNet/Specific/Streams/Kstream/KNetTimestampExtractor.cs diff --git a/src/net/KNet/Specific/Consumer/KNetConsumerCallback.cs b/src/net/KNet/Specific/Consumer/KNetConsumerCallback.cs index 869f69e6da..9dce4004bf 100644 --- a/src/net/KNet/Specific/Consumer/KNetConsumerCallback.cs +++ b/src/net/KNet/Specific/Consumer/KNetConsumerCallback.cs @@ -53,7 +53,7 @@ public KNetConsumerCallback(Action> recordReady, IKNetD void OnRecordReadyEventHandler(object sender, CLRListenerEventArgs data) { var record = this.BridgeInstance.Invoke>("getRecord"); - OnRecordReady(new KNetConsumerRecord(record, _keyDeserializer, _valueDeserializer)); + recordReadyFunction(new KNetConsumerRecord(record, _keyDeserializer, _valueDeserializer)); } public virtual void RecordReady(KNetConsumerRecord message) { } diff --git a/src/net/KNet/Specific/Serialization/KNetSerDes.cs b/src/net/KNet/Specific/Serialization/KNetSerDes.cs index e5514e91dc..737900527e 100644 --- a/src/net/KNet/Specific/Serialization/KNetSerDes.cs +++ b/src/net/KNet/Specific/Serialization/KNetSerDes.cs @@ -29,7 +29,10 @@ namespace MASES.KNet.Serialization /// The type to serialize/deserialize public interface IKNetSerDes : IKNetSerializer, IKNetDeserializer { - + /// + /// The to use in Apache Kafka + /// + Serde KafkaSerde { get; } } /// @@ -38,25 +41,36 @@ public interface IKNetSerDes : IKNetSerializer, IKNetDeserializer /// The type to serialize/deserialize public class KNetSerDes : IKNetSerDes { + #region private fields readonly KNetSerialization.SerializationType _SerializationType = KNetSerialization.InternalSerDesType(); + Serde _KafkaSerde = new Serde(); Serializer _KafkaSerializer = new ByteArraySerializer(); Deserializer _KafkaDeserializer = new ByteArrayDeserializer(); + #endregion + + #region Private methods + + Serializer kafkaSerializer() + { + return _KafkaSerializer; + } + + Deserializer kafkaDeserializer() + { + return _KafkaDeserializer; + } + + #endregion + + #region Constructor /// - /// External serialization function - /// - public Func OnSerialize { get; set; } - /// - /// External serialization function using - /// - public Func OnSerializeWithHeaders { get; set; } - /// - /// External deserialization function - /// - public Func OnDeserialize { get; set; } - /// - /// External deserialization function using + /// Default initializer /// - public Func OnDeserializeWithHeaders { get; set; } + public KNetSerDes() + { + _KafkaSerde.OnSerializer = kafkaSerializer; + _KafkaSerde.OnDeserializer = kafkaDeserializer; + } /// /// Finalizer /// @@ -68,11 +82,34 @@ public class KNetSerDes : IKNetSerDes public void Dispose() { GC.SuppressFinalize(this); + _KafkaSerde?.Dispose(); + _KafkaSerde = null; _KafkaSerializer?.Dispose(); _KafkaSerializer = null; _KafkaDeserializer?.Dispose(); _KafkaDeserializer = null; } + #endregion + + #region IKNetSerDes + /// + /// External serialization function + /// + public Func OnSerialize { get; set; } + /// + /// External serialization function using + /// + public Func OnSerializeWithHeaders { get; set; } + /// + /// External deserialization function + /// + public Func OnDeserialize { get; set; } + /// + /// External deserialization function using + /// + public Func OnDeserializeWithHeaders { get; set; } + /// + public Serde KafkaSerde => _KafkaSerde; /// public Serializer KafkaSerializer => _KafkaSerializer; /// @@ -146,5 +183,6 @@ public virtual T DeserializeWithHeaders(string topic, Headers headers, byte[] da return Deserialize(topic, data); } + #endregion } } diff --git a/src/net/KNet/Specific/Streams/KNetStreamBuilder.cs b/src/net/KNet/Specific/Streams/KNetStreamBuilder.cs new file mode 100644 index 0000000000..ccc741ead4 --- /dev/null +++ b/src/net/KNet/Specific/Streams/KNetStreamBuilder.cs @@ -0,0 +1,253 @@ +/* +* Copyright 2023 MASES s.r.l. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +* Refer to LICENSE for more information. +*/ + +using Java.Util; +using MASES.KNet.Consumer; +using MASES.KNet.Producer; +using MASES.KNet.Serialization; +using MASES.KNet.Specific.Streams.Processor; +using Org.Apache.Kafka.Clients.Admin; +using Org.Apache.Kafka.Clients.Consumer; +using Org.Apache.Kafka.Clients.Producer; +using Org.Apache.Kafka.Streams; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MASES.KNet.Specific.Streams +{ + /// + /// KNet extension of + /// + public class KNetStreamBuilder : StreamsBuilder + { + #region Constructors + /// + public KNetStreamBuilder() : base() { } + /// + public KNetStreamBuilder(params object[] args) : base(args) { } + /// + /// + /// + /// + public KNetStreamBuilder(Org.Apache.Kafka.Streams.TopologyConfig arg0) + : base(arg0) + { + } + + #endregion + + #region Instance methods + /// + /// + /// + /// + /// + /// + /// + /// + /// + public Org.Apache.Kafka.Streams.Kstream.GlobalKTable GlobalTable(string arg0, Org.Apache.Kafka.Streams.Kstream.Consumed arg1, Org.Apache.Kafka.Streams.Kstream.Materialized> arg2) + { + return IExecute>("globalTable", arg0, arg1, arg2); + } + /// + /// + /// + /// + /// + /// + /// + /// + public Org.Apache.Kafka.Streams.Kstream.GlobalKTable GlobalTable(string arg0, Org.Apache.Kafka.Streams.Kstream.Consumed arg1) + { + return IExecute>("globalTable", arg0, arg1); + } + /// + /// + /// + /// + /// + /// + /// + /// + public Org.Apache.Kafka.Streams.Kstream.GlobalKTable GlobalTable(string arg0, Org.Apache.Kafka.Streams.Kstream.Materialized> arg1) + { + return IExecute>("globalTable", arg0, arg1); + } + /// + /// + /// + /// + /// + /// + /// + public Org.Apache.Kafka.Streams.Kstream.GlobalKTable GlobalTable(string arg0) + { + return IExecute>("globalTable", arg0); + } + /// + /// + /// + /// + /// + /// + /// + /// + public Org.Apache.Kafka.Streams.Kstream.KStream Stream(string arg0, Org.Apache.Kafka.Streams.Kstream.Consumed arg1) + { + return IExecute>("stream", arg0, arg1); + } + /// + /// + /// + /// + /// + /// + /// + public Org.Apache.Kafka.Streams.Kstream.KStream Stream(string arg0) + { + return IExecute>("stream", arg0); + } + /// + /// + /// + /// + /// + /// + /// + /// + public Org.Apache.Kafka.Streams.Kstream.KStream Stream(Java.Util.Collection arg0, Org.Apache.Kafka.Streams.Kstream.Consumed arg1) + { + return IExecute>("stream", arg0, arg1); + } + /// + /// + /// + /// + /// + /// + /// + public Org.Apache.Kafka.Streams.Kstream.KStream Stream(Java.Util.Collection arg0) + { + return IExecute>("stream", arg0); + } + /// + /// + /// + /// + /// + /// + /// + /// + public Org.Apache.Kafka.Streams.Kstream.KStream Stream(Java.Util.Regex.Pattern arg0, Org.Apache.Kafka.Streams.Kstream.Consumed arg1) + { + return IExecute>("stream", arg0, arg1); + } + /// + /// + /// + /// + /// + /// + /// + public Org.Apache.Kafka.Streams.Kstream.KStream Stream(Java.Util.Regex.Pattern arg0) + { + return IExecute>("stream", arg0); + } + /// + /// + /// + /// + /// + /// + /// + /// + /// + public Org.Apache.Kafka.Streams.Kstream.KTable Table(string arg0, Org.Apache.Kafka.Streams.Kstream.Consumed arg1, Org.Apache.Kafka.Streams.Kstream.Materialized> arg2) + { + return IExecute>("table", arg0, arg1, arg2); + } + /// + /// + /// + /// + /// + /// + /// + /// + public Org.Apache.Kafka.Streams.Kstream.KTable Table(string arg0, Org.Apache.Kafka.Streams.Kstream.Consumed arg1) + { + return IExecute>("table", arg0, arg1); + } + /// + /// + /// + /// + /// + /// + /// + /// + public Org.Apache.Kafka.Streams.Kstream.KTable Table(string arg0, Org.Apache.Kafka.Streams.Kstream.Materialized> arg1) + { + return IExecute>("table", arg0, arg1); + } + /// + /// + /// + /// + /// + /// + /// + public Org.Apache.Kafka.Streams.Kstream.KTable Table(string arg0) + { + return IExecute>("table", arg0); + } + /// + /// + /// + /// + /// + public Org.Apache.Kafka.Streams.StreamsBuilder AddStateStore(Org.Apache.Kafka.Streams.State.StoreBuilder arg0) + { + return IExecute("addStateStore", arg0); + } + /// + /// + /// + + /// + public Org.Apache.Kafka.Streams.Topology Build() + { + return IExecute("build"); + } + /// + /// + /// + /// + /// + public Org.Apache.Kafka.Streams.Topology Build(Java.Util.Properties arg0) + { + return IExecute("build", arg0); + } + + #endregion + } +} diff --git a/src/net/KNet/Specific/Streams/Kstream/KNetTimestampExtractor.cs b/src/net/KNet/Specific/Streams/Kstream/KNetTimestampExtractor.cs new file mode 100644 index 0000000000..0e30e1d2a5 --- /dev/null +++ b/src/net/KNet/Specific/Streams/Kstream/KNetTimestampExtractor.cs @@ -0,0 +1,72 @@ +/* +* Copyright 2023 MASES s.r.l. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +* Refer to LICENSE for more information. +*/ + +using Java.Security; +using MASES.JCOBridge.C2JBridge; +using MASES.KNet.Consumer; +using MASES.KNet.Serialization; +using Org.Apache.Kafka.Clients.Consumer; +using Org.Apache.Kafka.Streams.Kstream; +using Org.Apache.Kafka.Streams.Processor; +using System; + +namespace MASES.KNet.Specific.Streams.Kstream +{ + /// + /// KNet extension of + /// + /// The key type + /// The value type + public class KNetTimestampExtractor : TimestampExtractor + { + IKNetSerDes _keySerializer; + IKNetSerDes _valueSerializer; + /// + /// Default initializer + /// + public KNetTimestampExtractor(IKNetSerDes keySerializer, IKNetSerDes valueSerializer) : base() + { + _keySerializer = keySerializer; + _valueSerializer = valueSerializer; + } + + /// + /// Handler for + /// + /// If has a value it takes precedence over corresponding class method + public new System.Func, long, long> OnExtract { get; set; } = null; + + /// + public sealed override long Extract(ConsumerRecord arg0, long arg1) + { + var record = arg0.Cast>(); // KNet consider the data within Apache Kafka Streams defined always as byte[] + var methodToExecute = (OnExtract != null) ? OnExtract : Extract; + return methodToExecute(new KNetConsumerRecord(record, _keySerializer, _valueSerializer), arg1); + } + /// + /// KNet implementation of + /// + /// The with information + /// + /// + public virtual long Extract(KNetConsumerRecord arg0, long arg1) + { + return default; + } + } +} diff --git a/src/net/KNet/Specific/Streams/Processor/KNetStreamPartitioner.cs b/src/net/KNet/Specific/Streams/Processor/KNetStreamPartitioner.cs index 4dbdb02cc6..8675aa6d03 100644 --- a/src/net/KNet/Specific/Streams/Processor/KNetStreamPartitioner.cs +++ b/src/net/KNet/Specific/Streams/Processor/KNetStreamPartitioner.cs @@ -49,10 +49,17 @@ public KNetStreamPartitioner(IKNetSerDes keySerializer, IKNetSerDes public IKNetSerDes ValueSerializer => _valueSerializer; + /// + /// Handler for + /// + /// If has a value it takes precedence over corresponding class method + public new System.Func>> OnPartitions { get; set; } = null; + /// public sealed override Optional> Partitions(string arg0, byte[] arg1, byte[] arg2, int arg3) { - return Partitions(arg0, _keySerializer.Deserialize(arg0, arg1), _valueSerializer.Deserialize(arg0, arg2), arg3); + var methodToExecute = (OnPartitions != null) ? OnPartitions : Partitions; + return methodToExecute(arg0, _keySerializer.Deserialize(arg0, arg1), _valueSerializer.Deserialize(arg0, arg2), arg3); } /// /// KNet override of diff --git a/tests/KNetTest/Program.cs b/tests/KNetTest/Program.cs index b6ff62ec73..54211512f0 100644 --- a/tests/KNetTest/Program.cs +++ b/tests/KNetTest/Program.cs @@ -73,7 +73,7 @@ static void Main(string[] args) KNetSerDes serializer = new KNetSerDes() { - OnSerialize = (topic, type) => { return new byte[0]; } + OnSerialize = (topic, type) => { return Array.Empty(); } }; KNetSerDes deserializer = new KNetSerDes() diff --git a/tests/KNetTestStreams/Program.cs b/tests/KNetTestStreams/Program.cs index bde0a9279a..4a20105727 100644 --- a/tests/KNetTestStreams/Program.cs +++ b/tests/KNetTestStreams/Program.cs @@ -197,9 +197,9 @@ static void WordCountDemo() } finally { - if (valueMapper != null) valueMapper.Dispose(); - if (keyValuemapper != null) keyValuemapper.Dispose(); - if (errorHandler != null) errorHandler.Dispose(); + valueMapper?.Dispose(); + keyValuemapper?.Dispose(); + errorHandler?.Dispose(); } } catch (Java.Util.Concurrent.ExecutionException ex) From 6d0ea6eaa0b1daa4d2bbee67201cbea47373ba69 Mon Sep 17 00:00:00 2001 From: masesdevelopers <94312179+masesdevelopers@users.noreply.github.com> Date: Sun, 7 Jan 2024 02:38:21 +0100 Subject: [PATCH 05/18] Temp commit --- src/net/KNet/Specific/Streams/KNetTopology.cs | 174 +++++++++++------- .../Specific/Streams/KNetTopologyConfig.cs | 58 ++++++ 2 files changed, 163 insertions(+), 69 deletions(-) create mode 100644 src/net/KNet/Specific/Streams/KNetTopologyConfig.cs diff --git a/src/net/KNet/Specific/Streams/KNetTopology.cs b/src/net/KNet/Specific/Streams/KNetTopology.cs index 5eb259d04d..fa7934e6cf 100644 --- a/src/net/KNet/Specific/Streams/KNetTopology.cs +++ b/src/net/KNet/Specific/Streams/KNetTopology.cs @@ -16,6 +16,9 @@ * Refer to LICENSE for more information. */ +using MASES.JCOBridge.C2JBridge; +using MASES.KNet.Serialization; +using MASES.KNet.Specific.Streams.Processor; using Org.Apache.Kafka.Streams; namespace MASES.KNet.Specific.Streams @@ -23,22 +26,35 @@ namespace MASES.KNet.Specific.Streams /// /// KNet implementation of /// - public class KNetTopology : Topology + public class KNetTopology { + Topology _Topology; + #region Constructors /// - public KNetTopology() : base() { } - /// - public KNetTopology(params object[] args) : base(args) { } - + public KNetTopology() { _Topology = new Topology(); } /// /// KNet override of /// - /// - public KNetTopology(Org.Apache.Kafka.Streams.TopologyConfig arg0) - : base(arg0) + /// + public KNetTopology(KNetTopologyConfig arg0) { + _Topology = new Topology(arg0); } + + KNetTopology(Topology topology) + { + _Topology = topology; + } + + #endregion + + #region Class/Interface conversion operators + /// + /// Converter from to + /// + public static implicit operator Topology(KNetTopology t) => t._Topology; + #endregion #region Instance methods @@ -53,9 +69,10 @@ public KNetTopology(Org.Apache.Kafka.Streams.TopologyConfig arg0) /// /// /// - public Org.Apache.Kafka.Streams.Topology AddSink(string arg0, string arg1, Org.Apache.Kafka.Common.Serialization.Serializer arg2, Org.Apache.Kafka.Common.Serialization.Serializer arg3, params string[] arg4) + public KNetTopology AddSink(string arg0, string arg1, IKNetSerializer arg2, IKNetSerializer arg3, params string[] arg4) { - if (arg4.Length == 0) return IExecute("addSink", arg0, arg1, arg2, arg3); else return IExecute("addSink", arg0, arg1, arg2, arg3, arg4); + var top = _Topology.AddSink(arg0, arg1, arg2.KafkaSerializer, arg3.KafkaSerializer, arg4); + return new KNetTopology(top); } /// /// @@ -71,9 +88,10 @@ public Org.Apache.Kafka.Streams.Topology AddSink(string arg0, string arg1, /// /// /// - public Org.Apache.Kafka.Streams.Topology AddSink(string arg0, string arg1, Org.Apache.Kafka.Common.Serialization.Serializer arg2, Org.Apache.Kafka.Common.Serialization.Serializer arg3, Org.Apache.Kafka.Streams.Processor.StreamPartitioner arg4, params string[] arg5) where Arg4objectSuperK : K where Arg4objectSuperV : V + public KNetTopology AddSink(string arg0, string arg1, IKNetSerializer arg2, IKNetSerializer arg3, KNetStreamPartitioner arg4, params string[] arg5) where Arg4objectSuperK : K where Arg4objectSuperV : V { - if (arg5.Length == 0) return IExecute("addSink", arg0, arg1, arg2, arg3, arg4); else return IExecute("addSink", arg0, arg1, arg2, arg3, arg4, arg5); + var top = _Topology.AddSink(arg0, arg1, arg2.KafkaSerializer, arg3.KafkaSerializer, arg4, arg5); + return new KNetTopology(top); } /// /// @@ -87,9 +105,10 @@ public Org.Apache.Kafka.Streams.Topology AddSink /// /// - public Org.Apache.Kafka.Streams.Topology AddSink(string arg0, string arg1, Org.Apache.Kafka.Streams.Processor.StreamPartitioner arg2, params string[] arg3) where Arg2objectSuperK : K where Arg2objectSuperV : V + public KNetTopology AddSink(string arg0, string arg1, KNetStreamPartitioner arg2, params string[] arg3) where Arg2objectSuperK : K where Arg2objectSuperV : V { - if (arg3.Length == 0) return IExecute("addSink", arg0, arg1, arg2); else return IExecute("addSink", arg0, arg1, arg2, arg3); + var top = _Topology.AddSink(arg0, arg1, arg2, arg3); + return new KNetTopology(top); } /// /// @@ -100,9 +119,10 @@ public Org.Apache.Kafka.Streams.Topology AddSink /// /// - public Org.Apache.Kafka.Streams.Topology AddSink(string arg0, Org.Apache.Kafka.Streams.Processor.TopicNameExtractor arg1, params string[] arg2) + public KNetTopology AddSink(string arg0, Org.Apache.Kafka.Streams.Processor.TopicNameExtractor arg1, params string[] arg2) { - if (arg2.Length == 0) return IExecute("addSink", arg0, arg1); else return IExecute("addSink", arg0, arg1, arg2); + var top = _Topology.AddSink(arg0, arg1, arg2); + return new KNetTopology(top); } /// /// @@ -115,9 +135,10 @@ public Org.Apache.Kafka.Streams.Topology AddSink(string arg0, Org.Apache.K /// /// /// - public Org.Apache.Kafka.Streams.Topology AddSink(string arg0, Org.Apache.Kafka.Streams.Processor.TopicNameExtractor arg1, Org.Apache.Kafka.Common.Serialization.Serializer arg2, Org.Apache.Kafka.Common.Serialization.Serializer arg3, params string[] arg4) + public KNetTopology AddSink(string arg0, Org.Apache.Kafka.Streams.Processor.TopicNameExtractor arg1, IKNetSerializer arg2, IKNetSerializer arg3, params string[] arg4) { - if (arg4.Length == 0) return IExecute("addSink", arg0, arg1, arg2, arg3); else return IExecute("addSink", arg0, arg1, arg2, arg3, arg4); + var top = _Topology.AddSink(arg0, arg1, arg2.KafkaSerializer, arg3.KafkaSerializer, arg4); + return new KNetTopology(top); } /// /// @@ -133,9 +154,10 @@ public Org.Apache.Kafka.Streams.Topology AddSink(string arg0, Org.Apache.K /// /// /// - public Org.Apache.Kafka.Streams.Topology AddSink(string arg0, Org.Apache.Kafka.Streams.Processor.TopicNameExtractor arg1, Org.Apache.Kafka.Common.Serialization.Serializer arg2, Org.Apache.Kafka.Common.Serialization.Serializer arg3, Org.Apache.Kafka.Streams.Processor.StreamPartitioner arg4, params string[] arg5) where Arg4objectSuperK : K where Arg4objectSuperV : V + public KNetTopology AddSink(string arg0, Org.Apache.Kafka.Streams.Processor.TopicNameExtractor arg1, IKNetSerializer arg2, IKNetSerializer arg3, KNetStreamPartitioner arg4, params string[] arg5) where Arg4objectSuperK : K where Arg4objectSuperV : V { - if (arg5.Length == 0) return IExecute("addSink", arg0, arg1, arg2, arg3, arg4); else return IExecute("addSink", arg0, arg1, arg2, arg3, arg4, arg5); + var top = _Topology.AddSink(arg0, arg1, arg2.KafkaSerializer, arg3.KafkaSerializer, arg4, arg5); + return new KNetTopology(top); } /// /// @@ -149,9 +171,10 @@ public Org.Apache.Kafka.Streams.Topology AddSink /// /// - public Org.Apache.Kafka.Streams.Topology AddSink(string arg0, Org.Apache.Kafka.Streams.Processor.TopicNameExtractor arg1, Org.Apache.Kafka.Streams.Processor.StreamPartitioner arg2, params string[] arg3) where Arg2objectSuperK : K where Arg2objectSuperV : V + public Org.Apache.Kafka.Streams.Topology AddSink(string arg0, Org.Apache.Kafka.Streams.Processor.TopicNameExtractor arg1, KNetStreamPartitioner arg2, params string[] arg3) where Arg2objectSuperK : K where Arg2objectSuperV : V { - if (arg3.Length == 0) return IExecute("addSink", arg0, arg1, arg2); else return IExecute("addSink", arg0, arg1, arg2, arg3); + var top = _Topology.AddSink(arg0, arg1, arg2, arg3); + return new KNetTopology(top); } /// /// @@ -170,9 +193,10 @@ public Org.Apache.Kafka.Streams.Topology AddSink(string arg0, string arg1, param /// /// /// - public Org.Apache.Kafka.Streams.Topology AddSource(string arg0, params string[] arg1) + public KNetTopology AddSource(string arg0, params string[] arg1) { - if (arg1.Length == 0) return IExecute("addSource", arg0); else return IExecute("addSource", arg0, arg1); + var top = _Topology.AddSource(arg0, arg1); + return new KNetTopology(top); } /// /// @@ -180,33 +204,36 @@ public Org.Apache.Kafka.Streams.Topology AddSource(string arg0, params string[] /// /// /// - public Org.Apache.Kafka.Streams.Topology AddSource(string arg0, Java.Util.Regex.Pattern arg1) + public KNetTopology AddSource(string arg0, Java.Util.Regex.Pattern arg1) { - return IExecute("addSource", arg0, arg1); + var top = _Topology.AddSource(arg0, arg1); + return new KNetTopology(top); } /// - /// + /// /// /// - /// - /// + /// + /// /// /// - public Org.Apache.Kafka.Streams.Topology AddSource(string arg0, Org.Apache.Kafka.Common.Serialization.Deserializer arg1, Org.Apache.Kafka.Common.Serialization.Deserializer arg2, params string[] arg3) + public KNetTopology AddSource(string arg0, IKNetDeserializer arg1, IKNetDeserializer arg2, params string[] arg3) { - if (arg3.Length == 0) return IExecute("addSource", arg0, arg1, arg2); else return IExecute("addSource", arg0, arg1, arg2, arg3); + var top = (arg3.Length == 0) ? _Topology.IExecute("addSource", arg0, arg1.KafkaDeserializer, arg2.KafkaDeserializer) : _Topology.IExecute("addSource", arg0, arg1.KafkaDeserializer, arg2.KafkaDeserializer, arg3); + return new KNetTopology(top); } /// - /// + /// /// /// - /// - /// + /// + /// /// /// - public Org.Apache.Kafka.Streams.Topology AddSource(string arg0, Org.Apache.Kafka.Common.Serialization.Deserializer arg1, Org.Apache.Kafka.Common.Serialization.Deserializer arg2, Java.Util.Regex.Pattern arg3) + public KNetTopology AddSource(string arg0, IKNetDeserializer arg1, IKNetDeserializer arg2, Java.Util.Regex.Pattern arg3) { - return IExecute("addSource", arg0, arg1, arg2, arg3); + var top = _Topology.IExecute("addSource", arg0, arg1.KafkaDeserializer, arg2.KafkaDeserializer, arg3); + return new KNetTopology(top); } /// /// @@ -215,9 +242,10 @@ public Org.Apache.Kafka.Streams.Topology AddSource(string arg0, Org.Apache.Kafka /// /// /// - public Org.Apache.Kafka.Streams.Topology AddSource(Org.Apache.Kafka.Streams.Processor.TimestampExtractor arg0, string arg1, params string[] arg2) + public KNetTopology AddSource(Org.Apache.Kafka.Streams.Processor.TimestampExtractor arg0, string arg1, params string[] arg2) { - if (arg2.Length == 0) return IExecute("addSource", arg0, arg1); else return IExecute("addSource", arg0, arg1, arg2); + var top = (arg2.Length == 0) ? _Topology.IExecute("addSource", arg0, arg1) : _Topology.IExecute("addSource", arg0, arg1, arg2); + return new KNetTopology(top); } /// /// @@ -226,9 +254,10 @@ public Org.Apache.Kafka.Streams.Topology AddSource(Org.Apache.Kafka.Streams.Proc /// /// /// - public Org.Apache.Kafka.Streams.Topology AddSource(Org.Apache.Kafka.Streams.Processor.TimestampExtractor arg0, string arg1, Java.Util.Regex.Pattern arg2) + public KNetTopology AddSource(Org.Apache.Kafka.Streams.Processor.TimestampExtractor arg0, string arg1, Java.Util.Regex.Pattern arg2) { - return IExecute("addSource", arg0, arg1, arg2); + var top = _Topology.AddSource(arg0, arg1, arg2); + return new KNetTopology(top); } /// /// @@ -237,9 +266,10 @@ public Org.Apache.Kafka.Streams.Topology AddSource(Org.Apache.Kafka.Streams.Proc /// /// /// - public Org.Apache.Kafka.Streams.Topology AddSource(Org.Apache.Kafka.Streams.Topology.AutoOffsetReset arg0, string arg1, params string[] arg2) + public KNetTopology AddSource(Org.Apache.Kafka.Streams.Topology.AutoOffsetReset arg0, string arg1, params string[] arg2) { - if (arg2.Length == 0) return IExecute("addSource", arg0, arg1); else return IExecute("addSource", arg0, arg1, arg2); + var top = _Topology.AddSource(arg0, arg1, arg2); + return new KNetTopology(top); } /// /// @@ -248,63 +278,68 @@ public Org.Apache.Kafka.Streams.Topology AddSource(Org.Apache.Kafka.Streams.Topo /// /// /// - public Org.Apache.Kafka.Streams.Topology AddSource(Org.Apache.Kafka.Streams.Topology.AutoOffsetReset arg0, string arg1, Java.Util.Regex.Pattern arg2) + public KNetTopology AddSource(Org.Apache.Kafka.Streams.Topology.AutoOffsetReset arg0, string arg1, Java.Util.Regex.Pattern arg2) { - return IExecute("addSource", arg0, arg1, arg2); + var top = _Topology.AddSource(arg0, arg1, arg2); + return new KNetTopology(top); } /// - /// + /// /// /// /// - /// - /// + /// + /// /// /// - public Org.Apache.Kafka.Streams.Topology AddSource(Org.Apache.Kafka.Streams.Topology.AutoOffsetReset arg0, string arg1, Org.Apache.Kafka.Common.Serialization.Deserializer arg2, Org.Apache.Kafka.Common.Serialization.Deserializer arg3, params string[] arg4) + public KNetTopology AddSource(Org.Apache.Kafka.Streams.Topology.AutoOffsetReset arg0, string arg1, IKNetDeserializer arg2, IKNetDeserializer arg3, params string[] arg4) { - if (arg4.Length == 0) return IExecute("addSource", arg0, arg1, arg2, arg3); else return IExecute("addSource", arg0, arg1, arg2, arg3, arg4); + var top = (arg4.Length == 0) ? _Topology.IExecute("addSource", arg0, arg1, arg2.KafkaDeserializer, arg3.KafkaDeserializer) : _Topology.IExecute("addSource", arg0, arg1, arg2.KafkaDeserializer, arg3.KafkaDeserializer, arg4); + return new KNetTopology(top); } /// - /// + /// /// /// /// - /// - /// + /// + /// /// /// - public Org.Apache.Kafka.Streams.Topology AddSource(Org.Apache.Kafka.Streams.Topology.AutoOffsetReset arg0, string arg1, Org.Apache.Kafka.Common.Serialization.Deserializer arg2, Org.Apache.Kafka.Common.Serialization.Deserializer arg3, Java.Util.Regex.Pattern arg4) + public KNetTopology AddSource(Org.Apache.Kafka.Streams.Topology.AutoOffsetReset arg0, string arg1, IKNetDeserializer arg2, IKNetDeserializer arg3, Java.Util.Regex.Pattern arg4) { - return IExecute("addSource", arg0, arg1, arg2, arg3, arg4); + var top = _Topology.IExecute("addSource", arg0, arg1, arg2.KafkaDeserializer, arg3.KafkaDeserializer, arg4); + return new KNetTopology(top); } /// - /// + /// /// /// /// /// - /// - /// + /// + /// /// /// - public Org.Apache.Kafka.Streams.Topology AddSource(Org.Apache.Kafka.Streams.Topology.AutoOffsetReset arg0, string arg1, Org.Apache.Kafka.Streams.Processor.TimestampExtractor arg2, Org.Apache.Kafka.Common.Serialization.Deserializer arg3, Org.Apache.Kafka.Common.Serialization.Deserializer arg4, params string[] arg5) + public KNetTopology AddSource(Org.Apache.Kafka.Streams.Topology.AutoOffsetReset arg0, string arg1, Org.Apache.Kafka.Streams.Processor.TimestampExtractor arg2, IKNetDeserializer arg3, IKNetDeserializer arg4, params string[] arg5) { - if (arg5.Length == 0) return IExecute("addSource", arg0, arg1, arg2, arg3, arg4); else return IExecute("addSource", arg0, arg1, arg2, arg3, arg4, arg5); + var top = (arg5.Length == 0) ? _Topology.IExecute("addSource", arg0, arg1, arg2, arg3.KafkaDeserializer, arg4.KafkaDeserializer) : _Topology.IExecute("addSource", arg0, arg1, arg2, arg3.KafkaDeserializer, arg4.KafkaDeserializer, arg5); + return new KNetTopology(top); } /// - /// + /// /// /// /// /// - /// - /// + /// + /// /// /// - public Org.Apache.Kafka.Streams.Topology AddSource(Org.Apache.Kafka.Streams.Topology.AutoOffsetReset arg0, string arg1, Org.Apache.Kafka.Streams.Processor.TimestampExtractor arg2, Org.Apache.Kafka.Common.Serialization.Deserializer arg3, Org.Apache.Kafka.Common.Serialization.Deserializer arg4, Java.Util.Regex.Pattern arg5) + public KNetTopology AddSource(Org.Apache.Kafka.Streams.Topology.AutoOffsetReset arg0, string arg1, Org.Apache.Kafka.Streams.Processor.TimestampExtractor arg2, IKNetDeserializer arg3, IKNetDeserializer arg4, Java.Util.Regex.Pattern arg5) { - return IExecute("addSource", arg0, arg1, arg2, arg3, arg4, arg5); + var top = _Topology.IExecute("addSource", arg0, arg1, arg2, arg3.KafkaDeserializer, arg4.KafkaDeserializer, arg5); + return new KNetTopology(top); } /// /// @@ -314,9 +349,10 @@ public Org.Apache.Kafka.Streams.Topology AddSource(Org.Apache.Kafka.Streams.Topo /// /// /// - public Org.Apache.Kafka.Streams.Topology AddSource(Org.Apache.Kafka.Streams.Topology.AutoOffsetReset arg0, Org.Apache.Kafka.Streams.Processor.TimestampExtractor arg1, string arg2, params string[] arg3) + public KNetTopology AddSource(Org.Apache.Kafka.Streams.Topology.AutoOffsetReset arg0, Org.Apache.Kafka.Streams.Processor.TimestampExtractor arg1, string arg2, params string[] arg3) { - if (arg3.Length == 0) return IExecute("addSource", arg0, arg1, arg2); else return IExecute("addSource", arg0, arg1, arg2, arg3); + var top = _Topology.AddSource(arg0, arg1, arg2, arg3); + return new KNetTopology(top); } /// /// @@ -326,12 +362,12 @@ public Org.Apache.Kafka.Streams.Topology AddSource(Org.Apache.Kafka.Streams.Topo /// /// /// - public Org.Apache.Kafka.Streams.Topology AddSource(Org.Apache.Kafka.Streams.Topology.AutoOffsetReset arg0, Org.Apache.Kafka.Streams.Processor.TimestampExtractor arg1, string arg2, Java.Util.Regex.Pattern arg3) + public KNetTopology AddSource(Org.Apache.Kafka.Streams.Topology.AutoOffsetReset arg0, Org.Apache.Kafka.Streams.Processor.TimestampExtractor arg1, string arg2, Java.Util.Regex.Pattern arg3) { - return IExecute("addSource", arg0, arg1, arg2, arg3); + var top = _Topology.AddSource(arg0, arg1, arg2, arg3); + return new KNetTopology(top); } - #endregion } } diff --git a/src/net/KNet/Specific/Streams/KNetTopologyConfig.cs b/src/net/KNet/Specific/Streams/KNetTopologyConfig.cs new file mode 100644 index 0000000000..08ada7cb3d --- /dev/null +++ b/src/net/KNet/Specific/Streams/KNetTopologyConfig.cs @@ -0,0 +1,58 @@ +/* +* Copyright 2023 MASES s.r.l. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +* Refer to LICENSE for more information. +*/ + +using MASES.KNet.Streams; +using Org.Apache.Kafka.Streams; + +namespace MASES.KNet.Specific.Streams +{ + /// + /// KNet implementation of + /// + public class KNetTopologyConfig : TopologyConfig + { + StreamsConfigBuilder _StreamsConfigBuilder; + + #region Constructors + /// + /// + /// + /// + /// + /// + public KNetTopologyConfig(string arg0, StreamsConfigBuilder arg1, Java.Util.Properties arg2) + : base(arg0, arg1, arg2) + { + _StreamsConfigBuilder = arg1; + } + /// + /// + /// + /// + public KNetTopologyConfig(StreamsConfigBuilder arg0) + : base(arg0) + { + _StreamsConfigBuilder = arg0; + } + #endregion + /// + /// used in initialization + /// + public StreamsConfigBuilder StreamsConfigBuilder => _StreamsConfigBuilder; + } +} From b4286348ac07c7c765f4ab829f059e0fab0546d3 Mon Sep 17 00:00:00 2001 From: masesdevelopers <94312179+masesdevelopers@users.noreply.github.com> Date: Mon, 8 Jan 2024 21:18:45 +0100 Subject: [PATCH 06/18] Name review --- ...redicate.java => KNetPredicateTester.java} | 6 ++--- ...NetPredicate.cs => KNetPredicateTester.cs} | 25 ++++++++++--------- 2 files changed, 16 insertions(+), 15 deletions(-) rename src/jvm/knet/src/main/java/org/mases/knet/streams/kstream/{KNetPredicate.java => KNetPredicateTester.java} (86%) rename src/net/KNet/Specific/Streams/Kstream/{KNetPredicate.cs => KNetPredicateTester.cs} (67%) diff --git a/src/jvm/knet/src/main/java/org/mases/knet/streams/kstream/KNetPredicate.java b/src/jvm/knet/src/main/java/org/mases/knet/streams/kstream/KNetPredicateTester.java similarity index 86% rename from src/jvm/knet/src/main/java/org/mases/knet/streams/kstream/KNetPredicate.java rename to src/jvm/knet/src/main/java/org/mases/knet/streams/kstream/KNetPredicateTester.java index 70d0570220..13003a1a12 100644 --- a/src/jvm/knet/src/main/java/org/mases/knet/streams/kstream/KNetPredicate.java +++ b/src/jvm/knet/src/main/java/org/mases/knet/streams/kstream/KNetPredicateTester.java @@ -23,17 +23,17 @@ import java.util.Arrays; -public final class KNetPredicate implements Predicate { +public final class KNetPredicateTester implements Predicate { Boolean _isKey = null; byte[] _key = null; byte[] _value = null; - public KNetPredicate(byte[] keyOrValue, boolean isKey) { + public KNetPredicateTester(byte[] keyOrValue, boolean isKey) { _isKey = isKey; _key = keyOrValue; } - public KNetPredicate(byte[] keyOrValue, byte[] value) { + public KNetPredicateTester(byte[] keyOrValue, byte[] value) { _key = keyOrValue; _value = value; } diff --git a/src/net/KNet/Specific/Streams/Kstream/KNetPredicate.cs b/src/net/KNet/Specific/Streams/Kstream/KNetPredicateTester.cs similarity index 67% rename from src/net/KNet/Specific/Streams/Kstream/KNetPredicate.cs rename to src/net/KNet/Specific/Streams/Kstream/KNetPredicateTester.cs index 8807f83ca7..91be722ec4 100644 --- a/src/net/KNet/Specific/Streams/Kstream/KNetPredicate.cs +++ b/src/net/KNet/Specific/Streams/Kstream/KNetPredicateTester.cs @@ -26,44 +26,45 @@ namespace MASES.KNet.Specific.Streams.Kstream /// /// KNet extension of /// - public class KNetPredicate : JVMBridgeBase + public class KNetPredicateTester : JVMBridgeBase { /// /// /// - public override string BridgeClassName => "org.mases.knet.streams.kstream.KNetPredicate"; + public override string BridgeClassName => "org.mases.knet.streams.kstream.KNetPredicateTester"; /// - /// Converter from to + /// Converter from to /// - public static implicit operator Predicate(KNetPredicate t) => t.Cast(); + public static implicit operator Predicate(KNetPredicateTester t) => t.Cast(); /// - /// Converter from to + /// Converter from to /// - public static implicit operator Predicate(KNetPredicate t) => t.Cast>(); + /// This cast is useful when an API needs in input a type like , however the behavior of the in output is different from the same class allocated directly + public static implicit operator Predicate(KNetPredicateTester t) => t.Cast>(); /// /// Default constructor: even if the corresponding Java class does not have one, it is mandatory for JCOBridge /// - public KNetPredicate() { } + public KNetPredicateTester() { } /// /// Generic constructor: it is useful for JCOBridge when there is a derived class which needs to pass arguments to the highest JVMBridgeBase class /// - public KNetPredicate(params object[] args) : base(args) { } + public KNetPredicateTester(params object[] args) : base(args) { } /// - /// Initialize a new for key or value comparison + /// Initialize a new for key or value comparison /// /// The key, or value, to use in comparison /// if represent a key, otherwise - public KNetPredicate(byte[] keyOrValue, bool isKey) + public KNetPredicateTester(byte[] keyOrValue, bool isKey) : base(keyOrValue, isKey) { } /// - /// Initialize a new for both key and value comparison + /// Initialize a new for both key and value comparison /// /// The key to use in comparison /// The value to use in comparison /// Both and shall be equal to input parameters of to return - public KNetPredicate(byte[] key, byte[] value) : base(key, value) + public KNetPredicateTester(byte[] key, byte[] value) : base(key, value) { } } From fd67decba44f1fb88eb834ad1c1303eb1053d6af Mon Sep 17 00:00:00 2001 From: masesdevelopers <94312179+masesdevelopers@users.noreply.github.com> Date: Thu, 11 Jan 2024 22:09:30 +0100 Subject: [PATCH 07/18] Other class updates --- .../Specific/Streams/KNetClientSupplier.cs | 22 +-- .../Specific/Streams/KNetStreamBuilder.cs | 13 -- src/net/KNet/Specific/Streams/KNetStreams.cs | 11 -- src/net/KNet/Specific/Streams/KNetTopology.cs | 164 +++++++++--------- .../Specific/Streams/Kstream/KNetPredicate.cs | 73 ++++++++ .../Streams/Kstream/KNetPredicateTester.cs | 2 - .../Streams/Kstream/KNetTimestampExtractor.cs | 3 - .../Processor/KNetTopicNameExtractor.cs | 74 ++++++++ 8 files changed, 236 insertions(+), 126 deletions(-) create mode 100644 src/net/KNet/Specific/Streams/Kstream/KNetPredicate.cs create mode 100644 src/net/KNet/Specific/Streams/Processor/KNetTopicNameExtractor.cs diff --git a/src/net/KNet/Specific/Streams/KNetClientSupplier.cs b/src/net/KNet/Specific/Streams/KNetClientSupplier.cs index ee27a160f8..eaa03d7ade 100644 --- a/src/net/KNet/Specific/Streams/KNetClientSupplier.cs +++ b/src/net/KNet/Specific/Streams/KNetClientSupplier.cs @@ -17,18 +17,10 @@ */ using Java.Util; -using MASES.KNet.Consumer; -using MASES.KNet.Producer; -using MASES.KNet.Serialization; using Org.Apache.Kafka.Clients.Admin; using Org.Apache.Kafka.Clients.Consumer; using Org.Apache.Kafka.Clients.Producer; using Org.Apache.Kafka.Streams; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace MASES.KNet.Specific.Streams { @@ -37,9 +29,9 @@ namespace MASES.KNet.Specific.Streams /// public class KNetClientSupplier : KafkaClientSupplier { - private readonly System.Collections.Generic.List _admins = new System.Collections.Generic.List(); - private readonly System.Collections.Generic.List> _consumers = new System.Collections.Generic.List>(); - private readonly System.Collections.Generic.List> _producers = new System.Collections.Generic.List>(); + private readonly System.Collections.Generic.List _admins = new(); + private readonly System.Collections.Generic.List> _consumers = new(); + private readonly System.Collections.Generic.List> _producers = new(); /// /// Default initializer /// @@ -59,7 +51,7 @@ public override Consumer GetConsumer(Map arg0) Properties properties = new(); properties.PutAll(arg0); - var consumer = new KNetConsumer(properties); + var consumer = new Consumer(properties); _consumers.Add(consumer); return consumer; } @@ -69,7 +61,7 @@ public override Consumer GetGlobalConsumer(Map a Properties properties = new(); properties.PutAll(arg0); - var consumer = new KNetConsumer(properties); + var consumer = new Consumer(properties); _consumers.Add(consumer); return consumer; } @@ -79,7 +71,7 @@ public override Producer GetProducer(Map arg0) Properties properties = new(); properties.PutAll(arg0); - var producer = new KNetProducer(properties); + var producer = new Producer(properties); _producers.Add(producer); return producer; } @@ -89,7 +81,7 @@ public override Consumer GetRestoreConsumer(Map Properties properties = new(); properties.PutAll(arg0); - var consumer = new KNetConsumer(properties); + var consumer = new Consumer(properties); _consumers.Add(consumer); return consumer; } diff --git a/src/net/KNet/Specific/Streams/KNetStreamBuilder.cs b/src/net/KNet/Specific/Streams/KNetStreamBuilder.cs index ccc741ead4..a77c394642 100644 --- a/src/net/KNet/Specific/Streams/KNetStreamBuilder.cs +++ b/src/net/KNet/Specific/Streams/KNetStreamBuilder.cs @@ -16,20 +16,7 @@ * Refer to LICENSE for more information. */ -using Java.Util; -using MASES.KNet.Consumer; -using MASES.KNet.Producer; -using MASES.KNet.Serialization; -using MASES.KNet.Specific.Streams.Processor; -using Org.Apache.Kafka.Clients.Admin; -using Org.Apache.Kafka.Clients.Consumer; -using Org.Apache.Kafka.Clients.Producer; using Org.Apache.Kafka.Streams; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace MASES.KNet.Specific.Streams { diff --git a/src/net/KNet/Specific/Streams/KNetStreams.cs b/src/net/KNet/Specific/Streams/KNetStreams.cs index 7eaa19bf75..03dfb3e67a 100644 --- a/src/net/KNet/Specific/Streams/KNetStreams.cs +++ b/src/net/KNet/Specific/Streams/KNetStreams.cs @@ -16,20 +16,9 @@ * Refer to LICENSE for more information. */ -using Java.Util; -using MASES.KNet.Consumer; -using MASES.KNet.Producer; using MASES.KNet.Serialization; using MASES.KNet.Specific.Streams.Processor; -using Org.Apache.Kafka.Clients.Admin; -using Org.Apache.Kafka.Clients.Consumer; -using Org.Apache.Kafka.Clients.Producer; using Org.Apache.Kafka.Streams; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace MASES.KNet.Specific.Streams { diff --git a/src/net/KNet/Specific/Streams/KNetTopology.cs b/src/net/KNet/Specific/Streams/KNetTopology.cs index fa7934e6cf..fdc6fa618b 100644 --- a/src/net/KNet/Specific/Streams/KNetTopology.cs +++ b/src/net/KNet/Specific/Streams/KNetTopology.cs @@ -16,7 +16,6 @@ * Refer to LICENSE for more information. */ -using MASES.JCOBridge.C2JBridge; using MASES.KNet.Serialization; using MASES.KNet.Specific.Streams.Processor; using Org.Apache.Kafka.Streams; @@ -63,12 +62,12 @@ public KNetTopology(KNetTopologyConfig arg0) /// /// /// - /// - /// + /// + /// /// /// /// - /// + /// public KNetTopology AddSink(string arg0, string arg1, IKNetSerializer arg2, IKNetSerializer arg3, params string[] arg4) { var top = _Topology.AddSink(arg0, arg1, arg2.KafkaSerializer, arg3.KafkaSerializer, arg4); @@ -79,15 +78,15 @@ public KNetTopology AddSink(string arg0, string arg1, IKNetSerializer a /// /// /// - /// - /// - /// + /// + /// + /// /// /// /// /// /// - /// + /// public KNetTopology AddSink(string arg0, string arg1, IKNetSerializer arg2, IKNetSerializer arg3, KNetStreamPartitioner arg4, params string[] arg5) where Arg4objectSuperK : K where Arg4objectSuperV : V { var top = _Topology.AddSink(arg0, arg1, arg2.KafkaSerializer, arg3.KafkaSerializer, arg4, arg5); @@ -98,28 +97,28 @@ public KNetTopology AddSink(string arg /// /// /// - /// + /// /// /// /// /// /// - /// + /// public KNetTopology AddSink(string arg0, string arg1, KNetStreamPartitioner arg2, params string[] arg3) where Arg2objectSuperK : K where Arg2objectSuperV : V { - var top = _Topology.AddSink(arg0, arg1, arg2, arg3); + var top = (arg3.Length == 0) ? _Topology.IExecute("addSink", arg0, arg1, arg2) : _Topology.IExecute("addSource", arg0, arg1, arg2, arg3); return new KNetTopology(top); } /// /// /// /// - /// + /// /// /// /// - /// - public KNetTopology AddSink(string arg0, Org.Apache.Kafka.Streams.Processor.TopicNameExtractor arg1, params string[] arg2) + /// + public KNetTopology AddSink(string arg0, KNetTopicNameExtractor arg1, params string[] arg2) { var top = _Topology.AddSink(arg0, arg1, arg2); return new KNetTopology(top); @@ -128,14 +127,14 @@ public KNetTopology AddSink(string arg0, Org.Apache.Kafka.Streams.Processo /// /// /// - /// - /// - /// + /// + /// + /// /// /// /// - /// - public KNetTopology AddSink(string arg0, Org.Apache.Kafka.Streams.Processor.TopicNameExtractor arg1, IKNetSerializer arg2, IKNetSerializer arg3, params string[] arg4) + /// + public KNetTopology AddSink(string arg0, KNetTopicNameExtractor arg1, IKNetSerializer arg2, IKNetSerializer arg3, params string[] arg4) { var top = _Topology.AddSink(arg0, arg1, arg2.KafkaSerializer, arg3.KafkaSerializer, arg4); return new KNetTopology(top); @@ -144,34 +143,34 @@ public KNetTopology AddSink(string arg0, Org.Apache.Kafka.Streams.Processo /// /// /// - /// - /// - /// - /// + /// + /// + /// + /// /// /// /// /// /// - /// - public KNetTopology AddSink(string arg0, Org.Apache.Kafka.Streams.Processor.TopicNameExtractor arg1, IKNetSerializer arg2, IKNetSerializer arg3, KNetStreamPartitioner arg4, params string[] arg5) where Arg4objectSuperK : K where Arg4objectSuperV : V + /// + public KNetTopology AddSink(string arg0, KNetTopicNameExtractor arg1, IKNetSerializer arg2, IKNetSerializer arg3, KNetStreamPartitioner arg4, params string[] arg5) where Arg4objectSuperK : K where Arg4objectSuperV : V { - var top = _Topology.AddSink(arg0, arg1, arg2.KafkaSerializer, arg3.KafkaSerializer, arg4, arg5); + var top = _Topology.AddSink(arg0, arg1, arg2.KafkaSerializer, arg3.KafkaSerializer, arg4, arg5); return new KNetTopology(top); } /// /// /// /// - /// - /// + /// + /// /// /// /// /// /// - /// - public Org.Apache.Kafka.Streams.Topology AddSink(string arg0, Org.Apache.Kafka.Streams.Processor.TopicNameExtractor arg1, KNetStreamPartitioner arg2, params string[] arg3) where Arg2objectSuperK : K where Arg2objectSuperV : V + /// + public KNetTopology AddSink(string arg0, KNetTopicNameExtractor arg1, KNetStreamPartitioner arg2, params string[] arg3) where Arg2objectSuperK : K where Arg2objectSuperV : V { var top = _Topology.AddSink(arg0, arg1, arg2, arg3); return new KNetTopology(top); @@ -182,17 +181,18 @@ public Org.Apache.Kafka.Streams.Topology AddSink /// /// - /// - public Org.Apache.Kafka.Streams.Topology AddSink(string arg0, string arg1, params string[] arg2) + /// + public KNetTopology AddSink(string arg0, string arg1, params string[] arg2) { - if (arg2.Length == 0) return IExecute("addSink", arg0, arg1); else return IExecute("addSink", arg0, arg1, arg2); + var top = _Topology.AddSink(arg0, arg1, arg2); + return new KNetTopology(top); } /// /// /// /// /// - /// + /// public KNetTopology AddSource(string arg0, params string[] arg1) { var top = _Topology.AddSource(arg0, arg1); @@ -203,7 +203,7 @@ public KNetTopology AddSource(string arg0, params string[] arg1) /// /// /// - /// + /// public KNetTopology AddSource(string arg0, Java.Util.Regex.Pattern arg1) { var top = _Topology.AddSource(arg0, arg1); @@ -213,26 +213,26 @@ public KNetTopology AddSource(string arg0, Java.Util.Regex.Pattern arg1) /// /// /// - /// - /// + /// + /// /// - /// + /// public KNetTopology AddSource(string arg0, IKNetDeserializer arg1, IKNetDeserializer arg2, params string[] arg3) { - var top = (arg3.Length == 0) ? _Topology.IExecute("addSource", arg0, arg1.KafkaDeserializer, arg2.KafkaDeserializer) : _Topology.IExecute("addSource", arg0, arg1.KafkaDeserializer, arg2.KafkaDeserializer, arg3); + var top = (arg3.Length == 0) ? _Topology.IExecute("addSource", arg0, arg1.KafkaDeserializer, arg2.KafkaDeserializer) : _Topology.IExecute("addSource", arg0, arg1.KafkaDeserializer, arg2.KafkaDeserializer, arg3); return new KNetTopology(top); } /// /// /// /// - /// - /// + /// + /// /// - /// + /// public KNetTopology AddSource(string arg0, IKNetDeserializer arg1, IKNetDeserializer arg2, Java.Util.Regex.Pattern arg3) { - var top = _Topology.IExecute("addSource", arg0, arg1.KafkaDeserializer, arg2.KafkaDeserializer, arg3); + var top = _Topology.IExecute("addSource", arg0, arg1.KafkaDeserializer, arg2.KafkaDeserializer, arg3); return new KNetTopology(top); } /// @@ -241,10 +241,10 @@ public KNetTopology AddSource(string arg0, IKNetDeserializer arg1, IKNet /// /// /// - /// + /// public KNetTopology AddSource(Org.Apache.Kafka.Streams.Processor.TimestampExtractor arg0, string arg1, params string[] arg2) { - var top = (arg2.Length == 0) ? _Topology.IExecute("addSource", arg0, arg1) : _Topology.IExecute("addSource", arg0, arg1, arg2); + var top = (arg2.Length == 0) ? _Topology.IExecute("addSource", arg0, arg1) : _Topology.IExecute("addSource", arg0, arg1, arg2); return new KNetTopology(top); } /// @@ -253,7 +253,7 @@ public KNetTopology AddSource(Org.Apache.Kafka.Streams.Processor.TimestampExtrac /// /// /// - /// + /// public KNetTopology AddSource(Org.Apache.Kafka.Streams.Processor.TimestampExtractor arg0, string arg1, Java.Util.Regex.Pattern arg2) { var top = _Topology.AddSource(arg0, arg1, arg2); @@ -262,11 +262,11 @@ public KNetTopology AddSource(Org.Apache.Kafka.Streams.Processor.TimestampExtrac /// /// /// - /// + /// /// /// - /// - public KNetTopology AddSource(Org.Apache.Kafka.Streams.Topology.AutoOffsetReset arg0, string arg1, params string[] arg2) + /// + public KNetTopology AddSource(Topology.AutoOffsetReset arg0, string arg1, params string[] arg2) { var top = _Topology.AddSource(arg0, arg1, arg2); return new KNetTopology(top); @@ -274,11 +274,11 @@ public KNetTopology AddSource(Org.Apache.Kafka.Streams.Topology.AutoOffsetReset /// /// /// - /// + /// /// /// - /// - public KNetTopology AddSource(Org.Apache.Kafka.Streams.Topology.AutoOffsetReset arg0, string arg1, Java.Util.Regex.Pattern arg2) + /// + public KNetTopology AddSource(Topology.AutoOffsetReset arg0, string arg1, Java.Util.Regex.Pattern arg2) { var top = _Topology.AddSource(arg0, arg1, arg2); return new KNetTopology(top); @@ -286,70 +286,70 @@ public KNetTopology AddSource(Org.Apache.Kafka.Streams.Topology.AutoOffsetReset /// /// /// - /// + /// /// - /// - /// + /// + /// /// - /// - public KNetTopology AddSource(Org.Apache.Kafka.Streams.Topology.AutoOffsetReset arg0, string arg1, IKNetDeserializer arg2, IKNetDeserializer arg3, params string[] arg4) + /// + public KNetTopology AddSource(Topology.AutoOffsetReset arg0, string arg1, IKNetDeserializer arg2, IKNetDeserializer arg3, params string[] arg4) { - var top = (arg4.Length == 0) ? _Topology.IExecute("addSource", arg0, arg1, arg2.KafkaDeserializer, arg3.KafkaDeserializer) : _Topology.IExecute("addSource", arg0, arg1, arg2.KafkaDeserializer, arg3.KafkaDeserializer, arg4); + var top = (arg4.Length == 0) ? _Topology.IExecute("addSource", arg0, arg1, arg2.KafkaDeserializer, arg3.KafkaDeserializer) : _Topology.IExecute("addSource", arg0, arg1, arg2.KafkaDeserializer, arg3.KafkaDeserializer, arg4); return new KNetTopology(top); } /// /// /// - /// + /// /// - /// - /// + /// + /// /// - /// - public KNetTopology AddSource(Org.Apache.Kafka.Streams.Topology.AutoOffsetReset arg0, string arg1, IKNetDeserializer arg2, IKNetDeserializer arg3, Java.Util.Regex.Pattern arg4) + /// + public KNetTopology AddSource(Topology.AutoOffsetReset arg0, string arg1, IKNetDeserializer arg2, IKNetDeserializer arg3, Java.Util.Regex.Pattern arg4) { - var top = _Topology.IExecute("addSource", arg0, arg1, arg2.KafkaDeserializer, arg3.KafkaDeserializer, arg4); + var top = _Topology.IExecute("addSource", arg0, arg1, arg2.KafkaDeserializer, arg3.KafkaDeserializer, arg4); return new KNetTopology(top); } /// /// /// - /// + /// /// /// - /// - /// + /// + /// /// - /// - public KNetTopology AddSource(Org.Apache.Kafka.Streams.Topology.AutoOffsetReset arg0, string arg1, Org.Apache.Kafka.Streams.Processor.TimestampExtractor arg2, IKNetDeserializer arg3, IKNetDeserializer arg4, params string[] arg5) + /// + public KNetTopology AddSource(Topology.AutoOffsetReset arg0, string arg1, Org.Apache.Kafka.Streams.Processor.TimestampExtractor arg2, IKNetDeserializer arg3, IKNetDeserializer arg4, params string[] arg5) { - var top = (arg5.Length == 0) ? _Topology.IExecute("addSource", arg0, arg1, arg2, arg3.KafkaDeserializer, arg4.KafkaDeserializer) : _Topology.IExecute("addSource", arg0, arg1, arg2, arg3.KafkaDeserializer, arg4.KafkaDeserializer, arg5); + var top = (arg5.Length == 0) ? _Topology.IExecute("addSource", arg0, arg1, arg2, arg3.KafkaDeserializer, arg4.KafkaDeserializer) : _Topology.IExecute("addSource", arg0, arg1, arg2, arg3.KafkaDeserializer, arg4.KafkaDeserializer, arg5); return new KNetTopology(top); } /// /// /// - /// + /// /// /// - /// - /// + /// + /// /// - /// - public KNetTopology AddSource(Org.Apache.Kafka.Streams.Topology.AutoOffsetReset arg0, string arg1, Org.Apache.Kafka.Streams.Processor.TimestampExtractor arg2, IKNetDeserializer arg3, IKNetDeserializer arg4, Java.Util.Regex.Pattern arg5) + /// + public KNetTopology AddSource(Topology.AutoOffsetReset arg0, string arg1, Org.Apache.Kafka.Streams.Processor.TimestampExtractor arg2, IKNetDeserializer arg3, IKNetDeserializer arg4, Java.Util.Regex.Pattern arg5) { - var top = _Topology.IExecute("addSource", arg0, arg1, arg2, arg3.KafkaDeserializer, arg4.KafkaDeserializer, arg5); + var top = _Topology.IExecute("addSource", arg0, arg1, arg2, arg3.KafkaDeserializer, arg4.KafkaDeserializer, arg5); return new KNetTopology(top); } /// /// /// - /// + /// /// /// /// - /// - public KNetTopology AddSource(Org.Apache.Kafka.Streams.Topology.AutoOffsetReset arg0, Org.Apache.Kafka.Streams.Processor.TimestampExtractor arg1, string arg2, params string[] arg3) + /// + public KNetTopology AddSource(Topology.AutoOffsetReset arg0, Org.Apache.Kafka.Streams.Processor.TimestampExtractor arg1, string arg2, params string[] arg3) { var top = _Topology.AddSource(arg0, arg1, arg2, arg3); return new KNetTopology(top); @@ -357,12 +357,12 @@ public KNetTopology AddSource(Org.Apache.Kafka.Streams.Topology.AutoOffsetReset /// /// /// - /// + /// /// /// /// - /// - public KNetTopology AddSource(Org.Apache.Kafka.Streams.Topology.AutoOffsetReset arg0, Org.Apache.Kafka.Streams.Processor.TimestampExtractor arg1, string arg2, Java.Util.Regex.Pattern arg3) + /// + public KNetTopology AddSource(Topology.AutoOffsetReset arg0, Org.Apache.Kafka.Streams.Processor.TimestampExtractor arg1, string arg2, Java.Util.Regex.Pattern arg3) { var top = _Topology.AddSource(arg0, arg1, arg2, arg3); return new KNetTopology(top); diff --git a/src/net/KNet/Specific/Streams/Kstream/KNetPredicate.cs b/src/net/KNet/Specific/Streams/Kstream/KNetPredicate.cs new file mode 100644 index 0000000000..0b7e16c4b9 --- /dev/null +++ b/src/net/KNet/Specific/Streams/Kstream/KNetPredicate.cs @@ -0,0 +1,73 @@ +/* +* Copyright 2023 MASES s.r.l. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +* Refer to LICENSE for more information. +*/ + +using MASES.KNet.Serialization; +using Org.Apache.Kafka.Streams.Kstream; + +namespace MASES.KNet.Specific.Streams.Kstream +{ + /// + /// KNet implementation of + /// + /// The key type + /// The value type + public class KNetPredicate : Predicate + { + IKNetSerDes _keySerializer; + IKNetSerDes _valueSerializer; + /// + /// Default initializer + /// + public KNetPredicate(IKNetSerDes keySerializer, IKNetSerDes valueSerializer) : base() + { + _keySerializer = keySerializer; + _valueSerializer = valueSerializer; + } + /// + /// The associated to + /// + public IKNetSerDes KeySerializer => _keySerializer; + /// + /// The associated to + /// + public IKNetSerDes ValueSerializer => _valueSerializer; + + /// + /// Handler for + /// + /// If has a value it takes precedence over corresponding class method + public new System.Func OnTest { get; set; } = null; + + /// + public sealed override bool Test(byte[] arg0, byte[] arg1) + { + var methodToExecute = (OnTest != null) ? OnTest : Test; + return methodToExecute(_keySerializer.Deserialize(null, arg0), _valueSerializer.Deserialize(null, arg1)); + } + /// + /// KNet override of + /// + /// The key of the record + /// The value of the record + /// + public virtual bool Test(TKey arg0, TValue arg1) + { + return default; + } + } +} diff --git a/src/net/KNet/Specific/Streams/Kstream/KNetPredicateTester.cs b/src/net/KNet/Specific/Streams/Kstream/KNetPredicateTester.cs index 91be722ec4..c3e3b6d09a 100644 --- a/src/net/KNet/Specific/Streams/Kstream/KNetPredicateTester.cs +++ b/src/net/KNet/Specific/Streams/Kstream/KNetPredicateTester.cs @@ -16,10 +16,8 @@ * Refer to LICENSE for more information. */ -using Java.Security; using MASES.JCOBridge.C2JBridge; using Org.Apache.Kafka.Streams.Kstream; -using System; namespace MASES.KNet.Specific.Streams.Kstream { diff --git a/src/net/KNet/Specific/Streams/Kstream/KNetTimestampExtractor.cs b/src/net/KNet/Specific/Streams/Kstream/KNetTimestampExtractor.cs index 0e30e1d2a5..f10e45eb14 100644 --- a/src/net/KNet/Specific/Streams/Kstream/KNetTimestampExtractor.cs +++ b/src/net/KNet/Specific/Streams/Kstream/KNetTimestampExtractor.cs @@ -16,14 +16,11 @@ * Refer to LICENSE for more information. */ -using Java.Security; using MASES.JCOBridge.C2JBridge; using MASES.KNet.Consumer; using MASES.KNet.Serialization; using Org.Apache.Kafka.Clients.Consumer; -using Org.Apache.Kafka.Streams.Kstream; using Org.Apache.Kafka.Streams.Processor; -using System; namespace MASES.KNet.Specific.Streams.Kstream { diff --git a/src/net/KNet/Specific/Streams/Processor/KNetTopicNameExtractor.cs b/src/net/KNet/Specific/Streams/Processor/KNetTopicNameExtractor.cs new file mode 100644 index 0000000000..c4d0e170c5 --- /dev/null +++ b/src/net/KNet/Specific/Streams/Processor/KNetTopicNameExtractor.cs @@ -0,0 +1,74 @@ +/* +* Copyright 2023 MASES s.r.l. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +* Refer to LICENSE for more information. +*/ + +using MASES.KNet.Serialization; +using Org.Apache.Kafka.Streams.Processor; + +namespace MASES.KNet.Specific.Streams.Processor +{ + /// + /// KNet implementation of + /// + /// The key type + /// The value type + public class KNetTopicNameExtractor : TopicNameExtractor + { + IKNetSerDes _keySerializer; + IKNetSerDes _valueSerializer; + /// + /// Default initializer + /// + public KNetTopicNameExtractor(IKNetSerDes keySerializer, IKNetSerDes valueSerializer) : base() + { + _keySerializer = keySerializer; + _valueSerializer = valueSerializer; + } + /// + /// The associated to + /// + public IKNetSerDes KeySerializer => _keySerializer; + /// + /// The associated to + /// + public IKNetSerDes ValueSerializer => _valueSerializer; + + /// + /// Handler for + /// + /// If has a value it takes precedence over corresponding class method + public new System.Func OnExtract { get; set; } = null; + + /// + public sealed override string Extract(byte[] arg0, byte[] arg1, Org.Apache.Kafka.Streams.Processor.RecordContext arg2) + { + var methodToExecute = (OnExtract != null) ? OnExtract : Extract; + return methodToExecute(_keySerializer.Deserialize(null, arg0), _valueSerializer.Deserialize(null, arg1), arg2); + } + /// + /// KNet override of + /// + /// + /// + /// + /// + public virtual string Extract(TKey arg0, TValue arg1, Org.Apache.Kafka.Streams.Processor.RecordContext arg2) + { + return default; + } + } +} From c6c839aa9844d371e88c8e5128f006eedb270c1a Mon Sep 17 00:00:00 2001 From: masesdevelopers <94312179+masesdevelopers@users.noreply.github.com> Date: Fri, 12 Jan 2024 13:56:59 +0100 Subject: [PATCH 08/18] Update class --- src/net/KNet/Specific/Streams/KNetClientSupplier.cs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/net/KNet/Specific/Streams/KNetClientSupplier.cs b/src/net/KNet/Specific/Streams/KNetClientSupplier.cs index eaa03d7ade..ceb690d9ca 100644 --- a/src/net/KNet/Specific/Streams/KNetClientSupplier.cs +++ b/src/net/KNet/Specific/Streams/KNetClientSupplier.cs @@ -17,6 +17,8 @@ */ using Java.Util; +using MASES.KNet.Consumer; +using MASES.KNet.Producer; using Org.Apache.Kafka.Clients.Admin; using Org.Apache.Kafka.Clients.Consumer; using Org.Apache.Kafka.Clients.Producer; @@ -27,6 +29,8 @@ namespace MASES.KNet.Specific.Streams /// /// KNet implementation of /// + /// The default used from allocates both and . + /// uses and , the instance shall be disposed when no more in use, but still be alive still is alive. public class KNetClientSupplier : KafkaClientSupplier { private readonly System.Collections.Generic.List _admins = new(); @@ -51,7 +55,7 @@ public override Consumer GetConsumer(Map arg0) Properties properties = new(); properties.PutAll(arg0); - var consumer = new Consumer(properties); + var consumer = new KNetConsumer(properties); _consumers.Add(consumer); return consumer; } @@ -61,7 +65,7 @@ public override Consumer GetGlobalConsumer(Map a Properties properties = new(); properties.PutAll(arg0); - var consumer = new Consumer(properties); + var consumer = new KNetConsumer(properties); _consumers.Add(consumer); return consumer; } @@ -71,7 +75,7 @@ public override Producer GetProducer(Map arg0) Properties properties = new(); properties.PutAll(arg0); - var producer = new Producer(properties); + var producer = new KNetProducer(properties); _producers.Add(producer); return producer; } @@ -81,7 +85,7 @@ public override Consumer GetRestoreConsumer(Map Properties properties = new(); properties.PutAll(arg0); - var consumer = new Consumer(properties); + var consumer = new KNetConsumer(properties); _consumers.Add(consumer); return consumer; } From 764104c13059b7aa250af8a2b97116efea351aa8 Mon Sep 17 00:00:00 2001 From: masesdevelopers <94312179+masesdevelopers@users.noreply.github.com> Date: Sun, 14 Jan 2024 04:09:42 +0100 Subject: [PATCH 09/18] Added many classes to manage state store, reviewed namespace and serialization context --- .../Specific/Consumer/KNetConsumerRecord.cs | 2 +- src/net/KNet/Specific/GenericConfigBuilder.cs | 81 ++++--- .../Serialization/IGenericSerDesFactory.cs | 51 ++++ .../IGenericSerDesFactoryApplier.cs | 31 +++ .../KNet/Specific/Serialization/KNetSerDes.cs | 2 +- .../Specific/Streams/KNetClientSupplier.cs | 2 +- src/net/KNet/Specific/Streams/KNetKeyValue.cs | 78 +++++++ .../Specific/Streams/KNetStreamBuilder.cs | 9 +- src/net/KNet/Specific/Streams/KNetStreams.cs | 148 ++++++++---- .../Streams/KNetTimestampedKeyValue.cs | 80 +++++++ .../KNetTimestampedWindowedKeyValue.cs | 68 ++++++ src/net/KNet/Specific/Streams/KNetTopology.cs | 132 ++++++----- .../Specific/Streams/KNetTopologyConfig.cs | 17 +- .../Specific/Streams/KNetWindowedKeyValue.cs | 68 ++++++ .../Specific/Streams/Kstream/KNetPredicate.cs | 30 +-- .../Streams/Kstream/KNetPredicateTester.cs | 2 +- .../Streams/Kstream/KNetTimestampExtractor.cs | 21 +- .../Specific/Streams/Kstream/KNetWindowed.cs | 53 +++++ .../Streams/Processor/Api/KNetProcessor.cs | 88 +++++++ .../Processor/Api/KNetProcessorContext.cs | 177 ++++++++++++++ .../Streams/Processor/Api/KNetRecord.cs | 140 +++++++++++ .../Processor/KNetStreamPartitioner.cs | 29 +-- .../Processor/KNetTopicNameExtractor.cs | 29 +-- .../Streams/State/KNetKeyValueIterator.cs | 110 +++++++++ .../Streams/State/KNetManagedStore.cs | 24 ++ .../Streams/State/KNetQueryableStoreTypes.cs | 78 +++++++ .../State/KNetReadOnlyKeyValueStore.cs | 98 ++++++++ .../Streams/State/KNetReadOnlySessionStore.cs | 220 ++++++++++++++++++ .../Streams/State/KNetReadOnlyWindowStore.cs | 145 ++++++++++++ .../State/KNetTimestampedKeyValueIterator.cs | 108 +++++++++ .../State/KNetTimestampedKeyValueStore.cs | 98 ++++++++ .../State/KNetTimestampedWindowStore.cs | 148 ++++++++++++ .../KNetTimestampedWindowStoreIterator.cs | 54 +++++ ...KNetTimestampedWindowedKeyValueIterator.cs | 99 ++++++++ .../Streams/State/KNetValueAndTimestamp.cs | 66 ++++++ .../Streams/State/KNetWindowStoreIterator.cs | 54 +++++ .../State/KNetWindowedKeyValueIterator.cs | 99 ++++++++ 37 files changed, 2511 insertions(+), 228 deletions(-) create mode 100644 src/net/KNet/Specific/Serialization/IGenericSerDesFactory.cs create mode 100644 src/net/KNet/Specific/Serialization/IGenericSerDesFactoryApplier.cs create mode 100644 src/net/KNet/Specific/Streams/KNetKeyValue.cs create mode 100644 src/net/KNet/Specific/Streams/KNetTimestampedKeyValue.cs create mode 100644 src/net/KNet/Specific/Streams/KNetTimestampedWindowedKeyValue.cs create mode 100644 src/net/KNet/Specific/Streams/KNetWindowedKeyValue.cs create mode 100644 src/net/KNet/Specific/Streams/Kstream/KNetWindowed.cs create mode 100644 src/net/KNet/Specific/Streams/Processor/Api/KNetProcessor.cs create mode 100644 src/net/KNet/Specific/Streams/Processor/Api/KNetProcessorContext.cs create mode 100644 src/net/KNet/Specific/Streams/Processor/Api/KNetRecord.cs create mode 100644 src/net/KNet/Specific/Streams/State/KNetKeyValueIterator.cs create mode 100644 src/net/KNet/Specific/Streams/State/KNetManagedStore.cs create mode 100644 src/net/KNet/Specific/Streams/State/KNetQueryableStoreTypes.cs create mode 100644 src/net/KNet/Specific/Streams/State/KNetReadOnlyKeyValueStore.cs create mode 100644 src/net/KNet/Specific/Streams/State/KNetReadOnlySessionStore.cs create mode 100644 src/net/KNet/Specific/Streams/State/KNetReadOnlyWindowStore.cs create mode 100644 src/net/KNet/Specific/Streams/State/KNetTimestampedKeyValueIterator.cs create mode 100644 src/net/KNet/Specific/Streams/State/KNetTimestampedKeyValueStore.cs create mode 100644 src/net/KNet/Specific/Streams/State/KNetTimestampedWindowStore.cs create mode 100644 src/net/KNet/Specific/Streams/State/KNetTimestampedWindowStoreIterator.cs create mode 100644 src/net/KNet/Specific/Streams/State/KNetTimestampedWindowedKeyValueIterator.cs create mode 100644 src/net/KNet/Specific/Streams/State/KNetValueAndTimestamp.cs create mode 100644 src/net/KNet/Specific/Streams/State/KNetWindowStoreIterator.cs create mode 100644 src/net/KNet/Specific/Streams/State/KNetWindowedKeyValueIterator.cs diff --git a/src/net/KNet/Specific/Consumer/KNetConsumerRecord.cs b/src/net/KNet/Specific/Consumer/KNetConsumerRecord.cs index 41ab037058..248c7e5163 100644 --- a/src/net/KNet/Specific/Consumer/KNetConsumerRecord.cs +++ b/src/net/KNet/Specific/Consumer/KNetConsumerRecord.cs @@ -39,7 +39,7 @@ public class KNetConsumerRecord /// The to use for initialization /// Key serializer base on /// Value serializer base on - public KNetConsumerRecord(ConsumerRecord record, IKNetDeserializer keyDeserializer, IKNetDeserializer valueDeserializer) + internal KNetConsumerRecord(ConsumerRecord record, IKNetDeserializer keyDeserializer, IKNetDeserializer valueDeserializer) { _record = record; _keyDeserializer = keyDeserializer; diff --git a/src/net/KNet/Specific/GenericConfigBuilder.cs b/src/net/KNet/Specific/GenericConfigBuilder.cs index eeeafdaad1..c32c075c78 100644 --- a/src/net/KNet/Specific/GenericConfigBuilder.cs +++ b/src/net/KNet/Specific/GenericConfigBuilder.cs @@ -21,6 +21,8 @@ using System; using MASES.KNet.Serialization; using System.Linq; +using System.Collections.Concurrent; +using static Javax.Lang.Model.Util.Elements; namespace MASES.KNet { @@ -28,7 +30,7 @@ namespace MASES.KNet /// Generic base configuration class /// /// - public class GenericConfigBuilder : System.ComponentModel.INotifyPropertyChanged + public class GenericConfigBuilder : System.ComponentModel.INotifyPropertyChanged, IGenericSerDesFactory where T : GenericConfigBuilder, new() { /// @@ -109,7 +111,9 @@ protected virtual T Clone() { var clone = new T { - _options = new System.Collections.Generic.Dictionary(_options) + _options = new System.Collections.Generic.Dictionary(_options), + _KNetKeySerDes = _KNetKeySerDes, + _KNetValueSerDes = _KNetValueSerDes }; return clone; } @@ -143,9 +147,7 @@ public Map ToMap() return props; } Type _KNetKeySerDes = null; - /// - /// The used to create an instance of for keys with - /// + /// public Type KNetKeySerDes { get { return _KNetKeySerDes; } @@ -172,9 +174,7 @@ public Type KNetKeySerDes } Type _KNetValueSerDes = null; - /// - /// The used to create an instance of for values with - /// + /// public Type KNetValueSerDes { get { return _KNetValueSerDes; } @@ -200,41 +200,54 @@ public Type KNetValueSerDes } } - /// - /// Builds an instance of using the defined in - /// - /// The type of the key - /// An instance of - /// If is + readonly ConcurrentDictionary _keySerDes = new(); + + /// public IKNetSerDes BuildKeySerDes() { - if (KNetSerialization.IsInternalManaged()) + lock (_keySerDes) { - return new KNetSerDes(); + if (!_keySerDes.TryGetValue(typeof(TKey), out object serDes)) + { + if (KNetSerialization.IsInternalManaged()) + { + serDes = new KNetSerDes(); + } + else + { + if (KNetKeySerDes == null) throw new InvalidOperationException($"No default serializer available for {typeof(TKey)}, property {nameof(KNetKeySerDes)} shall be set."); + var tmp = KNetKeySerDes.MakeGenericType(typeof(TKey)); + serDes = Activator.CreateInstance(tmp); + } + _keySerDes[typeof(TKey)] = serDes; + } + return serDes as IKNetSerDes; } - - if (KNetKeySerDes == null) throw new InvalidOperationException($"No default serializer available for {typeof(TKey)}, property {nameof(KNetKeySerDes)} shall be set."); - var tmp = KNetKeySerDes.MakeGenericType(typeof(TKey)); - var o = Activator.CreateInstance(tmp); - return o as IKNetSerDes; } - /// - /// Builds an instance of using the defined in - /// - /// The type of the key - /// An instance of - /// If is + + readonly ConcurrentDictionary _valueSerDes = new(); + + /// public IKNetSerDes BuildValueSerDes() { - if (KNetSerialization.IsInternalManaged()) + lock (_valueSerDes) { - return new KNetSerDes(); + if (!_valueSerDes.TryGetValue(typeof(TValue), out object serDes)) + { + if (KNetSerialization.IsInternalManaged()) + { + serDes = new KNetSerDes(); + } + else + { + if (KNetValueSerDes == null) throw new InvalidOperationException($"No default serializer available for {typeof(TValue)}, property {nameof(KNetValueSerDes)} shall be set."); + var tmp = KNetValueSerDes.MakeGenericType(typeof(TValue)); + serDes = Activator.CreateInstance(tmp); + } + _valueSerDes[typeof(TValue)] = serDes; + } + return serDes as IKNetSerDes; } - - if (KNetValueSerDes == null) throw new InvalidOperationException($"No default serializer available for {typeof(TValue)}, property {nameof(KNetValueSerDes)} shall be set."); - var tmp = KNetValueSerDes.MakeGenericType(typeof(TValue)); - var o = Activator.CreateInstance(tmp); - return o as IKNetSerDes; } } } diff --git a/src/net/KNet/Specific/Serialization/IGenericSerDesFactory.cs b/src/net/KNet/Specific/Serialization/IGenericSerDesFactory.cs new file mode 100644 index 0000000000..330510c2d4 --- /dev/null +++ b/src/net/KNet/Specific/Serialization/IGenericSerDesFactory.cs @@ -0,0 +1,51 @@ +/* +* Copyright 2023 MASES s.r.l. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +* Refer to LICENSE for more information. +*/ + +using System; + +namespace MASES.KNet.Serialization +{ + /// + /// Generic interface to access serializers + /// + public interface IGenericSerDesFactory + { + /// + /// The used to create an instance of for keys with + /// + public Type KNetKeySerDes { get; } + /// + /// The used to create an instance of for values with + /// + public Type KNetValueSerDes { get; } + /// + /// Builds an instance of using the defined in + /// + /// The type of the key + /// An instance of + /// If is + public IKNetSerDes BuildKeySerDes(); + /// + /// Builds an instance of using the defined in + /// + /// The type of the key + /// An instance of + /// If is + public IKNetSerDes BuildValueSerDes(); + } +} diff --git a/src/net/KNet/Specific/Serialization/IGenericSerDesFactoryApplier.cs b/src/net/KNet/Specific/Serialization/IGenericSerDesFactoryApplier.cs new file mode 100644 index 0000000000..72e6144216 --- /dev/null +++ b/src/net/KNet/Specific/Serialization/IGenericSerDesFactoryApplier.cs @@ -0,0 +1,31 @@ +/* +* Copyright 2023 MASES s.r.l. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +* Refer to LICENSE for more information. +*/ + +namespace MASES.KNet.Serialization +{ + /// + /// Generic interface to apply accessor + /// + public interface IGenericSerDesFactoryApplier + { + /// + /// Associated factory + /// + IGenericSerDesFactory Factory { get; set; } + } +} diff --git a/src/net/KNet/Specific/Serialization/KNetSerDes.cs b/src/net/KNet/Specific/Serialization/KNetSerDes.cs index 737900527e..ea71e0db08 100644 --- a/src/net/KNet/Specific/Serialization/KNetSerDes.cs +++ b/src/net/KNet/Specific/Serialization/KNetSerDes.cs @@ -43,7 +43,7 @@ public class KNetSerDes : IKNetSerDes { #region private fields readonly KNetSerialization.SerializationType _SerializationType = KNetSerialization.InternalSerDesType(); - Serde _KafkaSerde = new Serde(); + Serde _KafkaSerde = Serdes.ByteArray(); Serializer _KafkaSerializer = new ByteArraySerializer(); Deserializer _KafkaDeserializer = new ByteArrayDeserializer(); #endregion diff --git a/src/net/KNet/Specific/Streams/KNetClientSupplier.cs b/src/net/KNet/Specific/Streams/KNetClientSupplier.cs index ceb690d9ca..0c9e96d1ef 100644 --- a/src/net/KNet/Specific/Streams/KNetClientSupplier.cs +++ b/src/net/KNet/Specific/Streams/KNetClientSupplier.cs @@ -24,7 +24,7 @@ using Org.Apache.Kafka.Clients.Producer; using Org.Apache.Kafka.Streams; -namespace MASES.KNet.Specific.Streams +namespace MASES.KNet.Streams { /// /// KNet implementation of diff --git a/src/net/KNet/Specific/Streams/KNetKeyValue.cs b/src/net/KNet/Specific/Streams/KNetKeyValue.cs new file mode 100644 index 0000000000..1f3787251b --- /dev/null +++ b/src/net/KNet/Specific/Streams/KNetKeyValue.cs @@ -0,0 +1,78 @@ +/* +* Copyright 2023 MASES s.r.l. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +* Refer to LICENSE for more information. +*/ + +using MASES.KNet.Serialization; +using Org.Apache.Kafka.Streams; + +namespace MASES.KNet.Streams +{ + /// + /// KNet implementation of + /// + /// The key type + /// The value type + public class KNetKeyValue : IGenericSerDesFactoryApplier + { + readonly KeyValue _value = null; + readonly KeyValue _value2 = null; + readonly IKNetSerDes _keySerDes; + readonly IKNetSerDes _valueSerDes; + IGenericSerDesFactory _factory; + IGenericSerDesFactory IGenericSerDesFactoryApplier.Factory { get => _factory; set { _factory = value; } } + + internal KNetKeyValue(IGenericSerDesFactory factory, KeyValue value) + { + _factory = factory; + _keySerDes = _factory.BuildKeySerDes(); + _valueSerDes = _factory.BuildValueSerDes(); + _value = value; + } + + internal KNetKeyValue(IGenericSerDesFactory factory, KeyValue value) + { + _factory = factory; + _keySerDes = _factory.BuildKeySerDes(); + _valueSerDes = _factory.BuildValueSerDes(); + _value2 = value; + } + + /// + /// KNet implementation of + /// + public TKey Key + { + get + { + if (_value2 != null) return (TKey)(object)_value2.key; + var kk = _value.key; + return _keySerDes.Deserialize(null, kk); + } + } + /// + /// KNet implementation of + /// + public TValue Value + { + get + { + var kk = _value.value; + return _valueSerDes.Deserialize(null, kk); + } + } + } +} diff --git a/src/net/KNet/Specific/Streams/KNetStreamBuilder.cs b/src/net/KNet/Specific/Streams/KNetStreamBuilder.cs index a77c394642..ad656b60e1 100644 --- a/src/net/KNet/Specific/Streams/KNetStreamBuilder.cs +++ b/src/net/KNet/Specific/Streams/KNetStreamBuilder.cs @@ -16,15 +16,18 @@ * Refer to LICENSE for more information. */ +using MASES.KNet.Serialization; using Org.Apache.Kafka.Streams; -namespace MASES.KNet.Specific.Streams +namespace MASES.KNet.Streams { /// /// KNet extension of /// - public class KNetStreamBuilder : StreamsBuilder + public class KNetStreamBuilder : StreamsBuilder, IGenericSerDesFactoryApplier { + IGenericSerDesFactory _factory; + IGenericSerDesFactory IGenericSerDesFactoryApplier.Factory { get => _factory; set { _factory = value; } } #region Constructors /// public KNetStreamBuilder() : base() { } @@ -34,7 +37,7 @@ public KNetStreamBuilder(params object[] args) : base(args) { } /// /// /// - public KNetStreamBuilder(Org.Apache.Kafka.Streams.TopologyConfig arg0) + public KNetStreamBuilder(KNetTopologyConfig arg0) : base(arg0) { } diff --git a/src/net/KNet/Specific/Streams/KNetStreams.cs b/src/net/KNet/Specific/Streams/KNetStreams.cs index 03dfb3e67a..632b8ae816 100644 --- a/src/net/KNet/Specific/Streams/KNetStreams.cs +++ b/src/net/KNet/Specific/Streams/KNetStreams.cs @@ -17,16 +17,26 @@ */ using MASES.KNet.Serialization; -using MASES.KNet.Specific.Streams.Processor; +using MASES.KNet.Streams.Processor; +using MASES.KNet.Streams.State; using Org.Apache.Kafka.Streams; +using System; -namespace MASES.KNet.Specific.Streams +namespace MASES.KNet.Streams { /// /// KNet extension of /// - public class KNetStreams : KafkaStreams + public class KNetStreams : KafkaStreams, IGenericSerDesFactoryApplier { + readonly KNetClientSupplier _supplier = null; // used to avoid GC recall + IGenericSerDesFactory _factory; + IGenericSerDesFactory IGenericSerDesFactoryApplier.Factory { get => _factory; set { _factory = value; } } + + Org.Apache.Kafka.Streams.Processor.StateRestoreListener _stateRestoreListener; + Org.Apache.Kafka.Streams.KafkaStreams.StateListener _stateListener; + Org.Apache.Kafka.Streams.Errors.StreamsUncaughtExceptionHandler _streamsUncaughtExceptionHandler; + #region Constructors /// public KNetStreams() : base() { } @@ -38,9 +48,10 @@ public KNetStreams(params object[] args) : base(args) { } /// /// /// - public KNetStreams(KNetTopology arg0, Java.Util.Properties arg1, Org.Apache.Kafka.Common.Utils.Time arg2) + public KNetStreams(KNetTopology arg0, StreamsConfigBuilder arg1, Org.Apache.Kafka.Common.Utils.Time arg2) : base(arg0, arg1, arg2) { + _factory = arg1; } /// /// KNet override of @@ -49,9 +60,11 @@ public KNetStreams(KNetTopology arg0, Java.Util.Properties arg1, Org.Apache.Kafk /// /// /// - public KNetStreams(KNetTopology arg0, Java.Util.Properties arg1, KNetClientSupplier arg2, Org.Apache.Kafka.Common.Utils.Time arg3) + public KNetStreams(KNetTopology arg0, StreamsConfigBuilder arg1, KNetClientSupplier arg2, Org.Apache.Kafka.Common.Utils.Time arg3) : base(arg0, arg1, arg2, arg3) { + _factory = arg1; + _supplier = arg2; } /// /// KNet override of @@ -59,54 +72,27 @@ public KNetStreams(KNetTopology arg0, Java.Util.Properties arg1, KNetClientSuppl /// /// /// - public KNetStreams(KNetTopology arg0, Java.Util.Properties arg1, KNetClientSupplier arg2) + public KNetStreams(KNetTopology arg0, StreamsConfigBuilder arg1, KNetClientSupplier arg2) : base(arg0, arg1, arg2) { + _factory = arg1; + _supplier = arg2; } /// /// KNet override of /// /// /// - public KNetStreams(KNetTopology arg0, Java.Util.Properties arg1) + public KNetStreams(KNetTopology arg0, StreamsConfigBuilder arg1) : base(arg0, arg1) { + _factory = arg1; } - /// - /// KNet override of - /// - /// - /// - /// - public KNetStreams(KNetTopology arg0, Org.Apache.Kafka.Streams.StreamsConfig arg1, Org.Apache.Kafka.Common.Utils.Time arg2) - : base(arg0, arg1, arg2) - { - } - /// - /// KNet override of - /// - /// - /// - /// - public KNetStreams(KNetTopology arg0, Org.Apache.Kafka.Streams.StreamsConfig arg1, KNetClientSupplier arg2) - : base(arg0, arg1, arg2) - { - } - /// - /// KNet override of - /// - /// - /// - public KNetStreams(KNetTopology arg0, Org.Apache.Kafka.Streams.StreamsConfig arg1) - : base(arg0, arg1) - { - } - #endregion #region Instance methods /// - /// KNet override of + /// KNet implementation of /// /// /// @@ -118,7 +104,7 @@ public Org.Apache.Kafka.Streams.KeyQueryMetadata QueryMetadataForKey(strin return QueryMetadataForKey(arg0, arg2.Serialize(null, arg1), arg2.KafkaSerializer); } /// - /// KNet override of + /// KNet implementation of /// /// /// @@ -127,7 +113,89 @@ public Org.Apache.Kafka.Streams.KeyQueryMetadata QueryMetadataForKey(strin /// public Org.Apache.Kafka.Streams.KeyQueryMetadata QueryMetadataForKey(string arg0, TKey arg1, KNetStreamPartitioner arg2) { - return IExecute("queryMetadataForKey", arg0, arg2.KeySerializer.Serialize(null, arg1), arg2); + if (arg2 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; + var keySerDes = _factory.BuildKeySerDes(); + return IExecute("queryMetadataForKey", arg0, keySerDes.Serialize(null, arg1), arg2); + } + + /// + /// + /// + /// + /// + /// + /// + public TKNetManagedStore Store(Org.Apache.Kafka.Streams.StoreQueryParameters arg0) + where TKNetManagedStore : KNetManagedStore, IGenericSerDesFactoryApplier + { + var t = typeof(TKNetManagedStore); + var substore = Store(arg0); + return Activator.CreateInstance(t, _factory, substore) as TKNetManagedStore; + } + + /// + /// + /// + /// + /// + /// + /// + /// + public TKNetManagedStore Store(string storageId, KNetQueryableStoreTypes.StoreType storeType) + where TKNetManagedStore : KNetManagedStore, IGenericSerDesFactoryApplier + { + var sqp = StoreQueryParameters.FromNameAndType(storageId, storeType.Store); + var t = typeof(TKNetManagedStore); + var substore = Store(sqp); + return Activator.CreateInstance(t, _factory, substore) as TKNetManagedStore; + } + + /// + /// KNet implementation of + /// + /// + /// + public string RemoveStreamThread(TimeSpan arg0) + { + var res = base.RemoveStreamThread(arg0); + return res.IsPresent() ? res.Get() : null; + } + + /// + /// + /// + /// + public new State State => base.StateMethod(); + + /// + /// + /// + /// + public new void SetGlobalStateRestoreListener(Org.Apache.Kafka.Streams.Processor.StateRestoreListener arg0) + { + base.SetGlobalStateRestoreListener(null); + _stateRestoreListener = arg0; + base.SetGlobalStateRestoreListener(arg0); + } + /// + /// + /// + /// + public new void SetStateListener(Org.Apache.Kafka.Streams.KafkaStreams.StateListener arg0) + { + base.SetStateListener(null); + _stateListener = arg0; + base.SetStateListener(arg0); + } + /// + /// + /// + /// + public new void SetUncaughtExceptionHandler(Org.Apache.Kafka.Streams.Errors.StreamsUncaughtExceptionHandler arg0) + { + base.SetUncaughtExceptionHandler(null); + _streamsUncaughtExceptionHandler = arg0; + base.SetUncaughtExceptionHandler(arg0); } #endregion diff --git a/src/net/KNet/Specific/Streams/KNetTimestampedKeyValue.cs b/src/net/KNet/Specific/Streams/KNetTimestampedKeyValue.cs new file mode 100644 index 0000000000..8f4518f7b6 --- /dev/null +++ b/src/net/KNet/Specific/Streams/KNetTimestampedKeyValue.cs @@ -0,0 +1,80 @@ +/* +* Copyright 2023 MASES s.r.l. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +* Refer to LICENSE for more information. +*/ + +using MASES.KNet.Serialization; +using MASES.KNet.Streams.State; +using Org.Apache.Kafka.Streams; +using Org.Apache.Kafka.Streams.State; + +namespace MASES.KNet.Streams +{ + /// + /// KNet implementation of + /// + /// The key type + /// The value type + public class KNetTimestampedKeyValue : IGenericSerDesFactoryApplier + { + readonly KeyValue> _value; + readonly KeyValue> _value2; + readonly IKNetSerDes _keySerDes; + readonly IKNetSerDes _valueSerDes; + IGenericSerDesFactory _factory; + IGenericSerDesFactory IGenericSerDesFactoryApplier.Factory { get => _factory; set { _factory = value; } } + + internal KNetTimestampedKeyValue(IGenericSerDesFactory factory, KeyValue> value) + { + _factory = factory; + _keySerDes = _factory.BuildKeySerDes(); + _valueSerDes = _factory.BuildValueSerDes(); + _value = value; + } + + internal KNetTimestampedKeyValue(IGenericSerDesFactory factory, KeyValue> value) + { + _factory = factory; + _keySerDes = _factory.BuildKeySerDes(); + _valueSerDes = _factory.BuildValueSerDes(); + _value2 = value; + } + + /// + /// KNet implementation of + /// + public TKey Key + { + get + { + if (_value2 != null) return (TKey)(object)_value2.key; + var kk = _value.key; + return _keySerDes.Deserialize(null, kk); + } + } + /// + /// KNet implementation of + /// + public KNetValueAndTimestamp Value + { + get + { + var kk = _value.value; + return new KNetValueAndTimestamp(_factory, kk); + } + } + } +} diff --git a/src/net/KNet/Specific/Streams/KNetTimestampedWindowedKeyValue.cs b/src/net/KNet/Specific/Streams/KNetTimestampedWindowedKeyValue.cs new file mode 100644 index 0000000000..c5be383e81 --- /dev/null +++ b/src/net/KNet/Specific/Streams/KNetTimestampedWindowedKeyValue.cs @@ -0,0 +1,68 @@ +/* +* Copyright 2023 MASES s.r.l. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +* Refer to LICENSE for more information. +*/ + +using MASES.KNet.Serialization; +using MASES.KNet.Streams.Kstream; +using MASES.KNet.Streams.State; +using Org.Apache.Kafka.Streams; +using Org.Apache.Kafka.Streams.Kstream; +using Org.Apache.Kafka.Streams.State; + +namespace MASES.KNet.Streams +{ + /// + /// KNet implementation of + /// + /// The key type + /// The value type + public class KNetTimestampedWindowedKeyValue : IGenericSerDesFactoryApplier + { + readonly KeyValue, ValueAndTimestamp> _value; + IGenericSerDesFactory _factory; + IGenericSerDesFactory IGenericSerDesFactoryApplier.Factory { get => _factory; set { _factory = value; } } + + internal KNetTimestampedWindowedKeyValue(IGenericSerDesFactory factory, KeyValue, ValueAndTimestamp> value) + { + _factory = factory; + _value = value; + } + + /// + /// KNet implementation of + /// + public KNetWindowed Key + { + get + { + var kk = _value.key; + return new KNetWindowed(_factory, kk); + } + } + /// + /// KNet implementation of + /// + public KNetValueAndTimestamp Value + { + get + { + var kk = _value.value; + return new KNetValueAndTimestamp(_factory, kk); + } + } + } +} diff --git a/src/net/KNet/Specific/Streams/KNetTopology.cs b/src/net/KNet/Specific/Streams/KNetTopology.cs index fdc6fa618b..688cd756c6 100644 --- a/src/net/KNet/Specific/Streams/KNetTopology.cs +++ b/src/net/KNet/Specific/Streams/KNetTopology.cs @@ -17,33 +17,38 @@ */ using MASES.KNet.Serialization; -using MASES.KNet.Specific.Streams.Processor; +using MASES.KNet.Streams.Kstream; +using MASES.KNet.Streams.Processor; using Org.Apache.Kafka.Streams; +using Org.Apache.Kafka.Streams.Processor; -namespace MASES.KNet.Specific.Streams +namespace MASES.KNet.Streams { /// /// KNet implementation of /// - public class KNetTopology + public class KNetTopology : IGenericSerDesFactoryApplier { - Topology _Topology; - + readonly Topology _topology; + IGenericSerDesFactory _factory; + IGenericSerDesFactory IGenericSerDesFactoryApplier.Factory { get => _factory; set { _factory = value; } } #region Constructors /// - public KNetTopology() { _Topology = new Topology(); } + public KNetTopology(IGenericSerDesFactory factory) : base() { _factory = factory; _topology = new Topology(); } /// - /// KNet override of + /// KNet implementation of /// /// public KNetTopology(KNetTopologyConfig arg0) { - _Topology = new Topology(arg0); + if (arg0 is IGenericSerDesFactoryApplier applier) _factory = applier.Factory; + _topology = new Topology(arg0); } - KNetTopology(Topology topology) + KNetTopology(Topology topology, IGenericSerDesFactory factory) { - _Topology = topology; + _factory = factory; + _topology = topology; } #endregion @@ -52,7 +57,7 @@ public KNetTopology(KNetTopologyConfig arg0) /// /// Converter from to /// - public static implicit operator Topology(KNetTopology t) => t._Topology; + public static implicit operator Topology(KNetTopology t) => t._topology; #endregion @@ -70,8 +75,8 @@ public KNetTopology(KNetTopologyConfig arg0) /// public KNetTopology AddSink(string arg0, string arg1, IKNetSerializer arg2, IKNetSerializer arg3, params string[] arg4) { - var top = _Topology.AddSink(arg0, arg1, arg2.KafkaSerializer, arg3.KafkaSerializer, arg4); - return new KNetTopology(top); + var top = _topology.AddSink(arg0, arg1, arg2.KafkaSerializer, arg3.KafkaSerializer, arg4); + return new KNetTopology(top, _factory); } /// /// @@ -89,8 +94,9 @@ public KNetTopology AddSink(string arg0, string arg1, IKNetSerializer a /// public KNetTopology AddSink(string arg0, string arg1, IKNetSerializer arg2, IKNetSerializer arg3, KNetStreamPartitioner arg4, params string[] arg5) where Arg4objectSuperK : K where Arg4objectSuperV : V { - var top = _Topology.AddSink(arg0, arg1, arg2.KafkaSerializer, arg3.KafkaSerializer, arg4, arg5); - return new KNetTopology(top); + if (arg4 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; + var top = _topology.AddSink(arg0, arg1, arg2.KafkaSerializer, arg3.KafkaSerializer, arg4, arg5); + return new KNetTopology(top, _factory); } /// /// @@ -106,8 +112,9 @@ public KNetTopology AddSink(string arg /// public KNetTopology AddSink(string arg0, string arg1, KNetStreamPartitioner arg2, params string[] arg3) where Arg2objectSuperK : K where Arg2objectSuperV : V { - var top = (arg3.Length == 0) ? _Topology.IExecute("addSink", arg0, arg1, arg2) : _Topology.IExecute("addSource", arg0, arg1, arg2, arg3); - return new KNetTopology(top); + if (arg2 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; + var top = (arg3.Length == 0) ? _topology.IExecute("addSink", arg0, arg1, arg2) : _topology.IExecute("addSource", arg0, arg1, arg2, arg3); + return new KNetTopology(top, _factory); } /// /// @@ -120,8 +127,9 @@ public KNetTopology AddSink(string arg /// public KNetTopology AddSink(string arg0, KNetTopicNameExtractor arg1, params string[] arg2) { - var top = _Topology.AddSink(arg0, arg1, arg2); - return new KNetTopology(top); + if (arg1 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; + var top = _topology.AddSink(arg0, arg1, arg2); + return new KNetTopology(top, _factory); } /// /// @@ -136,8 +144,9 @@ public KNetTopology AddSink(string arg0, KNetTopicNameExtractor arg1 /// public KNetTopology AddSink(string arg0, KNetTopicNameExtractor arg1, IKNetSerializer arg2, IKNetSerializer arg3, params string[] arg4) { - var top = _Topology.AddSink(arg0, arg1, arg2.KafkaSerializer, arg3.KafkaSerializer, arg4); - return new KNetTopology(top); + if (arg1 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; + var top = _topology.AddSink(arg0, arg1, arg2.KafkaSerializer, arg3.KafkaSerializer, arg4); + return new KNetTopology(top, _factory); } /// /// @@ -155,8 +164,9 @@ public KNetTopology AddSink(string arg0, KNetTopicNameExtractor arg1 /// public KNetTopology AddSink(string arg0, KNetTopicNameExtractor arg1, IKNetSerializer arg2, IKNetSerializer arg3, KNetStreamPartitioner arg4, params string[] arg5) where Arg4objectSuperK : K where Arg4objectSuperV : V { - var top = _Topology.AddSink(arg0, arg1, arg2.KafkaSerializer, arg3.KafkaSerializer, arg4, arg5); - return new KNetTopology(top); + if (arg1 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; + var top = _topology.AddSink(arg0, arg1, arg2.KafkaSerializer, arg3.KafkaSerializer, arg4, arg5); + return new KNetTopology(top, _factory); } /// /// @@ -172,8 +182,10 @@ public KNetTopology AddSink(string arg /// public KNetTopology AddSink(string arg0, KNetTopicNameExtractor arg1, KNetStreamPartitioner arg2, params string[] arg3) where Arg2objectSuperK : K where Arg2objectSuperV : V { - var top = _Topology.AddSink(arg0, arg1, arg2, arg3); - return new KNetTopology(top); + if (arg1 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; + if (arg2 is IGenericSerDesFactoryApplier applier1) applier1.Factory = _factory; + var top = _topology.AddSink(arg0, arg1, arg2, arg3); + return new KNetTopology(top, _factory); } /// /// @@ -184,8 +196,8 @@ public KNetTopology AddSink(string arg /// public KNetTopology AddSink(string arg0, string arg1, params string[] arg2) { - var top = _Topology.AddSink(arg0, arg1, arg2); - return new KNetTopology(top); + var top = _topology.AddSink(arg0, arg1, arg2); + return new KNetTopology(top, _factory); } /// /// @@ -195,8 +207,8 @@ public KNetTopology AddSink(string arg0, string arg1, params string[] arg2) /// public KNetTopology AddSource(string arg0, params string[] arg1) { - var top = _Topology.AddSource(arg0, arg1); - return new KNetTopology(top); + var top = _topology.AddSource(arg0, arg1); + return new KNetTopology(top, _factory); } /// /// @@ -206,8 +218,8 @@ public KNetTopology AddSource(string arg0, params string[] arg1) /// public KNetTopology AddSource(string arg0, Java.Util.Regex.Pattern arg1) { - var top = _Topology.AddSource(arg0, arg1); - return new KNetTopology(top); + var top = _topology.AddSource(arg0, arg1); + return new KNetTopology(top, _factory); } /// /// @@ -219,8 +231,8 @@ public KNetTopology AddSource(string arg0, Java.Util.Regex.Pattern arg1) /// public KNetTopology AddSource(string arg0, IKNetDeserializer arg1, IKNetDeserializer arg2, params string[] arg3) { - var top = (arg3.Length == 0) ? _Topology.IExecute("addSource", arg0, arg1.KafkaDeserializer, arg2.KafkaDeserializer) : _Topology.IExecute("addSource", arg0, arg1.KafkaDeserializer, arg2.KafkaDeserializer, arg3); - return new KNetTopology(top); + var top = (arg3.Length == 0) ? _topology.IExecute("addSource", arg0, arg1.KafkaDeserializer, arg2.KafkaDeserializer) : _topology.IExecute("addSource", arg0, arg1.KafkaDeserializer, arg2.KafkaDeserializer, arg3); + return new KNetTopology(top, _factory); } /// /// @@ -232,8 +244,8 @@ public KNetTopology AddSource(string arg0, IKNetDeserializer arg1, IKNet /// public KNetTopology AddSource(string arg0, IKNetDeserializer arg1, IKNetDeserializer arg2, Java.Util.Regex.Pattern arg3) { - var top = _Topology.IExecute("addSource", arg0, arg1.KafkaDeserializer, arg2.KafkaDeserializer, arg3); - return new KNetTopology(top); + var top = _topology.IExecute("addSource", arg0, arg1.KafkaDeserializer, arg2.KafkaDeserializer, arg3); + return new KNetTopology(top, _factory); } /// /// @@ -244,8 +256,9 @@ public KNetTopology AddSource(string arg0, IKNetDeserializer arg1, IKNet /// public KNetTopology AddSource(Org.Apache.Kafka.Streams.Processor.TimestampExtractor arg0, string arg1, params string[] arg2) { - var top = (arg2.Length == 0) ? _Topology.IExecute("addSource", arg0, arg1) : _Topology.IExecute("addSource", arg0, arg1, arg2); - return new KNetTopology(top); + if (arg0 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; + var top = (arg2.Length == 0) ? _topology.IExecute("addSource", arg0, arg1) : _topology.IExecute("addSource", arg0, arg1, arg2); + return new KNetTopology(top, _factory); } /// /// @@ -256,8 +269,9 @@ public KNetTopology AddSource(Org.Apache.Kafka.Streams.Processor.TimestampExtrac /// public KNetTopology AddSource(Org.Apache.Kafka.Streams.Processor.TimestampExtractor arg0, string arg1, Java.Util.Regex.Pattern arg2) { - var top = _Topology.AddSource(arg0, arg1, arg2); - return new KNetTopology(top); + if (arg0 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; + var top = _topology.AddSource(arg0, arg1, arg2); + return new KNetTopology(top, _factory); } /// /// @@ -268,8 +282,8 @@ public KNetTopology AddSource(Org.Apache.Kafka.Streams.Processor.TimestampExtrac /// public KNetTopology AddSource(Topology.AutoOffsetReset arg0, string arg1, params string[] arg2) { - var top = _Topology.AddSource(arg0, arg1, arg2); - return new KNetTopology(top); + var top = _topology.AddSource(arg0, arg1, arg2); + return new KNetTopology(top, _factory); } /// /// @@ -280,8 +294,8 @@ public KNetTopology AddSource(Topology.AutoOffsetReset arg0, string arg1, params /// public KNetTopology AddSource(Topology.AutoOffsetReset arg0, string arg1, Java.Util.Regex.Pattern arg2) { - var top = _Topology.AddSource(arg0, arg1, arg2); - return new KNetTopology(top); + var top = _topology.AddSource(arg0, arg1, arg2); + return new KNetTopology(top, _factory); } /// /// @@ -294,8 +308,8 @@ public KNetTopology AddSource(Topology.AutoOffsetReset arg0, string arg1, Java.U /// public KNetTopology AddSource(Topology.AutoOffsetReset arg0, string arg1, IKNetDeserializer arg2, IKNetDeserializer arg3, params string[] arg4) { - var top = (arg4.Length == 0) ? _Topology.IExecute("addSource", arg0, arg1, arg2.KafkaDeserializer, arg3.KafkaDeserializer) : _Topology.IExecute("addSource", arg0, arg1, arg2.KafkaDeserializer, arg3.KafkaDeserializer, arg4); - return new KNetTopology(top); + var top = (arg4.Length == 0) ? _topology.IExecute("addSource", arg0, arg1, arg2.KafkaDeserializer, arg3.KafkaDeserializer) : _topology.IExecute("addSource", arg0, arg1, arg2.KafkaDeserializer, arg3.KafkaDeserializer, arg4); + return new KNetTopology(top, _factory); } /// /// @@ -308,8 +322,8 @@ public KNetTopology AddSource(Topology.AutoOffsetReset arg0, string arg1, IKNetD /// public KNetTopology AddSource(Topology.AutoOffsetReset arg0, string arg1, IKNetDeserializer arg2, IKNetDeserializer arg3, Java.Util.Regex.Pattern arg4) { - var top = _Topology.IExecute("addSource", arg0, arg1, arg2.KafkaDeserializer, arg3.KafkaDeserializer, arg4); - return new KNetTopology(top); + var top = _topology.IExecute("addSource", arg0, arg1, arg2.KafkaDeserializer, arg3.KafkaDeserializer, arg4); + return new KNetTopology(top, _factory); } /// /// @@ -321,10 +335,11 @@ public KNetTopology AddSource(Topology.AutoOffsetReset arg0, string arg1, IKNetD /// /// /// - public KNetTopology AddSource(Topology.AutoOffsetReset arg0, string arg1, Org.Apache.Kafka.Streams.Processor.TimestampExtractor arg2, IKNetDeserializer arg3, IKNetDeserializer arg4, params string[] arg5) + public KNetTopology AddSource(Topology.AutoOffsetReset arg0, string arg1, TimestampExtractor arg2, IKNetDeserializer arg3, IKNetDeserializer arg4, params string[] arg5) { - var top = (arg5.Length == 0) ? _Topology.IExecute("addSource", arg0, arg1, arg2, arg3.KafkaDeserializer, arg4.KafkaDeserializer) : _Topology.IExecute("addSource", arg0, arg1, arg2, arg3.KafkaDeserializer, arg4.KafkaDeserializer, arg5); - return new KNetTopology(top); + if (arg2 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; + var top = (arg5.Length == 0) ? _topology.IExecute("addSource", arg0, arg1, arg2, arg3.KafkaDeserializer, arg4.KafkaDeserializer) : _topology.IExecute("addSource", arg0, arg1, arg2, arg3.KafkaDeserializer, arg4.KafkaDeserializer, arg5); + return new KNetTopology(top, _factory); } /// /// @@ -336,10 +351,11 @@ public KNetTopology AddSource(Topology.AutoOffsetReset arg0, string arg1, Org.Ap /// /// /// - public KNetTopology AddSource(Topology.AutoOffsetReset arg0, string arg1, Org.Apache.Kafka.Streams.Processor.TimestampExtractor arg2, IKNetDeserializer arg3, IKNetDeserializer arg4, Java.Util.Regex.Pattern arg5) + public KNetTopology AddSource(Topology.AutoOffsetReset arg0, string arg1, TimestampExtractor arg2, IKNetDeserializer arg3, IKNetDeserializer arg4, Java.Util.Regex.Pattern arg5) { - var top = _Topology.IExecute("addSource", arg0, arg1, arg2, arg3.KafkaDeserializer, arg4.KafkaDeserializer, arg5); - return new KNetTopology(top); + if (arg2 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; + var top = _topology.IExecute("addSource", arg0, arg1, arg2, arg3.KafkaDeserializer, arg4.KafkaDeserializer, arg5); + return new KNetTopology(top, _factory); } /// /// @@ -351,8 +367,9 @@ public KNetTopology AddSource(Topology.AutoOffsetReset arg0, string arg1, Org.Ap /// public KNetTopology AddSource(Topology.AutoOffsetReset arg0, Org.Apache.Kafka.Streams.Processor.TimestampExtractor arg1, string arg2, params string[] arg3) { - var top = _Topology.AddSource(arg0, arg1, arg2, arg3); - return new KNetTopology(top); + if (arg1 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; + var top = _topology.AddSource(arg0, arg1, arg2, arg3); + return new KNetTopology(top, _factory); } /// /// @@ -364,8 +381,9 @@ public KNetTopology AddSource(Topology.AutoOffsetReset arg0, Org.Apache.Kafka.St /// public KNetTopology AddSource(Topology.AutoOffsetReset arg0, Org.Apache.Kafka.Streams.Processor.TimestampExtractor arg1, string arg2, Java.Util.Regex.Pattern arg3) { - var top = _Topology.AddSource(arg0, arg1, arg2, arg3); - return new KNetTopology(top); + if (arg1 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; + var top = _topology.AddSource(arg0, arg1, arg2, arg3); + return new KNetTopology(top, _factory); } #endregion diff --git a/src/net/KNet/Specific/Streams/KNetTopologyConfig.cs b/src/net/KNet/Specific/Streams/KNetTopologyConfig.cs index 08ada7cb3d..37a3f6ff77 100644 --- a/src/net/KNet/Specific/Streams/KNetTopologyConfig.cs +++ b/src/net/KNet/Specific/Streams/KNetTopologyConfig.cs @@ -16,18 +16,19 @@ * Refer to LICENSE for more information. */ +using MASES.KNet.Serialization; using MASES.KNet.Streams; using Org.Apache.Kafka.Streams; -namespace MASES.KNet.Specific.Streams +namespace MASES.KNet.Streams { /// /// KNet implementation of /// - public class KNetTopologyConfig : TopologyConfig + public class KNetTopologyConfig : TopologyConfig, IGenericSerDesFactoryApplier { - StreamsConfigBuilder _StreamsConfigBuilder; - + IGenericSerDesFactory _factory; + IGenericSerDesFactory IGenericSerDesFactoryApplier.Factory { get => _factory; set { _factory = value; } } #region Constructors /// /// @@ -38,7 +39,7 @@ public class KNetTopologyConfig : TopologyConfig public KNetTopologyConfig(string arg0, StreamsConfigBuilder arg1, Java.Util.Properties arg2) : base(arg0, arg1, arg2) { - _StreamsConfigBuilder = arg1; + _factory = arg1; } /// /// @@ -47,12 +48,8 @@ public KNetTopologyConfig(string arg0, StreamsConfigBuilder arg1, Java.Util.Prop public KNetTopologyConfig(StreamsConfigBuilder arg0) : base(arg0) { - _StreamsConfigBuilder = arg0; + _factory = arg0; } #endregion - /// - /// used in initialization - /// - public StreamsConfigBuilder StreamsConfigBuilder => _StreamsConfigBuilder; } } diff --git a/src/net/KNet/Specific/Streams/KNetWindowedKeyValue.cs b/src/net/KNet/Specific/Streams/KNetWindowedKeyValue.cs new file mode 100644 index 0000000000..da4dbfb49c --- /dev/null +++ b/src/net/KNet/Specific/Streams/KNetWindowedKeyValue.cs @@ -0,0 +1,68 @@ +/* +* Copyright 2023 MASES s.r.l. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +* Refer to LICENSE for more information. +*/ + +using MASES.KNet.Serialization; +using MASES.KNet.Streams.Kstream; +using Org.Apache.Kafka.Streams; +using Org.Apache.Kafka.Streams.Kstream; + +namespace MASES.KNet.Streams +{ + /// + /// KNet implementation of + /// + /// The key type + /// The value type + public class KNetWindowedKeyValue : IGenericSerDesFactoryApplier + { + readonly KeyValue, byte[]> _value; + readonly IKNetSerDes _valueSerDes; + IGenericSerDesFactory _factory; + IGenericSerDesFactory IGenericSerDesFactoryApplier.Factory { get => _factory; set { _factory = value; } } + + internal KNetWindowedKeyValue(IGenericSerDesFactory factory, KeyValue, byte[]> value) + { + _factory = factory; + _valueSerDes = _factory.BuildValueSerDes(); + _value = value; + } + + /// + /// KNet implementation of + /// + public KNetWindowed Key + { + get + { + var kk = _value.key; + return new KNetWindowed(_factory, kk); + } + } + /// + /// KNet implementation of + /// + public TValue Value + { + get + { + var kk = _value.value; + return _valueSerDes.Deserialize(null, kk); + } + } + } +} diff --git a/src/net/KNet/Specific/Streams/Kstream/KNetPredicate.cs b/src/net/KNet/Specific/Streams/Kstream/KNetPredicate.cs index 0b7e16c4b9..cf5b33f732 100644 --- a/src/net/KNet/Specific/Streams/Kstream/KNetPredicate.cs +++ b/src/net/KNet/Specific/Streams/Kstream/KNetPredicate.cs @@ -19,34 +19,17 @@ using MASES.KNet.Serialization; using Org.Apache.Kafka.Streams.Kstream; -namespace MASES.KNet.Specific.Streams.Kstream +namespace MASES.KNet.Streams.Kstream { /// /// KNet implementation of /// /// The key type /// The value type - public class KNetPredicate : Predicate + public class KNetPredicate : Predicate, IGenericSerDesFactoryApplier { - IKNetSerDes _keySerializer; - IKNetSerDes _valueSerializer; - /// - /// Default initializer - /// - public KNetPredicate(IKNetSerDes keySerializer, IKNetSerDes valueSerializer) : base() - { - _keySerializer = keySerializer; - _valueSerializer = valueSerializer; - } - /// - /// The associated to - /// - public IKNetSerDes KeySerializer => _keySerializer; - /// - /// The associated to - /// - public IKNetSerDes ValueSerializer => _valueSerializer; - + IGenericSerDesFactory _factory; + IGenericSerDesFactory IGenericSerDesFactoryApplier.Factory { get => _factory; set { _factory = value; } } /// /// Handler for /// @@ -56,8 +39,11 @@ public KNetPredicate(IKNetSerDes keySerializer, IKNetSerDes valueS /// public sealed override bool Test(byte[] arg0, byte[] arg1) { + IKNetSerDes keySerializer = _factory.BuildKeySerDes(); + IKNetSerDes valueSerializer = _factory.BuildValueSerDes(); + var methodToExecute = (OnTest != null) ? OnTest : Test; - return methodToExecute(_keySerializer.Deserialize(null, arg0), _valueSerializer.Deserialize(null, arg1)); + return methodToExecute(keySerializer.Deserialize(null, arg0), valueSerializer.Deserialize(null, arg1)); } /// /// KNet override of diff --git a/src/net/KNet/Specific/Streams/Kstream/KNetPredicateTester.cs b/src/net/KNet/Specific/Streams/Kstream/KNetPredicateTester.cs index c3e3b6d09a..c9a86f3dda 100644 --- a/src/net/KNet/Specific/Streams/Kstream/KNetPredicateTester.cs +++ b/src/net/KNet/Specific/Streams/Kstream/KNetPredicateTester.cs @@ -19,7 +19,7 @@ using MASES.JCOBridge.C2JBridge; using Org.Apache.Kafka.Streams.Kstream; -namespace MASES.KNet.Specific.Streams.Kstream +namespace MASES.KNet.Streams.Kstream { /// /// KNet extension of diff --git a/src/net/KNet/Specific/Streams/Kstream/KNetTimestampExtractor.cs b/src/net/KNet/Specific/Streams/Kstream/KNetTimestampExtractor.cs index f10e45eb14..0be882e9cf 100644 --- a/src/net/KNet/Specific/Streams/Kstream/KNetTimestampExtractor.cs +++ b/src/net/KNet/Specific/Streams/Kstream/KNetTimestampExtractor.cs @@ -22,26 +22,17 @@ using Org.Apache.Kafka.Clients.Consumer; using Org.Apache.Kafka.Streams.Processor; -namespace MASES.KNet.Specific.Streams.Kstream +namespace MASES.KNet.Streams.Kstream { /// /// KNet extension of /// /// The key type /// The value type - public class KNetTimestampExtractor : TimestampExtractor + public class KNetTimestampExtractor : TimestampExtractor, IGenericSerDesFactoryApplier { - IKNetSerDes _keySerializer; - IKNetSerDes _valueSerializer; - /// - /// Default initializer - /// - public KNetTimestampExtractor(IKNetSerDes keySerializer, IKNetSerDes valueSerializer) : base() - { - _keySerializer = keySerializer; - _valueSerializer = valueSerializer; - } - + IGenericSerDesFactory _factory; + IGenericSerDesFactory IGenericSerDesFactoryApplier.Factory { get => _factory; set { _factory = value; } } /// /// Handler for /// @@ -51,9 +42,11 @@ public KNetTimestampExtractor(IKNetSerDes keySerializer, IKNetSerDes public sealed override long Extract(ConsumerRecord arg0, long arg1) { + IKNetSerDes keySerializer = _factory.BuildKeySerDes(); + IKNetSerDes valueSerializer = _factory.BuildValueSerDes(); var record = arg0.Cast>(); // KNet consider the data within Apache Kafka Streams defined always as byte[] var methodToExecute = (OnExtract != null) ? OnExtract : Extract; - return methodToExecute(new KNetConsumerRecord(record, _keySerializer, _valueSerializer), arg1); + return methodToExecute(new KNetConsumerRecord(record, keySerializer, valueSerializer), arg1); } /// /// KNet implementation of diff --git a/src/net/KNet/Specific/Streams/Kstream/KNetWindowed.cs b/src/net/KNet/Specific/Streams/Kstream/KNetWindowed.cs new file mode 100644 index 0000000000..89d9590860 --- /dev/null +++ b/src/net/KNet/Specific/Streams/Kstream/KNetWindowed.cs @@ -0,0 +1,53 @@ +/* +* Copyright 2023 MASES s.r.l. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +* Refer to LICENSE for more information. +*/ + +using MASES.KNet.Serialization; +using Org.Apache.Kafka.Streams.Kstream; + +namespace MASES.KNet.Streams.Kstream +{ + /// + /// KNet implementation of + /// + /// The key type + public class KNetWindowed : IGenericSerDesFactoryApplier + { + readonly Windowed _windowed; + readonly IKNetSerDes _keySerDes; + IGenericSerDesFactory _factory; + IGenericSerDesFactory IGenericSerDesFactoryApplier.Factory { get => _factory; set { _factory = value; } } + + internal KNetWindowed(IGenericSerDesFactory factory, Windowed windowed) + { + _factory = factory; + _keySerDes = _factory.BuildKeySerDes(); + _windowed = windowed; + } + + /// + /// KNet implementation of + /// + /// + public TKey Key => _keySerDes.Deserialize(null, _windowed.Key()); + /// + /// KNet implementation of + /// + /// + public Org.Apache.Kafka.Streams.Kstream.Window Window => _windowed.Window(); + } +} diff --git a/src/net/KNet/Specific/Streams/Processor/Api/KNetProcessor.cs b/src/net/KNet/Specific/Streams/Processor/Api/KNetProcessor.cs new file mode 100644 index 0000000000..6851150bfd --- /dev/null +++ b/src/net/KNet/Specific/Streams/Processor/Api/KNetProcessor.cs @@ -0,0 +1,88 @@ +/* +* Copyright 2023 MASES s.r.l. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +* Refer to LICENSE for more information. +*/ + +using MASES.KNet.Serialization; +using MASES.KNet.Streams; +using Org.Apache.Kafka.Streams.Processor.Api; + +namespace MASES.KNet.Streams.Processor.Api +{ + /// + /// KNet extension of + /// + /// The input key type + /// The input key type + /// The output key type + /// The output value type + public class KNetProcessor : Processor, IGenericSerDesFactoryApplier + { + KNetProcessorContext _processorContext = null; + IGenericSerDesFactory _factory; + IGenericSerDesFactory IGenericSerDesFactoryApplier.Factory { get => _factory; set { _factory = value; } } + /// + /// received from the init + /// + public KNetProcessorContext Context => _processorContext; + + /// + /// Handler for + /// + /// If has a value it takes precedence over corresponding class method + public new System.Action> OnProcess { get; set; } = null; + + /// + public sealed override void Process(Org.Apache.Kafka.Streams.Processor.Api.Record arg0) + { + var methodToExecute = OnProcess ?? Process; + methodToExecute(new KNetRecord(_factory, arg0, Context.RecordMetadata)); + } + + /// + /// KNet implementation of + /// + /// + public virtual void Process(KNetRecord arg0) + { + + } + + /// + /// Handler for + /// + /// If has a value it takes precedence over corresponding class method + public new System.Action> OnInit { get; set; } = null; + + /// + public sealed override void Init(Org.Apache.Kafka.Streams.Processor.Api.ProcessorContext arg0) + { + _processorContext = new KNetProcessorContext(arg0); + + var methodToExecute = OnInit ?? Init; + methodToExecute(_processorContext); + } + + /// + /// KNet implementation of + /// + /// + public virtual void Init(KNetProcessorContext arg0) + { + + } + } +} diff --git a/src/net/KNet/Specific/Streams/Processor/Api/KNetProcessorContext.cs b/src/net/KNet/Specific/Streams/Processor/Api/KNetProcessorContext.cs new file mode 100644 index 0000000000..9f5e7c0e69 --- /dev/null +++ b/src/net/KNet/Specific/Streams/Processor/Api/KNetProcessorContext.cs @@ -0,0 +1,177 @@ +/* +* Copyright 2023 MASES s.r.l. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +* Refer to LICENSE for more information. +*/ + +using Org.Apache.Kafka.Streams.Processor.Api; +using System; + +namespace MASES.KNet.Streams.Processor.Api +{ + /// + /// KNet implementation of + /// + /// + /// + public class KNetProcessorContext + { + internal KNetProcessorContext(ProcessorContext context) + { + _context = context; + } + + readonly ProcessorContext _context; + + /// + /// Converter from to + /// + public static implicit operator ProcessorContext(KNetProcessorContext t) => t._context; + + #region ProcessorContext + + /// + /// + /// + /// + /// + /// + /// + public void Forward(KNetRecord arg0, string arg1) where K : KForward where V : VForward + { + _context.Forward(arg0, arg1); + } + /// + /// + /// + /// + /// + /// + public void Forward(KNetRecord arg0) where K : KForward where V : VForward + { + _context.Forward(arg0); + } + + #endregion + + #region ProcessingContext + + /// + /// + /// + /// + /// + /// + public S GetStateStore(string arg0) where S : Org.Apache.Kafka.Streams.Processor.IStateStore, new() + { + return _context.GetStateStore(arg0); + } + /// + /// + /// + + /// + public Java.Io.File StateDir => _context.StateDir(); + + /// + /// + /// + + /// + public string ApplicationId => _context.ApplicationId(); + /// + /// + /// + /// + public Java.Util.Map AppConfigs => _context.AppConfigs(); + /// + /// + /// + /// + /// + public Java.Util.Map AppConfigsWithPrefix(string arg0) + { + return _context.AppConfigsWithPrefix(arg0); + } + /// + /// + /// + /// + public Org.Apache.Kafka.Streams.Processor.Api.RecordMetadata? RecordMetadata + { + get + { + var opt = _context.RecordMetadata(); + return opt.IsPresent() ? opt.Get() : null; + } + } + /// + /// + /// + /// + public long CurrentStreamTimeMs => _context.CurrentStreamTimeMs(); + /// + /// + /// + /// + public DateTime CurrentStreamDateTime => DateTimeOffset.FromUnixTimeMilliseconds(_context.CurrentStreamTimeMs()).DateTime; + /// + /// + /// + /// + public long CurrentSystemTimeMs => _context.CurrentSystemTimeMs(); + /// + /// + /// + /// + public DateTime CurrentSystemDateTime => DateTimeOffset.FromUnixTimeMilliseconds(_context.CurrentSystemTimeMs()).DateTime; + /// + /// + /// + /// + public Org.Apache.Kafka.Common.Serialization.Serde KeySerde => _context.KeySerde(); + /// + /// + /// + /// + public Org.Apache.Kafka.Common.Serialization.Serde ValueSerde => _context.ValueSerde(); + /// + /// + /// + /// + /// + /// + /// + public Org.Apache.Kafka.Streams.Processor.Cancellable Schedule(Java.Time.Duration arg0, Org.Apache.Kafka.Streams.Processor.PunctuationType arg1, Org.Apache.Kafka.Streams.Processor.Punctuator arg2) + { + return _context.Schedule(arg0, arg1, arg2); + } + /// + /// + /// + /// + public Org.Apache.Kafka.Streams.Processor.TaskId TaskId => _context.TaskId(); + /// + /// + /// + /// + public Org.Apache.Kafka.Streams.StreamsMetrics Metrics => _context.Metrics(); + /// + /// + /// + public void Commit() => _context.Commit(); + #endregion + } +} diff --git a/src/net/KNet/Specific/Streams/Processor/Api/KNetRecord.cs b/src/net/KNet/Specific/Streams/Processor/Api/KNetRecord.cs new file mode 100644 index 0000000000..69f38049dd --- /dev/null +++ b/src/net/KNet/Specific/Streams/Processor/Api/KNetRecord.cs @@ -0,0 +1,140 @@ +/* +* Copyright 2023 MASES s.r.l. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +* Refer to LICENSE for more information. +*/ + +using MASES.KNet.Serialization; +using Org.Apache.Kafka.Streams.Processor.Api; +using System; + +namespace MASES.KNet.Streams.Processor.Api +{ + /// + /// KNet extension of + /// + /// The key type + /// The value type + public class KNetRecord + { + internal KNetRecord(IGenericSerDesFactory builder, Record record, RecordMetadata metadata) + { + _builder = builder; + _record = record; + _metadata = metadata; + } + + readonly IGenericSerDesFactory _builder; + readonly Record _record; + readonly RecordMetadata _metadata; + + /// + /// Converter from to + /// + public static implicit operator Record(KNetRecord t) => t._record; + + /// + /// + /// + /// + /// + /// + public KNetRecord WithKey(NewK arg0) + { + var serDes = _builder.BuildKeySerDes(); + var record = _record.WithKey(serDes.SerializeWithHeaders(_metadata?.Topic(), _record.Headers(), arg0)); + return new KNetRecord(_builder, record, _metadata); + } + /// + /// + /// + /// + /// + /// + public KNetRecord WithValue(NewV arg0) + { + var serDes = _builder.BuildValueSerDes(); + var record = _record.WithValue(serDes.SerializeWithHeaders(_metadata?.Topic(), _record.Headers(), arg0)); + return new KNetRecord(_builder, record, _metadata); + } + /// + /// + /// + /// + public TKey Key + { + get + { + var serDes = _builder.BuildKeySerDes(); + return serDes.DeserializeWithHeaders(_metadata?.Topic(), _record.Headers(), _record.Key()); + } + } + /// + /// + /// + /// + public TValue Value + { + get + { + var serDes = _builder.BuildValueSerDes(); + return serDes.DeserializeWithHeaders(_metadata?.Topic(), _record.Headers(), _record.Value()); + } + } + /// + /// + /// + public long Timestamp => _record.Timestamp(); + /// + /// + /// + public DateTime DateTime => DateTimeOffset.FromUnixTimeMilliseconds(_record.Timestamp()).DateTime; + /// + /// + /// + /// + public Org.Apache.Kafka.Common.Header.Headers Headers => _record.Headers(); + /// + /// + /// + /// + /// + public KNetRecord WithHeaders(Org.Apache.Kafka.Common.Header.Headers arg0) + { + var record = _record.WithHeaders(arg0); + return new KNetRecord(_builder, record, _metadata); + } + /// + /// + /// + /// + /// + public KNetRecord WithTimestamp(long arg0) + { + var record = _record.WithTimestamp(arg0); + return new KNetRecord(_builder, record, _metadata); + } + /// + /// + /// + /// + /// + public KNetRecord WithDateTime(DateTime arg0) + { + return WithTimestamp(new DateTimeOffset(arg0).ToUnixTimeMilliseconds()); + } + + } +} diff --git a/src/net/KNet/Specific/Streams/Processor/KNetStreamPartitioner.cs b/src/net/KNet/Specific/Streams/Processor/KNetStreamPartitioner.cs index 8675aa6d03..90a105ad73 100644 --- a/src/net/KNet/Specific/Streams/Processor/KNetStreamPartitioner.cs +++ b/src/net/KNet/Specific/Streams/Processor/KNetStreamPartitioner.cs @@ -21,34 +21,17 @@ using MASES.KNet.Serialization; using Org.Apache.Kafka.Streams.Processor; -namespace MASES.KNet.Specific.Streams.Processor +namespace MASES.KNet.Streams.Processor { /// /// KNet implementation of /// /// The key type /// The value type - public class KNetStreamPartitioner : StreamPartitioner + public class KNetStreamPartitioner : StreamPartitioner, IGenericSerDesFactoryApplier { - IKNetSerDes _keySerializer; - IKNetSerDes _valueSerializer; - /// - /// Default initializer - /// - public KNetStreamPartitioner(IKNetSerDes keySerializer, IKNetSerDes valueSerializer) : base() - { - _keySerializer = keySerializer; - _valueSerializer = valueSerializer; - } - /// - /// The associated to - /// - public IKNetSerDes KeySerializer => _keySerializer; - /// - /// The associated to - /// - public IKNetSerDes ValueSerializer => _valueSerializer; - + IGenericSerDesFactory _factory; + IGenericSerDesFactory IGenericSerDesFactoryApplier.Factory { get => _factory; set { _factory = value; } } /// /// Handler for /// @@ -58,8 +41,10 @@ public KNetStreamPartitioner(IKNetSerDes keySerializer, IKNetSerDes public sealed override Optional> Partitions(string arg0, byte[] arg1, byte[] arg2, int arg3) { + IKNetSerDes keySerializer = _factory.BuildKeySerDes(); + IKNetSerDes valueSerializer = _factory.BuildValueSerDes(); var methodToExecute = (OnPartitions != null) ? OnPartitions : Partitions; - return methodToExecute(arg0, _keySerializer.Deserialize(arg0, arg1), _valueSerializer.Deserialize(arg0, arg2), arg3); + return methodToExecute(arg0, keySerializer.Deserialize(arg0, arg1), valueSerializer.Deserialize(arg0, arg2), arg3); } /// /// KNet override of diff --git a/src/net/KNet/Specific/Streams/Processor/KNetTopicNameExtractor.cs b/src/net/KNet/Specific/Streams/Processor/KNetTopicNameExtractor.cs index c4d0e170c5..f0fad705c2 100644 --- a/src/net/KNet/Specific/Streams/Processor/KNetTopicNameExtractor.cs +++ b/src/net/KNet/Specific/Streams/Processor/KNetTopicNameExtractor.cs @@ -19,34 +19,17 @@ using MASES.KNet.Serialization; using Org.Apache.Kafka.Streams.Processor; -namespace MASES.KNet.Specific.Streams.Processor +namespace MASES.KNet.Streams.Processor { /// /// KNet implementation of /// /// The key type /// The value type - public class KNetTopicNameExtractor : TopicNameExtractor + public class KNetTopicNameExtractor : TopicNameExtractor, IGenericSerDesFactoryApplier { - IKNetSerDes _keySerializer; - IKNetSerDes _valueSerializer; - /// - /// Default initializer - /// - public KNetTopicNameExtractor(IKNetSerDes keySerializer, IKNetSerDes valueSerializer) : base() - { - _keySerializer = keySerializer; - _valueSerializer = valueSerializer; - } - /// - /// The associated to - /// - public IKNetSerDes KeySerializer => _keySerializer; - /// - /// The associated to - /// - public IKNetSerDes ValueSerializer => _valueSerializer; - + IGenericSerDesFactory _factory; + IGenericSerDesFactory IGenericSerDesFactoryApplier.Factory { get => _factory; set { _factory = value; } } /// /// Handler for /// @@ -56,8 +39,10 @@ public KNetTopicNameExtractor(IKNetSerDes keySerializer, IKNetSerDes public sealed override string Extract(byte[] arg0, byte[] arg1, Org.Apache.Kafka.Streams.Processor.RecordContext arg2) { + IKNetSerDes keySerializer = _factory.BuildKeySerDes(); + IKNetSerDes valueSerializer = _factory.BuildValueSerDes(); var methodToExecute = (OnExtract != null) ? OnExtract : Extract; - return methodToExecute(_keySerializer.Deserialize(null, arg0), _valueSerializer.Deserialize(null, arg1), arg2); + return methodToExecute(keySerializer.Deserialize(null, arg0), valueSerializer.Deserialize(null, arg1), arg2); } /// /// KNet override of diff --git a/src/net/KNet/Specific/Streams/State/KNetKeyValueIterator.cs b/src/net/KNet/Specific/Streams/State/KNetKeyValueIterator.cs new file mode 100644 index 0000000000..3559da4313 --- /dev/null +++ b/src/net/KNet/Specific/Streams/State/KNetKeyValueIterator.cs @@ -0,0 +1,110 @@ +/* +* Copyright 2023 MASES s.r.l. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +* Refer to LICENSE for more information. +*/ + +using Java.Util; +using MASES.JCOBridge.C2JBridge; +using MASES.JCOBridge.C2JBridge.JVMInterop; +using MASES.KNet.Serialization; +using Org.Apache.Kafka.Streams.State; +using System.Collections.Generic; + +namespace MASES.KNet.Streams.State +{ + /// + /// KNet implementation of + /// + /// The key type + /// The value type + public class KNetKeyValueIterator : IGenericSerDesFactoryApplier + { + class LocalEnumerator(bool isVersion2, IGenericSerDesFactory factory, IJavaObject obj) : JVMBridgeBaseEnumerator>(obj), IGenericSerDesFactoryApplier + { + IGenericSerDesFactory _factory = factory; + IGenericSerDesFactory IGenericSerDesFactoryApplier.Factory { get => _factory; set { _factory = value; } } + + protected override object ConvertObject(object input) + { + return isVersion2 ? new KNetKeyValue(_factory, input as Org.Apache.Kafka.Streams.KeyValue) + : new KNetKeyValue(_factory, input as Org.Apache.Kafka.Streams.KeyValue); + } + } + + readonly KeyValueIterator _iterator; + readonly KeyValueIterator _iterator2; + readonly IKNetSerDes _keySerDes; + IGenericSerDesFactory _factory; + IGenericSerDesFactory IGenericSerDesFactoryApplier.Factory { get => _factory; set { _factory = value; } } + + internal KNetKeyValueIterator(IGenericSerDesFactory factory, KeyValueIterator iterator) + { + _factory = factory; + _keySerDes = _factory.BuildKeySerDes(); + _iterator = iterator; + } + + internal KNetKeyValueIterator(IGenericSerDesFactory factory, KeyValueIterator iterator) + { + _factory = factory; + _keySerDes = _factory.BuildKeySerDes(); + _iterator2 = iterator; + } + /// + /// KNet implementation of + /// + public bool HasNext => _iterator.HasNext; + /// + /// KNet implementation of + /// + public KNetKeyValue Next + { + get { return _iterator != null ? new KNetKeyValue(_factory, _iterator.Next) : new KNetKeyValue(_factory, _iterator2.Next); } + } + /// + /// + /// + public void Remove() + { + _iterator.Remove(); + } + /// + /// Converts an to a + /// + public IEnumerator> ToIEnumerator() => _iterator != null ? new LocalEnumerator(false, _factory, _iterator.BridgeInstance) : new LocalEnumerator(true, _factory, _iterator2.BridgeInstance); + /// + /// KNet implementation of + /// + /// + public TKey PeekNextKey + { + get + { + if (_iterator2 != null) return (TKey)(object)_iterator2.PeekNextKey(); + + var kk = _iterator.PeekNextKey(); + return _keySerDes.Deserialize(null, kk); + } + } + /// + /// KNet implementation of + /// + public void Close() + { + _iterator.Close(); + } + } +} diff --git a/src/net/KNet/Specific/Streams/State/KNetManagedStore.cs b/src/net/KNet/Specific/Streams/State/KNetManagedStore.cs new file mode 100644 index 0000000000..a976a36598 --- /dev/null +++ b/src/net/KNet/Specific/Streams/State/KNetManagedStore.cs @@ -0,0 +1,24 @@ +/* +* Copyright 2023 MASES s.r.l. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +* Refer to LICENSE for more information. +*/ + +namespace MASES.KNet.Streams.State +{ + public class KNetManagedStore + { + } +} diff --git a/src/net/KNet/Specific/Streams/State/KNetQueryableStoreTypes.cs b/src/net/KNet/Specific/Streams/State/KNetQueryableStoreTypes.cs new file mode 100644 index 0000000000..2cdaf6c54d --- /dev/null +++ b/src/net/KNet/Specific/Streams/State/KNetQueryableStoreTypes.cs @@ -0,0 +1,78 @@ +/* +* Copyright 2023 MASES s.r.l. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +* Refer to LICENSE for more information. +*/ + +using MASES.KNet.Serialization; +using Org.Apache.Kafka.Streams.State; + +namespace MASES.KNet.Streams.State +{ + /// + /// Generator of KNet + /// + public static class KNetQueryableStoreTypes + { + /// + /// Supporting class for + /// + /// + /// + public class StoreType where TKNetManagedStore : KNetManagedStore, IGenericSerDesFactoryApplier + { + internal StoreType(QueryableStoreType store) { Store = store; } + internal QueryableStoreType Store; + } + + /// + /// KNet value of based on array of + /// + public static StoreType, ReadOnlyKeyValueStore> KeyValueStore() + { + return new StoreType, ReadOnlyKeyValueStore>(QueryableStoreTypes.KeyValueStore()); + } + /// + /// KNet value of based on array of + /// + public static StoreType, ReadOnlySessionStore> SessionStore() + { + return new StoreType, ReadOnlySessionStore>(QueryableStoreTypes.SessionStore()); + } + /// + /// KNet value of based on array of + /// + public static StoreType, ReadOnlyWindowStore> WindowStore() + { + return new StoreType, ReadOnlyWindowStore>(QueryableStoreTypes.WindowStore()); + } + + /// + /// KNet value of based on array of + /// + public static StoreType, ReadOnlyKeyValueStore>> TimestampedKeyValueStore() + { + return new StoreType, ReadOnlyKeyValueStore>>(QueryableStoreTypes.TimestampedKeyValueStore()); + } + + /// + /// KNet value of based on array of + /// + public static StoreType, ReadOnlyWindowStore>> TimestampedWindowStore() + { + return new StoreType, ReadOnlyWindowStore>>(QueryableStoreTypes.TimestampedWindowStore()); + } + } +} diff --git a/src/net/KNet/Specific/Streams/State/KNetReadOnlyKeyValueStore.cs b/src/net/KNet/Specific/Streams/State/KNetReadOnlyKeyValueStore.cs new file mode 100644 index 0000000000..8e6e48b9ef --- /dev/null +++ b/src/net/KNet/Specific/Streams/State/KNetReadOnlyKeyValueStore.cs @@ -0,0 +1,98 @@ +/* +* Copyright 2023 MASES s.r.l. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +* Refer to LICENSE for more information. +*/ + +using MASES.KNet.Serialization; +using Org.Apache.Kafka.Streams.State; + +namespace MASES.KNet.Streams.State +{ + /// + /// KNet implementation of + /// + /// The key type + /// The value type + public class KNetReadOnlyKeyValueStore : KNetManagedStore>, IGenericSerDesFactoryApplier + { + readonly ReadOnlyKeyValueStore _store; + readonly IKNetSerDes _keySerDes; + readonly IKNetSerDes _valueSerDes; + IGenericSerDesFactory _factory; + IGenericSerDesFactory IGenericSerDesFactoryApplier.Factory { get => _factory; set { _factory = value; } } + + internal KNetReadOnlyKeyValueStore(IGenericSerDesFactory factory, ReadOnlyKeyValueStore store) + { + _factory = factory; + _keySerDes = _factory.BuildKeySerDes(); + _valueSerDes = _factory.BuildValueSerDes(); + _store = store; + } + + /// + /// KNet implementation of + /// + /// + public long ApproximateNumEntries => _store.ApproximateNumEntries(); + /// + /// KNet implementation of + /// + /// + public KNetKeyValueIterator All => new(_factory, _store.All()); + /// + /// KNet implementation of + /// + /// + /// + /// + public KNetKeyValueIterator Range(TKey arg0, TKey arg1) + { + var r0 = _keySerDes.Serialize(null, arg0); + var r1 = _keySerDes.Serialize(null, arg1); + + return new(_factory, _store.Range(r0, r1)); + } + /// + /// KNet implementation of + /// + /// + /// + public TValue Get(TKey arg0) + { + var r0 = _keySerDes.Serialize(null, arg0); + var res = _store.Get(r0); + return _valueSerDes.Deserialize(null, res); + } + /// + /// KNet implementation of + /// + /// + public KNetKeyValueIterator ReverseAll => new(_factory, _store.ReverseAll()); + /// + /// KNet implementation of + /// + /// + /// + /// + public KNetKeyValueIterator ReverseRange(TKey arg0, TKey arg1) + { + var r0 = _keySerDes.Serialize(null, arg0); + var r1 = _keySerDes.Serialize(null, arg1); + + return new(_factory, _store.ReverseRange(r0, r1)); + } + } +} diff --git a/src/net/KNet/Specific/Streams/State/KNetReadOnlySessionStore.cs b/src/net/KNet/Specific/Streams/State/KNetReadOnlySessionStore.cs new file mode 100644 index 0000000000..8bc655821a --- /dev/null +++ b/src/net/KNet/Specific/Streams/State/KNetReadOnlySessionStore.cs @@ -0,0 +1,220 @@ +/* +* Copyright 2023 MASES s.r.l. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +* Refer to LICENSE for more information. +*/ + +using MASES.KNet.Serialization; +using Org.Apache.Kafka.Streams.State; + +namespace MASES.KNet.Streams.State +{ + /// + /// KNet implementation of + /// + /// The key type + /// The value type + public class KNetReadOnlySessionStore : KNetManagedStore>, IGenericSerDesFactoryApplier + { + readonly ReadOnlySessionStore _store; + readonly IKNetSerDes _keySerDes; + readonly IKNetSerDes _valueSerDes; + IGenericSerDesFactory _factory; + IGenericSerDesFactory IGenericSerDesFactoryApplier.Factory { get => _factory; set { _factory = value; } } + + internal KNetReadOnlySessionStore(IGenericSerDesFactory factory, ReadOnlySessionStore store) + { + _factory = factory; + _keySerDes = _factory.BuildKeySerDes(); + _valueSerDes = _factory.BuildValueSerDes(); + _store = store; + } + + /// + /// + /// + /// + /// + /// + public KNetWindowedKeyValueIterator Fetch(K arg0, K arg1) + { + var r0 = _keySerDes.Serialize(null, arg0); + var r1 = _keySerDes.Serialize(null, arg1); + return new KNetWindowedKeyValueIterator(_factory, _store.Fetch(r0, r1)); + } + /// + /// + /// + /// + /// + public KNetWindowedKeyValueIterator Fetch(K arg0) + { + var r0 = _keySerDes.Serialize(null, arg0); + return new KNetWindowedKeyValueIterator(_factory, _store.Fetch(r0)); + } + /// + /// + /// + /// + /// + /// + /// + public AGG FetchSession(K arg0, Java.Time.Instant arg1, Java.Time.Instant arg2) + { + var r0 = _keySerDes.Serialize(null, arg0); + var agg = _store.FetchSession(r0, arg1, arg2); + return _valueSerDes.Deserialize(null, agg); + } + /// + /// + /// + /// + /// + /// + /// + public AGG FetchSession(K arg0, long arg1, long arg2) + { + var r0 = _keySerDes.Serialize(null, arg0); + var agg = _store.FetchSession(r0, arg1, arg2); + return _valueSerDes.Deserialize(null, agg); + } + /// + /// + /// + /// + /// + /// + public KNetWindowedKeyValueIterator BackwardFetch(K arg0, K arg1) + { + var r0 = _keySerDes.Serialize(null, arg0); + var r1 = _keySerDes.Serialize(null, arg1); + return new KNetWindowedKeyValueIterator(_factory, _store.BackwardFetch(r0, r1)); + } + /// + /// + /// + /// + /// + public KNetWindowedKeyValueIterator BackwardFetch(K arg0) + { + var r0 = _keySerDes.Serialize(null, arg0); + return new KNetWindowedKeyValueIterator(_factory, _store.BackwardFetch(r0)); + } + /// + /// + /// + /// + /// + /// + /// + public KNetWindowedKeyValueIterator BackwardFindSessions(K arg0, Java.Time.Instant arg1, Java.Time.Instant arg2) + { + var r0 = _keySerDes.Serialize(null, arg0); + return new KNetWindowedKeyValueIterator(_factory, _store.BackwardFindSessions(r0, arg1, arg2)); + } + /// + /// + /// + /// + /// + /// + /// + /// + public KNetWindowedKeyValueIterator BackwardFindSessions(K arg0, K arg1, Java.Time.Instant arg2, Java.Time.Instant arg3) + { + var r0 = _keySerDes.Serialize(null, arg0); + var r1 = _keySerDes.Serialize(null, arg1); + return new KNetWindowedKeyValueIterator(_factory, _store.BackwardFindSessions(r0, r1, arg2, arg3)); + } + /// + /// + /// + /// + /// + /// + /// + /// + public KNetWindowedKeyValueIterator BackwardFindSessions(K arg0, K arg1, long arg2, long arg3) + { + var r0 = _keySerDes.Serialize(null, arg0); + var r1 = _keySerDes.Serialize(null, arg1); + return new KNetWindowedKeyValueIterator(_factory, _store.BackwardFindSessions(r0, r1, arg2, arg3)); + } + /// + /// + /// + /// + /// + /// + /// + public KNetWindowedKeyValueIterator BackwardFindSessions(K arg0, long arg1, long arg2) + { + var r0 = _keySerDes.Serialize(null, arg0); + return new KNetWindowedKeyValueIterator(_factory, _store.BackwardFindSessions(r0, arg1, arg2)); + } + /// + /// + /// + /// + /// + /// + /// + public KNetWindowedKeyValueIterator FindSessions(K arg0, Java.Time.Instant arg1, Java.Time.Instant arg2) + { + var r0 = _keySerDes.Serialize(null, arg0); + return new KNetWindowedKeyValueIterator(_factory, _store.BackwardFindSessions(r0, arg1, arg2)); + } + /// + /// + /// + /// + /// + /// + /// + /// + public KNetWindowedKeyValueIterator FindSessions(K arg0, K arg1, Java.Time.Instant arg2, Java.Time.Instant arg3) + { + var r0 = _keySerDes.Serialize(null, arg0); + var r1 = _keySerDes.Serialize(null, arg1); + return new KNetWindowedKeyValueIterator(_factory, _store.FindSessions(r0, r1, arg2, arg3)); + } + /// + /// + /// + /// + /// + /// + /// + /// + public KNetWindowedKeyValueIterator FindSessions(K arg0, K arg1, long arg2, long arg3) + { + var r0 = _keySerDes.Serialize(null, arg0); + var r1 = _keySerDes.Serialize(null, arg1); + return new KNetWindowedKeyValueIterator(_factory, _store.FindSessions(r0, r1, arg2, arg3)); + } + /// + /// + /// + /// + /// + /// + /// + public KNetWindowedKeyValueIterator FindSessions(K arg0, long arg1, long arg2) + { + var r0 = _keySerDes.Serialize(null, arg0); + return new KNetWindowedKeyValueIterator(_factory, _store.FindSessions(r0, arg1, arg2)); + } + } +} diff --git a/src/net/KNet/Specific/Streams/State/KNetReadOnlyWindowStore.cs b/src/net/KNet/Specific/Streams/State/KNetReadOnlyWindowStore.cs new file mode 100644 index 0000000000..da77d371fb --- /dev/null +++ b/src/net/KNet/Specific/Streams/State/KNetReadOnlyWindowStore.cs @@ -0,0 +1,145 @@ +/* +* Copyright 2023 MASES s.r.l. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +* Refer to LICENSE for more information. +*/ + +using MASES.KNet.Serialization; +using Org.Apache.Kafka.Streams.State; + +namespace MASES.KNet.Streams.State +{ + /// + /// KNet implementation of + /// + /// The key type + /// The value type + public class KNetReadOnlyWindowStore : KNetManagedStore>, IGenericSerDesFactoryApplier + { + readonly ReadOnlyWindowStore _store; + readonly IKNetSerDes _keySerDes; + readonly IKNetSerDes _valueSerDes; + IGenericSerDesFactory _factory; + IGenericSerDesFactory IGenericSerDesFactoryApplier.Factory { get => _factory; set { _factory = value; } } + + internal KNetReadOnlyWindowStore(IGenericSerDesFactory factory, ReadOnlyWindowStore store) + { + _factory = factory; + _keySerDes = _factory.BuildKeySerDes(); + _valueSerDes = _factory.BuildValueSerDes(); + _store = store; + } + /// + /// + /// + /// + public KNetWindowedKeyValueIterator All => new KNetWindowedKeyValueIterator(_factory, _store.All()); + /// + /// + /// + /// + /// + /// + /// + /// + /// + public KNetWindowedKeyValueIterator Fetch(TKey arg0, TKey arg1, Java.Time.Instant arg2, Java.Time.Instant arg3) + { + var r0 = _keySerDes.Serialize(null, arg0); + var r1 = _keySerDes.Serialize(null, arg1); + return new KNetWindowedKeyValueIterator(_factory, _store.Fetch(r0, r1, arg2, arg3)); + } + /// + /// + /// + /// + /// + /// + /// + public KNetWindowedKeyValueIterator FetchAll(Java.Time.Instant arg0, Java.Time.Instant arg1) + { + return new KNetWindowedKeyValueIterator(_factory, _store.FetchAll(arg0, arg1)); + } + /// + /// + /// + /// + /// + /// + /// + /// + public KNetWindowStoreIterator Fetch(TKey arg0, Java.Time.Instant arg1, Java.Time.Instant arg2) + { + var r0 = _keySerDes.Serialize(null, arg0); + return new KNetWindowStoreIterator(_factory, _store.Fetch(r0, arg1, arg2)); + } + /// + /// + /// + /// + /// + /// + public TValue Fetch(TKey arg0, long arg1) + { + var r0 = _keySerDes.Serialize(null, arg0); + var agg = _store.Fetch(r0, arg1); + return _valueSerDes.Deserialize(null, agg); + } + /// + /// + /// + /// + public KNetWindowedKeyValueIterator BackwardAll => new KNetWindowedKeyValueIterator(_factory, _store.BackwardAll()); + /// + /// + /// + /// + /// + /// + /// + /// + /// + public KNetWindowedKeyValueIterator BackwardFetch(TKey arg0, TKey arg1, Java.Time.Instant arg2, Java.Time.Instant arg3) + { + var r0 = _keySerDes.Serialize(null, arg0); + var r1 = _keySerDes.Serialize(null, arg1); + return new KNetWindowedKeyValueIterator(_factory, _store.BackwardFetch(r0, r1, arg2, arg3)); + } + /// + /// + /// + /// + /// + /// + /// + public KNetWindowedKeyValueIterator BackwardFetchAll(Java.Time.Instant arg0, Java.Time.Instant arg1) + { + return new KNetWindowedKeyValueIterator(_factory, _store.BackwardFetchAll(arg0, arg1)); + } + /// + /// + /// + /// + /// + /// + /// + /// + public KNetWindowStoreIterator BackwardFetch(TKey arg0, Java.Time.Instant arg1, Java.Time.Instant arg2) + { + var r0 = _keySerDes.Serialize(null, arg0); + return new KNetWindowStoreIterator(_factory, _store.BackwardFetch(r0, arg1, arg2)); + } + } +} diff --git a/src/net/KNet/Specific/Streams/State/KNetTimestampedKeyValueIterator.cs b/src/net/KNet/Specific/Streams/State/KNetTimestampedKeyValueIterator.cs new file mode 100644 index 0000000000..0eaba350a3 --- /dev/null +++ b/src/net/KNet/Specific/Streams/State/KNetTimestampedKeyValueIterator.cs @@ -0,0 +1,108 @@ +/* +* Copyright 2023 MASES s.r.l. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +* Refer to LICENSE for more information. +*/ + +using Java.Util; +using MASES.JCOBridge.C2JBridge; +using MASES.JCOBridge.C2JBridge.JVMInterop; +using MASES.KNet.Serialization; +using Org.Apache.Kafka.Streams.State; +using System.Collections.Generic; + +namespace MASES.KNet.Streams.State +{ + /// + /// KNet implementation of + /// + /// The key type + /// The value type + public class KNetTimestampedKeyValueIterator : IGenericSerDesFactoryApplier + { + class LocalEnumerator(bool isVersion2, IGenericSerDesFactory factory, IJavaObject obj) : JVMBridgeBaseEnumerator>(obj), IGenericSerDesFactoryApplier + { + IGenericSerDesFactory _factory = factory; + IGenericSerDesFactory IGenericSerDesFactoryApplier.Factory { get => _factory; set { _factory = value; } } + + protected override object ConvertObject(object input) + { + return isVersion2 ? new KNetTimestampedKeyValue(_factory, input as Org.Apache.Kafka.Streams.KeyValue>) + : new KNetTimestampedKeyValue(_factory, input as Org.Apache.Kafka.Streams.KeyValue>); + } + } + + readonly KeyValueIterator> _iterator = null; + readonly KeyValueIterator> _iterator2 = null; + readonly IKNetSerDes _keySerDes; + IGenericSerDesFactory _factory; + IGenericSerDesFactory IGenericSerDesFactoryApplier.Factory { get => _factory; set { _factory = value; } } + + internal KNetTimestampedKeyValueIterator(IGenericSerDesFactory factory, KeyValueIterator> iterator) + { + _factory = factory; + _keySerDes = _factory.BuildKeySerDes(); + _iterator = iterator; + } + + internal KNetTimestampedKeyValueIterator(IGenericSerDesFactory factory, KeyValueIterator> iterator) + { + _factory = factory; + _keySerDes = _factory.BuildKeySerDes(); + _iterator2 = iterator; + } + /// + /// KNet implementation of + /// + public bool HasNext => _iterator.HasNext; + /// + /// KNet implementation of + /// + public KNetTimestampedKeyValue Next + { + get { return new KNetTimestampedKeyValue(_factory, _iterator.Next); } + } + /// + /// + /// + public void Remove() + { + _iterator.Remove(); + } + /// + /// Converts an to a + /// + public IEnumerator> ToIEnumerator() => _iterator != null ? new LocalEnumerator(false, _factory, _iterator.BridgeInstance) : new LocalEnumerator(true, _factory, _iterator2.BridgeInstance); + /// + /// KNet implementation of + /// + /// + public TKey PeekNextKey + { + get + { + var kk = _iterator.PeekNextKey(); + return _keySerDes.Deserialize(null, kk); + } + } + /// + /// KNet implementation of + /// + public void Close() + { + _iterator.Close(); + } + } +} diff --git a/src/net/KNet/Specific/Streams/State/KNetTimestampedKeyValueStore.cs b/src/net/KNet/Specific/Streams/State/KNetTimestampedKeyValueStore.cs new file mode 100644 index 0000000000..2ed4e9c9c6 --- /dev/null +++ b/src/net/KNet/Specific/Streams/State/KNetTimestampedKeyValueStore.cs @@ -0,0 +1,98 @@ +/* +* Copyright 2023 MASES s.r.l. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +* Refer to LICENSE for more information. +*/ + +using MASES.KNet.Serialization; +using Org.Apache.Kafka.Streams.State; + +namespace MASES.KNet.Streams.State +{ + /// + /// KNet implementation of + /// + /// The key type + /// The value type + public class KNetTimestampedKeyValueStore : KNetManagedStore>>, IGenericSerDesFactoryApplier + { + readonly ReadOnlyKeyValueStore> _store; + readonly IKNetSerDes _keySerDes; + readonly IKNetSerDes _valueSerDes; + IGenericSerDesFactory _factory; + IGenericSerDesFactory IGenericSerDesFactoryApplier.Factory { get => _factory; set { _factory = value; } } + + internal KNetTimestampedKeyValueStore(IGenericSerDesFactory factory, ReadOnlyKeyValueStore> store) + { + _factory = factory; + _keySerDes = _factory.BuildKeySerDes(); + _valueSerDes = _factory.BuildValueSerDes(); + _store = store; + } + + /// + /// KNet implementation of + /// + /// + public long ApproximateNumEntries => _store.ApproximateNumEntries(); + /// + /// KNet implementation of + /// + /// + public KNetTimestampedKeyValueIterator All => new(_factory, _store.All()); + /// + /// KNet implementation of + /// + /// + /// + /// + public KNetTimestampedKeyValueIterator Range(TKey arg0, TKey arg1) + { + var r0 = _keySerDes.Serialize(null, arg0); + var r1 = _keySerDes.Serialize(null, arg1); + + return new(_factory, _store.Range(r0, r1)); + } + /// + /// KNet implementation of + /// + /// + /// + public KNetValueAndTimestamp Get(TKey arg0) + { + var r0 = _keySerDes.Serialize(null, arg0); + var res = _store.Get(r0); + return new KNetValueAndTimestamp(_factory, res); + } + /// + /// KNet implementation of + /// + /// + public KNetTimestampedKeyValueIterator ReverseAll => new(_factory, _store.ReverseAll()); + /// + /// KNet implementation of + /// + /// + /// + /// + public KNetTimestampedKeyValueIterator ReverseRange(TKey arg0, TKey arg1) + { + var r0 = _keySerDes.Serialize(null, arg0); + var r1 = _keySerDes.Serialize(null, arg1); + + return new(_factory, _store.ReverseRange(r0, r1)); + } + } +} diff --git a/src/net/KNet/Specific/Streams/State/KNetTimestampedWindowStore.cs b/src/net/KNet/Specific/Streams/State/KNetTimestampedWindowStore.cs new file mode 100644 index 0000000000..538b07d06f --- /dev/null +++ b/src/net/KNet/Specific/Streams/State/KNetTimestampedWindowStore.cs @@ -0,0 +1,148 @@ +/* +* Copyright 2023 MASES s.r.l. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +* Refer to LICENSE for more information. +*/ + +using MASES.KNet.Serialization; +using Org.Apache.Kafka.Streams.State; + +namespace MASES.KNet.Streams.State +{ + /// + /// KNet implementation of + /// + /// The key type + /// The value type + public class KNetTimestampedWindowStore : KNetManagedStore>>, IGenericSerDesFactoryApplier + { + readonly ReadOnlyWindowStore> _store; + readonly IKNetSerDes _keySerDes; + readonly IKNetSerDes _valueSerDes; + IGenericSerDesFactory _factory; + IGenericSerDesFactory IGenericSerDesFactoryApplier.Factory { get => _factory; set { _factory = value; } } + + internal KNetTimestampedWindowStore(IGenericSerDesFactory factory, ReadOnlyWindowStore> store) + { + _factory = factory; + _keySerDes = _factory.BuildKeySerDes(); + _valueSerDes = _factory.BuildValueSerDes(); + _store = store; + } + /// + /// + /// + /// + public KNetTimestampedWindowedKeyValueIterator All => new KNetTimestampedWindowedKeyValueIterator(_factory, _store.All()); + /// + /// + /// + /// + /// + /// + /// + /// + /// + public KNetTimestampedWindowedKeyValueIterator Fetch(TKey arg0, TKey arg1, Java.Time.Instant arg2, Java.Time.Instant arg3) + { + var r0 = _keySerDes.Serialize(null, arg0); + var r1 = _keySerDes.Serialize(null, arg1); + + return new(_factory, _store.Fetch(r0, r1, arg2, arg3)); + } + /// + /// + /// + /// + /// + /// + /// + public KNetTimestampedWindowedKeyValueIterator FetchAll(Java.Time.Instant arg0, Java.Time.Instant arg1) + { + return new(_factory, _store.FetchAll(arg0, arg1)); + } + /// + /// + /// + /// + /// + /// + /// + /// + public KNetTimestampedWindowStoreIterator Fetch(TKey arg0, Java.Time.Instant arg1, Java.Time.Instant arg2) + { + var r0 = _keySerDes.Serialize(null, arg0); + return new(_factory, _store.Fetch(r0, arg1, arg2)); + } + /// + /// + /// + /// + /// + /// + public KNetValueAndTimestamp Fetch(TKey arg0, long arg1) + { + var r0 = _keySerDes.Serialize(null, arg0); + var agg = _store.Fetch(r0, arg1); + return new KNetValueAndTimestamp(_factory, agg); + } + /// + /// + /// + /// + public KNetTimestampedWindowedKeyValueIterator BackwardAll => new(_factory, _store.BackwardAll()); + /// + /// + /// + /// + /// + /// + /// + /// + /// + public KNetTimestampedWindowedKeyValueIterator BackwardFetch(TKey arg0, TKey arg1, Java.Time.Instant arg2, Java.Time.Instant arg3) + { + var r0 = _keySerDes.Serialize(null, arg0); + var r1 = _keySerDes.Serialize(null, arg1); + + return new(_factory, _store.BackwardFetch(r0, r1, arg2, arg3)); + } + /// + /// + /// + /// + /// + /// + /// + public KNetTimestampedWindowedKeyValueIterator BackwardFetchAll(Java.Time.Instant arg0, Java.Time.Instant arg1) + { + return new(_factory, _store.BackwardFetchAll(arg0, arg1)); + } + /// + /// + /// + /// + /// + /// + /// + /// + public KNetTimestampedWindowStoreIterator BackwardFetch(TKey arg0, Java.Time.Instant arg1, Java.Time.Instant arg2) + { + var r0 = _keySerDes.Serialize(null, arg0); + + return new(_factory, _store.BackwardFetch(r0, arg1, arg2)); + } + } +} diff --git a/src/net/KNet/Specific/Streams/State/KNetTimestampedWindowStoreIterator.cs b/src/net/KNet/Specific/Streams/State/KNetTimestampedWindowStoreIterator.cs new file mode 100644 index 0000000000..adac493a29 --- /dev/null +++ b/src/net/KNet/Specific/Streams/State/KNetTimestampedWindowStoreIterator.cs @@ -0,0 +1,54 @@ +/* +* Copyright 2023 MASES s.r.l. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +* Refer to LICENSE for more information. +*/ + +using MASES.JCOBridge.C2JBridge; +using MASES.KNet.Serialization; +using Org.Apache.Kafka.Streams.State; + +namespace MASES.KNet.Streams.State +{ + /// + /// KNet implementation of + /// + /// The value type + public class KNetTimestampedWindowStoreIterator : IGenericSerDesFactoryApplier + { + readonly WindowStoreIterator> _iterator; + IGenericSerDesFactory _factory; + IGenericSerDesFactory IGenericSerDesFactoryApplier.Factory { get => _factory; set { _factory = value; } } + + internal KNetTimestampedWindowStoreIterator(IGenericSerDesFactory factory, WindowStoreIterator> iterator) + { + _factory = factory; + _iterator = iterator; + } + + /// + /// Converter from to + /// + public static implicit operator KNetTimestampedKeyValueIterator(KNetTimestampedWindowStoreIterator t) => new KNetTimestampedKeyValueIterator(t._factory, t._iterator.Cast>>()); + + /// + /// KNet implementation of + /// + public void Close() + { + _iterator.Close(); + } + } +} diff --git a/src/net/KNet/Specific/Streams/State/KNetTimestampedWindowedKeyValueIterator.cs b/src/net/KNet/Specific/Streams/State/KNetTimestampedWindowedKeyValueIterator.cs new file mode 100644 index 0000000000..2fc8064127 --- /dev/null +++ b/src/net/KNet/Specific/Streams/State/KNetTimestampedWindowedKeyValueIterator.cs @@ -0,0 +1,99 @@ +/* +* Copyright 2023 MASES s.r.l. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +* Refer to LICENSE for more information. +*/ + +using Java.Util; +using MASES.JCOBridge.C2JBridge; +using MASES.JCOBridge.C2JBridge.JVMInterop; +using MASES.KNet.Serialization; +using MASES.KNet.Streams.Kstream; +using Org.Apache.Kafka.Streams.Kstream; +using Org.Apache.Kafka.Streams.State; +using System.Collections.Generic; + +namespace MASES.KNet.Streams.State +{ + /// + /// KNet implementation of + /// + /// The key type + /// The value type + public class KNetTimestampedWindowedKeyValueIterator : IGenericSerDesFactoryApplier + { + class LocalEnumerator(IGenericSerDesFactory factory, IJavaObject obj) : JVMBridgeBaseEnumerator>(obj), IGenericSerDesFactoryApplier + { + IGenericSerDesFactory _factory = factory; + IGenericSerDesFactory IGenericSerDesFactoryApplier.Factory { get => _factory; set { _factory = value; } } + + protected override object ConvertObject(object input) + { + return new KNetTimestampedWindowedKeyValue(_factory, input as Org.Apache.Kafka.Streams.KeyValue, ValueAndTimestamp>); + } + } + + readonly KeyValueIterator, ValueAndTimestamp> _iterator; + IGenericSerDesFactory _factory; + IGenericSerDesFactory IGenericSerDesFactoryApplier.Factory { get => _factory; set { _factory = value; } } + + internal KNetTimestampedWindowedKeyValueIterator(IGenericSerDesFactory factory, KeyValueIterator, ValueAndTimestamp> iterator) + { + _factory = factory; + _iterator = iterator; + } + /// + /// KNet implementation of + /// + public bool HasNext => _iterator.HasNext; + /// + /// KNet implementation of + /// + public KNetTimestampedWindowedKeyValue Next + { + get { return new KNetTimestampedWindowedKeyValue(_factory, _iterator.Next); } + } + /// + /// + /// + public void Remove() + { + _iterator.Remove(); + } + /// + /// Converts an to a + /// + public IEnumerator> ToIEnumerator() => new LocalEnumerator(_factory, _iterator.BridgeInstance); + /// + /// KNet implementation of + /// + /// + public KNetWindowed PeekNextKey + { + get + { + var kk = _iterator.PeekNextKey(); + return new KNetWindowed(_factory, kk); + } + } + /// + /// KNet implementation of + /// + public void Close() + { + _iterator.Close(); + } + } +} diff --git a/src/net/KNet/Specific/Streams/State/KNetValueAndTimestamp.cs b/src/net/KNet/Specific/Streams/State/KNetValueAndTimestamp.cs new file mode 100644 index 0000000000..ab485a56aa --- /dev/null +++ b/src/net/KNet/Specific/Streams/State/KNetValueAndTimestamp.cs @@ -0,0 +1,66 @@ +/* +* Copyright 2023 MASES s.r.l. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +* Refer to LICENSE for more information. +*/ + +using MASES.KNet.Serialization; +using Org.Apache.Kafka.Streams.State; +using System; + +namespace MASES.KNet.Streams.State +{ + /// + /// KNet Implementation of + /// + /// The value type + public class KNetValueAndTimestamp : IGenericSerDesFactoryApplier + { + readonly ValueAndTimestamp _valueAndTimestamp; + readonly IKNetSerDes _valueSerDes; + IGenericSerDesFactory _factory; + IGenericSerDesFactory IGenericSerDesFactoryApplier.Factory { get => _factory; set { _factory = value; } } + + internal KNetValueAndTimestamp(IGenericSerDesFactory factory, ValueAndTimestamp valueAndTimestamp) + { + _factory = factory; + _valueSerDes = _factory.BuildKeySerDes(); + _valueAndTimestamp = valueAndTimestamp; + } + + /// + /// + /// + /// + public long Timestamp => _valueAndTimestamp.Timestamp(); + /// + /// + /// + /// + public DateTime DateTime => DateTimeOffset.FromUnixTimeMilliseconds(Timestamp).DateTime; + /// + /// + /// + /// + public TValue Value + { + get + { + var vv = _valueAndTimestamp.Value(); + return _valueSerDes.Deserialize(null, vv); + } + } + } +} diff --git a/src/net/KNet/Specific/Streams/State/KNetWindowStoreIterator.cs b/src/net/KNet/Specific/Streams/State/KNetWindowStoreIterator.cs new file mode 100644 index 0000000000..92f17904b7 --- /dev/null +++ b/src/net/KNet/Specific/Streams/State/KNetWindowStoreIterator.cs @@ -0,0 +1,54 @@ +/* +* Copyright 2023 MASES s.r.l. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +* Refer to LICENSE for more information. +*/ + +using MASES.JCOBridge.C2JBridge; +using MASES.KNet.Serialization; +using Org.Apache.Kafka.Streams.State; + +namespace MASES.KNet.Streams.State +{ + /// + /// KNet implementation of + /// + /// The value type + public class KNetWindowStoreIterator : IGenericSerDesFactoryApplier + { + readonly WindowStoreIterator _iterator; + IGenericSerDesFactory _factory; + IGenericSerDesFactory IGenericSerDesFactoryApplier.Factory { get => _factory; set { _factory = value; } } + + internal KNetWindowStoreIterator(IGenericSerDesFactory factory, WindowStoreIterator iterator) + { + _factory = factory; + _iterator = iterator; + } + + /// + /// Converter from to + /// + public static implicit operator KNetKeyValueIterator(KNetWindowStoreIterator t) => new KNetKeyValueIterator(t._factory, t._iterator.Cast>()); + + /// + /// KNet implementation of + /// + public void Close() + { + _iterator.Close(); + } + } +} diff --git a/src/net/KNet/Specific/Streams/State/KNetWindowedKeyValueIterator.cs b/src/net/KNet/Specific/Streams/State/KNetWindowedKeyValueIterator.cs new file mode 100644 index 0000000000..9a158e2edf --- /dev/null +++ b/src/net/KNet/Specific/Streams/State/KNetWindowedKeyValueIterator.cs @@ -0,0 +1,99 @@ +/* +* Copyright 2023 MASES s.r.l. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +* Refer to LICENSE for more information. +*/ + +using Java.Util; +using MASES.JCOBridge.C2JBridge.JVMInterop; +using MASES.JCOBridge.C2JBridge; +using MASES.KNet.Serialization; +using MASES.KNet.Streams.Kstream; +using Org.Apache.Kafka.Streams.Kstream; +using Org.Apache.Kafka.Streams.State; +using System.Collections.Generic; + +namespace MASES.KNet.Streams.State +{ + /// + /// KNet implementation of where K is + /// + /// The key type + /// The value type + public class KNetWindowedKeyValueIterator : IGenericSerDesFactoryApplier + { + class LocalEnumerator(IGenericSerDesFactory factory, IJavaObject obj) : JVMBridgeBaseEnumerator>(obj), IGenericSerDesFactoryApplier + { + IGenericSerDesFactory _factory = factory; + IGenericSerDesFactory IGenericSerDesFactoryApplier.Factory { get => _factory; set { _factory = value; } } + + protected override object ConvertObject(object input) + { + return new KNetWindowedKeyValue(_factory, input as Org.Apache.Kafka.Streams.KeyValue, byte[]>); + } + } + + readonly KeyValueIterator, byte[]> _iterator; + IGenericSerDesFactory _factory; + IGenericSerDesFactory IGenericSerDesFactoryApplier.Factory { get => _factory; set { _factory = value; } } + + internal KNetWindowedKeyValueIterator(IGenericSerDesFactory factory, KeyValueIterator, byte[]> iterator) + { + _factory = factory; + _iterator = iterator; + } + /// + /// KNet implementation of + /// + public bool HasNext => _iterator.HasNext; + /// + /// KNet implementation of + /// + public KNetWindowedKeyValue Next + { + get { return new KNetWindowedKeyValue(_factory, _iterator.Next); } + } + /// + /// + /// + public void Remove() + { + _iterator.Remove(); + } + /// + /// Converts an to a + /// + public IEnumerator> ToIEnumerator() => new LocalEnumerator(_factory, _iterator.BridgeInstance); + /// + /// KNet implementation of + /// + /// + public KNetWindowed PeekNextKey + { + get + { + var kk = _iterator.PeekNextKey(); + return new KNetWindowed(_factory, kk); + } + } + /// + /// KNet implementation of + /// + public void Close() + { + _iterator.Close(); + } + } +} From 0e1fc789088fae8edc50d08d9dcd704b156a55c1 Mon Sep 17 00:00:00 2001 From: masesdevelopers <94312179+masesdevelopers@users.noreply.github.com> Date: Sun, 14 Jan 2024 19:48:03 +0100 Subject: [PATCH 10/18] Added new classes and removed occurrence in using of Apache Kafka reflected namespaces --- src/net/KNet/Specific/Streams/KNetKeyValue.cs | 11 +- .../Specific/Streams/KNetStreamBuilder.cs | 168 +++++++------ src/net/KNet/Specific/Streams/KNetStreams.cs | 9 +- .../Streams/KNetTimestampedKeyValue.cs | 10 +- .../KNetTimestampedWindowedKeyValue.cs | 9 +- src/net/KNet/Specific/Streams/KNetTopology.cs | 65 +++-- .../Specific/Streams/KNetTopologyConfig.cs | 6 +- .../Specific/Streams/KNetWindowedKeyValue.cs | 8 +- .../Specific/Streams/Kstream/KNetConsumed.cs | 146 +++++++++++ .../Streams/Kstream/KNetGlobalKTable.cs | 47 ++++ .../Specific/Streams/Kstream/KNetKStream.cs | 47 ++++ .../Specific/Streams/Kstream/KNetKTable.cs | 47 ++++ .../Streams/Kstream/KNetMaterialized.cs | 232 ++++++++++++++++++ .../Specific/Streams/Kstream/KNetPredicate.cs | 5 +- .../Streams/Kstream/KNetPredicateTester.cs | 11 +- .../Streams/Kstream/KNetTimestampExtractor.cs | 12 +- .../Specific/Streams/Kstream/KNetWindowed.cs | 7 +- .../Streams/Processor/Api/KNetProcessor.cs | 8 +- .../Processor/Api/KNetProcessorContext.cs | 11 +- .../Streams/Processor/Api/KNetRecord.cs | 11 +- .../Processor/KNetStreamPartitioner.cs | 5 +- .../Processor/KNetTopicNameExtractor.cs | 5 +- .../Streams/State/KNetKeyValueIterator.cs | 11 +- .../Streams/State/KNetQueryableStoreTypes.cs | 37 ++- .../State/KNetReadOnlyKeyValueStore.cs | 9 +- .../Streams/State/KNetReadOnlySessionStore.cs | 9 +- .../Streams/State/KNetReadOnlyWindowStore.cs | 9 +- .../State/KNetTimestampedKeyValueIterator.cs | 15 +- .../State/KNetTimestampedKeyValueStore.cs | 9 +- .../State/KNetTimestampedWindowStore.cs | 9 +- .../KNetTimestampedWindowStoreIterator.cs | 9 +- ...KNetTimestampedWindowedKeyValueIterator.cs | 10 +- .../Streams/State/KNetValueAndTimestamp.cs | 7 +- .../Streams/State/KNetWindowStoreIterator.cs | 9 +- .../State/KNetWindowedKeyValueIterator.cs | 10 +- 35 files changed, 762 insertions(+), 271 deletions(-) create mode 100644 src/net/KNet/Specific/Streams/Kstream/KNetConsumed.cs create mode 100644 src/net/KNet/Specific/Streams/Kstream/KNetGlobalKTable.cs create mode 100644 src/net/KNet/Specific/Streams/Kstream/KNetKStream.cs create mode 100644 src/net/KNet/Specific/Streams/Kstream/KNetKTable.cs create mode 100644 src/net/KNet/Specific/Streams/Kstream/KNetMaterialized.cs diff --git a/src/net/KNet/Specific/Streams/KNetKeyValue.cs b/src/net/KNet/Specific/Streams/KNetKeyValue.cs index 1f3787251b..aba29bd772 100644 --- a/src/net/KNet/Specific/Streams/KNetKeyValue.cs +++ b/src/net/KNet/Specific/Streams/KNetKeyValue.cs @@ -17,25 +17,24 @@ */ using MASES.KNet.Serialization; -using Org.Apache.Kafka.Streams; namespace MASES.KNet.Streams { /// - /// KNet implementation of + /// KNet implementation of /// /// The key type /// The value type public class KNetKeyValue : IGenericSerDesFactoryApplier { - readonly KeyValue _value = null; - readonly KeyValue _value2 = null; + readonly Org.Apache.Kafka.Streams.KeyValue _value = null; + readonly Org.Apache.Kafka.Streams.KeyValue _value2 = null; readonly IKNetSerDes _keySerDes; readonly IKNetSerDes _valueSerDes; IGenericSerDesFactory _factory; IGenericSerDesFactory IGenericSerDesFactoryApplier.Factory { get => _factory; set { _factory = value; } } - internal KNetKeyValue(IGenericSerDesFactory factory, KeyValue value) + internal KNetKeyValue(IGenericSerDesFactory factory, Org.Apache.Kafka.Streams.KeyValue value) { _factory = factory; _keySerDes = _factory.BuildKeySerDes(); @@ -43,7 +42,7 @@ internal KNetKeyValue(IGenericSerDesFactory factory, KeyValue va _value = value; } - internal KNetKeyValue(IGenericSerDesFactory factory, KeyValue value) + internal KNetKeyValue(IGenericSerDesFactory factory, Org.Apache.Kafka.Streams.KeyValue value) { _factory = factory; _keySerDes = _factory.BuildKeySerDes(); diff --git a/src/net/KNet/Specific/Streams/KNetStreamBuilder.cs b/src/net/KNet/Specific/Streams/KNetStreamBuilder.cs index ad656b60e1..ff5fcaa2ec 100644 --- a/src/net/KNet/Specific/Streams/KNetStreamBuilder.cs +++ b/src/net/KNet/Specific/Streams/KNetStreamBuilder.cs @@ -17,70 +17,76 @@ */ using MASES.KNet.Serialization; -using Org.Apache.Kafka.Streams; +using MASES.KNet.Streams.Kstream; namespace MASES.KNet.Streams { /// - /// KNet extension of + /// KNet extension of /// - public class KNetStreamBuilder : StreamsBuilder, IGenericSerDesFactoryApplier + public class KNetStreamsBuilder : IGenericSerDesFactoryApplier { + Org.Apache.Kafka.Streams.StreamsBuilder _builder; IGenericSerDesFactory _factory; IGenericSerDesFactory IGenericSerDesFactoryApplier.Factory { get => _factory; set { _factory = value; } } #region Constructors /// - public KNetStreamBuilder() : base() { } - /// - public KNetStreamBuilder(params object[] args) : base(args) { } + public KNetStreamsBuilder(IGenericSerDesFactory factory) : base() { _factory = factory; _builder = new Org.Apache.Kafka.Streams.StreamsBuilder(); } /// /// /// /// - public KNetStreamBuilder(KNetTopologyConfig arg0) - : base(arg0) + public KNetStreamsBuilder(KNetTopologyConfig arg0) { + if (arg0 is IGenericSerDesFactoryApplier applier) _factory = applier.Factory; + _builder = new Org.Apache.Kafka.Streams.StreamsBuilder(arg0); } + KNetStreamsBuilder(IGenericSerDesFactory factory, Org.Apache.Kafka.Streams.StreamsBuilder builder) : base() { _factory = factory; _builder = builder; } + #endregion #region Instance methods /// - /// + /// /// /// - /// - /// + /// + /// /// /// - /// - public Org.Apache.Kafka.Streams.Kstream.GlobalKTable GlobalTable(string arg0, Org.Apache.Kafka.Streams.Kstream.Consumed arg1, Org.Apache.Kafka.Streams.Kstream.Materialized> arg2) + /// + public KNetGlobalKTable GlobalTable(string arg0, KNetConsumed arg1, KNetMaterialized arg2) { - return IExecute>("globalTable", arg0, arg1, arg2); + if (arg1 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; + if (arg2 is IGenericSerDesFactoryApplier applier2) applier2.Factory = _factory; + return new KNetGlobalKTable(_factory, _builder.GlobalTable(arg0, arg1, arg2)); } /// - /// + /// /// /// - /// + /// /// /// - /// - public Org.Apache.Kafka.Streams.Kstream.GlobalKTable GlobalTable(string arg0, Org.Apache.Kafka.Streams.Kstream.Consumed arg1) + /// + public KNetGlobalKTable GlobalTable(string arg0, KNetConsumed arg1) { - return IExecute>("globalTable", arg0, arg1); + if (arg1 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; + return new KNetGlobalKTable(_factory, _builder.GlobalTable(arg0, arg1)); } /// - /// + /// /// /// - /// + /// /// /// - /// - public Org.Apache.Kafka.Streams.Kstream.GlobalKTable GlobalTable(string arg0, Org.Apache.Kafka.Streams.Kstream.Materialized> arg1) + /// + public KNetGlobalKTable GlobalTable(string arg0, KNetMaterialized arg1) { - return IExecute>("globalTable", arg0, arg1); + if (arg1 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; + return new KNetGlobalKTable(_factory, _builder.GlobalTable(arg0, arg1)); } /// /// @@ -88,22 +94,23 @@ public Org.Apache.Kafka.Streams.Kstream.GlobalKTable GlobalTable(str /// /// /// - /// - public Org.Apache.Kafka.Streams.Kstream.GlobalKTable GlobalTable(string arg0) + /// + public KNetGlobalKTable GlobalTable(string arg0) { - return IExecute>("globalTable", arg0); + return new KNetGlobalKTable(_factory, _builder.GlobalTable(arg0)); } /// - /// + /// /// /// - /// + /// /// /// - /// - public Org.Apache.Kafka.Streams.Kstream.KStream Stream(string arg0, Org.Apache.Kafka.Streams.Kstream.Consumed arg1) + /// + public KNetKStream Stream(string arg0, KNetConsumed arg1) { - return IExecute>("stream", arg0, arg1); + if (arg1 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; + return new KNetKStream(_factory, _builder.Stream(arg0)); } /// /// @@ -111,22 +118,23 @@ public Org.Apache.Kafka.Streams.Kstream.KStream Stream(string arg0, /// /// /// - /// - public Org.Apache.Kafka.Streams.Kstream.KStream Stream(string arg0) + /// + public KNetKStream Stream(string arg0) { - return IExecute>("stream", arg0); + return new KNetKStream(_factory, _builder.Stream(arg0)); } /// - /// + /// /// /// - /// + /// /// /// - /// - public Org.Apache.Kafka.Streams.Kstream.KStream Stream(Java.Util.Collection arg0, Org.Apache.Kafka.Streams.Kstream.Consumed arg1) + /// + public KNetKStream Stream(Java.Util.Collection arg0, KNetConsumed arg1) { - return IExecute>("stream", arg0, arg1); + if (arg1 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; + return new KNetKStream(_factory, _builder.Stream(arg0)); } /// /// @@ -134,22 +142,23 @@ public Org.Apache.Kafka.Streams.Kstream.KStream Stream(Java.Util.Col /// /// /// - /// - public Org.Apache.Kafka.Streams.Kstream.KStream Stream(Java.Util.Collection arg0) + /// + public KNetKStream Stream(Java.Util.Collection arg0) { - return IExecute>("stream", arg0); + return new KNetKStream(_factory, _builder.Stream(arg0)); } /// - /// + /// /// /// - /// + /// /// /// - /// - public Org.Apache.Kafka.Streams.Kstream.KStream Stream(Java.Util.Regex.Pattern arg0, Org.Apache.Kafka.Streams.Kstream.Consumed arg1) + /// + public KNetKStream Stream(Java.Util.Regex.Pattern arg0, KNetConsumed arg1) { - return IExecute>("stream", arg0, arg1); + if (arg1 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; + return new KNetKStream(_factory, _builder.Stream(arg0)); } /// /// @@ -157,47 +166,51 @@ public Org.Apache.Kafka.Streams.Kstream.KStream Stream(Java.Util.Reg /// /// /// - /// - public Org.Apache.Kafka.Streams.Kstream.KStream Stream(Java.Util.Regex.Pattern arg0) + /// + public KNetKStream Stream(Java.Util.Regex.Pattern arg0) { - return IExecute>("stream", arg0); + return new KNetKStream(_factory, _builder.Stream(arg0)); } /// - /// + /// /// /// - /// - /// + /// + /// /// /// /// - public Org.Apache.Kafka.Streams.Kstream.KTable Table(string arg0, Org.Apache.Kafka.Streams.Kstream.Consumed arg1, Org.Apache.Kafka.Streams.Kstream.Materialized> arg2) + public KNetKTable Table(string arg0, KNetConsumed arg1, KNetMaterialized arg2) { - return IExecute>("table", arg0, arg1, arg2); + if (arg1 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; + if (arg2 is IGenericSerDesFactoryApplier applier2) applier2.Factory = _factory; + return new KNetKTable(_factory, _builder.Table(arg0, arg1, arg2)); } /// - /// + /// /// /// - /// + /// /// /// - /// - public Org.Apache.Kafka.Streams.Kstream.KTable Table(string arg0, Org.Apache.Kafka.Streams.Kstream.Consumed arg1) + /// + public KNetKTable Table(string arg0, KNetConsumed arg1) { - return IExecute>("table", arg0, arg1); + if (arg1 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; + return new KNetKTable(_factory, _builder.Table(arg0, arg1)); } /// - /// + /// /// /// - /// + /// /// /// - /// - public Org.Apache.Kafka.Streams.Kstream.KTable Table(string arg0, Org.Apache.Kafka.Streams.Kstream.Materialized> arg1) + /// + public KNetKTable Table(string arg0, KNetMaterialized arg1) { - return IExecute>("table", arg0, arg1); + if (arg1 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; + return new KNetKTable(_factory, _builder.Table(arg0, arg1)); } /// /// @@ -205,37 +218,36 @@ public Org.Apache.Kafka.Streams.Kstream.KTable Table(string arg0, Or /// /// /// - /// - public Org.Apache.Kafka.Streams.Kstream.KTable Table(string arg0) + /// + public KNetKTable Table(string arg0) { - return IExecute>("table", arg0); + return new KNetKTable(_factory, _builder.Table(arg0)); } /// /// /// /// - /// - public Org.Apache.Kafka.Streams.StreamsBuilder AddStateStore(Org.Apache.Kafka.Streams.State.StoreBuilder arg0) + /// + public KNetStreamsBuilder AddStateStore(Org.Apache.Kafka.Streams.State.StoreBuilder arg0) { - return IExecute("addStateStore", arg0); + return new KNetStreamsBuilder(_factory, _builder.AddStateStore(arg0)); } /// /// /// - - /// - public Org.Apache.Kafka.Streams.Topology Build() + /// + public KNetTopology Build() { - return IExecute("build"); + return new KNetTopology(_builder.Build(), _factory); } /// /// /// /// /// - public Org.Apache.Kafka.Streams.Topology Build(Java.Util.Properties arg0) + public KNetTopology Build(Java.Util.Properties arg0) { - return IExecute("build", arg0); + return new KNetTopology(_builder.Build(arg0), _factory); } #endregion diff --git a/src/net/KNet/Specific/Streams/KNetStreams.cs b/src/net/KNet/Specific/Streams/KNetStreams.cs index 632b8ae816..26f6bc6311 100644 --- a/src/net/KNet/Specific/Streams/KNetStreams.cs +++ b/src/net/KNet/Specific/Streams/KNetStreams.cs @@ -19,22 +19,21 @@ using MASES.KNet.Serialization; using MASES.KNet.Streams.Processor; using MASES.KNet.Streams.State; -using Org.Apache.Kafka.Streams; using System; namespace MASES.KNet.Streams { /// - /// KNet extension of + /// KNet extension of /// - public class KNetStreams : KafkaStreams, IGenericSerDesFactoryApplier + public class KNetStreams : Org.Apache.Kafka.Streams.KafkaStreams, IGenericSerDesFactoryApplier { readonly KNetClientSupplier _supplier = null; // used to avoid GC recall IGenericSerDesFactory _factory; IGenericSerDesFactory IGenericSerDesFactoryApplier.Factory { get => _factory; set { _factory = value; } } Org.Apache.Kafka.Streams.Processor.StateRestoreListener _stateRestoreListener; - Org.Apache.Kafka.Streams.KafkaStreams.StateListener _stateListener; + StateListener _stateListener; Org.Apache.Kafka.Streams.Errors.StreamsUncaughtExceptionHandler _streamsUncaughtExceptionHandler; #region Constructors @@ -144,7 +143,7 @@ public TKNetManagedStore Store(Org.Apache.Kafka.Strea public TKNetManagedStore Store(string storageId, KNetQueryableStoreTypes.StoreType storeType) where TKNetManagedStore : KNetManagedStore, IGenericSerDesFactoryApplier { - var sqp = StoreQueryParameters.FromNameAndType(storageId, storeType.Store); + var sqp = Org.Apache.Kafka.Streams.StoreQueryParameters.FromNameAndType(storageId, storeType.Store); var t = typeof(TKNetManagedStore); var substore = Store(sqp); return Activator.CreateInstance(t, _factory, substore) as TKNetManagedStore; diff --git a/src/net/KNet/Specific/Streams/KNetTimestampedKeyValue.cs b/src/net/KNet/Specific/Streams/KNetTimestampedKeyValue.cs index 8f4518f7b6..0837a69168 100644 --- a/src/net/KNet/Specific/Streams/KNetTimestampedKeyValue.cs +++ b/src/net/KNet/Specific/Streams/KNetTimestampedKeyValue.cs @@ -18,8 +18,6 @@ using MASES.KNet.Serialization; using MASES.KNet.Streams.State; -using Org.Apache.Kafka.Streams; -using Org.Apache.Kafka.Streams.State; namespace MASES.KNet.Streams { @@ -30,14 +28,14 @@ namespace MASES.KNet.Streams /// The value type public class KNetTimestampedKeyValue : IGenericSerDesFactoryApplier { - readonly KeyValue> _value; - readonly KeyValue> _value2; + readonly Org.Apache.Kafka.Streams.KeyValue> _value; + readonly Org.Apache.Kafka.Streams.KeyValue> _value2; readonly IKNetSerDes _keySerDes; readonly IKNetSerDes _valueSerDes; IGenericSerDesFactory _factory; IGenericSerDesFactory IGenericSerDesFactoryApplier.Factory { get => _factory; set { _factory = value; } } - internal KNetTimestampedKeyValue(IGenericSerDesFactory factory, KeyValue> value) + internal KNetTimestampedKeyValue(IGenericSerDesFactory factory, Org.Apache.Kafka.Streams.KeyValue> value) { _factory = factory; _keySerDes = _factory.BuildKeySerDes(); @@ -45,7 +43,7 @@ internal KNetTimestampedKeyValue(IGenericSerDesFactory factory, KeyValue> value) + internal KNetTimestampedKeyValue(IGenericSerDesFactory factory, Org.Apache.Kafka.Streams.KeyValue> value) { _factory = factory; _keySerDes = _factory.BuildKeySerDes(); diff --git a/src/net/KNet/Specific/Streams/KNetTimestampedWindowedKeyValue.cs b/src/net/KNet/Specific/Streams/KNetTimestampedWindowedKeyValue.cs index c5be383e81..bc3aa861e1 100644 --- a/src/net/KNet/Specific/Streams/KNetTimestampedWindowedKeyValue.cs +++ b/src/net/KNet/Specific/Streams/KNetTimestampedWindowedKeyValue.cs @@ -19,24 +19,21 @@ using MASES.KNet.Serialization; using MASES.KNet.Streams.Kstream; using MASES.KNet.Streams.State; -using Org.Apache.Kafka.Streams; -using Org.Apache.Kafka.Streams.Kstream; -using Org.Apache.Kafka.Streams.State; namespace MASES.KNet.Streams { /// - /// KNet implementation of + /// KNet implementation of /// /// The key type /// The value type public class KNetTimestampedWindowedKeyValue : IGenericSerDesFactoryApplier { - readonly KeyValue, ValueAndTimestamp> _value; + readonly Org.Apache.Kafka.Streams.KeyValue, Org.Apache.Kafka.Streams.State.ValueAndTimestamp> _value; IGenericSerDesFactory _factory; IGenericSerDesFactory IGenericSerDesFactoryApplier.Factory { get => _factory; set { _factory = value; } } - internal KNetTimestampedWindowedKeyValue(IGenericSerDesFactory factory, KeyValue, ValueAndTimestamp> value) + internal KNetTimestampedWindowedKeyValue(IGenericSerDesFactory factory, Org.Apache.Kafka.Streams.KeyValue, Org.Apache.Kafka.Streams.State.ValueAndTimestamp> value) { _factory = factory; _value = value; diff --git a/src/net/KNet/Specific/Streams/KNetTopology.cs b/src/net/KNet/Specific/Streams/KNetTopology.cs index 688cd756c6..d0c0ec03f5 100644 --- a/src/net/KNet/Specific/Streams/KNetTopology.cs +++ b/src/net/KNet/Specific/Streams/KNetTopology.cs @@ -17,24 +17,21 @@ */ using MASES.KNet.Serialization; -using MASES.KNet.Streams.Kstream; using MASES.KNet.Streams.Processor; -using Org.Apache.Kafka.Streams; -using Org.Apache.Kafka.Streams.Processor; namespace MASES.KNet.Streams { /// - /// KNet implementation of + /// KNet implementation of /// public class KNetTopology : IGenericSerDesFactoryApplier { - readonly Topology _topology; + readonly Org.Apache.Kafka.Streams.Topology _topology; IGenericSerDesFactory _factory; IGenericSerDesFactory IGenericSerDesFactoryApplier.Factory { get => _factory; set { _factory = value; } } #region Constructors /// - public KNetTopology(IGenericSerDesFactory factory) : base() { _factory = factory; _topology = new Topology(); } + public KNetTopology(IGenericSerDesFactory factory) : base() { _factory = factory; _topology = new Org.Apache.Kafka.Streams.Topology(); } /// /// KNet implementation of /// @@ -42,10 +39,10 @@ public class KNetTopology : IGenericSerDesFactoryApplier public KNetTopology(KNetTopologyConfig arg0) { if (arg0 is IGenericSerDesFactoryApplier applier) _factory = applier.Factory; - _topology = new Topology(arg0); + _topology = new Org.Apache.Kafka.Streams.Topology(arg0); } - KNetTopology(Topology topology, IGenericSerDesFactory factory) + internal KNetTopology(Org.Apache.Kafka.Streams.Topology topology, IGenericSerDesFactory factory) { _factory = factory; _topology = topology; @@ -55,9 +52,9 @@ public KNetTopology(KNetTopologyConfig arg0) #region Class/Interface conversion operators /// - /// Converter from to + /// Converter from to /// - public static implicit operator Topology(KNetTopology t) => t._topology; + public static implicit operator Org.Apache.Kafka.Streams.Topology(KNetTopology t) => t._topology; #endregion @@ -113,7 +110,7 @@ public KNetTopology AddSink(string arg public KNetTopology AddSink(string arg0, string arg1, KNetStreamPartitioner arg2, params string[] arg3) where Arg2objectSuperK : K where Arg2objectSuperV : V { if (arg2 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; - var top = (arg3.Length == 0) ? _topology.IExecute("addSink", arg0, arg1, arg2) : _topology.IExecute("addSource", arg0, arg1, arg2, arg3); + var top = (arg3.Length == 0) ? _topology.IExecute("addSink", arg0, arg1, arg2) : _topology.IExecute("addSource", arg0, arg1, arg2, arg3); return new KNetTopology(top, _factory); } /// @@ -231,7 +228,7 @@ public KNetTopology AddSource(string arg0, Java.Util.Regex.Pattern arg1) /// public KNetTopology AddSource(string arg0, IKNetDeserializer arg1, IKNetDeserializer arg2, params string[] arg3) { - var top = (arg3.Length == 0) ? _topology.IExecute("addSource", arg0, arg1.KafkaDeserializer, arg2.KafkaDeserializer) : _topology.IExecute("addSource", arg0, arg1.KafkaDeserializer, arg2.KafkaDeserializer, arg3); + var top = (arg3.Length == 0) ? _topology.IExecute("addSource", arg0, arg1.KafkaDeserializer, arg2.KafkaDeserializer) : _topology.IExecute("addSource", arg0, arg1.KafkaDeserializer, arg2.KafkaDeserializer, arg3); return new KNetTopology(top, _factory); } /// @@ -244,7 +241,7 @@ public KNetTopology AddSource(string arg0, IKNetDeserializer arg1, IKNet /// public KNetTopology AddSource(string arg0, IKNetDeserializer arg1, IKNetDeserializer arg2, Java.Util.Regex.Pattern arg3) { - var top = _topology.IExecute("addSource", arg0, arg1.KafkaDeserializer, arg2.KafkaDeserializer, arg3); + var top = _topology.IExecute("addSource", arg0, arg1.KafkaDeserializer, arg2.KafkaDeserializer, arg3); return new KNetTopology(top, _factory); } /// @@ -257,7 +254,7 @@ public KNetTopology AddSource(string arg0, IKNetDeserializer arg1, IKNet public KNetTopology AddSource(Org.Apache.Kafka.Streams.Processor.TimestampExtractor arg0, string arg1, params string[] arg2) { if (arg0 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; - var top = (arg2.Length == 0) ? _topology.IExecute("addSource", arg0, arg1) : _topology.IExecute("addSource", arg0, arg1, arg2); + var top = (arg2.Length == 0) ? _topology.IExecute("addSource", arg0, arg1) : _topology.IExecute("addSource", arg0, arg1, arg2); return new KNetTopology(top, _factory); } /// @@ -276,11 +273,11 @@ public KNetTopology AddSource(Org.Apache.Kafka.Streams.Processor.TimestampExtrac /// /// /// - /// + /// /// /// /// - public KNetTopology AddSource(Topology.AutoOffsetReset arg0, string arg1, params string[] arg2) + public KNetTopology AddSource(Org.Apache.Kafka.Streams.Topology.AutoOffsetReset arg0, string arg1, params string[] arg2) { var top = _topology.AddSource(arg0, arg1, arg2); return new KNetTopology(top, _factory); @@ -288,11 +285,11 @@ public KNetTopology AddSource(Topology.AutoOffsetReset arg0, string arg1, params /// /// /// - /// + /// /// /// /// - public KNetTopology AddSource(Topology.AutoOffsetReset arg0, string arg1, Java.Util.Regex.Pattern arg2) + public KNetTopology AddSource(Org.Apache.Kafka.Streams.Topology.AutoOffsetReset arg0, string arg1, Java.Util.Regex.Pattern arg2) { var top = _topology.AddSource(arg0, arg1, arg2); return new KNetTopology(top, _factory); @@ -300,72 +297,72 @@ public KNetTopology AddSource(Topology.AutoOffsetReset arg0, string arg1, Java.U /// /// /// - /// + /// /// /// /// /// /// - public KNetTopology AddSource(Topology.AutoOffsetReset arg0, string arg1, IKNetDeserializer arg2, IKNetDeserializer arg3, params string[] arg4) + public KNetTopology AddSource(Org.Apache.Kafka.Streams.Topology.AutoOffsetReset arg0, string arg1, IKNetDeserializer arg2, IKNetDeserializer arg3, params string[] arg4) { - var top = (arg4.Length == 0) ? _topology.IExecute("addSource", arg0, arg1, arg2.KafkaDeserializer, arg3.KafkaDeserializer) : _topology.IExecute("addSource", arg0, arg1, arg2.KafkaDeserializer, arg3.KafkaDeserializer, arg4); + var top = (arg4.Length == 0) ? _topology.IExecute("addSource", arg0, arg1, arg2.KafkaDeserializer, arg3.KafkaDeserializer) : _topology.IExecute("addSource", arg0, arg1, arg2.KafkaDeserializer, arg3.KafkaDeserializer, arg4); return new KNetTopology(top, _factory); } /// /// /// - /// + /// /// /// /// /// /// - public KNetTopology AddSource(Topology.AutoOffsetReset arg0, string arg1, IKNetDeserializer arg2, IKNetDeserializer arg3, Java.Util.Regex.Pattern arg4) + public KNetTopology AddSource(Org.Apache.Kafka.Streams.Topology.AutoOffsetReset arg0, string arg1, IKNetDeserializer arg2, IKNetDeserializer arg3, Java.Util.Regex.Pattern arg4) { - var top = _topology.IExecute("addSource", arg0, arg1, arg2.KafkaDeserializer, arg3.KafkaDeserializer, arg4); + var top = _topology.IExecute("addSource", arg0, arg1, arg2.KafkaDeserializer, arg3.KafkaDeserializer, arg4); return new KNetTopology(top, _factory); } /// /// /// - /// + /// /// /// /// /// /// /// - public KNetTopology AddSource(Topology.AutoOffsetReset arg0, string arg1, TimestampExtractor arg2, IKNetDeserializer arg3, IKNetDeserializer arg4, params string[] arg5) + public KNetTopology AddSource(Org.Apache.Kafka.Streams.Topology.AutoOffsetReset arg0, string arg1, Org.Apache.Kafka.Streams.Processor.TimestampExtractor arg2, IKNetDeserializer arg3, IKNetDeserializer arg4, params string[] arg5) { if (arg2 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; - var top = (arg5.Length == 0) ? _topology.IExecute("addSource", arg0, arg1, arg2, arg3.KafkaDeserializer, arg4.KafkaDeserializer) : _topology.IExecute("addSource", arg0, arg1, arg2, arg3.KafkaDeserializer, arg4.KafkaDeserializer, arg5); + var top = (arg5.Length == 0) ? _topology.IExecute("addSource", arg0, arg1, arg2, arg3.KafkaDeserializer, arg4.KafkaDeserializer) : _topology.IExecute("addSource", arg0, arg1, arg2, arg3.KafkaDeserializer, arg4.KafkaDeserializer, arg5); return new KNetTopology(top, _factory); } /// /// /// - /// + /// /// /// /// /// /// /// - public KNetTopology AddSource(Topology.AutoOffsetReset arg0, string arg1, TimestampExtractor arg2, IKNetDeserializer arg3, IKNetDeserializer arg4, Java.Util.Regex.Pattern arg5) + public KNetTopology AddSource(Org.Apache.Kafka.Streams.Topology.AutoOffsetReset arg0, string arg1, Org.Apache.Kafka.Streams.Processor.TimestampExtractor arg2, IKNetDeserializer arg3, IKNetDeserializer arg4, Java.Util.Regex.Pattern arg5) { if (arg2 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; - var top = _topology.IExecute("addSource", arg0, arg1, arg2, arg3.KafkaDeserializer, arg4.KafkaDeserializer, arg5); + var top = _topology.IExecute("addSource", arg0, arg1, arg2, arg3.KafkaDeserializer, arg4.KafkaDeserializer, arg5); return new KNetTopology(top, _factory); } /// /// /// - /// + /// /// /// /// /// - public KNetTopology AddSource(Topology.AutoOffsetReset arg0, Org.Apache.Kafka.Streams.Processor.TimestampExtractor arg1, string arg2, params string[] arg3) + public KNetTopology AddSource(Org.Apache.Kafka.Streams.Topology.AutoOffsetReset arg0, Org.Apache.Kafka.Streams.Processor.TimestampExtractor arg1, string arg2, params string[] arg3) { if (arg1 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; var top = _topology.AddSource(arg0, arg1, arg2, arg3); @@ -374,12 +371,12 @@ public KNetTopology AddSource(Topology.AutoOffsetReset arg0, Org.Apache.Kafka.St /// /// /// - /// + /// /// /// /// /// - public KNetTopology AddSource(Topology.AutoOffsetReset arg0, Org.Apache.Kafka.Streams.Processor.TimestampExtractor arg1, string arg2, Java.Util.Regex.Pattern arg3) + public KNetTopology AddSource(Org.Apache.Kafka.Streams.Topology.AutoOffsetReset arg0, Org.Apache.Kafka.Streams.Processor.TimestampExtractor arg1, string arg2, Java.Util.Regex.Pattern arg3) { if (arg1 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; var top = _topology.AddSource(arg0, arg1, arg2, arg3); diff --git a/src/net/KNet/Specific/Streams/KNetTopologyConfig.cs b/src/net/KNet/Specific/Streams/KNetTopologyConfig.cs index 37a3f6ff77..3d6d6596a2 100644 --- a/src/net/KNet/Specific/Streams/KNetTopologyConfig.cs +++ b/src/net/KNet/Specific/Streams/KNetTopologyConfig.cs @@ -17,15 +17,13 @@ */ using MASES.KNet.Serialization; -using MASES.KNet.Streams; -using Org.Apache.Kafka.Streams; namespace MASES.KNet.Streams { /// - /// KNet implementation of + /// KNet implementation of /// - public class KNetTopologyConfig : TopologyConfig, IGenericSerDesFactoryApplier + public class KNetTopologyConfig : Org.Apache.Kafka.Streams.TopologyConfig, IGenericSerDesFactoryApplier { IGenericSerDesFactory _factory; IGenericSerDesFactory IGenericSerDesFactoryApplier.Factory { get => _factory; set { _factory = value; } } diff --git a/src/net/KNet/Specific/Streams/KNetWindowedKeyValue.cs b/src/net/KNet/Specific/Streams/KNetWindowedKeyValue.cs index da4dbfb49c..565d6da8a3 100644 --- a/src/net/KNet/Specific/Streams/KNetWindowedKeyValue.cs +++ b/src/net/KNet/Specific/Streams/KNetWindowedKeyValue.cs @@ -18,24 +18,22 @@ using MASES.KNet.Serialization; using MASES.KNet.Streams.Kstream; -using Org.Apache.Kafka.Streams; -using Org.Apache.Kafka.Streams.Kstream; namespace MASES.KNet.Streams { /// - /// KNet implementation of + /// KNet implementation of /// /// The key type /// The value type public class KNetWindowedKeyValue : IGenericSerDesFactoryApplier { - readonly KeyValue, byte[]> _value; + readonly Org.Apache.Kafka.Streams.KeyValue, byte[]> _value; readonly IKNetSerDes _valueSerDes; IGenericSerDesFactory _factory; IGenericSerDesFactory IGenericSerDesFactoryApplier.Factory { get => _factory; set { _factory = value; } } - internal KNetWindowedKeyValue(IGenericSerDesFactory factory, KeyValue, byte[]> value) + internal KNetWindowedKeyValue(IGenericSerDesFactory factory, Org.Apache.Kafka.Streams.KeyValue, byte[]> value) { _factory = factory; _valueSerDes = _factory.BuildValueSerDes(); diff --git a/src/net/KNet/Specific/Streams/Kstream/KNetConsumed.cs b/src/net/KNet/Specific/Streams/Kstream/KNetConsumed.cs new file mode 100644 index 0000000000..608a802bab --- /dev/null +++ b/src/net/KNet/Specific/Streams/Kstream/KNetConsumed.cs @@ -0,0 +1,146 @@ +/* +* Copyright 2023 MASES s.r.l. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +* Refer to LICENSE for more information. +*/ + +using MASES.KNet.Serialization; + +namespace MASES.KNet.Streams.Kstream +{ + /// + /// KNet extension of + /// + /// + /// + public class KNetConsumed : IGenericSerDesFactoryApplier + { + readonly Org.Apache.Kafka.Streams.Kstream.Consumed _consumed; + IGenericSerDesFactory _factory; + IGenericSerDesFactory IGenericSerDesFactoryApplier.Factory { get => _factory; set { _factory = value; } } + + KNetConsumed(Org.Apache.Kafka.Streams.Kstream.Consumed consumed) + { + _consumed = consumed; + } + + /// + /// Converter from to + /// + public static implicit operator Org.Apache.Kafka.Streams.Kstream.Consumed(KNetConsumed t) => t._consumed; + + #region Static methods + /// + /// + /// + /// + /// + public static KNetConsumed As(string arg0) + { + var cons = Org.Apache.Kafka.Streams.Kstream.Consumed.As(arg0); + return new KNetConsumed(cons); + } + /// + /// + /// + /// + /// + /// + /// + /// + public static KNetConsumed With(IKNetSerDes arg0, IKNetSerDes arg1, KNetTimestampExtractor arg2, Org.Apache.Kafka.Streams.Topology.AutoOffsetReset arg3) + { + var cons = Org.Apache.Kafka.Streams.Kstream.Consumed.With(arg0.KafkaSerde, arg1.KafkaSerde, arg2, arg3); + return new KNetConsumed(cons); + } + /// + /// + /// + /// + /// + /// + public static KNetConsumed With(IKNetSerDes arg0, IKNetSerDes arg1) + { + var cons = Org.Apache.Kafka.Streams.Kstream.Consumed.With(arg0.KafkaSerde, arg1.KafkaSerde); + return new KNetConsumed(cons); + } + /// + /// + /// + /// + /// + public static KNetConsumed With(KNetTimestampExtractor arg0) + { + var cons = Org.Apache.Kafka.Streams.Kstream.Consumed.With(arg0); + return new KNetConsumed(cons); + } + /// + /// + /// + /// + /// + public static KNetConsumed With(Org.Apache.Kafka.Streams.Topology.AutoOffsetReset arg0) + { + var cons = Org.Apache.Kafka.Streams.Kstream.Consumed.With(arg0); + return new KNetConsumed(cons); + } + + #endregion + + #region Instance methods + /// + /// + /// + /// + /// + public KNetConsumed WithKeySerde(IKNetSerDes arg0) + { + _consumed?.WithKeySerde(arg0.KafkaSerde); + return this; + } + /// + /// + /// + /// + /// + public KNetConsumed WithOffsetResetPolicy(Org.Apache.Kafka.Streams.Topology.AutoOffsetReset arg0) + { + _consumed?.WithOffsetResetPolicy(arg0); + return this; + } + /// + /// + /// + /// + /// + public KNetConsumed WithTimestampExtractor(KNetTimestampExtractor arg0) + { + _consumed?.WithTimestampExtractor(arg0); + return this; + } + /// + /// + /// + /// + /// + public KNetConsumed WithValueSerde(IKNetSerDes arg0) + { + _consumed?.WithValueSerde(arg0.KafkaSerde); + return this; + } + + #endregion + } +} diff --git a/src/net/KNet/Specific/Streams/Kstream/KNetGlobalKTable.cs b/src/net/KNet/Specific/Streams/Kstream/KNetGlobalKTable.cs new file mode 100644 index 0000000000..42b7f88ba8 --- /dev/null +++ b/src/net/KNet/Specific/Streams/Kstream/KNetGlobalKTable.cs @@ -0,0 +1,47 @@ +/* +* Copyright 2023 MASES s.r.l. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +* Refer to LICENSE for more information. +*/ + +using MASES.KNet.Serialization; + +namespace MASES.KNet.Streams.Kstream +{ + /// + /// KNet extension of + /// + /// + /// + public class KNetGlobalKTable : IGenericSerDesFactoryApplier + { + Org.Apache.Kafka.Streams.Kstream.GlobalKTable _table; + + IGenericSerDesFactory _factory; + IGenericSerDesFactory IGenericSerDesFactoryApplier.Factory { get => _factory; set { _factory = value; } } + + internal KNetGlobalKTable(IGenericSerDesFactory factory, Org.Apache.Kafka.Streams.Kstream.GlobalKTable table) + { + _factory = factory; + _table = table; + } + + /// + /// Converter from to + /// + public static implicit operator Org.Apache.Kafka.Streams.Kstream.GlobalKTable(KNetGlobalKTable t) => t._table; + + } +} diff --git a/src/net/KNet/Specific/Streams/Kstream/KNetKStream.cs b/src/net/KNet/Specific/Streams/Kstream/KNetKStream.cs new file mode 100644 index 0000000000..325835849a --- /dev/null +++ b/src/net/KNet/Specific/Streams/Kstream/KNetKStream.cs @@ -0,0 +1,47 @@ +/* +* Copyright 2023 MASES s.r.l. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +* Refer to LICENSE for more information. +*/ + +using MASES.KNet.Serialization; + +namespace MASES.KNet.Streams.Kstream +{ + /// + /// KNet extension of + /// + /// + /// + public class KNetKStream : IGenericSerDesFactoryApplier + { + Org.Apache.Kafka.Streams.Kstream.KStream _stream; + + IGenericSerDesFactory _factory; + IGenericSerDesFactory IGenericSerDesFactoryApplier.Factory { get => _factory; set { _factory = value; } } + + internal KNetKStream(IGenericSerDesFactory factory, Org.Apache.Kafka.Streams.Kstream.KStream table) + { + _factory = factory; + _stream = table; + } + + /// + /// Converter from to + /// + public static implicit operator Org.Apache.Kafka.Streams.Kstream.KStream(KNetKStream t) => t._stream; + + } +} diff --git a/src/net/KNet/Specific/Streams/Kstream/KNetKTable.cs b/src/net/KNet/Specific/Streams/Kstream/KNetKTable.cs new file mode 100644 index 0000000000..370f3911b0 --- /dev/null +++ b/src/net/KNet/Specific/Streams/Kstream/KNetKTable.cs @@ -0,0 +1,47 @@ +/* +* Copyright 2023 MASES s.r.l. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +* Refer to LICENSE for more information. +*/ + +using MASES.KNet.Serialization; + +namespace MASES.KNet.Streams.Kstream +{ + /// + /// KNet extension of + /// + /// + /// + public class KNetKTable : IGenericSerDesFactoryApplier + { + Org.Apache.Kafka.Streams.Kstream.KTable _table; + + IGenericSerDesFactory _factory; + IGenericSerDesFactory IGenericSerDesFactoryApplier.Factory { get => _factory; set { _factory = value; } } + + internal KNetKTable(IGenericSerDesFactory factory, Org.Apache.Kafka.Streams.Kstream.KTable table) + { + _factory = factory; + _table = table; + } + + /// + /// Converter from to + /// + public static implicit operator Org.Apache.Kafka.Streams.Kstream.KTable(KNetKTable t) => t._table; + + } +} diff --git a/src/net/KNet/Specific/Streams/Kstream/KNetMaterialized.cs b/src/net/KNet/Specific/Streams/Kstream/KNetMaterialized.cs new file mode 100644 index 0000000000..0f3a70e43b --- /dev/null +++ b/src/net/KNet/Specific/Streams/Kstream/KNetMaterialized.cs @@ -0,0 +1,232 @@ +/* +* Copyright 2023 MASES s.r.l. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +* Refer to LICENSE for more information. +*/ + +using MASES.JCOBridge.C2JBridge; +using MASES.KNet.Serialization; + +namespace MASES.KNet.Streams.Kstream +{ + /// + /// KNet extension of + /// + /// + /// + public class KNetMaterialized : IGenericSerDesFactoryApplier + { + readonly Org.Apache.Kafka.Streams.Kstream.Materialized> _keyStore; + readonly Org.Apache.Kafka.Streams.Kstream.Materialized> _sessionStore; + readonly Org.Apache.Kafka.Streams.Kstream.Materialized> _windowStore; + + IGenericSerDesFactory _factory; + IGenericSerDesFactory IGenericSerDesFactoryApplier.Factory { get => _factory; set { _factory = value; } } + + KNetMaterialized(Org.Apache.Kafka.Streams.Kstream.Materialized> materialized) + { + _keyStore = materialized; + } + + KNetMaterialized(Org.Apache.Kafka.Streams.Kstream.Materialized> materialized) + { + _sessionStore = materialized; + } + + KNetMaterialized(Org.Apache.Kafka.Streams.Kstream.Materialized> materialized) + { + _windowStore = materialized; + } + + /// + /// Converter from to + /// + public static implicit operator Org.Apache.Kafka.Streams.Kstream.Materialized>(KNetMaterialized t) => t._keyStore; + + /// + /// Converter from to + /// + public static implicit operator Org.Apache.Kafka.Streams.Kstream.Materialized>(KNetMaterialized t) => t._sessionStore; + + /// + /// Converter from to + /// + public static implicit operator Org.Apache.Kafka.Streams.Kstream.Materialized>(KNetMaterialized t) => t._windowStore; + + #region Static methods + /// + /// + /// + /// + /// + public static KNetMaterialized As(string arg0) + { + var mat = Org.Apache.Kafka.Streams.Kstream.Materialized>.As(arg0); + return new KNetMaterialized(mat.Cast>>()); + } + /// + /// + /// + /// + /// + public static KNetMaterialized As(Org.Apache.Kafka.Streams.Kstream.Materialized.StoreType arg0) + { + var mat = Org.Apache.Kafka.Streams.Kstream.Materialized>.As(arg0); + return new KNetMaterialized(mat.Cast>>()); + } + /// + /// + /// + /// + /// + /// + public static KNetMaterialized With(IKNetSerDes arg0, IKNetSerDes arg1) + { + var mat = Org.Apache.Kafka.Streams.Kstream.Materialized>.With(arg0.KafkaSerde, arg1.KafkaSerde); + return new KNetMaterialized(mat.Cast>>()); + } + /// + /// + /// + /// + /// + public static KNetMaterialized As(Org.Apache.Kafka.Streams.State.KeyValueBytesStoreSupplier arg0) + { + var mat = Org.Apache.Kafka.Streams.Kstream.Materialized>.As(arg0); + return new KNetMaterialized(mat); + } + /// + /// + /// + /// + /// + public static KNetMaterialized As(Org.Apache.Kafka.Streams.State.SessionBytesStoreSupplier arg0) + { + var mat = Org.Apache.Kafka.Streams.Kstream.Materialized>.As(arg0); + return new KNetMaterialized(mat); + } + /// + /// + /// + /// + /// + public static KNetMaterialized As(Org.Apache.Kafka.Streams.State.WindowBytesStoreSupplier arg0) + { + var mat = Org.Apache.Kafka.Streams.Kstream.Materialized>.As(arg0); + return new KNetMaterialized(mat); + } + + #endregion + + #region Instance methods + /// + /// + /// + /// + public KNetMaterialized WithCachingDisabled() + { + _keyStore?.WithCachingDisabled(); + _sessionStore?.WithCachingDisabled(); + _windowStore?.WithCachingDisabled(); + return this; + } + /// + /// + /// + /// + public KNetMaterialized WithCachingEnabled() + { + _keyStore?.WithCachingEnabled(); + _sessionStore?.WithCachingEnabled(); + _windowStore?.WithCachingEnabled(); + return this; + } + /// + /// + /// + /// + /// + public KNetMaterialized WithKeySerde(IKNetSerDes arg0) + { + _keyStore?.WithKeySerde(arg0.KafkaSerde); + _sessionStore?.WithKeySerde(arg0.KafkaSerde); + _windowStore?.WithKeySerde(arg0.KafkaSerde); + return this; + } + /// + /// + /// + /// + public KNetMaterialized WithLoggingDisabled() + { + _keyStore?.WithLoggingDisabled(); + _sessionStore?.WithLoggingDisabled(); + _windowStore?.WithLoggingDisabled(); + return this; + } + /// + /// + /// + /// + /// + public KNetMaterialized WithLoggingEnabled(Java.Util.Map arg0) + { + _keyStore?.WithLoggingEnabled(arg0); + _sessionStore?.WithLoggingEnabled(arg0); + _windowStore?.WithLoggingEnabled(arg0); + return this; + } + /// + /// + /// + /// + /// + /// + public KNetMaterialized WithRetention(Java.Time.Duration arg0) + { + _keyStore?.WithRetention(arg0); + _sessionStore?.WithRetention(arg0); + _windowStore?.WithRetention(arg0); + return this; + } + /// + /// + /// + /// + /// + /// + public KNetMaterialized WithStoreType(Org.Apache.Kafka.Streams.Kstream.Materialized.StoreType arg0) + { + _keyStore?.WithStoreType(arg0); + _sessionStore?.WithStoreType(arg0); + _windowStore?.WithStoreType(arg0); + return this; + } + /// + /// + /// + /// + /// + public KNetMaterialized WithValueSerde(IKNetSerDes arg0) + { + _keyStore?.WithValueSerde(arg0.KafkaSerde); + _sessionStore?.WithValueSerde(arg0.KafkaSerde); + _windowStore?.WithValueSerde(arg0.KafkaSerde); + return this; + } + + #endregion + } +} diff --git a/src/net/KNet/Specific/Streams/Kstream/KNetPredicate.cs b/src/net/KNet/Specific/Streams/Kstream/KNetPredicate.cs index cf5b33f732..88d18287d5 100644 --- a/src/net/KNet/Specific/Streams/Kstream/KNetPredicate.cs +++ b/src/net/KNet/Specific/Streams/Kstream/KNetPredicate.cs @@ -17,16 +17,15 @@ */ using MASES.KNet.Serialization; -using Org.Apache.Kafka.Streams.Kstream; namespace MASES.KNet.Streams.Kstream { /// - /// KNet implementation of + /// KNet implementation of /// /// The key type /// The value type - public class KNetPredicate : Predicate, IGenericSerDesFactoryApplier + public class KNetPredicate : Org.Apache.Kafka.Streams.Kstream.Predicate, IGenericSerDesFactoryApplier { IGenericSerDesFactory _factory; IGenericSerDesFactory IGenericSerDesFactoryApplier.Factory { get => _factory; set { _factory = value; } } diff --git a/src/net/KNet/Specific/Streams/Kstream/KNetPredicateTester.cs b/src/net/KNet/Specific/Streams/Kstream/KNetPredicateTester.cs index c9a86f3dda..c801f15a68 100644 --- a/src/net/KNet/Specific/Streams/Kstream/KNetPredicateTester.cs +++ b/src/net/KNet/Specific/Streams/Kstream/KNetPredicateTester.cs @@ -17,7 +17,6 @@ */ using MASES.JCOBridge.C2JBridge; -using Org.Apache.Kafka.Streams.Kstream; namespace MASES.KNet.Streams.Kstream { @@ -33,12 +32,12 @@ public class KNetPredicateTester : JVMBridgeBase /// /// Converter from to /// - public static implicit operator Predicate(KNetPredicateTester t) => t.Cast(); + public static implicit operator Org.Apache.Kafka.Streams.Kstream.Predicate(KNetPredicateTester t) => t.Cast(); /// - /// Converter from to + /// Converter from to /// - /// This cast is useful when an API needs in input a type like , however the behavior of the in output is different from the same class allocated directly - public static implicit operator Predicate(KNetPredicateTester t) => t.Cast>(); + /// This cast is useful when an API needs in input a type like , however the behavior of the in output is different from the same class allocated directly + public static implicit operator Org.Apache.Kafka.Streams.Kstream.Predicate(KNetPredicateTester t) => t.Cast>(); /// /// Default constructor: even if the corresponding Java class does not have one, it is mandatory for JCOBridge /// @@ -61,7 +60,7 @@ public KNetPredicateTester(byte[] keyOrValue, bool isKey) /// /// The key to use in comparison /// The value to use in comparison - /// Both and shall be equal to input parameters of to return + /// Both and shall be equal to input parameters of to return public KNetPredicateTester(byte[] key, byte[] value) : base(key, value) { } diff --git a/src/net/KNet/Specific/Streams/Kstream/KNetTimestampExtractor.cs b/src/net/KNet/Specific/Streams/Kstream/KNetTimestampExtractor.cs index 0be882e9cf..2342606dd3 100644 --- a/src/net/KNet/Specific/Streams/Kstream/KNetTimestampExtractor.cs +++ b/src/net/KNet/Specific/Streams/Kstream/KNetTimestampExtractor.cs @@ -19,17 +19,15 @@ using MASES.JCOBridge.C2JBridge; using MASES.KNet.Consumer; using MASES.KNet.Serialization; -using Org.Apache.Kafka.Clients.Consumer; -using Org.Apache.Kafka.Streams.Processor; namespace MASES.KNet.Streams.Kstream { /// - /// KNet extension of + /// KNet extension of /// /// The key type /// The value type - public class KNetTimestampExtractor : TimestampExtractor, IGenericSerDesFactoryApplier + public class KNetTimestampExtractor : Org.Apache.Kafka.Streams.Processor.TimestampExtractor, IGenericSerDesFactoryApplier { IGenericSerDesFactory _factory; IGenericSerDesFactory IGenericSerDesFactoryApplier.Factory { get => _factory; set { _factory = value; } } @@ -40,16 +38,16 @@ public class KNetTimestampExtractor : TimestampExtractor, IGeneric public new System.Func, long, long> OnExtract { get; set; } = null; /// - public sealed override long Extract(ConsumerRecord arg0, long arg1) + public sealed override long Extract(Org.Apache.Kafka.Clients.Consumer.ConsumerRecord arg0, long arg1) { IKNetSerDes keySerializer = _factory.BuildKeySerDes(); IKNetSerDes valueSerializer = _factory.BuildValueSerDes(); - var record = arg0.Cast>(); // KNet consider the data within Apache Kafka Streams defined always as byte[] + var record = arg0.Cast>(); // KNet consider the data within Apache Kafka Streams defined always as byte[] var methodToExecute = (OnExtract != null) ? OnExtract : Extract; return methodToExecute(new KNetConsumerRecord(record, keySerializer, valueSerializer), arg1); } /// - /// KNet implementation of + /// KNet implementation of /// /// The with information /// diff --git a/src/net/KNet/Specific/Streams/Kstream/KNetWindowed.cs b/src/net/KNet/Specific/Streams/Kstream/KNetWindowed.cs index 89d9590860..364a646731 100644 --- a/src/net/KNet/Specific/Streams/Kstream/KNetWindowed.cs +++ b/src/net/KNet/Specific/Streams/Kstream/KNetWindowed.cs @@ -17,22 +17,21 @@ */ using MASES.KNet.Serialization; -using Org.Apache.Kafka.Streams.Kstream; namespace MASES.KNet.Streams.Kstream { /// - /// KNet implementation of + /// KNet implementation of /// /// The key type public class KNetWindowed : IGenericSerDesFactoryApplier { - readonly Windowed _windowed; + readonly Org.Apache.Kafka.Streams.Kstream.Windowed _windowed; readonly IKNetSerDes _keySerDes; IGenericSerDesFactory _factory; IGenericSerDesFactory IGenericSerDesFactoryApplier.Factory { get => _factory; set { _factory = value; } } - internal KNetWindowed(IGenericSerDesFactory factory, Windowed windowed) + internal KNetWindowed(IGenericSerDesFactory factory, Org.Apache.Kafka.Streams.Kstream.Windowed windowed) { _factory = factory; _keySerDes = _factory.BuildKeySerDes(); diff --git a/src/net/KNet/Specific/Streams/Processor/Api/KNetProcessor.cs b/src/net/KNet/Specific/Streams/Processor/Api/KNetProcessor.cs index 6851150bfd..1c0cd055ea 100644 --- a/src/net/KNet/Specific/Streams/Processor/Api/KNetProcessor.cs +++ b/src/net/KNet/Specific/Streams/Processor/Api/KNetProcessor.cs @@ -17,19 +17,17 @@ */ using MASES.KNet.Serialization; -using MASES.KNet.Streams; -using Org.Apache.Kafka.Streams.Processor.Api; namespace MASES.KNet.Streams.Processor.Api { /// - /// KNet extension of + /// KNet extension of /// /// The input key type /// The input key type /// The output key type /// The output value type - public class KNetProcessor : Processor, IGenericSerDesFactoryApplier + public class KNetProcessor : Org.Apache.Kafka.Streams.Processor.Api.Processor, IGenericSerDesFactoryApplier { KNetProcessorContext _processorContext = null; IGenericSerDesFactory _factory; @@ -53,7 +51,7 @@ public sealed override void Process(Org.Apache.Kafka.Streams.Processor.Api.Recor } /// - /// KNet implementation of + /// KNet implementation of /// /// public virtual void Process(KNetRecord arg0) diff --git a/src/net/KNet/Specific/Streams/Processor/Api/KNetProcessorContext.cs b/src/net/KNet/Specific/Streams/Processor/Api/KNetProcessorContext.cs index 9f5e7c0e69..a5c50a1e0a 100644 --- a/src/net/KNet/Specific/Streams/Processor/Api/KNetProcessorContext.cs +++ b/src/net/KNet/Specific/Streams/Processor/Api/KNetProcessorContext.cs @@ -16,29 +16,28 @@ * Refer to LICENSE for more information. */ -using Org.Apache.Kafka.Streams.Processor.Api; using System; namespace MASES.KNet.Streams.Processor.Api { /// - /// KNet implementation of + /// KNet implementation of /// /// /// public class KNetProcessorContext { - internal KNetProcessorContext(ProcessorContext context) + internal KNetProcessorContext(Org.Apache.Kafka.Streams.Processor.Api.ProcessorContext context) { _context = context; } - readonly ProcessorContext _context; + readonly Org.Apache.Kafka.Streams.Processor.Api.ProcessorContext _context; /// - /// Converter from to + /// Converter from to /// - public static implicit operator ProcessorContext(KNetProcessorContext t) => t._context; + public static implicit operator Org.Apache.Kafka.Streams.Processor.Api.ProcessorContext(KNetProcessorContext t) => t._context; #region ProcessorContext diff --git a/src/net/KNet/Specific/Streams/Processor/Api/KNetRecord.cs b/src/net/KNet/Specific/Streams/Processor/Api/KNetRecord.cs index 69f38049dd..f723341df4 100644 --- a/src/net/KNet/Specific/Streams/Processor/Api/KNetRecord.cs +++ b/src/net/KNet/Specific/Streams/Processor/Api/KNetRecord.cs @@ -17,19 +17,18 @@ */ using MASES.KNet.Serialization; -using Org.Apache.Kafka.Streams.Processor.Api; using System; namespace MASES.KNet.Streams.Processor.Api { /// - /// KNet extension of + /// KNet extension of /// /// The key type /// The value type public class KNetRecord { - internal KNetRecord(IGenericSerDesFactory builder, Record record, RecordMetadata metadata) + internal KNetRecord(IGenericSerDesFactory builder, Org.Apache.Kafka.Streams.Processor.Api.Record record, Org.Apache.Kafka.Streams.Processor.Api.RecordMetadata metadata) { _builder = builder; _record = record; @@ -37,13 +36,13 @@ internal KNetRecord(IGenericSerDesFactory builder, Record record } readonly IGenericSerDesFactory _builder; - readonly Record _record; - readonly RecordMetadata _metadata; + readonly Org.Apache.Kafka.Streams.Processor.Api.Record _record; + readonly Org.Apache.Kafka.Streams.Processor.Api.RecordMetadata _metadata; /// /// Converter from to /// - public static implicit operator Record(KNetRecord t) => t._record; + public static implicit operator Org.Apache.Kafka.Streams.Processor.Api.Record(KNetRecord t) => t._record; /// /// diff --git a/src/net/KNet/Specific/Streams/Processor/KNetStreamPartitioner.cs b/src/net/KNet/Specific/Streams/Processor/KNetStreamPartitioner.cs index 90a105ad73..28cbf61a1c 100644 --- a/src/net/KNet/Specific/Streams/Processor/KNetStreamPartitioner.cs +++ b/src/net/KNet/Specific/Streams/Processor/KNetStreamPartitioner.cs @@ -19,16 +19,15 @@ using Java.Lang; using Java.Util; using MASES.KNet.Serialization; -using Org.Apache.Kafka.Streams.Processor; namespace MASES.KNet.Streams.Processor { /// - /// KNet implementation of + /// KNet implementation of /// /// The key type /// The value type - public class KNetStreamPartitioner : StreamPartitioner, IGenericSerDesFactoryApplier + public class KNetStreamPartitioner : Org.Apache.Kafka.Streams.Processor.StreamPartitioner, IGenericSerDesFactoryApplier { IGenericSerDesFactory _factory; IGenericSerDesFactory IGenericSerDesFactoryApplier.Factory { get => _factory; set { _factory = value; } } diff --git a/src/net/KNet/Specific/Streams/Processor/KNetTopicNameExtractor.cs b/src/net/KNet/Specific/Streams/Processor/KNetTopicNameExtractor.cs index f0fad705c2..46f9b7377f 100644 --- a/src/net/KNet/Specific/Streams/Processor/KNetTopicNameExtractor.cs +++ b/src/net/KNet/Specific/Streams/Processor/KNetTopicNameExtractor.cs @@ -17,16 +17,15 @@ */ using MASES.KNet.Serialization; -using Org.Apache.Kafka.Streams.Processor; namespace MASES.KNet.Streams.Processor { /// - /// KNet implementation of + /// KNet implementation of /// /// The key type /// The value type - public class KNetTopicNameExtractor : TopicNameExtractor, IGenericSerDesFactoryApplier + public class KNetTopicNameExtractor : Org.Apache.Kafka.Streams.Processor.TopicNameExtractor, IGenericSerDesFactoryApplier { IGenericSerDesFactory _factory; IGenericSerDesFactory IGenericSerDesFactoryApplier.Factory { get => _factory; set { _factory = value; } } diff --git a/src/net/KNet/Specific/Streams/State/KNetKeyValueIterator.cs b/src/net/KNet/Specific/Streams/State/KNetKeyValueIterator.cs index 3559da4313..ddfc879933 100644 --- a/src/net/KNet/Specific/Streams/State/KNetKeyValueIterator.cs +++ b/src/net/KNet/Specific/Streams/State/KNetKeyValueIterator.cs @@ -20,13 +20,12 @@ using MASES.JCOBridge.C2JBridge; using MASES.JCOBridge.C2JBridge.JVMInterop; using MASES.KNet.Serialization; -using Org.Apache.Kafka.Streams.State; using System.Collections.Generic; namespace MASES.KNet.Streams.State { /// - /// KNet implementation of + /// KNet implementation of /// /// The key type /// The value type @@ -44,20 +43,20 @@ protected override object ConvertObject(object input) } } - readonly KeyValueIterator _iterator; - readonly KeyValueIterator _iterator2; + readonly Org.Apache.Kafka.Streams.State.KeyValueIterator _iterator; + readonly Org.Apache.Kafka.Streams.State.KeyValueIterator _iterator2; readonly IKNetSerDes _keySerDes; IGenericSerDesFactory _factory; IGenericSerDesFactory IGenericSerDesFactoryApplier.Factory { get => _factory; set { _factory = value; } } - internal KNetKeyValueIterator(IGenericSerDesFactory factory, KeyValueIterator iterator) + internal KNetKeyValueIterator(IGenericSerDesFactory factory, Org.Apache.Kafka.Streams.State.KeyValueIterator iterator) { _factory = factory; _keySerDes = _factory.BuildKeySerDes(); _iterator = iterator; } - internal KNetKeyValueIterator(IGenericSerDesFactory factory, KeyValueIterator iterator) + internal KNetKeyValueIterator(IGenericSerDesFactory factory, Org.Apache.Kafka.Streams.State.KeyValueIterator iterator) { _factory = factory; _keySerDes = _factory.BuildKeySerDes(); diff --git a/src/net/KNet/Specific/Streams/State/KNetQueryableStoreTypes.cs b/src/net/KNet/Specific/Streams/State/KNetQueryableStoreTypes.cs index 2cdaf6c54d..58696ad3c8 100644 --- a/src/net/KNet/Specific/Streams/State/KNetQueryableStoreTypes.cs +++ b/src/net/KNet/Specific/Streams/State/KNetQueryableStoreTypes.cs @@ -17,12 +17,11 @@ */ using MASES.KNet.Serialization; -using Org.Apache.Kafka.Streams.State; namespace MASES.KNet.Streams.State { /// - /// Generator of KNet + /// Generator of KNet /// public static class KNetQueryableStoreTypes { @@ -33,46 +32,46 @@ public static class KNetQueryableStoreTypes /// public class StoreType where TKNetManagedStore : KNetManagedStore, IGenericSerDesFactoryApplier { - internal StoreType(QueryableStoreType store) { Store = store; } - internal QueryableStoreType Store; + internal StoreType(Org.Apache.Kafka.Streams.State.QueryableStoreType store) { Store = store; } + internal Org.Apache.Kafka.Streams.State.QueryableStoreType Store; } /// - /// KNet value of based on array of + /// KNet value of based on array of /// - public static StoreType, ReadOnlyKeyValueStore> KeyValueStore() + public static StoreType, Org.Apache.Kafka.Streams.State.ReadOnlyKeyValueStore> KeyValueStore() { - return new StoreType, ReadOnlyKeyValueStore>(QueryableStoreTypes.KeyValueStore()); + return new StoreType, Org.Apache.Kafka.Streams.State.ReadOnlyKeyValueStore>(Org.Apache.Kafka.Streams.State.QueryableStoreTypes.KeyValueStore()); } /// - /// KNet value of based on array of + /// KNet value of based on array of /// - public static StoreType, ReadOnlySessionStore> SessionStore() + public static StoreType, Org.Apache.Kafka.Streams.State.ReadOnlySessionStore> SessionStore() { - return new StoreType, ReadOnlySessionStore>(QueryableStoreTypes.SessionStore()); + return new StoreType, Org.Apache.Kafka.Streams.State.ReadOnlySessionStore>(Org.Apache.Kafka.Streams.State.QueryableStoreTypes.SessionStore()); } /// - /// KNet value of based on array of + /// KNet value of based on array of /// - public static StoreType, ReadOnlyWindowStore> WindowStore() + public static StoreType, Org.Apache.Kafka.Streams.State.ReadOnlyWindowStore> WindowStore() { - return new StoreType, ReadOnlyWindowStore>(QueryableStoreTypes.WindowStore()); + return new StoreType, Org.Apache.Kafka.Streams.State.ReadOnlyWindowStore>(Org.Apache.Kafka.Streams.State.QueryableStoreTypes.WindowStore()); } /// - /// KNet value of based on array of + /// KNet value of based on array of /// - public static StoreType, ReadOnlyKeyValueStore>> TimestampedKeyValueStore() + public static StoreType, Org.Apache.Kafka.Streams.State.ReadOnlyKeyValueStore>> TimestampedKeyValueStore() { - return new StoreType, ReadOnlyKeyValueStore>>(QueryableStoreTypes.TimestampedKeyValueStore()); + return new StoreType, Org.Apache.Kafka.Streams.State.ReadOnlyKeyValueStore>>(Org.Apache.Kafka.Streams.State.QueryableStoreTypes.TimestampedKeyValueStore()); } /// - /// KNet value of based on array of + /// KNet value of based on array of /// - public static StoreType, ReadOnlyWindowStore>> TimestampedWindowStore() + public static StoreType, Org.Apache.Kafka.Streams.State.ReadOnlyWindowStore>> TimestampedWindowStore() { - return new StoreType, ReadOnlyWindowStore>>(QueryableStoreTypes.TimestampedWindowStore()); + return new StoreType, Org.Apache.Kafka.Streams.State.ReadOnlyWindowStore>>(Org.Apache.Kafka.Streams.State.QueryableStoreTypes.TimestampedWindowStore()); } } } diff --git a/src/net/KNet/Specific/Streams/State/KNetReadOnlyKeyValueStore.cs b/src/net/KNet/Specific/Streams/State/KNetReadOnlyKeyValueStore.cs index 8e6e48b9ef..abefab5e66 100644 --- a/src/net/KNet/Specific/Streams/State/KNetReadOnlyKeyValueStore.cs +++ b/src/net/KNet/Specific/Streams/State/KNetReadOnlyKeyValueStore.cs @@ -17,24 +17,23 @@ */ using MASES.KNet.Serialization; -using Org.Apache.Kafka.Streams.State; namespace MASES.KNet.Streams.State { /// - /// KNet implementation of + /// KNet implementation of /// /// The key type /// The value type - public class KNetReadOnlyKeyValueStore : KNetManagedStore>, IGenericSerDesFactoryApplier + public class KNetReadOnlyKeyValueStore : KNetManagedStore>, IGenericSerDesFactoryApplier { - readonly ReadOnlyKeyValueStore _store; + readonly Org.Apache.Kafka.Streams.State.ReadOnlyKeyValueStore _store; readonly IKNetSerDes _keySerDes; readonly IKNetSerDes _valueSerDes; IGenericSerDesFactory _factory; IGenericSerDesFactory IGenericSerDesFactoryApplier.Factory { get => _factory; set { _factory = value; } } - internal KNetReadOnlyKeyValueStore(IGenericSerDesFactory factory, ReadOnlyKeyValueStore store) + internal KNetReadOnlyKeyValueStore(IGenericSerDesFactory factory, Org.Apache.Kafka.Streams.State.ReadOnlyKeyValueStore store) { _factory = factory; _keySerDes = _factory.BuildKeySerDes(); diff --git a/src/net/KNet/Specific/Streams/State/KNetReadOnlySessionStore.cs b/src/net/KNet/Specific/Streams/State/KNetReadOnlySessionStore.cs index 8bc655821a..923ccebf25 100644 --- a/src/net/KNet/Specific/Streams/State/KNetReadOnlySessionStore.cs +++ b/src/net/KNet/Specific/Streams/State/KNetReadOnlySessionStore.cs @@ -17,24 +17,23 @@ */ using MASES.KNet.Serialization; -using Org.Apache.Kafka.Streams.State; namespace MASES.KNet.Streams.State { /// - /// KNet implementation of + /// KNet implementation of /// /// The key type /// The value type - public class KNetReadOnlySessionStore : KNetManagedStore>, IGenericSerDesFactoryApplier + public class KNetReadOnlySessionStore : KNetManagedStore>, IGenericSerDesFactoryApplier { - readonly ReadOnlySessionStore _store; + readonly Org.Apache.Kafka.Streams.State.ReadOnlySessionStore _store; readonly IKNetSerDes _keySerDes; readonly IKNetSerDes _valueSerDes; IGenericSerDesFactory _factory; IGenericSerDesFactory IGenericSerDesFactoryApplier.Factory { get => _factory; set { _factory = value; } } - internal KNetReadOnlySessionStore(IGenericSerDesFactory factory, ReadOnlySessionStore store) + internal KNetReadOnlySessionStore(IGenericSerDesFactory factory, Org.Apache.Kafka.Streams.State.ReadOnlySessionStore store) { _factory = factory; _keySerDes = _factory.BuildKeySerDes(); diff --git a/src/net/KNet/Specific/Streams/State/KNetReadOnlyWindowStore.cs b/src/net/KNet/Specific/Streams/State/KNetReadOnlyWindowStore.cs index da77d371fb..fa1dcd00ff 100644 --- a/src/net/KNet/Specific/Streams/State/KNetReadOnlyWindowStore.cs +++ b/src/net/KNet/Specific/Streams/State/KNetReadOnlyWindowStore.cs @@ -17,24 +17,23 @@ */ using MASES.KNet.Serialization; -using Org.Apache.Kafka.Streams.State; namespace MASES.KNet.Streams.State { /// - /// KNet implementation of + /// KNet implementation of /// /// The key type /// The value type - public class KNetReadOnlyWindowStore : KNetManagedStore>, IGenericSerDesFactoryApplier + public class KNetReadOnlyWindowStore : KNetManagedStore>, IGenericSerDesFactoryApplier { - readonly ReadOnlyWindowStore _store; + readonly Org.Apache.Kafka.Streams.State.ReadOnlyWindowStore _store; readonly IKNetSerDes _keySerDes; readonly IKNetSerDes _valueSerDes; IGenericSerDesFactory _factory; IGenericSerDesFactory IGenericSerDesFactoryApplier.Factory { get => _factory; set { _factory = value; } } - internal KNetReadOnlyWindowStore(IGenericSerDesFactory factory, ReadOnlyWindowStore store) + internal KNetReadOnlyWindowStore(IGenericSerDesFactory factory, Org.Apache.Kafka.Streams.State.ReadOnlyWindowStore store) { _factory = factory; _keySerDes = _factory.BuildKeySerDes(); diff --git a/src/net/KNet/Specific/Streams/State/KNetTimestampedKeyValueIterator.cs b/src/net/KNet/Specific/Streams/State/KNetTimestampedKeyValueIterator.cs index 0eaba350a3..d1dc1953e9 100644 --- a/src/net/KNet/Specific/Streams/State/KNetTimestampedKeyValueIterator.cs +++ b/src/net/KNet/Specific/Streams/State/KNetTimestampedKeyValueIterator.cs @@ -20,13 +20,12 @@ using MASES.JCOBridge.C2JBridge; using MASES.JCOBridge.C2JBridge.JVMInterop; using MASES.KNet.Serialization; -using Org.Apache.Kafka.Streams.State; using System.Collections.Generic; namespace MASES.KNet.Streams.State { /// - /// KNet implementation of + /// KNet implementation of /// /// The key type /// The value type @@ -39,25 +38,25 @@ class LocalEnumerator(bool isVersion2, IGenericSerDesFactory factory, IJavaObjec protected override object ConvertObject(object input) { - return isVersion2 ? new KNetTimestampedKeyValue(_factory, input as Org.Apache.Kafka.Streams.KeyValue>) - : new KNetTimestampedKeyValue(_factory, input as Org.Apache.Kafka.Streams.KeyValue>); + return isVersion2 ? new KNetTimestampedKeyValue(_factory, input as Org.Apache.Kafka.Streams.KeyValue>) + : new KNetTimestampedKeyValue(_factory, input as Org.Apache.Kafka.Streams.KeyValue>); } } - readonly KeyValueIterator> _iterator = null; - readonly KeyValueIterator> _iterator2 = null; + readonly Org.Apache.Kafka.Streams.State.KeyValueIterator> _iterator = null; + readonly Org.Apache.Kafka.Streams.State.KeyValueIterator> _iterator2 = null; readonly IKNetSerDes _keySerDes; IGenericSerDesFactory _factory; IGenericSerDesFactory IGenericSerDesFactoryApplier.Factory { get => _factory; set { _factory = value; } } - internal KNetTimestampedKeyValueIterator(IGenericSerDesFactory factory, KeyValueIterator> iterator) + internal KNetTimestampedKeyValueIterator(IGenericSerDesFactory factory, Org.Apache.Kafka.Streams.State.KeyValueIterator> iterator) { _factory = factory; _keySerDes = _factory.BuildKeySerDes(); _iterator = iterator; } - internal KNetTimestampedKeyValueIterator(IGenericSerDesFactory factory, KeyValueIterator> iterator) + internal KNetTimestampedKeyValueIterator(IGenericSerDesFactory factory, Org.Apache.Kafka.Streams.State.KeyValueIterator> iterator) { _factory = factory; _keySerDes = _factory.BuildKeySerDes(); diff --git a/src/net/KNet/Specific/Streams/State/KNetTimestampedKeyValueStore.cs b/src/net/KNet/Specific/Streams/State/KNetTimestampedKeyValueStore.cs index 2ed4e9c9c6..a349063ae8 100644 --- a/src/net/KNet/Specific/Streams/State/KNetTimestampedKeyValueStore.cs +++ b/src/net/KNet/Specific/Streams/State/KNetTimestampedKeyValueStore.cs @@ -17,24 +17,23 @@ */ using MASES.KNet.Serialization; -using Org.Apache.Kafka.Streams.State; namespace MASES.KNet.Streams.State { /// - /// KNet implementation of + /// KNet implementation of /// /// The key type /// The value type - public class KNetTimestampedKeyValueStore : KNetManagedStore>>, IGenericSerDesFactoryApplier + public class KNetTimestampedKeyValueStore : KNetManagedStore>>, IGenericSerDesFactoryApplier { - readonly ReadOnlyKeyValueStore> _store; + readonly Org.Apache.Kafka.Streams.State.ReadOnlyKeyValueStore> _store; readonly IKNetSerDes _keySerDes; readonly IKNetSerDes _valueSerDes; IGenericSerDesFactory _factory; IGenericSerDesFactory IGenericSerDesFactoryApplier.Factory { get => _factory; set { _factory = value; } } - internal KNetTimestampedKeyValueStore(IGenericSerDesFactory factory, ReadOnlyKeyValueStore> store) + internal KNetTimestampedKeyValueStore(IGenericSerDesFactory factory, Org.Apache.Kafka.Streams.State.ReadOnlyKeyValueStore> store) { _factory = factory; _keySerDes = _factory.BuildKeySerDes(); diff --git a/src/net/KNet/Specific/Streams/State/KNetTimestampedWindowStore.cs b/src/net/KNet/Specific/Streams/State/KNetTimestampedWindowStore.cs index 538b07d06f..9760810212 100644 --- a/src/net/KNet/Specific/Streams/State/KNetTimestampedWindowStore.cs +++ b/src/net/KNet/Specific/Streams/State/KNetTimestampedWindowStore.cs @@ -17,24 +17,23 @@ */ using MASES.KNet.Serialization; -using Org.Apache.Kafka.Streams.State; namespace MASES.KNet.Streams.State { /// - /// KNet implementation of + /// KNet implementation of /// /// The key type /// The value type - public class KNetTimestampedWindowStore : KNetManagedStore>>, IGenericSerDesFactoryApplier + public class KNetTimestampedWindowStore : KNetManagedStore>>, IGenericSerDesFactoryApplier { - readonly ReadOnlyWindowStore> _store; + readonly Org.Apache.Kafka.Streams.State.ReadOnlyWindowStore> _store; readonly IKNetSerDes _keySerDes; readonly IKNetSerDes _valueSerDes; IGenericSerDesFactory _factory; IGenericSerDesFactory IGenericSerDesFactoryApplier.Factory { get => _factory; set { _factory = value; } } - internal KNetTimestampedWindowStore(IGenericSerDesFactory factory, ReadOnlyWindowStore> store) + internal KNetTimestampedWindowStore(IGenericSerDesFactory factory, Org.Apache.Kafka.Streams.State.ReadOnlyWindowStore> store) { _factory = factory; _keySerDes = _factory.BuildKeySerDes(); diff --git a/src/net/KNet/Specific/Streams/State/KNetTimestampedWindowStoreIterator.cs b/src/net/KNet/Specific/Streams/State/KNetTimestampedWindowStoreIterator.cs index adac493a29..952f777f7e 100644 --- a/src/net/KNet/Specific/Streams/State/KNetTimestampedWindowStoreIterator.cs +++ b/src/net/KNet/Specific/Streams/State/KNetTimestampedWindowStoreIterator.cs @@ -18,21 +18,20 @@ using MASES.JCOBridge.C2JBridge; using MASES.KNet.Serialization; -using Org.Apache.Kafka.Streams.State; namespace MASES.KNet.Streams.State { /// - /// KNet implementation of + /// KNet implementation of /// /// The value type public class KNetTimestampedWindowStoreIterator : IGenericSerDesFactoryApplier { - readonly WindowStoreIterator> _iterator; + readonly Org.Apache.Kafka.Streams.State.WindowStoreIterator> _iterator; IGenericSerDesFactory _factory; IGenericSerDesFactory IGenericSerDesFactoryApplier.Factory { get => _factory; set { _factory = value; } } - internal KNetTimestampedWindowStoreIterator(IGenericSerDesFactory factory, WindowStoreIterator> iterator) + internal KNetTimestampedWindowStoreIterator(IGenericSerDesFactory factory, Org.Apache.Kafka.Streams.State.WindowStoreIterator> iterator) { _factory = factory; _iterator = iterator; @@ -41,7 +40,7 @@ internal KNetTimestampedWindowStoreIterator(IGenericSerDesFactory factory, Windo /// /// Converter from to /// - public static implicit operator KNetTimestampedKeyValueIterator(KNetTimestampedWindowStoreIterator t) => new KNetTimestampedKeyValueIterator(t._factory, t._iterator.Cast>>()); + public static implicit operator KNetTimestampedKeyValueIterator(KNetTimestampedWindowStoreIterator t) => new KNetTimestampedKeyValueIterator(t._factory, t._iterator.Cast>>()); /// /// KNet implementation of diff --git a/src/net/KNet/Specific/Streams/State/KNetTimestampedWindowedKeyValueIterator.cs b/src/net/KNet/Specific/Streams/State/KNetTimestampedWindowedKeyValueIterator.cs index 2fc8064127..84acca4aab 100644 --- a/src/net/KNet/Specific/Streams/State/KNetTimestampedWindowedKeyValueIterator.cs +++ b/src/net/KNet/Specific/Streams/State/KNetTimestampedWindowedKeyValueIterator.cs @@ -21,14 +21,12 @@ using MASES.JCOBridge.C2JBridge.JVMInterop; using MASES.KNet.Serialization; using MASES.KNet.Streams.Kstream; -using Org.Apache.Kafka.Streams.Kstream; -using Org.Apache.Kafka.Streams.State; using System.Collections.Generic; namespace MASES.KNet.Streams.State { /// - /// KNet implementation of + /// KNet implementation of /// /// The key type /// The value type @@ -41,15 +39,15 @@ class LocalEnumerator(IGenericSerDesFactory factory, IJavaObject obj) : JVMBridg protected override object ConvertObject(object input) { - return new KNetTimestampedWindowedKeyValue(_factory, input as Org.Apache.Kafka.Streams.KeyValue, ValueAndTimestamp>); + return new KNetTimestampedWindowedKeyValue(_factory, input as Org.Apache.Kafka.Streams.KeyValue, Org.Apache.Kafka.Streams.State.ValueAndTimestamp>); } } - readonly KeyValueIterator, ValueAndTimestamp> _iterator; + readonly Org.Apache.Kafka.Streams.State.KeyValueIterator, Org.Apache.Kafka.Streams.State.ValueAndTimestamp> _iterator; IGenericSerDesFactory _factory; IGenericSerDesFactory IGenericSerDesFactoryApplier.Factory { get => _factory; set { _factory = value; } } - internal KNetTimestampedWindowedKeyValueIterator(IGenericSerDesFactory factory, KeyValueIterator, ValueAndTimestamp> iterator) + internal KNetTimestampedWindowedKeyValueIterator(IGenericSerDesFactory factory, Org.Apache.Kafka.Streams.State.KeyValueIterator, Org.Apache.Kafka.Streams.State.ValueAndTimestamp> iterator) { _factory = factory; _iterator = iterator; diff --git a/src/net/KNet/Specific/Streams/State/KNetValueAndTimestamp.cs b/src/net/KNet/Specific/Streams/State/KNetValueAndTimestamp.cs index ab485a56aa..afc1c51bbd 100644 --- a/src/net/KNet/Specific/Streams/State/KNetValueAndTimestamp.cs +++ b/src/net/KNet/Specific/Streams/State/KNetValueAndTimestamp.cs @@ -17,23 +17,22 @@ */ using MASES.KNet.Serialization; -using Org.Apache.Kafka.Streams.State; using System; namespace MASES.KNet.Streams.State { /// - /// KNet Implementation of + /// KNet Implementation of /// /// The value type public class KNetValueAndTimestamp : IGenericSerDesFactoryApplier { - readonly ValueAndTimestamp _valueAndTimestamp; + readonly Org.Apache.Kafka.Streams.State.ValueAndTimestamp _valueAndTimestamp; readonly IKNetSerDes _valueSerDes; IGenericSerDesFactory _factory; IGenericSerDesFactory IGenericSerDesFactoryApplier.Factory { get => _factory; set { _factory = value; } } - internal KNetValueAndTimestamp(IGenericSerDesFactory factory, ValueAndTimestamp valueAndTimestamp) + internal KNetValueAndTimestamp(IGenericSerDesFactory factory, Org.Apache.Kafka.Streams.State.ValueAndTimestamp valueAndTimestamp) { _factory = factory; _valueSerDes = _factory.BuildKeySerDes(); diff --git a/src/net/KNet/Specific/Streams/State/KNetWindowStoreIterator.cs b/src/net/KNet/Specific/Streams/State/KNetWindowStoreIterator.cs index 92f17904b7..2cf381bd7d 100644 --- a/src/net/KNet/Specific/Streams/State/KNetWindowStoreIterator.cs +++ b/src/net/KNet/Specific/Streams/State/KNetWindowStoreIterator.cs @@ -18,21 +18,20 @@ using MASES.JCOBridge.C2JBridge; using MASES.KNet.Serialization; -using Org.Apache.Kafka.Streams.State; namespace MASES.KNet.Streams.State { /// - /// KNet implementation of + /// KNet implementation of /// /// The value type public class KNetWindowStoreIterator : IGenericSerDesFactoryApplier { - readonly WindowStoreIterator _iterator; + readonly Org.Apache.Kafka.Streams.State.WindowStoreIterator _iterator; IGenericSerDesFactory _factory; IGenericSerDesFactory IGenericSerDesFactoryApplier.Factory { get => _factory; set { _factory = value; } } - internal KNetWindowStoreIterator(IGenericSerDesFactory factory, WindowStoreIterator iterator) + internal KNetWindowStoreIterator(IGenericSerDesFactory factory, Org.Apache.Kafka.Streams.State.WindowStoreIterator iterator) { _factory = factory; _iterator = iterator; @@ -41,7 +40,7 @@ internal KNetWindowStoreIterator(IGenericSerDesFactory factory, WindowStoreItera /// /// Converter from to /// - public static implicit operator KNetKeyValueIterator(KNetWindowStoreIterator t) => new KNetKeyValueIterator(t._factory, t._iterator.Cast>()); + public static implicit operator KNetKeyValueIterator(KNetWindowStoreIterator t) => new KNetKeyValueIterator(t._factory, t._iterator.Cast>()); /// /// KNet implementation of diff --git a/src/net/KNet/Specific/Streams/State/KNetWindowedKeyValueIterator.cs b/src/net/KNet/Specific/Streams/State/KNetWindowedKeyValueIterator.cs index 9a158e2edf..2e86ef463e 100644 --- a/src/net/KNet/Specific/Streams/State/KNetWindowedKeyValueIterator.cs +++ b/src/net/KNet/Specific/Streams/State/KNetWindowedKeyValueIterator.cs @@ -21,14 +21,12 @@ using MASES.JCOBridge.C2JBridge; using MASES.KNet.Serialization; using MASES.KNet.Streams.Kstream; -using Org.Apache.Kafka.Streams.Kstream; -using Org.Apache.Kafka.Streams.State; using System.Collections.Generic; namespace MASES.KNet.Streams.State { /// - /// KNet implementation of where K is + /// KNet implementation of where K is /// /// The key type /// The value type @@ -41,15 +39,15 @@ class LocalEnumerator(IGenericSerDesFactory factory, IJavaObject obj) : JVMBridg protected override object ConvertObject(object input) { - return new KNetWindowedKeyValue(_factory, input as Org.Apache.Kafka.Streams.KeyValue, byte[]>); + return new KNetWindowedKeyValue(_factory, input as Org.Apache.Kafka.Streams.KeyValue, byte[]>); } } - readonly KeyValueIterator, byte[]> _iterator; + readonly Org.Apache.Kafka.Streams.State.KeyValueIterator, byte[]> _iterator; IGenericSerDesFactory _factory; IGenericSerDesFactory IGenericSerDesFactoryApplier.Factory { get => _factory; set { _factory = value; } } - internal KNetWindowedKeyValueIterator(IGenericSerDesFactory factory, KeyValueIterator, byte[]> iterator) + internal KNetWindowedKeyValueIterator(IGenericSerDesFactory factory, Org.Apache.Kafka.Streams.State.KeyValueIterator, byte[]> iterator) { _factory = factory; _iterator = iterator; From a864ca76df213755a23dfb16f8e2e802bec00ee3 Mon Sep 17 00:00:00 2001 From: masesdevelopers <94312179+masesdevelopers@users.noreply.github.com> Date: Mon, 15 Jan 2024 03:59:03 +0100 Subject: [PATCH 11/18] Managed KNetKStream and added many classes --- .../Specific/Streams/Kstream/KNetConsumed.cs | 3 +- .../Streams/Kstream/KNetForeachAction.cs | 59 + .../Specific/Streams/Kstream/KNetGrouped.cs | 47 + .../Specific/Streams/Kstream/KNetJoined.cs | 47 + .../Streams/Kstream/KNetKBranchedKStream.cs | 48 + .../Streams/Kstream/KNetKGroupedStream.cs | 48 + .../Specific/Streams/Kstream/KNetKStream.cs | 1037 +++++++++++++++++ .../Streams/Kstream/KNetKeyValueMapper.cs | 152 +++ .../Specific/Streams/Kstream/KNetPrinted.cs | 46 + .../Specific/Streams/Kstream/KNetProduced.cs | 153 +++ .../Streams/Kstream/KNetRepartitioned.cs | 136 +++ .../Streams/Kstream/KNetStreamJoined.cs | 47 + .../Streams/Kstream/KNetValueJoiner.cs | 63 + .../Streams/Kstream/KNetValueJoinerWithKey.cs | 66 ++ .../Streams/Kstream/KNetValueMapper.cs | 105 ++ .../Streams/Kstream/KNetValueMapperWithKey.cs | 112 ++ .../KNetTimestampExtractor.cs | 2 +- 17 files changed, 2169 insertions(+), 2 deletions(-) create mode 100644 src/net/KNet/Specific/Streams/Kstream/KNetForeachAction.cs create mode 100644 src/net/KNet/Specific/Streams/Kstream/KNetGrouped.cs create mode 100644 src/net/KNet/Specific/Streams/Kstream/KNetJoined.cs create mode 100644 src/net/KNet/Specific/Streams/Kstream/KNetKBranchedKStream.cs create mode 100644 src/net/KNet/Specific/Streams/Kstream/KNetKGroupedStream.cs create mode 100644 src/net/KNet/Specific/Streams/Kstream/KNetKeyValueMapper.cs create mode 100644 src/net/KNet/Specific/Streams/Kstream/KNetPrinted.cs create mode 100644 src/net/KNet/Specific/Streams/Kstream/KNetProduced.cs create mode 100644 src/net/KNet/Specific/Streams/Kstream/KNetRepartitioned.cs create mode 100644 src/net/KNet/Specific/Streams/Kstream/KNetStreamJoined.cs create mode 100644 src/net/KNet/Specific/Streams/Kstream/KNetValueJoiner.cs create mode 100644 src/net/KNet/Specific/Streams/Kstream/KNetValueJoinerWithKey.cs create mode 100644 src/net/KNet/Specific/Streams/Kstream/KNetValueMapper.cs create mode 100644 src/net/KNet/Specific/Streams/Kstream/KNetValueMapperWithKey.cs rename src/net/KNet/Specific/Streams/{Kstream => Processor}/KNetTimestampExtractor.cs (98%) diff --git a/src/net/KNet/Specific/Streams/Kstream/KNetConsumed.cs b/src/net/KNet/Specific/Streams/Kstream/KNetConsumed.cs index 608a802bab..2a3a5f0dbe 100644 --- a/src/net/KNet/Specific/Streams/Kstream/KNetConsumed.cs +++ b/src/net/KNet/Specific/Streams/Kstream/KNetConsumed.cs @@ -37,7 +37,7 @@ public class KNetConsumed : IGenericSerDesFactoryApplier } /// - /// Converter from to + /// Converter from to /// public static implicit operator Org.Apache.Kafka.Streams.Kstream.Consumed(KNetConsumed t) => t._consumed; @@ -127,6 +127,7 @@ public KNetConsumed WithOffsetResetPolicy(Org.Apache.Kafka.Streams.Topolog /// public KNetConsumed WithTimestampExtractor(KNetTimestampExtractor arg0) { + if (arg0 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; _consumed?.WithTimestampExtractor(arg0); return this; } diff --git a/src/net/KNet/Specific/Streams/Kstream/KNetForeachAction.cs b/src/net/KNet/Specific/Streams/Kstream/KNetForeachAction.cs new file mode 100644 index 0000000000..44c4333e92 --- /dev/null +++ b/src/net/KNet/Specific/Streams/Kstream/KNetForeachAction.cs @@ -0,0 +1,59 @@ +/* +* Copyright 2023 MASES s.r.l. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +* Refer to LICENSE for more information. +*/ + +using MASES.KNet.Serialization; + +namespace MASES.KNet.Streams.Kstream +{ + /// + /// KNet extension of + /// + /// key value type + /// first value type + public class KNetForeachAction : Org.Apache.Kafka.Streams.Kstream.ForeachAction, IGenericSerDesFactoryApplier + { + IGenericSerDesFactory _factory; + IGenericSerDesFactory IGenericSerDesFactoryApplier.Factory { get => _factory; set { _factory = value; } } + + /// + /// Handler for + /// + /// If has a value it takes precedence over corresponding class method + public new System.Action OnApply { get; set; } = null; + + /// + public sealed override void Apply(byte[] arg0, byte[] arg1) + { + IKNetSerDes kSerializer = _factory.BuildKeySerDes(); + IKNetSerDes vSerializer = _factory.BuildValueSerDes(); + + var methodToExecute = (OnApply != null) ? OnApply : Apply; + methodToExecute(kSerializer.Deserialize(null, arg0), vSerializer.Deserialize(null, arg1)); + } + + /// + /// + /// + /// + /// + public virtual void Apply(K arg0, V arg1) + { + + } + } +} diff --git a/src/net/KNet/Specific/Streams/Kstream/KNetGrouped.cs b/src/net/KNet/Specific/Streams/Kstream/KNetGrouped.cs new file mode 100644 index 0000000000..77d4d7df60 --- /dev/null +++ b/src/net/KNet/Specific/Streams/Kstream/KNetGrouped.cs @@ -0,0 +1,47 @@ +/* +* Copyright 2023 MASES s.r.l. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +* Refer to LICENSE for more information. +*/ + +using MASES.KNet.Serialization; +using MASES.KNet.Streams.Processor; + +namespace MASES.KNet.Streams.Kstream +{ + /// + /// KNet extension of + /// + /// + /// + public class KNetGrouped : IGenericSerDesFactoryApplier + { + readonly Org.Apache.Kafka.Streams.Kstream.Grouped _produced; + IGenericSerDesFactory _factory; + IGenericSerDesFactory IGenericSerDesFactoryApplier.Factory { get => _factory; set { _factory = value; } } + + KNetGrouped(Org.Apache.Kafka.Streams.Kstream.Grouped produced) + { + _produced = produced; + } + + /// + /// Converter from to + /// + public static implicit operator Org.Apache.Kafka.Streams.Kstream.Grouped(KNetGrouped t) => t._produced; + +#warning shall be completed + } +} diff --git a/src/net/KNet/Specific/Streams/Kstream/KNetJoined.cs b/src/net/KNet/Specific/Streams/Kstream/KNetJoined.cs new file mode 100644 index 0000000000..b93d1e3433 --- /dev/null +++ b/src/net/KNet/Specific/Streams/Kstream/KNetJoined.cs @@ -0,0 +1,47 @@ +/* +* Copyright 2023 MASES s.r.l. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +* Refer to LICENSE for more information. +*/ + +using MASES.KNet.Serialization; + +namespace MASES.KNet.Streams.Kstream +{ + /// + /// KNet extension of + /// + /// + /// + /// + public class KNetJoined : IGenericSerDesFactoryApplier + { + readonly Org.Apache.Kafka.Streams.Kstream.Joined _produced; + IGenericSerDesFactory _factory; + IGenericSerDesFactory IGenericSerDesFactoryApplier.Factory { get => _factory; set { _factory = value; } } + + KNetJoined(Org.Apache.Kafka.Streams.Kstream.Joined produced) + { + _produced = produced; + } + + /// + /// Converter from to + /// + public static implicit operator Org.Apache.Kafka.Streams.Kstream.Joined(KNetJoined t) => t._produced; + +#warning shall be completed + } +} diff --git a/src/net/KNet/Specific/Streams/Kstream/KNetKBranchedKStream.cs b/src/net/KNet/Specific/Streams/Kstream/KNetKBranchedKStream.cs new file mode 100644 index 0000000000..cb60d7b4c2 --- /dev/null +++ b/src/net/KNet/Specific/Streams/Kstream/KNetKBranchedKStream.cs @@ -0,0 +1,48 @@ +/* +* Copyright 2023 MASES s.r.l. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +* Refer to LICENSE for more information. +*/ + +using MASES.KNet.Serialization; + +namespace MASES.KNet.Streams.Kstream +{ + /// + /// KNet extension of + /// + /// + /// + public class KNetBranchedKStream : IGenericSerDesFactoryApplier + { + Org.Apache.Kafka.Streams.Kstream.BranchedKStream _table; + + IGenericSerDesFactory _factory; + IGenericSerDesFactory IGenericSerDesFactoryApplier.Factory { get => _factory; set { _factory = value; } } + + internal KNetBranchedKStream(IGenericSerDesFactory factory, Org.Apache.Kafka.Streams.Kstream.BranchedKStream table) + { + _factory = factory; + _table = table; + } + + /// + /// Converter from to + /// + public static implicit operator Org.Apache.Kafka.Streams.Kstream.BranchedKStream(KNetBranchedKStream t) => t._table; + +#warning shall be completed + } +} diff --git a/src/net/KNet/Specific/Streams/Kstream/KNetKGroupedStream.cs b/src/net/KNet/Specific/Streams/Kstream/KNetKGroupedStream.cs new file mode 100644 index 0000000000..fb81f8f697 --- /dev/null +++ b/src/net/KNet/Specific/Streams/Kstream/KNetKGroupedStream.cs @@ -0,0 +1,48 @@ +/* +* Copyright 2023 MASES s.r.l. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +* Refer to LICENSE for more information. +*/ + +using MASES.KNet.Serialization; + +namespace MASES.KNet.Streams.Kstream +{ + /// + /// KNet extension of + /// + /// + /// + public class KNetKGroupedStream : IGenericSerDesFactoryApplier + { + Org.Apache.Kafka.Streams.Kstream.KGroupedStream _table; + + IGenericSerDesFactory _factory; + IGenericSerDesFactory IGenericSerDesFactoryApplier.Factory { get => _factory; set { _factory = value; } } + + internal KNetKGroupedStream(IGenericSerDesFactory factory, Org.Apache.Kafka.Streams.Kstream.KGroupedStream table) + { + _factory = factory; + _table = table; + } + + /// + /// Converter from to + /// + public static implicit operator Org.Apache.Kafka.Streams.Kstream.KGroupedStream(KNetKGroupedStream t) => t._table; + +#warning shall be completed + } +} diff --git a/src/net/KNet/Specific/Streams/Kstream/KNetKStream.cs b/src/net/KNet/Specific/Streams/Kstream/KNetKStream.cs index 325835849a..ee71bd2597 100644 --- a/src/net/KNet/Specific/Streams/Kstream/KNetKStream.cs +++ b/src/net/KNet/Specific/Streams/Kstream/KNetKStream.cs @@ -17,6 +17,7 @@ */ using MASES.KNet.Serialization; +using MASES.KNet.Streams.Processor; namespace MASES.KNet.Streams.Kstream { @@ -43,5 +44,1041 @@ internal KNetKStream(IGenericSerDesFactory factory, Org.Apache.Kafka.Streams.Kst /// public static implicit operator Org.Apache.Kafka.Streams.Kstream.KStream(KNetKStream t) => t._stream; + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public KNetKStream Join(KNetGlobalKTable arg0, KNetKeyValueMapper arg1, KNetValueJoiner arg2, Org.Apache.Kafka.Streams.Kstream.Named arg3) where Arg1objectSuperK : K where Arg1objectSuperV : V where Arg1ExtendsGK : GK where Arg2objectSuperV : V where Arg2objectSuperGV : GV where Arg2ExtendsRV : RV + { + if (arg1 is IGenericSerDesFactoryApplier applier1) applier1.Factory = _factory; + if (arg2 is IGenericSerDesFactoryApplier applier2) applier2.Factory = _factory; + return new KNetKStream(_factory, _stream.Join(arg0, arg1, arg2, arg3)); + } + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public KNetKStream Join(KNetGlobalKTable arg0, KNetKeyValueMapper arg1, KNetValueJoiner arg2) where Arg1objectSuperK : K where Arg1objectSuperV : V where Arg1ExtendsGK : GK where Arg2objectSuperV : V where Arg2objectSuperGV : GV where Arg2ExtendsRV : RV + { + if (arg1 is IGenericSerDesFactoryApplier applier1) applier1.Factory = _factory; + if (arg2 is IGenericSerDesFactoryApplier applier2) applier2.Factory = _factory; + return new KNetKStream(_factory, _stream.Join(arg0, arg1, arg2)); + } + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public KNetKStream Join(KNetGlobalKTable arg0, KNetKeyValueMapper arg1, KNetValueJoinerWithKey arg2, Org.Apache.Kafka.Streams.Kstream.Named arg3) where Arg1objectSuperK : K where Arg1objectSuperV : V where Arg1ExtendsGK : GK where Arg2objectSuperK : K where Arg2objectSuperV : V where Arg2objectSuperGV : GV where Arg2ExtendsRV : RV + { + if (arg1 is IGenericSerDesFactoryApplier applier1) applier1.Factory = _factory; + if (arg2 is IGenericSerDesFactoryApplier applier2) applier2.Factory = _factory; + return new KNetKStream(_factory, _stream.Join(arg0, arg1, arg2, arg3)); + } + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public KNetKStream Join(KNetGlobalKTable arg0, KNetKeyValueMapper arg1, KNetValueJoinerWithKey arg2) where Arg1objectSuperK : K where Arg1objectSuperV : V where Arg1ExtendsGK : GK where Arg2objectSuperK : K where Arg2objectSuperV : V where Arg2objectSuperGV : GV where Arg2ExtendsRV : RV + { + if (arg1 is IGenericSerDesFactoryApplier applier1) applier1.Factory = _factory; + if (arg2 is IGenericSerDesFactoryApplier applier2) applier2.Factory = _factory; + return new KNetKStream(_factory, _stream.Join(arg0, arg1, arg2)); + } + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public KNetKStream LeftJoin(KNetGlobalKTable arg0, KNetKeyValueMapper arg1, KNetValueJoiner arg2, Org.Apache.Kafka.Streams.Kstream.Named arg3) where Arg1objectSuperK : K where Arg1objectSuperV : V where Arg1ExtendsGK : GK where Arg2objectSuperV : V where Arg2objectSuperGV : GV where Arg2ExtendsRV : RV + { + if (arg1 is IGenericSerDesFactoryApplier applier1) applier1.Factory = _factory; + if (arg2 is IGenericSerDesFactoryApplier applier2) applier2.Factory = _factory; + return new KNetKStream(_factory, _stream.LeftJoin(arg0, arg1, arg2, arg3)); + } + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public KNetKStream LeftJoin(KNetGlobalKTable arg0, KNetKeyValueMapper arg1, KNetValueJoiner arg2) where Arg1objectSuperK : K where Arg1objectSuperV : V where Arg1ExtendsGK : GK where Arg2objectSuperV : V where Arg2objectSuperGV : GV where Arg2ExtendsRV : RV + { + if (arg1 is IGenericSerDesFactoryApplier applier1) applier1.Factory = _factory; + if (arg2 is IGenericSerDesFactoryApplier applier2) applier2.Factory = _factory; + return new KNetKStream(_factory, _stream.LeftJoin(arg0, arg1, arg2)); + } + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public KNetKStream LeftJoin(KNetGlobalKTable arg0, KNetKeyValueMapper arg1, KNetValueJoinerWithKey arg2, Org.Apache.Kafka.Streams.Kstream.Named arg3) where Arg1objectSuperK : K where Arg1objectSuperV : V where Arg1ExtendsGK : GK where Arg2objectSuperK : K where Arg2objectSuperV : V where Arg2objectSuperGV : GV where Arg2ExtendsRV : RV + { + if (arg1 is IGenericSerDesFactoryApplier applier1) applier1.Factory = _factory; + if (arg2 is IGenericSerDesFactoryApplier applier2) applier2.Factory = _factory; + return new KNetKStream(_factory, _stream.LeftJoin(arg0, arg1, arg2, arg3)); + } + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public KNetKStream LeftJoin(KNetGlobalKTable arg0, KNetKeyValueMapper arg1, KNetValueJoinerWithKey arg2) where Arg1objectSuperK : K where Arg1objectSuperV : V where Arg1ExtendsGK : GK where Arg2objectSuperK : K where Arg2objectSuperV : V where Arg2objectSuperGV : GV where Arg2ExtendsRV : RV + { + if (arg1 is IGenericSerDesFactoryApplier applier1) applier1.Factory = _factory; + if (arg2 is IGenericSerDesFactoryApplier applier2) applier2.Factory = _factory; + return new KNetKStream(_factory, _stream.LeftJoin(arg0, arg1, arg2)); + } + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public KNetKStream FlatMap(KNetEnumerableKeyValueMapper arg0, Org.Apache.Kafka.Streams.Kstream.Named arg1) where Arg0objectSuperK : K where Arg0objectSuperV : V where Arg0ExtendsKR : KR where Arg0ExtendsVR : VR + { + if (arg0 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; + return new KNetKStream(_factory, _stream.FlatMap>, Org.Apache.Kafka.Streams.KeyValue, byte[], byte[]>(arg0, arg1)); + } + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public KNetKStream FlatMap(KNetEnumerableKeyValueMapper arg0) where Arg0objectSuperK : K where Arg0objectSuperV : V where Arg0ExtendsKR : KR where Arg0ExtendsVR : VR + { + if (arg0 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; + return new KNetKStream(_factory, _stream.FlatMap>, Org.Apache.Kafka.Streams.KeyValue, byte[], byte[]>(arg0)); + } + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public KNetKStream Map(KNetKeyValueKeyValueMapper arg0, Org.Apache.Kafka.Streams.Kstream.Named arg1) where Arg0objectSuperK : K where Arg0objectSuperV : V where Arg0ExtendsKR : KR where Arg0ExtendsVR : VR + { + if (arg0 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; + return new KNetKStream(_factory, _stream.Map, byte[], byte[]>(arg0, arg1)); + } + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public KNetKStream Map(KNetKeyValueKeyValueMapper arg0) where Arg0objectSuperK : K where Arg0objectSuperV : V where Arg0ExtendsKR : KR where Arg0ExtendsVR : VR + { + if (arg0 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; + return new KNetKStream(_factory, _stream.Map, byte[], byte[]>(arg0)); + } + /// + /// + /// + /// + /// + /// + /// + /// + /// + public KNetKGroupedStream GroupBy(KNetKeyValueMapper arg0, KNetGrouped arg1) where Arg0objectSuperK : K where Arg0objectSuperV : V + { + if (arg0 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; + if (arg1 is IGenericSerDesFactoryApplier applier1) applier1.Factory = _factory; + return new KNetKGroupedStream(_factory, _stream.GroupBy(arg0, arg1)); + } + /// + /// + /// + /// + /// + /// + /// + /// + public KNetKGroupedStream GroupBy(KNetKeyValueMapper arg0) where Arg0objectSuperK : K where Arg0objectSuperV : V + { + if (arg0 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; + return new KNetKGroupedStream(_factory, _stream.GroupBy(arg0)); + } + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public KNetKStream SelectKey(KNetKeyValueMapper arg0, Org.Apache.Kafka.Streams.Kstream.Named arg1) where Arg0objectSuperK : K where Arg0objectSuperV : V where Arg0ExtendsKR : KR + { + if (arg0 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; + return new KNetKStream(_factory, _stream.SelectKey(arg0, arg1)); + } + /// + /// + /// + /// + /// + /// + /// + /// + /// + public KNetKStream SelectKey(KNetKeyValueMapper arg0) where Arg0objectSuperK : K where Arg0objectSuperV : V where Arg0ExtendsKR : KR + { + if (arg0 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; + return new KNetKStream(_factory, _stream.SelectKey(arg0)); + } + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public KNetKStream Join(KNetKStream arg0, KNetValueJoiner arg1, Org.Apache.Kafka.Streams.Kstream.JoinWindows arg2, KNetStreamJoined arg3) where Arg1objectSuperV : V where Arg1objectSuperVO : VO where Arg1ExtendsVR : VR + { + if (arg1 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; + if (arg3 is IGenericSerDesFactoryApplier applier3) applier3.Factory = _factory; + return new KNetKStream(_factory, _stream.Join(arg0, arg1, arg2, arg3)); + } + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public KNetKStream Join(KNetKStream arg0, KNetValueJoiner arg1, Org.Apache.Kafka.Streams.Kstream.JoinWindows arg2) where Arg1objectSuperV : V where Arg1objectSuperVO : VO where Arg1ExtendsVR : VR + { + if (arg1 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; + return new KNetKStream(_factory, _stream.Join(arg0, arg1, arg2)); + } + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public KNetKStream Join(KNetKStream arg0, KNetValueJoinerWithKey arg1, Org.Apache.Kafka.Streams.Kstream.JoinWindows arg2, KNetStreamJoined arg3) where Arg1objectSuperK : K where Arg1objectSuperV : V where Arg1objectSuperVO : VO where Arg1ExtendsVR : VR + { + if (arg1 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; + if (arg3 is IGenericSerDesFactoryApplier applier3) applier3.Factory = _factory; + return new KNetKStream(_factory, _stream.Join(arg0, arg1, arg2, arg3)); + } + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public KNetKStream Join(KNetKStream arg0, KNetValueJoinerWithKey arg1, Org.Apache.Kafka.Streams.Kstream.JoinWindows arg2) where Arg1objectSuperK : K where Arg1objectSuperV : V where Arg1objectSuperVO : VO where Arg1ExtendsVR : VR + { + if (arg1 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; + return new KNetKStream(_factory, _stream.LeftJoin(arg0, arg1, arg2)); + } + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public KNetKStream LeftJoin(KNetKStream arg0, KNetValueJoiner arg1, Org.Apache.Kafka.Streams.Kstream.JoinWindows arg2, KNetStreamJoined arg3) where Arg1objectSuperV : V where Arg1objectSuperVO : VO where Arg1ExtendsVR : VR + { + if (arg1 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; + if (arg3 is IGenericSerDesFactoryApplier applier3) applier3.Factory = _factory; + return new KNetKStream(_factory, _stream.LeftJoin(arg0, arg1, arg2, arg3)); + } + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public KNetKStream LeftJoin(KNetKStream arg0, KNetValueJoiner arg1, Org.Apache.Kafka.Streams.Kstream.JoinWindows arg2) where Arg1objectSuperV : V where Arg1objectSuperVO : VO where Arg1ExtendsVR : VR + { + if (arg1 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; + return new KNetKStream(_factory, _stream.LeftJoin(arg0, arg1, arg2)); + } + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public KNetKStream LeftJoin(KNetKStream arg0, KNetValueJoinerWithKey arg1, Org.Apache.Kafka.Streams.Kstream.JoinWindows arg2, KNetStreamJoined arg3) where Arg1objectSuperK : K where Arg1objectSuperV : V where Arg1objectSuperVO : VO where Arg1ExtendsVR : VR + { + if (arg1 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; + if (arg3 is IGenericSerDesFactoryApplier applier3) applier3.Factory = _factory; + return new KNetKStream(_factory, _stream.LeftJoin(arg0, arg1, arg2, arg3)); + } + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public KNetKStream LeftJoin(KNetKStream arg0, KNetValueJoinerWithKey arg1, Org.Apache.Kafka.Streams.Kstream.JoinWindows arg2) where Arg1objectSuperK : K where Arg1objectSuperV : V where Arg1objectSuperVO : VO where Arg1ExtendsVR : VR + { + if (arg1 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; + return new KNetKStream(_factory, _stream.LeftJoin(arg0, arg1, arg2)); + } + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public KNetKStream OuterJoin(KNetKStream arg0, KNetValueJoiner arg1, Org.Apache.Kafka.Streams.Kstream.JoinWindows arg2, KNetStreamJoined arg3) where Arg1objectSuperV : V where Arg1objectSuperVO : VO where Arg1ExtendsVR : VR + { + if (arg1 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; + if (arg3 is IGenericSerDesFactoryApplier applier3) applier3.Factory = _factory; + return new KNetKStream(_factory, _stream.OuterJoin(arg0, arg1, arg2, arg3)); + } + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public KNetKStream OuterJoin(KNetKStream arg0, KNetValueJoiner arg1, Org.Apache.Kafka.Streams.Kstream.JoinWindows arg2) where Arg1objectSuperV : V where Arg1objectSuperVO : VO where Arg1ExtendsVR : VR + { + if (arg1 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; + return new KNetKStream(_factory, _stream.OuterJoin(arg0, arg1, arg2)); + } + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public KNetKStream OuterJoin(KNetKStream arg0, KNetValueJoinerWithKey arg1, Org.Apache.Kafka.Streams.Kstream.JoinWindows arg2, KNetStreamJoined arg3) where Arg1objectSuperK : K where Arg1objectSuperV : V where Arg1objectSuperVO : VO where Arg1ExtendsVR : VR + { + if (arg1 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; + if (arg3 is IGenericSerDesFactoryApplier applier3) applier3.Factory = _factory; + return new KNetKStream(_factory, _stream.OuterJoin(arg0, arg1, arg2, arg3)); + } + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public KNetKStream OuterJoin(KNetKStream arg0, KNetValueJoinerWithKey arg1, Org.Apache.Kafka.Streams.Kstream.JoinWindows arg2) where Arg1objectSuperK : K where Arg1objectSuperV : V where Arg1objectSuperVO : VO where Arg1ExtendsVR : VR + { + if (arg1 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; + return new KNetKStream(_factory, _stream.OuterJoin(arg0, arg1, arg2)); + } + /// + /// + /// + /// + /// + /// + /// + /// + /// + public KNetKStream FlatMapValues(KNetEnumerableValueMapper arg0, Org.Apache.Kafka.Streams.Kstream.Named arg1) where Arg0objectSuperV : V where Arg0ExtendsVR : VR + { + if (arg0 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; + return new KNetKStream(_factory, _stream.FlatMapValues, byte[]>(arg0, arg1)); + } + /// + /// + /// + /// + /// + /// + /// + /// + public KNetKStream FlatMapValues(KNetEnumerableValueMapper arg0) where Arg0objectSuperV : V where Arg0ExtendsVR : VR + { + if (arg0 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; + return new KNetKStream(_factory, _stream.FlatMapValues, byte[]>(arg0)); + } + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public KNetKStream FlatMapValues(KNetEnumerableValueMapperWithKey arg0, Org.Apache.Kafka.Streams.Kstream.Named arg1) where Arg0objectSuperK : K where Arg0objectSuperV : V where Arg0ExtendsVR : VR + { + if (arg0 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; + return new KNetKStream(_factory, _stream.FlatMapValues, byte[]>(arg0, arg1)); + } + /// + /// + /// + /// + /// + /// + /// + /// + /// + public KNetKStream FlatMapValues(KNetEnumerableValueMapperWithKey arg0) where Arg0objectSuperK : K where Arg0objectSuperV : V where Arg0ExtendsVR : VR + { + if (arg0 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; + return new KNetKStream(_factory, _stream.FlatMapValues, byte[]>(arg0)); + } + /// + /// + /// + /// + /// + /// + /// + /// + /// + public KNetKStream MapValues(KNetValueMapper arg0, Org.Apache.Kafka.Streams.Kstream.Named arg1) where Arg0objectSuperV : V where Arg0ExtendsVR : VR + { + if (arg0 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; + return new KNetKStream(_factory, _stream.MapValues(arg0)); + } + /// + /// + /// + /// + /// + /// + /// + /// + public KNetKStream MapValues(KNetValueMapper arg0) where Arg0objectSuperV : V where Arg0ExtendsVR : VR + { + if (arg0 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; + return new KNetKStream(_factory, _stream.MapValues(arg0)); + } + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public KNetKStream MapValues(KNetValueMapperWithKey arg0, Org.Apache.Kafka.Streams.Kstream.Named arg1) where Arg0objectSuperK : K where Arg0objectSuperV : V where Arg0ExtendsVR : VR + { + if (arg0 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; + return new KNetKStream(_factory, _stream.MapValues(arg0, arg1)); + } + /// + /// + /// + /// + /// + /// + /// + /// + /// + public KNetKStream MapValues(KNetValueMapperWithKey arg0) where Arg0objectSuperK : K where Arg0objectSuperV : V where Arg0ExtendsVR : VR + { + if (arg0 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; + return new KNetKStream(_factory, _stream.MapValues(arg0)); + } + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public KNetKStream Join(KNetKTable arg0, KNetValueJoiner arg1, KNetJoined arg2) where Arg1objectSuperV : V where Arg1objectSuperVT : VT where Arg1ExtendsVR : VR + { + if (arg1 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; + if (arg2 is IGenericSerDesFactoryApplier applier2) applier2.Factory = _factory; + return new KNetKStream(_factory, _stream.Join(arg0, arg1, arg2)); + } + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public KNetKStream Join(KNetKTable arg0, KNetValueJoiner arg1) where Arg1objectSuperV : V where Arg1objectSuperVT : VT where Arg1ExtendsVR : VR + { + if (arg1 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; + return new KNetKStream(_factory, _stream.Join(arg0, arg1)); + } + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public KNetKStream Join(KNetKTable arg0, KNetValueJoinerWithKey arg1, KNetJoined arg2) where Arg1objectSuperK : K where Arg1objectSuperV : V where Arg1objectSuperVT : VT where Arg1ExtendsVR : VR + { + if (arg1 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; + if (arg2 is IGenericSerDesFactoryApplier applier2) applier2.Factory = _factory; + return new KNetKStream(_factory, _stream.Join(arg0, arg1, arg2)); + } + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public KNetKStream Join(KNetKTable arg0, KNetValueJoinerWithKey arg1) where Arg1objectSuperK : K where Arg1objectSuperV : V where Arg1objectSuperVT : VT where Arg1ExtendsVR : VR + { + if (arg1 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; + return new KNetKStream(_factory, _stream.LeftJoin(arg0, arg1)); + } + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public KNetKStream LeftJoin(KNetKTable arg0, KNetValueJoiner arg1, KNetJoined arg2) where Arg1objectSuperV : V where Arg1objectSuperVT : VT where Arg1ExtendsVR : VR + { + if (arg1 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; + if (arg2 is IGenericSerDesFactoryApplier applier2) applier2.Factory = _factory; + return new KNetKStream(_factory, _stream.LeftJoin(arg0, arg1, arg2)); + } + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public KNetKStream LeftJoin(KNetKTable arg0, KNetValueJoiner arg1) where Arg1objectSuperV : V where Arg1objectSuperVT : VT where Arg1ExtendsVR : VR + { + if (arg1 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; + return new KNetKStream(_factory, _stream.LeftJoin(arg0, arg1)); + } + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public KNetKStream LeftJoin(KNetKTable arg0, KNetValueJoinerWithKey arg1, KNetJoined arg2) where Arg1objectSuperK : K where Arg1objectSuperV : V where Arg1objectSuperVT : VT where Arg1ExtendsVR : VR + { + if (arg1 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; + return new KNetKStream(_factory, _stream.LeftJoin(arg0, arg1, arg2)); + } + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public KNetKStream LeftJoin(KNetKTable arg0, KNetValueJoinerWithKey arg1) where Arg1objectSuperK : K where Arg1objectSuperV : V where Arg1objectSuperVT : VT where Arg1ExtendsVR : VR + { + if (arg1 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; + return new KNetKStream(_factory, _stream.LeftJoin(arg0, arg1)); + } + /// + /// + /// + /// + public KNetBranchedKStream Split() + { + return new KNetBranchedKStream(_factory, _stream.Split()); + } + /// + /// + /// + /// + /// + public KNetBranchedKStream Split(Org.Apache.Kafka.Streams.Kstream.Named arg0) + { + return new KNetBranchedKStream(_factory, _stream.Split(arg0)); + } + /// + /// + /// + /// + public KNetKGroupedStream GroupByKey() + { + return new KNetKGroupedStream(_factory, _stream.GroupByKey()); + } + /// + /// + /// + /// + /// + public KNetKGroupedStream GroupByKey(KNetGrouped arg0) + { + if (arg0 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; + return new KNetKGroupedStream(_factory, _stream.GroupByKey(arg0)); + } + /// + /// + /// + /// + /// + /// + /// + /// + public KNetKStream Filter(KNetPredicate arg0, Org.Apache.Kafka.Streams.Kstream.Named arg1) where Arg0objectSuperK : K where Arg0objectSuperV : V + { + if (arg0 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; + return new KNetKStream(_factory, _stream.Filter(arg0, arg1)); + } + /// + /// + /// + /// + /// + /// + /// + public KNetKStream Filter(KNetPredicate arg0) where Arg0objectSuperK : K where Arg0objectSuperV : V + { + if (arg0 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; + return new KNetKStream(_factory, _stream.Filter(arg0)); + } + /// + /// + /// + /// + /// + /// + /// + /// + public KNetKStream FilterNot(KNetPredicate arg0, Org.Apache.Kafka.Streams.Kstream.Named arg1) where Arg0objectSuperK : K where Arg0objectSuperV : V + { + if (arg0 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; + return new KNetKStream(_factory, _stream.FilterNot(arg0, arg1)); + } + /// + /// + /// + /// + /// + /// + /// + public KNetKStream FilterNot(KNetPredicate arg0) where Arg0objectSuperK : K where Arg0objectSuperV : V + { + if (arg0 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; + return new KNetKStream(_factory, _stream.FilterNot(arg0)); + } + /// + /// + /// + /// + /// + /// + public KNetKStream Merge(KNetKStream arg0, Org.Apache.Kafka.Streams.Kstream.Named arg1) + { + return new KNetKStream(_factory, _stream.Merge(arg0, arg1)); + } + /// + /// + /// + /// + /// + public KNetKStream Merge(KNetKStream arg0) + { + return new KNetKStream(_factory, _stream.Merge(arg0)); + } + /// + /// + /// + /// + /// + /// + /// + /// + public KNetKStream Peek(KNetForeachAction arg0, Org.Apache.Kafka.Streams.Kstream.Named arg1) where Arg0objectSuperK : K where Arg0objectSuperV : V + { + if (arg0 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; + return new KNetKStream(_factory, _stream.Peek(arg0, arg1)); + } + /// + /// + /// + /// + /// + /// + /// + public KNetKStream Peek(KNetForeachAction arg0) where Arg0objectSuperK : K where Arg0objectSuperV : V + { + if (arg0 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; + return new KNetKStream(_factory, _stream.Peek(arg0)); + } + /// + /// + /// + /// + public KNetKStream Repartition() + { + return new KNetKStream(_factory, _stream.Repartition()); + } + /// + /// + /// + /// + /// + public KNetKStream Repartition(KNetRepartitioned arg0) + { + if (arg0 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; + return new KNetKStream(_factory, _stream.Repartition(arg0)); + } + /// + /// + /// + + /// + public KNetKTable ToTable() + { + return new KNetKTable(_factory, _stream.ToTable()); + } + /// + /// + /// + /// + /// + public KNetKTable ToTable(KNetMaterialized arg0) + { + if (arg0 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; + return new KNetKTable(_factory, _stream.ToTable(arg0)); + } + /// + /// + /// + /// + /// + /// + public KNetKTable ToTable(Org.Apache.Kafka.Streams.Kstream.Named arg0, KNetMaterialized arg1) + { + if (arg1 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; + return new KNetKTable(_factory, _stream.ToTable(arg0, arg1)); + } + /// + /// + /// + /// + /// + public KNetKTable ToTable(Org.Apache.Kafka.Streams.Kstream.Named arg0) + { + return new KNetKTable(_factory, _stream.ToTable(arg0)); + } + /// + /// + /// + /// + /// + /// + /// + public void Foreach(KNetForeachAction arg0, Org.Apache.Kafka.Streams.Kstream.Named arg1) where Arg0objectSuperK : K where Arg0objectSuperV : V + { + if (arg0 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; + _stream.Foreach(arg0, arg1); + } + /// + /// + /// + /// + /// + /// + public void Foreach(KNetForeachAction arg0) where Arg0objectSuperK : K where Arg0objectSuperV : V + { + if (arg0 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; + _stream.Foreach(arg0); + } + /// + /// + /// + /// + public void Print(KNetPrinted arg0) + { + if (arg0 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; + _stream.Print(arg0); + } + /// + /// + /// + /// + /// + public void To(string arg0, KNetProduced arg1) + { + if (arg1 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; + _stream.To(arg0, arg1); + } + /// + /// + /// + /// + public void To(string arg0) + { + _stream.To(arg0); + } + /// + /// + /// + /// + /// + public void To(KNetTopicNameExtractor arg0, KNetProduced arg1) + { + if (arg0 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; + if (arg1 is IGenericSerDesFactoryApplier applier1) applier1.Factory = _factory; + _stream.To(arg0, arg1); + } + /// + /// + /// + /// + public void To(KNetTopicNameExtractor arg0) + { + if (arg0 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; + _stream.To(arg0); + } } } diff --git a/src/net/KNet/Specific/Streams/Kstream/KNetKeyValueMapper.cs b/src/net/KNet/Specific/Streams/Kstream/KNetKeyValueMapper.cs new file mode 100644 index 0000000000..d7448bab7e --- /dev/null +++ b/src/net/KNet/Specific/Streams/Kstream/KNetKeyValueMapper.cs @@ -0,0 +1,152 @@ +/* +* Copyright 2023 MASES s.r.l. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +* Refer to LICENSE for more information. +*/ + +using Java.Util; +using MASES.KNet.Serialization; +using System.Collections; +using System.Collections.Generic; + +namespace MASES.KNet.Streams.Kstream +{ + /// + /// KNet extension of + /// + /// key value type + /// first value type + /// joined value type + public class KNetKeyValueMapper : Org.Apache.Kafka.Streams.Kstream.KeyValueMapper, IGenericSerDesFactoryApplier + { + IGenericSerDesFactory _factory; + IGenericSerDesFactory IGenericSerDesFactoryApplier.Factory { get => _factory; set { _factory = value; } } + + /// + /// Handler for + /// + /// If has a value it takes precedence over corresponding class method + public new System.Func OnApply { get; set; } = null; + /// + public sealed override byte[] Apply(byte[] arg0, byte[] arg1) + { + IKNetSerDes kSerializer = _factory.BuildKeySerDes(); + IKNetSerDes vSerializer = _factory.BuildValueSerDes(); + IKNetSerDes vrSerializer = _factory.BuildValueSerDes(); + + var methodToExecute = (OnApply != null) ? OnApply : Apply; + var res = methodToExecute(kSerializer.Deserialize(null, arg0), vSerializer.Deserialize(null, arg1)); + return vrSerializer.Serialize(null, res); + } + /// + /// + /// + /// + /// + /// + public virtual VR Apply(K arg0, V arg1) + { + return default; + } + } + + /// + /// KNet extension of + /// + /// key value type + /// first value type + /// first value type + /// joined value type + public class KNetKeyValueKeyValueMapper : Org.Apache.Kafka.Streams.Kstream.KeyValueMapper>, IGenericSerDesFactoryApplier + { + IGenericSerDesFactory _factory; + IGenericSerDesFactory IGenericSerDesFactoryApplier.Factory { get => _factory; set { _factory = value; } } + + /// + /// Handler for + /// + /// If has a value it takes precedence over corresponding class method + public new System.Func OnApply { get; set; } = null; + /// + public sealed override Org.Apache.Kafka.Streams.KeyValue Apply(byte[] arg0, byte[] arg1) + { + IKNetSerDes kSerializer = _factory.BuildKeySerDes(); + IKNetSerDes vSerializer = _factory.BuildValueSerDes(); + IKNetSerDes krSerializer = _factory.BuildValueSerDes(); + IKNetSerDes vrSerializer = _factory.BuildValueSerDes(); + + var methodToExecute = (OnApply != null) ? OnApply : Apply; + var res = methodToExecute(kSerializer.Deserialize(null, arg0), vSerializer.Deserialize(null, arg1)); + return new Org.Apache.Kafka.Streams.KeyValue(krSerializer.Serialize(null, res.Item1), vrSerializer.Serialize(null, res.Item2)); ; + } + /// + /// + /// + /// + /// + /// + public virtual (KR, VR) Apply(K arg0, V arg1) + { + return default; + } + } + + /// + /// KNet extension of + /// + /// key value type + /// first value type + /// first value type + /// joined value type + public class KNetEnumerableKeyValueMapper : Org.Apache.Kafka.Streams.Kstream.KeyValueMapper>>, IGenericSerDesFactoryApplier + { + IGenericSerDesFactory _factory; + IGenericSerDesFactory IGenericSerDesFactoryApplier.Factory { get => _factory; set { _factory = value; } } + + /// + /// Handler for + /// + /// If has a value it takes precedence over corresponding class method + public new System.Func> OnApply { get; set; } = null; + /// + public sealed override Java.Lang.Iterable> Apply(byte[] arg0, byte[] arg1) + { + IKNetSerDes kSerializer = _factory.BuildKeySerDes(); + IKNetSerDes vSerializer = _factory.BuildValueSerDes(); + IKNetSerDes krSerializer = _factory.BuildValueSerDes(); + IKNetSerDes vrSerializer = _factory.BuildValueSerDes(); + + var methodToExecute = (OnApply != null) ? OnApply : Apply; + var res = methodToExecute(kSerializer.Deserialize(null, arg0), vSerializer.Deserialize(null, arg1)); + var result = new ArrayList>(); + foreach (var item in res) + { + var data = new Org.Apache.Kafka.Streams.KeyValue(krSerializer.Serialize(null, item.Item1), vrSerializer.Serialize(null, item.Item2)); + result.Add(data); + } + return result; + } + /// + /// + /// + /// + /// + /// + public virtual IEnumerable<(KR, VR)> Apply(K arg0, V arg1) + { + return default; + } + } +} diff --git a/src/net/KNet/Specific/Streams/Kstream/KNetPrinted.cs b/src/net/KNet/Specific/Streams/Kstream/KNetPrinted.cs new file mode 100644 index 0000000000..67cd379996 --- /dev/null +++ b/src/net/KNet/Specific/Streams/Kstream/KNetPrinted.cs @@ -0,0 +1,46 @@ +/* +* Copyright 2023 MASES s.r.l. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +* Refer to LICENSE for more information. +*/ + +using MASES.KNet.Serialization; + +namespace MASES.KNet.Streams.Kstream +{ + /// + /// KNet extension of + /// + /// + /// + public class KNetPrinted : IGenericSerDesFactoryApplier + { + readonly Org.Apache.Kafka.Streams.Kstream.Printed _inner; + IGenericSerDesFactory _factory; + IGenericSerDesFactory IGenericSerDesFactoryApplier.Factory { get => _factory; set { _factory = value; } } + + KNetPrinted(Org.Apache.Kafka.Streams.Kstream.Printed inner) + { + _inner = inner; + } + + /// + /// Converter from to + /// + public static implicit operator Org.Apache.Kafka.Streams.Kstream.Printed(KNetPrinted t) => t._inner; + +#warning shall be completed + } +} diff --git a/src/net/KNet/Specific/Streams/Kstream/KNetProduced.cs b/src/net/KNet/Specific/Streams/Kstream/KNetProduced.cs new file mode 100644 index 0000000000..4ad8b499e4 --- /dev/null +++ b/src/net/KNet/Specific/Streams/Kstream/KNetProduced.cs @@ -0,0 +1,153 @@ +/* +* Copyright 2023 MASES s.r.l. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +* Refer to LICENSE for more information. +*/ + +using MASES.KNet.Serialization; +using MASES.KNet.Streams.Processor; + +namespace MASES.KNet.Streams.Kstream +{ + /// + /// KNet extension of + /// + /// + /// + public class KNetProduced : IGenericSerDesFactoryApplier + { + readonly Org.Apache.Kafka.Streams.Kstream.Produced _produced; + IGenericSerDesFactory _factory; + IGenericSerDesFactory IGenericSerDesFactoryApplier.Factory { get => _factory; set { _factory = value; } } + + KNetProduced(Org.Apache.Kafka.Streams.Kstream.Produced produced) + { + _produced = produced; + } + + /// + /// Converter from to + /// + public static implicit operator Org.Apache.Kafka.Streams.Kstream.Produced(KNetProduced t) => t._produced; + + #region Static methods + /// + /// + /// + /// + /// + public static KNetProduced As(string arg0) + { + var cons = Org.Apache.Kafka.Streams.Kstream.Produced.As(arg0); + return new KNetProduced(cons); + } + /// + /// + /// + /// + /// + public static KNetProduced KeySerde(IKNetSerDes arg0) + { + var cons = Org.Apache.Kafka.Streams.Kstream.Produced.KeySerde(arg0.KafkaSerde); + return new KNetProduced(cons); + } + /// + /// + /// + /// + /// + /// + /// + public static KNetProduced StreamPartitioner(KNetStreamPartitioner arg0) where Arg0objectSuperK : K where Arg0objectSuperV : V + { + var cons = Org.Apache.Kafka.Streams.Kstream.Produced.StreamPartitioner(arg0); + return new KNetProduced(cons); + } + /// + /// + /// + /// + /// + public static KNetProduced ValueSerde(IKNetSerDes arg0) + { + var cons = Org.Apache.Kafka.Streams.Kstream.Produced.ValueSerde(arg0.KafkaSerde); + return new KNetProduced(cons); + } + /// + /// + /// + /// + /// + /// + /// + /// + /// + public static KNetProduced With(IKNetSerDes arg0, IKNetSerDes arg1, KNetStreamPartitioner arg2) where Arg2objectSuperK : K where Arg2objectSuperV : V + { + var cons = Org.Apache.Kafka.Streams.Kstream.Produced.With(arg0.KafkaSerde, arg1.KafkaSerde, arg2); + return new KNetProduced(cons); + } + /// + /// + /// + /// + /// + /// + public static KNetProduced With(IKNetSerDes arg0, IKNetSerDes arg1) + { + var cons = Org.Apache.Kafka.Streams.Kstream.Produced.With(arg0.KafkaSerde, arg1.KafkaSerde); + return new KNetProduced(cons); + } + + #endregion + + #region Instance methods + /// + /// + /// + /// + /// + public KNetProduced WithKeySerde(IKNetSerDes arg0) + { + _produced?.WithKeySerde(arg0.KafkaSerde); + return this; + } + /// + /// + /// + /// + /// + /// + /// + public KNetProduced WithStreamPartitioner(KNetStreamPartitioner arg0) where Arg0objectSuperK : K where Arg0objectSuperV : V + { + if (arg0 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; + _produced?.WithStreamPartitioner(arg0); + return this; + } + /// + /// + /// + /// + /// + public KNetProduced WithValueSerde(IKNetSerDes arg0) + { + _produced?.WithValueSerde(arg0.KafkaSerde); + return this; + } + + #endregion + } +} diff --git a/src/net/KNet/Specific/Streams/Kstream/KNetRepartitioned.cs b/src/net/KNet/Specific/Streams/Kstream/KNetRepartitioned.cs new file mode 100644 index 0000000000..2a3da1e407 --- /dev/null +++ b/src/net/KNet/Specific/Streams/Kstream/KNetRepartitioned.cs @@ -0,0 +1,136 @@ +/* +* Copyright 2023 MASES s.r.l. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +* Refer to LICENSE for more information. +*/ + +using MASES.KNet.Serialization; +using MASES.KNet.Streams.Processor; +using System.Runtime.InteropServices; + +namespace MASES.KNet.Streams.Kstream +{ + /// + /// KNet extension of + /// + /// + /// + public class KNetRepartitioned : IGenericSerDesFactoryApplier + { + readonly Org.Apache.Kafka.Streams.Kstream.Repartitioned _repartitioned; + IGenericSerDesFactory _factory; + IGenericSerDesFactory IGenericSerDesFactoryApplier.Factory { get => _factory; set { _factory = value; } } + + KNetRepartitioned(Org.Apache.Kafka.Streams.Kstream.Repartitioned repartitioned) + { + _repartitioned = repartitioned; + } + + /// + /// Converter from to + /// + public static implicit operator Org.Apache.Kafka.Streams.Kstream.Repartitioned(KNetRepartitioned t) => t._repartitioned; + + #region Static methods + /// + /// + /// + /// + /// + public static KNetRepartitioned As(string arg0) + { + var cons = Org.Apache.Kafka.Streams.Kstream.Repartitioned.As(arg0); + return new KNetRepartitioned(cons); + } + /// + /// + /// + /// + /// + public static KNetRepartitioned NumberOfPartitions(int arg0) + { + var cons = Org.Apache.Kafka.Streams.Kstream.Repartitioned.NumberOfPartitions(arg0); + return new KNetRepartitioned(cons); + } + /// + /// + /// + /// + /// + public static KNetRepartitioned StreamPartitioner(KNetStreamPartitioner arg0) + { + var cons = Org.Apache.Kafka.Streams.Kstream.Repartitioned.StreamPartitioner(arg0); + return new KNetRepartitioned(cons); + } + /// + /// + /// + /// + /// + /// + public static KNetRepartitioned With(IKNetSerDes arg0, IKNetSerDes arg1) + { + var cons = Org.Apache.Kafka.Streams.Kstream.Repartitioned.With(arg0.KafkaSerde, arg1.KafkaSerde); + return new KNetRepartitioned(cons); + } + + #endregion + + #region Instance methods + /// + /// + /// + /// + /// + public KNetRepartitioned WithKeySerde(IKNetSerDes arg0) + { + _repartitioned?.WithKeySerde(arg0.KafkaSerde); + return this; + } + /// + /// + /// + /// + /// + public KNetRepartitioned WithNumberOfPartitions(int arg0) + { + _repartitioned?.WithNumberOfPartitions(arg0); + return this; + } + /// + /// + /// + /// + /// + public KNetRepartitioned WithStreamPartitioner(KNetStreamPartitioner arg0) + { + if (arg0 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; + _repartitioned?.WithStreamPartitioner(arg0); + return this; + } + /// + /// + /// + /// + /// + public KNetRepartitioned WithValueSerde(IKNetSerDes arg0) + { + _repartitioned?.WithValueSerde(arg0.KafkaSerde); + return this; + } + + #endregion + } +} diff --git a/src/net/KNet/Specific/Streams/Kstream/KNetStreamJoined.cs b/src/net/KNet/Specific/Streams/Kstream/KNetStreamJoined.cs new file mode 100644 index 0000000000..b9dca3f732 --- /dev/null +++ b/src/net/KNet/Specific/Streams/Kstream/KNetStreamJoined.cs @@ -0,0 +1,47 @@ +/* +* Copyright 2023 MASES s.r.l. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +* Refer to LICENSE for more information. +*/ + +using MASES.KNet.Serialization; + +namespace MASES.KNet.Streams.Kstream +{ + /// + /// KNet extension of + /// + /// + /// + /// + public class KNetStreamJoined : IGenericSerDesFactoryApplier + { + readonly Org.Apache.Kafka.Streams.Kstream.StreamJoined _inner; + IGenericSerDesFactory _factory; + IGenericSerDesFactory IGenericSerDesFactoryApplier.Factory { get => _factory; set { _factory = value; } } + + KNetStreamJoined(Org.Apache.Kafka.Streams.Kstream.StreamJoined inner) + { + _inner = inner; + } + + /// + /// Converter from to + /// + public static implicit operator Org.Apache.Kafka.Streams.Kstream.StreamJoined(KNetStreamJoined t) => t._inner; + +#warning shall be completed + } +} diff --git a/src/net/KNet/Specific/Streams/Kstream/KNetValueJoiner.cs b/src/net/KNet/Specific/Streams/Kstream/KNetValueJoiner.cs new file mode 100644 index 0000000000..3714161692 --- /dev/null +++ b/src/net/KNet/Specific/Streams/Kstream/KNetValueJoiner.cs @@ -0,0 +1,63 @@ +/* +* Copyright 2023 MASES s.r.l. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +* Refer to LICENSE for more information. +*/ + +using MASES.KNet.Serialization; + +namespace MASES.KNet.Streams.Kstream +{ + /// + /// KNet extension of + /// + /// first value type + /// second value type + /// joined value type + public class KNetValueJoiner : Org.Apache.Kafka.Streams.Kstream.ValueJoiner, IGenericSerDesFactoryApplier + { + IGenericSerDesFactory _factory; + IGenericSerDesFactory IGenericSerDesFactoryApplier.Factory { get => _factory; set { _factory = value; } } + + /// + /// Handler for + /// + /// If has a value it takes precedence over corresponding class method + public new System.Func OnApply { get; set; } = null; + /// + public sealed override byte[] Apply(byte[] arg0, byte[] arg1) + { + IKNetSerDes v1Serializer = _factory.BuildValueSerDes(); + IKNetSerDes v2Serializer = _factory.BuildValueSerDes(); + IKNetSerDes vrSerializer = _factory.BuildValueSerDes(); + + var methodToExecute = (OnApply != null) ? OnApply : Apply; + var res = methodToExecute(v1Serializer.Deserialize(null, arg0), v2Serializer.Deserialize(null, arg1)); + return vrSerializer.Serialize(null, res); + } + + /// + /// + /// + /// + /// + /// + public virtual VR Apply(V1 arg0, V2 arg1) + { + return default; + } + + } +} diff --git a/src/net/KNet/Specific/Streams/Kstream/KNetValueJoinerWithKey.cs b/src/net/KNet/Specific/Streams/Kstream/KNetValueJoinerWithKey.cs new file mode 100644 index 0000000000..85e0afbde2 --- /dev/null +++ b/src/net/KNet/Specific/Streams/Kstream/KNetValueJoinerWithKey.cs @@ -0,0 +1,66 @@ +/* +* Copyright 2023 MASES s.r.l. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +* Refer to LICENSE for more information. +*/ + +using MASES.KNet.Serialization; + +namespace MASES.KNet.Streams.Kstream +{ + /// + /// KNet extension of + /// + /// key value type + /// first value type + /// second value type + /// joined value type + public class KNetValueJoinerWithKey : Org.Apache.Kafka.Streams.Kstream.ValueJoinerWithKey, IGenericSerDesFactoryApplier + { + IGenericSerDesFactory _factory; + IGenericSerDesFactory IGenericSerDesFactoryApplier.Factory { get => _factory; set { _factory = value; } } + + /// + /// Handler for + /// + /// If has a value it takes precedence over corresponding class method + public new System.Func OnApply { get; set; } = null; + /// + public sealed override byte[] Apply(byte[] arg0, byte[] arg1, byte[] arg2) + { + IKNetSerDes k1Serializer = _factory.BuildKeySerDes(); + IKNetSerDes v1Serializer = _factory.BuildValueSerDes(); + IKNetSerDes v2Serializer = _factory.BuildValueSerDes(); + IKNetSerDes vrSerializer = _factory.BuildValueSerDes(); + + var methodToExecute = (OnApply != null) ? OnApply : Apply; + var res = methodToExecute(k1Serializer.Deserialize(null, arg0), v1Serializer.Deserialize(null, arg1), v2Serializer.Deserialize(null, arg2)); + return vrSerializer.Serialize(null, res); + } + + /// + /// + /// + /// + /// + /// + /// + public virtual VR Apply(K1 arg0, V1 arg1, V2 arg2) + { + return default; + } + + } +} diff --git a/src/net/KNet/Specific/Streams/Kstream/KNetValueMapper.cs b/src/net/KNet/Specific/Streams/Kstream/KNetValueMapper.cs new file mode 100644 index 0000000000..20031ea028 --- /dev/null +++ b/src/net/KNet/Specific/Streams/Kstream/KNetValueMapper.cs @@ -0,0 +1,105 @@ +/* +* Copyright 2023 MASES s.r.l. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +* Refer to LICENSE for more information. +*/ + +using Java.Util; +using MASES.KNet.Serialization; +using System.Collections.Generic; + +namespace MASES.KNet.Streams.Kstream +{ + /// + /// KNet extension of + /// + /// first value type + /// joined value type + public class KNetValueMapper : Org.Apache.Kafka.Streams.Kstream.ValueMapper, IGenericSerDesFactoryApplier + { + IGenericSerDesFactory _factory; + IGenericSerDesFactory IGenericSerDesFactoryApplier.Factory { get => _factory; set { _factory = value; } } + + /// + /// Handler for + /// + /// If has a value it takes precedence over corresponding class method + public new System.Func OnApply { get; set; } = null; + + /// + public sealed override byte[] Apply(byte[] arg0) + { + IKNetSerDes vSerializer = _factory.BuildValueSerDes(); + IKNetSerDes vrSerializer = _factory.BuildValueSerDes(); + + var methodToExecute = (OnApply != null) ? OnApply : Apply; + var res = methodToExecute(vSerializer.Deserialize(null, arg0)); + return vrSerializer.Serialize(null, res); + } + + /// + /// + /// + /// + /// + public virtual VR Apply(V arg0) + { + return default; + } + } + + /// + /// KNet extension of + /// + /// first value type + /// joined value type + public class KNetEnumerableValueMapper : Org.Apache.Kafka.Streams.Kstream.ValueMapper>, IGenericSerDesFactoryApplier + { + IGenericSerDesFactory _factory; + IGenericSerDesFactory IGenericSerDesFactoryApplier.Factory { get => _factory; set { _factory = value; } } + + /// + /// Handler for + /// + /// If has a value it takes precedence over corresponding class method + public new System.Func> OnApply { get; set; } = null; + + /// + public sealed override Java.Lang.Iterable Apply(byte[] arg0) + { + IKNetSerDes vSerializer = _factory.BuildValueSerDes(); + IKNetSerDes vrSerializer = _factory.BuildValueSerDes(); + + var methodToExecute = (OnApply != null) ? OnApply : Apply; + var res = methodToExecute(vSerializer.Deserialize(null, arg0)); + var result = new ArrayList(); + foreach (var item in res) + { + result.Add(vrSerializer.Serialize(null, item)); + } + return result; + } + + /// + /// + /// + /// + /// + public virtual IEnumerable Apply(V arg0) + { + return default; + } + } +} diff --git a/src/net/KNet/Specific/Streams/Kstream/KNetValueMapperWithKey.cs b/src/net/KNet/Specific/Streams/Kstream/KNetValueMapperWithKey.cs new file mode 100644 index 0000000000..df876dd0fc --- /dev/null +++ b/src/net/KNet/Specific/Streams/Kstream/KNetValueMapperWithKey.cs @@ -0,0 +1,112 @@ +/* +* Copyright 2023 MASES s.r.l. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +* Refer to LICENSE for more information. +*/ + +using Java.Util; +using MASES.JCOBridge.C2JBridge; +using MASES.KNet.Serialization; +using System.Collections.Generic; + +namespace MASES.KNet.Streams.Kstream +{ + /// + /// KNet extension of + /// + /// key value type + /// first value type + /// joined value type + public class KNetValueMapperWithKey : Org.Apache.Kafka.Streams.Kstream.ValueMapperWithKey, IGenericSerDesFactoryApplier + { + IGenericSerDesFactory _factory; + IGenericSerDesFactory IGenericSerDesFactoryApplier.Factory { get => _factory; set { _factory = value; } } + + /// + /// Handler for + /// + /// If has a value it takes precedence over corresponding class method + public new System.Func OnApply { get; set; } = null; + + /// + public sealed override byte[] Apply(byte[] arg0, byte[] arg1) + { + IKNetSerDes kSerializer = _factory.BuildKeySerDes(); + IKNetSerDes vSerializer = _factory.BuildValueSerDes(); + IKNetSerDes vrSerializer = _factory.BuildValueSerDes(); + + var methodToExecute = (OnApply != null) ? OnApply : Apply; + var res = methodToExecute(kSerializer.Deserialize(null, arg0), vSerializer.Deserialize(null, arg1)); + return vrSerializer.Serialize(null, res); + } + + /// + /// + /// + /// + /// + /// + public virtual VR Apply(K arg0, V arg1) + { + return default; + } + } + + /// + /// KNet extension of + /// + /// key value type + /// first value type + /// joined value type + public class KNetEnumerableValueMapperWithKey : Org.Apache.Kafka.Streams.Kstream.ValueMapperWithKey>, IGenericSerDesFactoryApplier + { + IGenericSerDesFactory _factory; + IGenericSerDesFactory IGenericSerDesFactoryApplier.Factory { get => _factory; set { _factory = value; } } + + /// + /// Handler for + /// + /// If has a value it takes precedence over corresponding class method + public new System.Func> OnApply { get; set; } = null; + + /// + public sealed override Java.Lang.Iterable Apply(byte[] arg0, byte[] arg1) + { + IKNetSerDes kSerializer = _factory.BuildKeySerDes(); + IKNetSerDes vSerializer = _factory.BuildValueSerDes(); + IKNetSerDes vrSerializer = _factory.BuildValueSerDes(); + + var methodToExecute = (OnApply != null) ? OnApply : Apply; + var res = methodToExecute(kSerializer.Deserialize(null, arg0), vSerializer.Deserialize(null, arg1)); + var result = new ArrayList(); + foreach (var item in res) + { + result.Add(vrSerializer.Serialize(null, item)); + } + return result; + } + + /// + /// + /// + /// + /// + /// + public virtual IEnumerable Apply(K arg0, V arg1) + { + return default; + } + } +} diff --git a/src/net/KNet/Specific/Streams/Kstream/KNetTimestampExtractor.cs b/src/net/KNet/Specific/Streams/Processor/KNetTimestampExtractor.cs similarity index 98% rename from src/net/KNet/Specific/Streams/Kstream/KNetTimestampExtractor.cs rename to src/net/KNet/Specific/Streams/Processor/KNetTimestampExtractor.cs index 2342606dd3..55b90d04b1 100644 --- a/src/net/KNet/Specific/Streams/Kstream/KNetTimestampExtractor.cs +++ b/src/net/KNet/Specific/Streams/Processor/KNetTimestampExtractor.cs @@ -20,7 +20,7 @@ using MASES.KNet.Consumer; using MASES.KNet.Serialization; -namespace MASES.KNet.Streams.Kstream +namespace MASES.KNet.Streams.Processor { /// /// KNet extension of From dd34c463b2110411d17a4415c7a2e4dfadeae869 Mon Sep 17 00:00:00 2001 From: masesdevelopers <94312179+masesdevelopers@users.noreply.github.com> Date: Mon, 15 Jan 2024 21:58:06 +0100 Subject: [PATCH 12/18] Many other classes implemented --- .../Streams/KNetTimestampedKeyValue.cs | 2 +- .../Streams/Kstream/KNetAggregator.cs | 64 ++ .../Specific/Streams/Kstream/KNetBranched.cs | 46 ++ .../Specific/Streams/Kstream/KNetConsumed.cs | 56 +- .../Streams/Kstream/KNetGlobalKTable.cs | 11 +- .../Specific/Streams/Kstream/KNetGrouped.cs | 10 +- .../Streams/Kstream/KNetInitializer.cs | 56 ++ .../Specific/Streams/Kstream/KNetJoined.cs | 10 +- .../Streams/Kstream/KNetKBranchedKStream.cs | 85 +- .../Streams/Kstream/KNetKGroupedStream.cs | 10 +- .../Streams/Kstream/KNetKGroupedTable.cs | 209 +++++ .../Specific/Streams/Kstream/KNetKStream.cs | 146 ++-- .../Specific/Streams/Kstream/KNetKTable.cs | 782 +++++++++++++++++- .../Streams/Kstream/KNetMaterialized.cs | 20 + .../Streams/Kstream/KNetPredicateTester.cs | 4 +- .../Specific/Streams/Kstream/KNetPrinted.cs | 2 +- .../Specific/Streams/Kstream/KNetProduced.cs | 43 +- .../Specific/Streams/Kstream/KNetReducer.cs | 59 ++ .../Streams/Kstream/KNetRepartitioned.cs | 31 +- .../Streams/Kstream/KNetStreamJoined.cs | 2 +- .../Streams/Kstream/KNetSuppressed.cs | 45 + .../Streams/Kstream/KNetTableJoined.cs | 46 ++ .../Specific/Streams/Kstream/KNetWindowed.cs | 13 +- .../Specific/Streams/Utils/KNetFunction.cs | 57 ++ 24 files changed, 1650 insertions(+), 159 deletions(-) create mode 100644 src/net/KNet/Specific/Streams/Kstream/KNetAggregator.cs create mode 100644 src/net/KNet/Specific/Streams/Kstream/KNetBranched.cs create mode 100644 src/net/KNet/Specific/Streams/Kstream/KNetInitializer.cs create mode 100644 src/net/KNet/Specific/Streams/Kstream/KNetKGroupedTable.cs create mode 100644 src/net/KNet/Specific/Streams/Kstream/KNetReducer.cs create mode 100644 src/net/KNet/Specific/Streams/Kstream/KNetSuppressed.cs create mode 100644 src/net/KNet/Specific/Streams/Kstream/KNetTableJoined.cs create mode 100644 src/net/KNet/Specific/Streams/Utils/KNetFunction.cs diff --git a/src/net/KNet/Specific/Streams/KNetTimestampedKeyValue.cs b/src/net/KNet/Specific/Streams/KNetTimestampedKeyValue.cs index 0837a69168..6bbe23ddaa 100644 --- a/src/net/KNet/Specific/Streams/KNetTimestampedKeyValue.cs +++ b/src/net/KNet/Specific/Streams/KNetTimestampedKeyValue.cs @@ -22,7 +22,7 @@ namespace MASES.KNet.Streams { /// - /// KNet implementation of + /// KNet implementation of /// /// The key type /// The value type diff --git a/src/net/KNet/Specific/Streams/Kstream/KNetAggregator.cs b/src/net/KNet/Specific/Streams/Kstream/KNetAggregator.cs new file mode 100644 index 0000000000..912e7ffed6 --- /dev/null +++ b/src/net/KNet/Specific/Streams/Kstream/KNetAggregator.cs @@ -0,0 +1,64 @@ +/* +* Copyright 2023 MASES s.r.l. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +* Refer to LICENSE for more information. +*/ + +using MASES.KNet.Serialization; + +namespace MASES.KNet.Streams.Kstream +{ + /// + /// KNet implementation of + /// + /// + /// + /// The key type + public class KNetAggregator : Org.Apache.Kafka.Streams.Kstream.Aggregator, IGenericSerDesFactoryApplier + { + IGenericSerDesFactory _factory; + IGenericSerDesFactory IGenericSerDesFactoryApplier.Factory { get => _factory; set { _factory = value; } } + + /// + /// Handler for + /// + /// If has a value it takes precedence over corresponding class method + public new System.Func OnApply { get; set; } = null; + /// + public sealed override byte[] Apply(byte[] arg0, byte[] arg1, byte[] arg2) + { + IKNetSerDes kSerializer = _factory.BuildKeySerDes(); + IKNetSerDes vSerializer = _factory.BuildValueSerDes(); + IKNetSerDes vaSerializer = _factory.BuildValueSerDes(); + + var methodToExecute = (OnApply != null) ? OnApply : Apply; + var res = methodToExecute(kSerializer.Deserialize(null, arg0), vSerializer.Deserialize(null, arg1), vaSerializer.Deserialize(null, arg2)); + + return vaSerializer.Serialize(null, res); + } + + /// + /// + /// + /// + /// + /// + /// + public virtual VA Apply(K arg0, V arg1, VA arg2) + { + return default; + } + } +} diff --git a/src/net/KNet/Specific/Streams/Kstream/KNetBranched.cs b/src/net/KNet/Specific/Streams/Kstream/KNetBranched.cs new file mode 100644 index 0000000000..91e586c01f --- /dev/null +++ b/src/net/KNet/Specific/Streams/Kstream/KNetBranched.cs @@ -0,0 +1,46 @@ +/* +* Copyright 2023 MASES s.r.l. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +* Refer to LICENSE for more information. +*/ + +using MASES.KNet.Serialization; + +namespace MASES.KNet.Streams.Kstream +{ + /// + /// KNet extension of + /// + /// + /// + public class KNetBranched : IGenericSerDesFactoryApplier + { + readonly Org.Apache.Kafka.Streams.Kstream.Branched _inner; + IGenericSerDesFactory _factory; + IGenericSerDesFactory IGenericSerDesFactoryApplier.Factory { get => _factory; set { _factory = value; } } + + KNetBranched(Org.Apache.Kafka.Streams.Kstream.Branched inner) + { + _inner = inner; + } + + /// + /// Converter from to + /// + public static implicit operator Org.Apache.Kafka.Streams.Kstream.Branched(KNetBranched t) => t._inner; + +#warning till now it is only an empty class shall be completed with the method of inner class + } +} diff --git a/src/net/KNet/Specific/Streams/Kstream/KNetConsumed.cs b/src/net/KNet/Specific/Streams/Kstream/KNetConsumed.cs index 2a3a5f0dbe..ef30df018c 100644 --- a/src/net/KNet/Specific/Streams/Kstream/KNetConsumed.cs +++ b/src/net/KNet/Specific/Streams/Kstream/KNetConsumed.cs @@ -17,6 +17,7 @@ */ using MASES.KNet.Serialization; +using MASES.KNet.Streams.Processor; namespace MASES.KNet.Streams.Kstream { @@ -27,26 +28,36 @@ namespace MASES.KNet.Streams.Kstream /// public class KNetConsumed : IGenericSerDesFactoryApplier { - readonly Org.Apache.Kafka.Streams.Kstream.Consumed _consumed; + KNetTimestampExtractor _timestampExtractor = null; + readonly Org.Apache.Kafka.Streams.Kstream.Consumed _inner; IGenericSerDesFactory _factory; - IGenericSerDesFactory IGenericSerDesFactoryApplier.Factory { get => _factory; set { _factory = value; } } + IGenericSerDesFactory IGenericSerDesFactoryApplier.Factory + { + get => _factory; + set + { + _factory = value; + if (_timestampExtractor is IGenericSerDesFactoryApplier applier) applier.Factory = value; + } + } - KNetConsumed(Org.Apache.Kafka.Streams.Kstream.Consumed consumed) + KNetConsumed(Org.Apache.Kafka.Streams.Kstream.Consumed inner, KNetTimestampExtractor timestampExtractor = null) { - _consumed = consumed; + _inner = inner; + _timestampExtractor = timestampExtractor; } /// /// Converter from to /// - public static implicit operator Org.Apache.Kafka.Streams.Kstream.Consumed(KNetConsumed t) => t._consumed; + public static implicit operator Org.Apache.Kafka.Streams.Kstream.Consumed(KNetConsumed t) => t._inner; #region Static methods /// /// /// /// - /// + /// public static KNetConsumed As(string arg0) { var cons = Org.Apache.Kafka.Streams.Kstream.Consumed.As(arg0); @@ -55,22 +66,22 @@ public static KNetConsumed As(string arg0) /// /// /// - /// - /// - /// + /// + /// + /// /// - /// + /// public static KNetConsumed With(IKNetSerDes arg0, IKNetSerDes arg1, KNetTimestampExtractor arg2, Org.Apache.Kafka.Streams.Topology.AutoOffsetReset arg3) { var cons = Org.Apache.Kafka.Streams.Kstream.Consumed.With(arg0.KafkaSerde, arg1.KafkaSerde, arg2, arg3); - return new KNetConsumed(cons); + return new KNetConsumed(cons, arg2); } /// /// /// - /// - /// - /// + /// + /// + /// public static KNetConsumed With(IKNetSerDes arg0, IKNetSerDes arg1) { var cons = Org.Apache.Kafka.Streams.Kstream.Consumed.With(arg0.KafkaSerde, arg1.KafkaSerde); @@ -79,18 +90,18 @@ public static KNetConsumed With(IKNetSerDes arg0, IKNetSerDes arg1) /// /// /// - /// - /// + /// + /// public static KNetConsumed With(KNetTimestampExtractor arg0) { var cons = Org.Apache.Kafka.Streams.Kstream.Consumed.With(arg0); - return new KNetConsumed(cons); + return new KNetConsumed(cons, arg0); } /// /// /// /// - /// + /// public static KNetConsumed With(Org.Apache.Kafka.Streams.Topology.AutoOffsetReset arg0) { var cons = Org.Apache.Kafka.Streams.Kstream.Consumed.With(arg0); @@ -107,7 +118,7 @@ public static KNetConsumed With(Org.Apache.Kafka.Streams.Topology.AutoOffs /// public KNetConsumed WithKeySerde(IKNetSerDes arg0) { - _consumed?.WithKeySerde(arg0.KafkaSerde); + _inner?.WithKeySerde(arg0.KafkaSerde); return this; } /// @@ -117,7 +128,7 @@ public KNetConsumed WithKeySerde(IKNetSerDes arg0) /// public KNetConsumed WithOffsetResetPolicy(Org.Apache.Kafka.Streams.Topology.AutoOffsetReset arg0) { - _consumed?.WithOffsetResetPolicy(arg0); + _inner?.WithOffsetResetPolicy(arg0); return this; } /// @@ -128,7 +139,8 @@ public KNetConsumed WithOffsetResetPolicy(Org.Apache.Kafka.Streams.Topolog public KNetConsumed WithTimestampExtractor(KNetTimestampExtractor arg0) { if (arg0 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; - _consumed?.WithTimestampExtractor(arg0); + _timestampExtractor = arg0; + _inner?.WithTimestampExtractor(arg0); return this; } /// @@ -138,7 +150,7 @@ public KNetConsumed WithTimestampExtractor(KNetTimestampExtractor ar /// public KNetConsumed WithValueSerde(IKNetSerDes arg0) { - _consumed?.WithValueSerde(arg0.KafkaSerde); + _inner?.WithValueSerde(arg0.KafkaSerde); return this; } diff --git a/src/net/KNet/Specific/Streams/Kstream/KNetGlobalKTable.cs b/src/net/KNet/Specific/Streams/Kstream/KNetGlobalKTable.cs index 42b7f88ba8..ee18bb2575 100644 --- a/src/net/KNet/Specific/Streams/Kstream/KNetGlobalKTable.cs +++ b/src/net/KNet/Specific/Streams/Kstream/KNetGlobalKTable.cs @@ -27,7 +27,7 @@ namespace MASES.KNet.Streams.Kstream /// public class KNetGlobalKTable : IGenericSerDesFactoryApplier { - Org.Apache.Kafka.Streams.Kstream.GlobalKTable _table; + Org.Apache.Kafka.Streams.Kstream.GlobalKTable _inner; IGenericSerDesFactory _factory; IGenericSerDesFactory IGenericSerDesFactoryApplier.Factory { get => _factory; set { _factory = value; } } @@ -35,13 +35,18 @@ public class KNetGlobalKTable : IGenericSerDesFactoryApplier internal KNetGlobalKTable(IGenericSerDesFactory factory, Org.Apache.Kafka.Streams.Kstream.GlobalKTable table) { _factory = factory; - _table = table; + _inner = table; } /// /// Converter from to /// - public static implicit operator Org.Apache.Kafka.Streams.Kstream.GlobalKTable(KNetGlobalKTable t) => t._table; + public static implicit operator Org.Apache.Kafka.Streams.Kstream.GlobalKTable(KNetGlobalKTable t) => t._inner; + /// + /// + /// + /// + public string QueryableStoreName => _inner.QueryableStoreName(); } } diff --git a/src/net/KNet/Specific/Streams/Kstream/KNetGrouped.cs b/src/net/KNet/Specific/Streams/Kstream/KNetGrouped.cs index 77d4d7df60..45152cfc60 100644 --- a/src/net/KNet/Specific/Streams/Kstream/KNetGrouped.cs +++ b/src/net/KNet/Specific/Streams/Kstream/KNetGrouped.cs @@ -28,20 +28,20 @@ namespace MASES.KNet.Streams.Kstream /// public class KNetGrouped : IGenericSerDesFactoryApplier { - readonly Org.Apache.Kafka.Streams.Kstream.Grouped _produced; + readonly Org.Apache.Kafka.Streams.Kstream.Grouped _inner; IGenericSerDesFactory _factory; IGenericSerDesFactory IGenericSerDesFactoryApplier.Factory { get => _factory; set { _factory = value; } } - KNetGrouped(Org.Apache.Kafka.Streams.Kstream.Grouped produced) + KNetGrouped(Org.Apache.Kafka.Streams.Kstream.Grouped inner) { - _produced = produced; + _inner = inner; } /// /// Converter from to /// - public static implicit operator Org.Apache.Kafka.Streams.Kstream.Grouped(KNetGrouped t) => t._produced; + public static implicit operator Org.Apache.Kafka.Streams.Kstream.Grouped(KNetGrouped t) => t._inner; -#warning shall be completed +#warning till now it is only an empty class shall be completed with the method of inner class } } diff --git a/src/net/KNet/Specific/Streams/Kstream/KNetInitializer.cs b/src/net/KNet/Specific/Streams/Kstream/KNetInitializer.cs new file mode 100644 index 0000000000..5eb1e7fd4a --- /dev/null +++ b/src/net/KNet/Specific/Streams/Kstream/KNetInitializer.cs @@ -0,0 +1,56 @@ +/* +* Copyright 2023 MASES s.r.l. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +* Refer to LICENSE for more information. +*/ + +using MASES.KNet.Serialization; + +namespace MASES.KNet.Streams.Kstream +{ + /// + /// KNet implementation of + /// + /// The key type + public class KNetInitializer : Org.Apache.Kafka.Streams.Kstream.Initializer, IGenericSerDesFactoryApplier + { + IGenericSerDesFactory _factory; + IGenericSerDesFactory IGenericSerDesFactoryApplier.Factory { get => _factory; set { _factory = value; } } + + /// + /// Handler for + /// + /// If has a value it takes precedence over corresponding class method + public System.Func OnApply2 { get; set; } = null; + /// + public sealed override byte[] Apply() + { + IKNetSerDes valueSerializer = _factory.BuildValueSerDes(); + + var methodToExecute = (OnApply2 != null) ? OnApply2 : Apply2; + var res = methodToExecute(); + return valueSerializer.Serialize(null, res); + } + + /// + /// + /// + /// + public virtual VA Apply2() + { + return default; + } + } +} diff --git a/src/net/KNet/Specific/Streams/Kstream/KNetJoined.cs b/src/net/KNet/Specific/Streams/Kstream/KNetJoined.cs index b93d1e3433..a6f2368976 100644 --- a/src/net/KNet/Specific/Streams/Kstream/KNetJoined.cs +++ b/src/net/KNet/Specific/Streams/Kstream/KNetJoined.cs @@ -28,20 +28,20 @@ namespace MASES.KNet.Streams.Kstream /// public class KNetJoined : IGenericSerDesFactoryApplier { - readonly Org.Apache.Kafka.Streams.Kstream.Joined _produced; + readonly Org.Apache.Kafka.Streams.Kstream.Joined _inner; IGenericSerDesFactory _factory; IGenericSerDesFactory IGenericSerDesFactoryApplier.Factory { get => _factory; set { _factory = value; } } - KNetJoined(Org.Apache.Kafka.Streams.Kstream.Joined produced) + KNetJoined(Org.Apache.Kafka.Streams.Kstream.Joined inner) { - _produced = produced; + _inner = inner; } /// /// Converter from to /// - public static implicit operator Org.Apache.Kafka.Streams.Kstream.Joined(KNetJoined t) => t._produced; + public static implicit operator Org.Apache.Kafka.Streams.Kstream.Joined(KNetJoined t) => t._inner; -#warning shall be completed +#warning till now it is only an empty class shall be completed with the method of inner class } } diff --git a/src/net/KNet/Specific/Streams/Kstream/KNetKBranchedKStream.cs b/src/net/KNet/Specific/Streams/Kstream/KNetKBranchedKStream.cs index cb60d7b4c2..e42b3c75ab 100644 --- a/src/net/KNet/Specific/Streams/Kstream/KNetKBranchedKStream.cs +++ b/src/net/KNet/Specific/Streams/Kstream/KNetKBranchedKStream.cs @@ -27,22 +27,97 @@ namespace MASES.KNet.Streams.Kstream /// public class KNetBranchedKStream : IGenericSerDesFactoryApplier { - Org.Apache.Kafka.Streams.Kstream.BranchedKStream _table; + Org.Apache.Kafka.Streams.Kstream.BranchedKStream _inner; IGenericSerDesFactory _factory; IGenericSerDesFactory IGenericSerDesFactoryApplier.Factory { get => _factory; set { _factory = value; } } - internal KNetBranchedKStream(IGenericSerDesFactory factory, Org.Apache.Kafka.Streams.Kstream.BranchedKStream table) + internal KNetBranchedKStream(IGenericSerDesFactory factory, Org.Apache.Kafka.Streams.Kstream.BranchedKStream inner) { _factory = factory; - _table = table; + _inner = inner; } /// /// Converter from to /// - public static implicit operator Org.Apache.Kafka.Streams.Kstream.BranchedKStream(KNetBranchedKStream t) => t._table; + public static implicit operator Org.Apache.Kafka.Streams.Kstream.BranchedKStream(KNetBranchedKStream t) => t._inner; -#warning shall be completed + /// + /// + /// + /// + public System.Collections.Generic.IReadOnlyDictionary> DefaultBranch() + { + var dict = new System.Collections.Generic.Dictionary>(); + var map = _inner.DefaultBranch(); + foreach (var item in map.KeySet()) + { + var kStream = new KNetKStream(_factory, map.Get(item)); + dict.Add(item, kStream); + } + + return dict; + } + /// + /// + /// + /// + /// + public System.Collections.Generic.IReadOnlyDictionary> DefaultBranch(KNetBranched arg0) + { + var dict = new System.Collections.Generic.Dictionary>(); + if (arg0 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; + var map = _inner.DefaultBranch(arg0); + foreach (var item in map.KeySet()) + { + var kStream = new KNetKStream(_factory, map.Get(item)); + dict.Add(item, kStream); + } + + return dict; + } + /// + /// + /// + /// + public System.Collections.Generic.IReadOnlyDictionary> NoDefaultBranch() + { + var dict = new System.Collections.Generic.Dictionary>(); + var map = _inner.NoDefaultBranch(); + foreach (var item in map.KeySet()) + { + var kStream = new KNetKStream(_factory, map.Get(item)); + dict.Add(item, kStream); + } + + return dict; + } + /// + /// + /// + /// + /// + /// + /// + /// + public KNetBranchedKStream Branch(KNetPredicate arg0, KNetBranched arg1) where Arg0objectSuperK : K where Arg0objectSuperV : V + { + if (arg0 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; + if (arg1 is IGenericSerDesFactoryApplier applier1) applier1.Factory = _factory; + return new KNetBranchedKStream(_factory, _inner.Branch(arg0, arg1)); + } + /// + /// + /// + /// + /// + /// + /// + public KNetBranchedKStream Branch(KNetPredicate arg0) where Arg0objectSuperK : K where Arg0objectSuperV : V + { + if (arg0 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; + return new KNetBranchedKStream(_factory, _inner.Branch(arg0)); + } } } diff --git a/src/net/KNet/Specific/Streams/Kstream/KNetKGroupedStream.cs b/src/net/KNet/Specific/Streams/Kstream/KNetKGroupedStream.cs index fb81f8f697..1bc31207dd 100644 --- a/src/net/KNet/Specific/Streams/Kstream/KNetKGroupedStream.cs +++ b/src/net/KNet/Specific/Streams/Kstream/KNetKGroupedStream.cs @@ -27,22 +27,22 @@ namespace MASES.KNet.Streams.Kstream /// public class KNetKGroupedStream : IGenericSerDesFactoryApplier { - Org.Apache.Kafka.Streams.Kstream.KGroupedStream _table; + Org.Apache.Kafka.Streams.Kstream.KGroupedStream _inner; IGenericSerDesFactory _factory; IGenericSerDesFactory IGenericSerDesFactoryApplier.Factory { get => _factory; set { _factory = value; } } - internal KNetKGroupedStream(IGenericSerDesFactory factory, Org.Apache.Kafka.Streams.Kstream.KGroupedStream table) + internal KNetKGroupedStream(IGenericSerDesFactory factory, Org.Apache.Kafka.Streams.Kstream.KGroupedStream inner) { _factory = factory; - _table = table; + _inner = inner; } /// /// Converter from to /// - public static implicit operator Org.Apache.Kafka.Streams.Kstream.KGroupedStream(KNetKGroupedStream t) => t._table; + public static implicit operator Org.Apache.Kafka.Streams.Kstream.KGroupedStream(KNetKGroupedStream t) => t._inner; -#warning shall be completed +#warning till now it is only an empty class shall be completed with the method of inner class } } diff --git a/src/net/KNet/Specific/Streams/Kstream/KNetKGroupedTable.cs b/src/net/KNet/Specific/Streams/Kstream/KNetKGroupedTable.cs new file mode 100644 index 0000000000..1e7aa84771 --- /dev/null +++ b/src/net/KNet/Specific/Streams/Kstream/KNetKGroupedTable.cs @@ -0,0 +1,209 @@ +/* +* Copyright 2023 MASES s.r.l. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +* Refer to LICENSE for more information. +*/ + +using MASES.KNet.Serialization; + +namespace MASES.KNet.Streams.Kstream +{ + /// + /// KNet extension of + /// + /// + /// + public class KNetKGroupedTable : IGenericSerDesFactoryApplier + { + Org.Apache.Kafka.Streams.Kstream.KGroupedTable _inner; + + IGenericSerDesFactory _factory; + IGenericSerDesFactory IGenericSerDesFactoryApplier.Factory { get => _factory; set { _factory = value; } } + + internal KNetKGroupedTable(IGenericSerDesFactory factory, Org.Apache.Kafka.Streams.Kstream.KGroupedTable inner) + { + _factory = factory; + _inner = inner; + } + + /// + /// Converter from to + /// + public static implicit operator Org.Apache.Kafka.Streams.Kstream.KGroupedTable(KNetKGroupedTable t) => t._inner; + + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public KNetKTable Aggregate(KNetInitializer arg0, KNetAggregator arg1, KNetAggregator arg2, KNetMaterialized arg3) where Arg1objectSuperK : K where Arg1objectSuperV : V where Arg2objectSuperK : K where Arg2objectSuperV : V + { + if (arg0 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; + if (arg1 is IGenericSerDesFactoryApplier applier1) applier1.Factory = _factory; + if (arg2 is IGenericSerDesFactoryApplier applier2) applier2.Factory = _factory; + if (arg3 is IGenericSerDesFactoryApplier applier3) applier3.Factory = _factory; + return new KNetKTable(_factory, _inner.Aggregate(arg0, arg1, arg2, arg3)); + } + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public KNetKTable Aggregate(KNetInitializer arg0, KNetAggregator arg1, KNetAggregator arg2, Org.Apache.Kafka.Streams.Kstream.Named arg3, KNetMaterialized arg4) where Arg1objectSuperK : K where Arg1objectSuperV : V where Arg2objectSuperK : K where Arg2objectSuperV : V + { + if (arg0 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; + if (arg1 is IGenericSerDesFactoryApplier applier1) applier1.Factory = _factory; + if (arg2 is IGenericSerDesFactoryApplier applier2) applier2.Factory = _factory; + if (arg4 is IGenericSerDesFactoryApplier applier4) applier4.Factory = _factory; + return new KNetKTable(_factory, _inner.Aggregate(arg0, arg1, arg2, arg3, arg4)); + } + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public KNetKTable Aggregate(KNetInitializer arg0, KNetAggregator arg1, KNetAggregator arg2, Org.Apache.Kafka.Streams.Kstream.Named arg3) where Arg1objectSuperK : K where Arg1objectSuperV : V where Arg2objectSuperK : K where Arg2objectSuperV : V + { + if (arg0 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; + if (arg1 is IGenericSerDesFactoryApplier applier1) applier1.Factory = _factory; + if (arg2 is IGenericSerDesFactoryApplier applier2) applier2.Factory = _factory; + return new KNetKTable(_factory, _inner.Aggregate(arg0, arg1, arg2, arg3)); + } + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public KNetKTable Aggregate(KNetInitializer arg0, KNetAggregator arg1, KNetAggregator arg2) where Arg1objectSuperK : K where Arg1objectSuperV : V where Arg2objectSuperK : K where Arg2objectSuperV : V + { + if (arg0 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; + if (arg1 is IGenericSerDesFactoryApplier applier1) applier1.Factory = _factory; + if (arg2 is IGenericSerDesFactoryApplier applier2) applier2.Factory = _factory; + return new KNetKTable(_factory, _inner.Aggregate(arg0, arg1, arg2)); + } + /// + /// + /// + /// + public KNetKTable Count() + { + return new KNetKTable(_factory, _inner.Count()); + } + /// + /// + /// + /// + /// + public KNetKTable Count(KNetMaterialized arg0) + { + if (arg0 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; + return new KNetKTable(_factory, _inner.Count(arg0)); + } + /// + /// + /// + /// + /// + /// + public KNetKTable Count(Org.Apache.Kafka.Streams.Kstream.Named arg0, KNetMaterialized arg1) + { + if (arg1 is IGenericSerDesFactoryApplier applier1) applier1.Factory = _factory; + return new KNetKTable(_factory, _inner.Count(arg0, arg1)); + } + /// + /// + /// + /// + /// + public KNetKTable Count(Org.Apache.Kafka.Streams.Kstream.Named arg0) + { + return new KNetKTable(_factory, _inner.Count(arg0)); + } + /// + /// + /// + /// + /// + /// + /// + public KNetKTable Reduce(KNetReducer arg0, KNetReducer arg1, KNetMaterialized arg2) + { + if (arg0 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; + if (arg1 is IGenericSerDesFactoryApplier applier1) applier1.Factory = _factory; + if (arg2 is IGenericSerDesFactoryApplier applier2) applier2.Factory = _factory; + return new KNetKTable(_factory, _inner.Reduce(arg0, arg1, arg2)); + } + /// + /// + /// + /// + /// + /// + /// + /// + public KNetKTable Reduce(KNetReducer arg0, KNetReducer arg1, Org.Apache.Kafka.Streams.Kstream.Named arg2, KNetMaterialized arg3) + { + if (arg0 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; + if (arg1 is IGenericSerDesFactoryApplier applier1) applier1.Factory = _factory; + if (arg3 is IGenericSerDesFactoryApplier applier3) applier3.Factory = _factory; + return new KNetKTable(_factory, _inner.Reduce(arg0, arg1, arg2, arg3)); + } + /// + /// + /// + /// + /// + /// + public KNetKTable Reduce(KNetReducer arg0, KNetReducer arg1) + { + if (arg0 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; + if (arg1 is IGenericSerDesFactoryApplier applier1) applier1.Factory = _factory; + return new KNetKTable(_factory, _inner.Reduce(arg0, arg1)); + } + + } +} diff --git a/src/net/KNet/Specific/Streams/Kstream/KNetKStream.cs b/src/net/KNet/Specific/Streams/Kstream/KNetKStream.cs index ee71bd2597..c997aaf02f 100644 --- a/src/net/KNet/Specific/Streams/Kstream/KNetKStream.cs +++ b/src/net/KNet/Specific/Streams/Kstream/KNetKStream.cs @@ -28,21 +28,21 @@ namespace MASES.KNet.Streams.Kstream /// public class KNetKStream : IGenericSerDesFactoryApplier { - Org.Apache.Kafka.Streams.Kstream.KStream _stream; + Org.Apache.Kafka.Streams.Kstream.KStream _inner; IGenericSerDesFactory _factory; IGenericSerDesFactory IGenericSerDesFactoryApplier.Factory { get => _factory; set { _factory = value; } } - internal KNetKStream(IGenericSerDesFactory factory, Org.Apache.Kafka.Streams.Kstream.KStream table) + internal KNetKStream(IGenericSerDesFactory factory, Org.Apache.Kafka.Streams.Kstream.KStream inner) { _factory = factory; - _stream = table; + _inner = inner; } /// /// Converter from to /// - public static implicit operator Org.Apache.Kafka.Streams.Kstream.KStream(KNetKStream t) => t._stream; + public static implicit operator Org.Apache.Kafka.Streams.Kstream.KStream(KNetKStream t) => t._inner; /// /// @@ -65,7 +65,7 @@ public KNetKStream Join(_factory, _stream.Join(arg0, arg1, arg2, arg3)); + return new KNetKStream(_factory, _inner.Join(arg0, arg1, arg2, arg3)); } /// /// @@ -87,7 +87,7 @@ public KNetKStream Join(_factory, _stream.Join(arg0, arg1, arg2)); + return new KNetKStream(_factory, _inner.Join(arg0, arg1, arg2)); } /// /// @@ -111,7 +111,7 @@ public KNetKStream Join(_factory, _stream.Join(arg0, arg1, arg2, arg3)); + return new KNetKStream(_factory, _inner.Join(arg0, arg1, arg2, arg3)); } /// /// @@ -134,7 +134,7 @@ public KNetKStream Join(_factory, _stream.Join(arg0, arg1, arg2)); + return new KNetKStream(_factory, _inner.Join(arg0, arg1, arg2)); } /// /// @@ -157,7 +157,7 @@ public KNetKStream LeftJoin(_factory, _stream.LeftJoin(arg0, arg1, arg2, arg3)); + return new KNetKStream(_factory, _inner.LeftJoin(arg0, arg1, arg2, arg3)); } /// /// @@ -179,7 +179,7 @@ public KNetKStream LeftJoin(_factory, _stream.LeftJoin(arg0, arg1, arg2)); + return new KNetKStream(_factory, _inner.LeftJoin(arg0, arg1, arg2)); } /// /// @@ -203,7 +203,7 @@ public KNetKStream LeftJoin(_factory, _stream.LeftJoin(arg0, arg1, arg2, arg3)); + return new KNetKStream(_factory, _inner.LeftJoin(arg0, arg1, arg2, arg3)); } /// /// @@ -226,7 +226,7 @@ public KNetKStream LeftJoin(_factory, _stream.LeftJoin(arg0, arg1, arg2)); + return new KNetKStream(_factory, _inner.LeftJoin(arg0, arg1, arg2)); } /// /// @@ -243,7 +243,7 @@ public KNetKStream LeftJoin FlatMap(KNetEnumerableKeyValueMapper arg0, Org.Apache.Kafka.Streams.Kstream.Named arg1) where Arg0objectSuperK : K where Arg0objectSuperV : V where Arg0ExtendsKR : KR where Arg0ExtendsVR : VR { if (arg0 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; - return new KNetKStream(_factory, _stream.FlatMap>, Org.Apache.Kafka.Streams.KeyValue, byte[], byte[]>(arg0, arg1)); + return new KNetKStream(_factory, _inner.FlatMap>, Org.Apache.Kafka.Streams.KeyValue, byte[], byte[]>(arg0, arg1)); } /// /// @@ -259,7 +259,7 @@ public KNetKStream FlatMap FlatMap(KNetEnumerableKeyValueMapper arg0) where Arg0objectSuperK : K where Arg0objectSuperV : V where Arg0ExtendsKR : KR where Arg0ExtendsVR : VR { if (arg0 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; - return new KNetKStream(_factory, _stream.FlatMap>, Org.Apache.Kafka.Streams.KeyValue, byte[], byte[]>(arg0)); + return new KNetKStream(_factory, _inner.FlatMap>, Org.Apache.Kafka.Streams.KeyValue, byte[], byte[]>(arg0)); } /// /// @@ -276,7 +276,7 @@ public KNetKStream FlatMap Map(KNetKeyValueKeyValueMapper arg0, Org.Apache.Kafka.Streams.Kstream.Named arg1) where Arg0objectSuperK : K where Arg0objectSuperV : V where Arg0ExtendsKR : KR where Arg0ExtendsVR : VR { if (arg0 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; - return new KNetKStream(_factory, _stream.Map, byte[], byte[]>(arg0, arg1)); + return new KNetKStream(_factory, _inner.Map, byte[], byte[]>(arg0, arg1)); } /// /// @@ -292,7 +292,7 @@ public KNetKStream Map Map(KNetKeyValueKeyValueMapper arg0) where Arg0objectSuperK : K where Arg0objectSuperV : V where Arg0ExtendsKR : KR where Arg0ExtendsVR : VR { if (arg0 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; - return new KNetKStream(_factory, _stream.Map, byte[], byte[]>(arg0)); + return new KNetKStream(_factory, _inner.Map, byte[], byte[]>(arg0)); } /// /// @@ -307,7 +307,7 @@ public KNetKGroupedStream GroupBy { if (arg0 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; if (arg1 is IGenericSerDesFactoryApplier applier1) applier1.Factory = _factory; - return new KNetKGroupedStream(_factory, _stream.GroupBy(arg0, arg1)); + return new KNetKGroupedStream(_factory, _inner.GroupBy(arg0, arg1)); } /// /// @@ -320,7 +320,7 @@ public KNetKGroupedStream GroupBy public KNetKGroupedStream GroupBy(KNetKeyValueMapper arg0) where Arg0objectSuperK : K where Arg0objectSuperV : V { if (arg0 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; - return new KNetKGroupedStream(_factory, _stream.GroupBy(arg0)); + return new KNetKGroupedStream(_factory, _inner.GroupBy(arg0)); } /// /// @@ -335,7 +335,7 @@ public KNetKGroupedStream GroupBy public KNetKStream SelectKey(KNetKeyValueMapper arg0, Org.Apache.Kafka.Streams.Kstream.Named arg1) where Arg0objectSuperK : K where Arg0objectSuperV : V where Arg0ExtendsKR : KR { if (arg0 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; - return new KNetKStream(_factory, _stream.SelectKey(arg0, arg1)); + return new KNetKStream(_factory, _inner.SelectKey(arg0, arg1)); } /// /// @@ -349,7 +349,7 @@ public KNetKStream SelectKey SelectKey(KNetKeyValueMapper arg0) where Arg0objectSuperK : K where Arg0objectSuperV : V where Arg0ExtendsKR : KR { if (arg0 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; - return new KNetKStream(_factory, _stream.SelectKey(arg0)); + return new KNetKStream(_factory, _inner.SelectKey(arg0)); } /// /// @@ -368,7 +368,7 @@ public KNetKStream Join(_factory, _stream.Join(arg0, arg1, arg2, arg3)); + return new KNetKStream(_factory, _inner.Join(arg0, arg1, arg2, arg3)); } /// /// @@ -385,7 +385,7 @@ public KNetKStream Join Join(KNetKStream arg0, KNetValueJoiner arg1, Org.Apache.Kafka.Streams.Kstream.JoinWindows arg2) where Arg1objectSuperV : V where Arg1objectSuperVO : VO where Arg1ExtendsVR : VR { if (arg1 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; - return new KNetKStream(_factory, _stream.Join(arg0, arg1, arg2)); + return new KNetKStream(_factory, _inner.Join(arg0, arg1, arg2)); } /// /// @@ -405,7 +405,7 @@ public KNetKStream Join(_factory, _stream.Join(arg0, arg1, arg2, arg3)); + return new KNetKStream(_factory, _inner.Join(arg0, arg1, arg2, arg3)); } /// /// @@ -423,7 +423,7 @@ public KNetKStream Join Join(KNetKStream arg0, KNetValueJoinerWithKey arg1, Org.Apache.Kafka.Streams.Kstream.JoinWindows arg2) where Arg1objectSuperK : K where Arg1objectSuperV : V where Arg1objectSuperVO : VO where Arg1ExtendsVR : VR { if (arg1 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; - return new KNetKStream(_factory, _stream.LeftJoin(arg0, arg1, arg2)); + return new KNetKStream(_factory, _inner.LeftJoin(arg0, arg1, arg2)); } /// /// @@ -442,7 +442,7 @@ public KNetKStream LeftJoin(_factory, _stream.LeftJoin(arg0, arg1, arg2, arg3)); + return new KNetKStream(_factory, _inner.LeftJoin(arg0, arg1, arg2, arg3)); } /// /// @@ -459,7 +459,7 @@ public KNetKStream LeftJoin LeftJoin(KNetKStream arg0, KNetValueJoiner arg1, Org.Apache.Kafka.Streams.Kstream.JoinWindows arg2) where Arg1objectSuperV : V where Arg1objectSuperVO : VO where Arg1ExtendsVR : VR { if (arg1 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; - return new KNetKStream(_factory, _stream.LeftJoin(arg0, arg1, arg2)); + return new KNetKStream(_factory, _inner.LeftJoin(arg0, arg1, arg2)); } /// /// @@ -479,7 +479,7 @@ public KNetKStream LeftJoin(_factory, _stream.LeftJoin(arg0, arg1, arg2, arg3)); + return new KNetKStream(_factory, _inner.LeftJoin(arg0, arg1, arg2, arg3)); } /// /// @@ -497,7 +497,7 @@ public KNetKStream LeftJoin LeftJoin(KNetKStream arg0, KNetValueJoinerWithKey arg1, Org.Apache.Kafka.Streams.Kstream.JoinWindows arg2) where Arg1objectSuperK : K where Arg1objectSuperV : V where Arg1objectSuperVO : VO where Arg1ExtendsVR : VR { if (arg1 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; - return new KNetKStream(_factory, _stream.LeftJoin(arg0, arg1, arg2)); + return new KNetKStream(_factory, _inner.LeftJoin(arg0, arg1, arg2)); } /// /// @@ -516,7 +516,7 @@ public KNetKStream OuterJoin(_factory, _stream.OuterJoin(arg0, arg1, arg2, arg3)); + return new KNetKStream(_factory, _inner.OuterJoin(arg0, arg1, arg2, arg3)); } /// /// @@ -533,7 +533,7 @@ public KNetKStream OuterJoin OuterJoin(KNetKStream arg0, KNetValueJoiner arg1, Org.Apache.Kafka.Streams.Kstream.JoinWindows arg2) where Arg1objectSuperV : V where Arg1objectSuperVO : VO where Arg1ExtendsVR : VR { if (arg1 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; - return new KNetKStream(_factory, _stream.OuterJoin(arg0, arg1, arg2)); + return new KNetKStream(_factory, _inner.OuterJoin(arg0, arg1, arg2)); } /// /// @@ -553,7 +553,7 @@ public KNetKStream OuterJoin(_factory, _stream.OuterJoin(arg0, arg1, arg2, arg3)); + return new KNetKStream(_factory, _inner.OuterJoin(arg0, arg1, arg2, arg3)); } /// /// @@ -571,7 +571,7 @@ public KNetKStream OuterJoin OuterJoin(KNetKStream arg0, KNetValueJoinerWithKey arg1, Org.Apache.Kafka.Streams.Kstream.JoinWindows arg2) where Arg1objectSuperK : K where Arg1objectSuperV : V where Arg1objectSuperVO : VO where Arg1ExtendsVR : VR { if (arg1 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; - return new KNetKStream(_factory, _stream.OuterJoin(arg0, arg1, arg2)); + return new KNetKStream(_factory, _inner.OuterJoin(arg0, arg1, arg2)); } /// /// @@ -585,7 +585,7 @@ public KNetKStream OuterJoin FlatMapValues(KNetEnumerableValueMapper arg0, Org.Apache.Kafka.Streams.Kstream.Named arg1) where Arg0objectSuperV : V where Arg0ExtendsVR : VR { if (arg0 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; - return new KNetKStream(_factory, _stream.FlatMapValues, byte[]>(arg0, arg1)); + return new KNetKStream(_factory, _inner.FlatMapValues, byte[]>(arg0, arg1)); } /// /// @@ -598,7 +598,7 @@ public KNetKStream FlatMapValues(KNe public KNetKStream FlatMapValues(KNetEnumerableValueMapper arg0) where Arg0objectSuperV : V where Arg0ExtendsVR : VR { if (arg0 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; - return new KNetKStream(_factory, _stream.FlatMapValues, byte[]>(arg0)); + return new KNetKStream(_factory, _inner.FlatMapValues, byte[]>(arg0)); } /// /// @@ -613,7 +613,7 @@ public KNetKStream FlatMapValues(KNe public KNetKStream FlatMapValues(KNetEnumerableValueMapperWithKey arg0, Org.Apache.Kafka.Streams.Kstream.Named arg1) where Arg0objectSuperK : K where Arg0objectSuperV : V where Arg0ExtendsVR : VR { if (arg0 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; - return new KNetKStream(_factory, _stream.FlatMapValues, byte[]>(arg0, arg1)); + return new KNetKStream(_factory, _inner.FlatMapValues, byte[]>(arg0, arg1)); } /// /// @@ -627,7 +627,7 @@ public KNetKStream FlatMapValues FlatMapValues(KNetEnumerableValueMapperWithKey arg0) where Arg0objectSuperK : K where Arg0objectSuperV : V where Arg0ExtendsVR : VR { if (arg0 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; - return new KNetKStream(_factory, _stream.FlatMapValues, byte[]>(arg0)); + return new KNetKStream(_factory, _inner.FlatMapValues, byte[]>(arg0)); } /// /// @@ -641,7 +641,7 @@ public KNetKStream FlatMapValues MapValues(KNetValueMapper arg0, Org.Apache.Kafka.Streams.Kstream.Named arg1) where Arg0objectSuperV : V where Arg0ExtendsVR : VR { if (arg0 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; - return new KNetKStream(_factory, _stream.MapValues(arg0)); + return new KNetKStream(_factory, _inner.MapValues(arg0)); } /// /// @@ -654,7 +654,7 @@ public KNetKStream MapValues(KNetVal public KNetKStream MapValues(KNetValueMapper arg0) where Arg0objectSuperV : V where Arg0ExtendsVR : VR { if (arg0 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; - return new KNetKStream(_factory, _stream.MapValues(arg0)); + return new KNetKStream(_factory, _inner.MapValues(arg0)); } /// /// @@ -669,7 +669,7 @@ public KNetKStream MapValues(KNetVal public KNetKStream MapValues(KNetValueMapperWithKey arg0, Org.Apache.Kafka.Streams.Kstream.Named arg1) where Arg0objectSuperK : K where Arg0objectSuperV : V where Arg0ExtendsVR : VR { if (arg0 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; - return new KNetKStream(_factory, _stream.MapValues(arg0, arg1)); + return new KNetKStream(_factory, _inner.MapValues(arg0, arg1)); } /// /// @@ -683,7 +683,7 @@ public KNetKStream MapValues MapValues(KNetValueMapperWithKey arg0) where Arg0objectSuperK : K where Arg0objectSuperV : V where Arg0ExtendsVR : VR { if (arg0 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; - return new KNetKStream(_factory, _stream.MapValues(arg0)); + return new KNetKStream(_factory, _inner.MapValues(arg0)); } /// /// @@ -701,7 +701,7 @@ public KNetKStream Join(_factory, _stream.Join(arg0, arg1, arg2)); + return new KNetKStream(_factory, _inner.Join(arg0, arg1, arg2)); } /// /// @@ -717,7 +717,7 @@ public KNetKStream Join Join(KNetKTable arg0, KNetValueJoiner arg1) where Arg1objectSuperV : V where Arg1objectSuperVT : VT where Arg1ExtendsVR : VR { if (arg1 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; - return new KNetKStream(_factory, _stream.Join(arg0, arg1)); + return new KNetKStream(_factory, _inner.Join(arg0, arg1)); } /// /// @@ -736,7 +736,7 @@ public KNetKStream Join(_factory, _stream.Join(arg0, arg1, arg2)); + return new KNetKStream(_factory, _inner.Join(arg0, arg1, arg2)); } /// /// @@ -753,7 +753,7 @@ public KNetKStream Join Join(KNetKTable arg0, KNetValueJoinerWithKey arg1) where Arg1objectSuperK : K where Arg1objectSuperV : V where Arg1objectSuperVT : VT where Arg1ExtendsVR : VR { if (arg1 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; - return new KNetKStream(_factory, _stream.LeftJoin(arg0, arg1)); + return new KNetKStream(_factory, _inner.LeftJoin(arg0, arg1)); } /// /// @@ -771,7 +771,7 @@ public KNetKStream LeftJoin(_factory, _stream.LeftJoin(arg0, arg1, arg2)); + return new KNetKStream(_factory, _inner.LeftJoin(arg0, arg1, arg2)); } /// /// @@ -787,7 +787,7 @@ public KNetKStream LeftJoin LeftJoin(KNetKTable arg0, KNetValueJoiner arg1) where Arg1objectSuperV : V where Arg1objectSuperVT : VT where Arg1ExtendsVR : VR { if (arg1 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; - return new KNetKStream(_factory, _stream.LeftJoin(arg0, arg1)); + return new KNetKStream(_factory, _inner.LeftJoin(arg0, arg1)); } /// /// @@ -805,7 +805,7 @@ public KNetKStream LeftJoin LeftJoin(KNetKTable arg0, KNetValueJoinerWithKey arg1, KNetJoined arg2) where Arg1objectSuperK : K where Arg1objectSuperV : V where Arg1objectSuperVT : VT where Arg1ExtendsVR : VR { if (arg1 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; - return new KNetKStream(_factory, _stream.LeftJoin(arg0, arg1, arg2)); + return new KNetKStream(_factory, _inner.LeftJoin(arg0, arg1, arg2)); } /// /// @@ -822,7 +822,7 @@ public KNetKStream LeftJoin LeftJoin(KNetKTable arg0, KNetValueJoinerWithKey arg1) where Arg1objectSuperK : K where Arg1objectSuperV : V where Arg1objectSuperVT : VT where Arg1ExtendsVR : VR { if (arg1 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; - return new KNetKStream(_factory, _stream.LeftJoin(arg0, arg1)); + return new KNetKStream(_factory, _inner.LeftJoin(arg0, arg1)); } /// /// @@ -830,7 +830,7 @@ public KNetKStream LeftJoin public KNetBranchedKStream Split() { - return new KNetBranchedKStream(_factory, _stream.Split()); + return new KNetBranchedKStream(_factory, _inner.Split()); } /// /// @@ -839,7 +839,7 @@ public KNetBranchedKStream Split() /// public KNetBranchedKStream Split(Org.Apache.Kafka.Streams.Kstream.Named arg0) { - return new KNetBranchedKStream(_factory, _stream.Split(arg0)); + return new KNetBranchedKStream(_factory, _inner.Split(arg0)); } /// /// @@ -847,7 +847,7 @@ public KNetBranchedKStream Split(Org.Apache.Kafka.Streams.Kstream.Named ar /// public KNetKGroupedStream GroupByKey() { - return new KNetKGroupedStream(_factory, _stream.GroupByKey()); + return new KNetKGroupedStream(_factory, _inner.GroupByKey()); } /// /// @@ -857,7 +857,7 @@ public KNetKGroupedStream GroupByKey() public KNetKGroupedStream GroupByKey(KNetGrouped arg0) { if (arg0 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; - return new KNetKGroupedStream(_factory, _stream.GroupByKey(arg0)); + return new KNetKGroupedStream(_factory, _inner.GroupByKey(arg0)); } /// /// @@ -870,7 +870,7 @@ public KNetKGroupedStream GroupByKey(KNetGrouped arg0) public KNetKStream Filter(KNetPredicate arg0, Org.Apache.Kafka.Streams.Kstream.Named arg1) where Arg0objectSuperK : K where Arg0objectSuperV : V { if (arg0 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; - return new KNetKStream(_factory, _stream.Filter(arg0, arg1)); + return new KNetKStream(_factory, _inner.Filter(arg0, arg1)); } /// /// @@ -882,7 +882,7 @@ public KNetKStream Filter(KNetPredicat public KNetKStream Filter(KNetPredicate arg0) where Arg0objectSuperK : K where Arg0objectSuperV : V { if (arg0 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; - return new KNetKStream(_factory, _stream.Filter(arg0)); + return new KNetKStream(_factory, _inner.Filter(arg0)); } /// /// @@ -895,7 +895,7 @@ public KNetKStream Filter(KNetPredicat public KNetKStream FilterNot(KNetPredicate arg0, Org.Apache.Kafka.Streams.Kstream.Named arg1) where Arg0objectSuperK : K where Arg0objectSuperV : V { if (arg0 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; - return new KNetKStream(_factory, _stream.FilterNot(arg0, arg1)); + return new KNetKStream(_factory, _inner.FilterNot(arg0, arg1)); } /// /// @@ -907,7 +907,7 @@ public KNetKStream FilterNot(KNetPredi public KNetKStream FilterNot(KNetPredicate arg0) where Arg0objectSuperK : K where Arg0objectSuperV : V { if (arg0 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; - return new KNetKStream(_factory, _stream.FilterNot(arg0)); + return new KNetKStream(_factory, _inner.FilterNot(arg0)); } /// /// @@ -917,7 +917,7 @@ public KNetKStream FilterNot(KNetPredi /// public KNetKStream Merge(KNetKStream arg0, Org.Apache.Kafka.Streams.Kstream.Named arg1) { - return new KNetKStream(_factory, _stream.Merge(arg0, arg1)); + return new KNetKStream(_factory, _inner.Merge(arg0, arg1)); } /// /// @@ -926,7 +926,7 @@ public KNetKStream Merge(KNetKStream arg0, Org.Apache.Kafka.Streams. /// public KNetKStream Merge(KNetKStream arg0) { - return new KNetKStream(_factory, _stream.Merge(arg0)); + return new KNetKStream(_factory, _inner.Merge(arg0)); } /// /// @@ -939,7 +939,7 @@ public KNetKStream Merge(KNetKStream arg0) public KNetKStream Peek(KNetForeachAction arg0, Org.Apache.Kafka.Streams.Kstream.Named arg1) where Arg0objectSuperK : K where Arg0objectSuperV : V { if (arg0 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; - return new KNetKStream(_factory, _stream.Peek(arg0, arg1)); + return new KNetKStream(_factory, _inner.Peek(arg0, arg1)); } /// /// @@ -951,7 +951,7 @@ public KNetKStream Peek(KNetForeachAct public KNetKStream Peek(KNetForeachAction arg0) where Arg0objectSuperK : K where Arg0objectSuperV : V { if (arg0 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; - return new KNetKStream(_factory, _stream.Peek(arg0)); + return new KNetKStream(_factory, _inner.Peek(arg0)); } /// /// @@ -959,7 +959,7 @@ public KNetKStream Peek(KNetForeachAct /// public KNetKStream Repartition() { - return new KNetKStream(_factory, _stream.Repartition()); + return new KNetKStream(_factory, _inner.Repartition()); } /// /// @@ -969,7 +969,7 @@ public KNetKStream Repartition() public KNetKStream Repartition(KNetRepartitioned arg0) { if (arg0 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; - return new KNetKStream(_factory, _stream.Repartition(arg0)); + return new KNetKStream(_factory, _inner.Repartition(arg0)); } /// /// @@ -978,7 +978,7 @@ public KNetKStream Repartition(KNetRepartitioned arg0) /// public KNetKTable ToTable() { - return new KNetKTable(_factory, _stream.ToTable()); + return new KNetKTable(_factory, _inner.ToTable()); } /// /// @@ -988,7 +988,7 @@ public KNetKTable ToTable() public KNetKTable ToTable(KNetMaterialized arg0) { if (arg0 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; - return new KNetKTable(_factory, _stream.ToTable(arg0)); + return new KNetKTable(_factory, _inner.ToTable(arg0)); } /// /// @@ -999,7 +999,7 @@ public KNetKTable ToTable(KNetMaterialized arg0) public KNetKTable ToTable(Org.Apache.Kafka.Streams.Kstream.Named arg0, KNetMaterialized arg1) { if (arg1 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; - return new KNetKTable(_factory, _stream.ToTable(arg0, arg1)); + return new KNetKTable(_factory, _inner.ToTable(arg0, arg1)); } /// /// @@ -1008,7 +1008,7 @@ public KNetKTable ToTable(Org.Apache.Kafka.Streams.Kstream.Named arg0, KNe /// public KNetKTable ToTable(Org.Apache.Kafka.Streams.Kstream.Named arg0) { - return new KNetKTable(_factory, _stream.ToTable(arg0)); + return new KNetKTable(_factory, _inner.ToTable(arg0)); } /// /// @@ -1020,7 +1020,7 @@ public KNetKTable ToTable(Org.Apache.Kafka.Streams.Kstream.Named arg0) public void Foreach(KNetForeachAction arg0, Org.Apache.Kafka.Streams.Kstream.Named arg1) where Arg0objectSuperK : K where Arg0objectSuperV : V { if (arg0 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; - _stream.Foreach(arg0, arg1); + _inner.Foreach(arg0, arg1); } /// /// @@ -1031,7 +1031,7 @@ public void Foreach(KNetForeachAction(KNetForeachAction arg0) where Arg0objectSuperK : K where Arg0objectSuperV : V { if (arg0 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; - _stream.Foreach(arg0); + _inner.Foreach(arg0); } /// /// @@ -1040,7 +1040,7 @@ public void Foreach(KNetForeachAction arg0) { if (arg0 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; - _stream.Print(arg0); + _inner.Print(arg0); } /// /// @@ -1050,7 +1050,7 @@ public void Print(KNetPrinted arg0) public void To(string arg0, KNetProduced arg1) { if (arg1 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; - _stream.To(arg0, arg1); + _inner.To(arg0, arg1); } /// /// @@ -1058,7 +1058,7 @@ public void To(string arg0, KNetProduced arg1) /// public void To(string arg0) { - _stream.To(arg0); + _inner.To(arg0); } /// /// @@ -1069,7 +1069,7 @@ public void To(KNetTopicNameExtractor arg0, KNetProduced arg1) { if (arg0 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; if (arg1 is IGenericSerDesFactoryApplier applier1) applier1.Factory = _factory; - _stream.To(arg0, arg1); + _inner.To(arg0, arg1); } /// /// @@ -1078,7 +1078,7 @@ public void To(KNetTopicNameExtractor arg0, KNetProduced arg1) public void To(KNetTopicNameExtractor arg0) { if (arg0 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; - _stream.To(arg0); + _inner.To(arg0); } } } diff --git a/src/net/KNet/Specific/Streams/Kstream/KNetKTable.cs b/src/net/KNet/Specific/Streams/Kstream/KNetKTable.cs index 370f3911b0..8a642a0b34 100644 --- a/src/net/KNet/Specific/Streams/Kstream/KNetKTable.cs +++ b/src/net/KNet/Specific/Streams/Kstream/KNetKTable.cs @@ -17,6 +17,8 @@ */ using MASES.KNet.Serialization; +using MASES.KNet.Streams.Utils; +using System; namespace MASES.KNet.Streams.Kstream { @@ -27,21 +29,793 @@ namespace MASES.KNet.Streams.Kstream /// public class KNetKTable : IGenericSerDesFactoryApplier { - Org.Apache.Kafka.Streams.Kstream.KTable _table; + Org.Apache.Kafka.Streams.Kstream.KTable _inner; + Org.Apache.Kafka.Streams.Kstream.KTable _inner2; IGenericSerDesFactory _factory; IGenericSerDesFactory IGenericSerDesFactoryApplier.Factory { get => _factory; set { _factory = value; } } - internal KNetKTable(IGenericSerDesFactory factory, Org.Apache.Kafka.Streams.Kstream.KTable table) + internal KNetKTable(IGenericSerDesFactory factory, Org.Apache.Kafka.Streams.Kstream.KTable inner) { _factory = factory; - _table = table; + _inner = inner; } + internal KNetKTable(IGenericSerDesFactory factory, Org.Apache.Kafka.Streams.Kstream.KTable inner) + { + _factory = factory; + _inner2 = inner; + } + + /// + /// Converter from to + /// + public static implicit operator Org.Apache.Kafka.Streams.Kstream.KTable(KNetKTable t) => t._inner; + /// /// Converter from to /// - public static implicit operator Org.Apache.Kafka.Streams.Kstream.KTable(KNetKTable t) => t._table; + public static implicit operator Org.Apache.Kafka.Streams.Kstream.KTable(KNetKTable t) => t._inner2; + + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public KNetKGroupedTable GroupBy(KNetKeyValueKeyValueMapper arg0, KNetGrouped arg1) where Arg0objectSuperK : K where Arg0objectSuperV : V + { + if (_inner == null && _inner2 != null) throw new InvalidOperationException("Current implementation does not manage KNetKTable generated from Count methods of KNetKGroupedTable"); + + if (arg0 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; + if (arg1 is IGenericSerDesFactoryApplier applier1) applier1.Factory = _factory; + return new KNetKGroupedTable(_factory, _inner.GroupBy(arg0, arg1)); + } + /// + /// + /// + /// + /// + /// + /// + /// + /// + public KNetKGroupedTable GroupBy(KNetKeyValueKeyValueMapper arg0) where Arg0objectSuperK : K where Arg0objectSuperV : V + { + if (_inner == null && _inner2 != null) throw new InvalidOperationException("Current implementation does not manage KNetKTable generated from Count methods of KNetKGroupedTable"); + + if (arg0 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; + return new KNetKGroupedTable(_factory, _inner.GroupBy(arg0)); + } + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public KNetKStream ToStream(KNetKeyValueMapper arg0, Org.Apache.Kafka.Streams.Kstream.Named arg1) where Arg0objectSuperK : K where Arg0objectSuperV : V where Arg0ExtendsKR : KR + { + if (_inner == null && _inner2 != null) throw new InvalidOperationException("Current implementation does not manage KNetKTable generated from Count methods of KNetKGroupedTable"); + + if (arg0 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; + return new KNetKStream(_factory, _inner.ToStream(arg0, arg1)); + } + /// + /// + /// + /// + /// + /// + /// + /// + /// + public KNetKStream ToStream(KNetKeyValueMapper arg0) where Arg0objectSuperK : K where Arg0objectSuperV : V where Arg0ExtendsKR : KR + { + if (_inner == null && _inner2 != null) throw new InvalidOperationException("Current implementation does not manage KNetKTable generated from Count methods of KNetKGroupedTable"); + + if (arg0 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; + return new KNetKStream(_factory, _inner.ToStream(arg0)); + } + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public KNetKTable Join(KNetKTable arg0, KNetValueJoiner arg1, KNetMaterialized arg2) where Arg1objectSuperV : V where Arg1objectSuperVO : VO where Arg1ExtendsVR : VR + { + if (_inner == null && _inner2 != null) throw new InvalidOperationException("Current implementation does not manage KNetKTable generated from Count methods of KNetKGroupedTable"); + + if (arg1 is IGenericSerDesFactoryApplier applier1) applier1.Factory = _factory; + if (arg2 is IGenericSerDesFactoryApplier applier2) applier2.Factory = _factory; + return new KNetKTable(_factory, _inner.Join(arg0, arg1, arg2)); + } + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public KNetKTable Join(KNetKTable arg0, KNetValueJoiner arg1, Org.Apache.Kafka.Streams.Kstream.Named arg2, KNetMaterialized arg3) where Arg1objectSuperV : V where Arg1objectSuperVO : VO where Arg1ExtendsVR : VR + { + if (_inner == null && _inner2 != null) throw new InvalidOperationException("Current implementation does not manage KNetKTable generated from Count methods of KNetKGroupedTable"); + + if (arg1 is IGenericSerDesFactoryApplier applier1) applier1.Factory = _factory; + if (arg3 is IGenericSerDesFactoryApplier applier3) applier3.Factory = _factory; + return new KNetKTable(_factory, _inner.Join(arg0, arg1, arg2, arg3)); + } + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public KNetKTable Join(KNetKTable arg0, KNetValueJoiner arg1, Org.Apache.Kafka.Streams.Kstream.Named arg2) where Arg1objectSuperV : V where Arg1objectSuperVO : VO where Arg1ExtendsVR : VR + { + if (_inner == null && _inner2 != null) throw new InvalidOperationException("Current implementation does not manage KNetKTable generated from Count methods of KNetKGroupedTable"); + + if (arg1 is IGenericSerDesFactoryApplier applier1) applier1.Factory = _factory; + return new KNetKTable(_factory, _inner.Join(arg0, arg1, arg2)); + } + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public KNetKTable Join(KNetKTable arg0, KNetValueJoiner arg1) where Arg1objectSuperV : V where Arg1objectSuperVO : VO where Arg1ExtendsVR : VR + { + if (_inner == null && _inner2 != null) throw new InvalidOperationException("Current implementation does not manage KNetKTable generated from Count methods of KNetKGroupedTable"); + + if (arg1 is IGenericSerDesFactoryApplier applier1) applier1.Factory = _factory; + return new KNetKTable(_factory, _inner.Join(arg0, arg1)); + } + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public KNetKTable LeftJoin(KNetKTable arg0, KNetValueJoiner arg1, KNetMaterialized arg2) where Arg1objectSuperV : V where Arg1objectSuperVO : VO where Arg1ExtendsVR : VR + { + if (_inner == null && _inner2 != null) throw new InvalidOperationException("Current implementation does not manage KNetKTable generated from Count methods of KNetKGroupedTable"); + + if (arg1 is IGenericSerDesFactoryApplier applier1) applier1.Factory = _factory; + if (arg2 is IGenericSerDesFactoryApplier applier2) applier2.Factory = _factory; + return new KNetKTable(_factory, _inner.LeftJoin(arg0, arg1, arg2)); + } + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public KNetKTable LeftJoin(KNetKTable arg0, KNetValueJoiner arg1, Org.Apache.Kafka.Streams.Kstream.Named arg2, KNetMaterialized arg3) where Arg1objectSuperV : V where Arg1objectSuperVO : VO where Arg1ExtendsVR : VR + { + if (_inner == null && _inner2 != null) throw new InvalidOperationException("Current implementation does not manage KNetKTable generated from Count methods of KNetKGroupedTable"); + if (arg1 is IGenericSerDesFactoryApplier applier1) applier1.Factory = _factory; + if (arg3 is IGenericSerDesFactoryApplier applier3) applier3.Factory = _factory; + return new KNetKTable(_factory, _inner.LeftJoin(arg0, arg1, arg2, arg3)); + } + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public KNetKTable LeftJoin(KNetKTable arg0, KNetValueJoiner arg1, Org.Apache.Kafka.Streams.Kstream.Named arg2) where Arg1objectSuperV : V where Arg1objectSuperVO : VO where Arg1ExtendsVR : VR + { + if (_inner == null && _inner2 != null) throw new InvalidOperationException("Current implementation does not manage KNetKTable generated from Count methods of KNetKGroupedTable"); + + if (arg1 is IGenericSerDesFactoryApplier applier1) applier1.Factory = _factory; + return new KNetKTable(_factory, _inner.LeftJoin(arg0, arg1, arg2)); + } + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public KNetKTable LeftJoin(KNetKTable arg0, KNetValueJoiner arg1) where Arg1objectSuperV : V where Arg1objectSuperVO : VO where Arg1ExtendsVR : VR + { + if (_inner == null && _inner2 != null) throw new InvalidOperationException("Current implementation does not manage KNetKTable generated from Count methods of KNetKGroupedTable"); + + if (arg1 is IGenericSerDesFactoryApplier applier1) applier1.Factory = _factory; + return new KNetKTable(_factory, _inner.LeftJoin(arg0, arg1)); + } + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public KNetKTable OuterJoin(KNetKTable arg0, KNetValueJoiner arg1, KNetMaterialized arg2) where Arg1objectSuperV : V where Arg1objectSuperVO : VO where Arg1ExtendsVR : VR + { + if (_inner == null && _inner2 != null) throw new InvalidOperationException("Current implementation does not manage KNetKTable generated from Count methods of KNetKGroupedTable"); + + if (arg1 is IGenericSerDesFactoryApplier applier1) applier1.Factory = _factory; + if (arg2 is IGenericSerDesFactoryApplier applier2) applier2.Factory = _factory; + return new KNetKTable(_factory, _inner.OuterJoin(arg0, arg1, arg2)); + } + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public KNetKTable OuterJoin(KNetKTable arg0, KNetValueJoiner arg1, Org.Apache.Kafka.Streams.Kstream.Named arg2, KNetMaterialized arg3) where Arg1objectSuperV : V where Arg1objectSuperVO : VO where Arg1ExtendsVR : VR + { + if (_inner == null && _inner2 != null) throw new InvalidOperationException("Current implementation does not manage KNetKTable generated from Count methods of KNetKGroupedTable"); + + if (arg1 is IGenericSerDesFactoryApplier applier1) applier1.Factory = _factory; + if (arg3 is IGenericSerDesFactoryApplier applier3) applier3.Factory = _factory; + return new KNetKTable(_factory, _inner.OuterJoin(arg0, arg1, arg2, arg3)); + } + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public KNetKTable OuterJoin(KNetKTable arg0, KNetValueJoiner arg1, Org.Apache.Kafka.Streams.Kstream.Named arg2) where Arg1objectSuperV : V where Arg1objectSuperVO : VO where Arg1ExtendsVR : VR + { + if (_inner == null && _inner2 != null) throw new InvalidOperationException("Current implementation does not manage KNetKTable generated from Count methods of KNetKGroupedTable"); + + if (arg1 is IGenericSerDesFactoryApplier applier1) applier1.Factory = _factory; + return new KNetKTable(_factory, _inner.OuterJoin(arg0, arg1, arg2)); + } + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public KNetKTable OuterJoin(KNetKTable arg0, KNetValueJoiner arg1) where Arg1objectSuperV : V where Arg1objectSuperVO : VO where Arg1ExtendsVR : VR + { + if (_inner == null && _inner2 != null) throw new InvalidOperationException("Current implementation does not manage KNetKTable generated from Count methods of KNetKGroupedTable"); + + if (arg1 is IGenericSerDesFactoryApplier applier1) applier1.Factory = _factory; + return new KNetKTable(_factory, _inner.OuterJoin(arg0, arg1)); + } + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public KNetKTable Join(KNetKTable arg0, KNetFunction arg1, KNetValueJoiner arg2, KNetMaterialized arg3) + { + if (_inner == null && _inner2 != null) throw new InvalidOperationException("Current implementation does not manage KNetKTable generated from Count methods of KNetKGroupedTable"); + + if (arg1 is IGenericSerDesFactoryApplier applier1) applier1.Factory = _factory; + if (arg2 is IGenericSerDesFactoryApplier applier2) applier2.Factory = _factory; + if (arg3 is IGenericSerDesFactoryApplier applier3) applier3.Factory = _factory; + return new KNetKTable(_factory, _inner.Join(arg0, arg1, arg2, arg3)); + } + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public KNetKTable Join(KNetKTable arg0, KNetFunction arg1, KNetValueJoiner arg2, KNetTableJoined arg3, KNetMaterialized arg4) + { + if (_inner == null && _inner2 != null) throw new InvalidOperationException("Current implementation does not manage KNetKTable generated from Count methods of KNetKGroupedTable"); + + if (arg1 is IGenericSerDesFactoryApplier applier1) applier1.Factory = _factory; + if (arg2 is IGenericSerDesFactoryApplier applier2) applier2.Factory = _factory; + if (arg3 is IGenericSerDesFactoryApplier applier3) applier3.Factory = _factory; + if (arg4 is IGenericSerDesFactoryApplier applier4) applier4.Factory = _factory; + return new KNetKTable(_factory, _inner.Join(arg0, arg1, arg2, arg3, arg4)); + } + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public KNetKTable Join(KNetKTable arg0, KNetFunction arg1, KNetValueJoiner arg2, KNetTableJoined arg3) + { + if (_inner == null && _inner2 != null) throw new InvalidOperationException("Current implementation does not manage KNetKTable generated from Count methods of KNetKGroupedTable"); + + if (arg1 is IGenericSerDesFactoryApplier applier1) applier1.Factory = _factory; + if (arg2 is IGenericSerDesFactoryApplier applier2) applier2.Factory = _factory; + if (arg3 is IGenericSerDesFactoryApplier applier3) applier3.Factory = _factory; + return new KNetKTable(_factory, _inner.Join(arg0, arg1, arg2, arg3)); + } + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public KNetKTable Join(KNetKTable arg0, KNetFunction arg1, KNetValueJoiner arg2) + { + if (_inner == null && _inner2 != null) throw new InvalidOperationException("Current implementation does not manage KNetKTable generated from Count methods of KNetKGroupedTable"); + + if (arg1 is IGenericSerDesFactoryApplier applier1) applier1.Factory = _factory; + if (arg2 is IGenericSerDesFactoryApplier applier2) applier2.Factory = _factory; + return new KNetKTable(_factory, _inner.Join(arg0, arg1, arg2)); + } + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public KNetKTable LeftJoin(KNetKTable arg0, KNetFunction arg1, KNetValueJoiner arg2, KNetMaterialized arg3) + { + if (_inner == null && _inner2 != null) throw new InvalidOperationException("Current implementation does not manage KNetKTable generated from Count methods of KNetKGroupedTable"); + + if (arg1 is IGenericSerDesFactoryApplier applier1) applier1.Factory = _factory; + if (arg2 is IGenericSerDesFactoryApplier applier2) applier2.Factory = _factory; + if (arg3 is IGenericSerDesFactoryApplier applier3) applier3.Factory = _factory; + return new KNetKTable(_factory, _inner.LeftJoin(arg0, arg1, arg2, arg3)); + } + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public KNetKTable LeftJoin(KNetKTable arg0, KNetFunction arg1, KNetValueJoiner arg2, KNetTableJoined arg3, KNetMaterialized arg4) + { + if (_inner == null && _inner2 != null) throw new InvalidOperationException("Current implementation does not manage KNetKTable generated from Count methods of KNetKGroupedTable"); + + if (arg1 is IGenericSerDesFactoryApplier applier1) applier1.Factory = _factory; + if (arg2 is IGenericSerDesFactoryApplier applier2) applier2.Factory = _factory; + if (arg3 is IGenericSerDesFactoryApplier applier3) applier3.Factory = _factory; + if (arg4 is IGenericSerDesFactoryApplier applier4) applier4.Factory = _factory; + return new KNetKTable(_factory, _inner.LeftJoin(arg0, arg1, arg2, arg3, arg4)); + } + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public KNetKTable LeftJoin(KNetKTable arg0, KNetFunction arg1, KNetValueJoiner arg2, KNetTableJoined arg3) + { + if (_inner == null && _inner2 != null) throw new InvalidOperationException("Current implementation does not manage KNetKTable generated from Count methods of KNetKGroupedTable"); + + if (arg1 is IGenericSerDesFactoryApplier applier1) applier1.Factory = _factory; + if (arg2 is IGenericSerDesFactoryApplier applier2) applier2.Factory = _factory; + if (arg3 is IGenericSerDesFactoryApplier applier3) applier3.Factory = _factory; + return new KNetKTable(_factory, _inner.LeftJoin(arg0, arg1, arg2, arg3)); + } + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public KNetKTable LeftJoin(KNetKTable arg0, KNetFunction arg1, KNetValueJoiner arg2) + { + if (_inner == null && _inner2 != null) throw new InvalidOperationException("Current implementation does not manage KNetKTable generated from Count methods of KNetKGroupedTable"); + + if (arg1 is IGenericSerDesFactoryApplier applier1) applier1.Factory = _factory; + if (arg2 is IGenericSerDesFactoryApplier applier2) applier2.Factory = _factory; + return new KNetKTable(_factory, _inner.LeftJoin(arg0, arg1, arg2)); + } + /// + /// + /// + /// + /// + /// + /// + /// + /// + public KNetKTable MapValues(KNetValueMapper arg0, KNetMaterialized arg1) where Arg0objectSuperV : V where Arg0ExtendsVR : VR + { + if (_inner == null && _inner2 != null) throw new InvalidOperationException("Current implementation does not manage KNetKTable generated from Count methods of KNetKGroupedTable"); + + if (arg0 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; + if (arg1 is IGenericSerDesFactoryApplier applier1) applier1.Factory = _factory; + return new KNetKTable(_factory, _inner.MapValues(arg0, arg1)); + } + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public KNetKTable MapValues(KNetValueMapper arg0, Org.Apache.Kafka.Streams.Kstream.Named arg1, KNetMaterialized arg2) where Arg0objectSuperV : V where Arg0ExtendsVR : VR + { + if (_inner == null && _inner2 != null) throw new InvalidOperationException("Current implementation does not manage KNetKTable generated from Count methods of KNetKGroupedTable"); + + if (arg0 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; + if (arg2 is IGenericSerDesFactoryApplier applier2) applier2.Factory = _factory; + return new KNetKTable(_factory, _inner.MapValues(arg0, arg1, arg2)); + } + /// + /// + /// + /// + /// + /// + /// + /// + /// + public KNetKTable MapValues(KNetValueMapper arg0, Org.Apache.Kafka.Streams.Kstream.Named arg1) where Arg0objectSuperV : V where Arg0ExtendsVR : VR + { + if (_inner == null && _inner2 != null) throw new InvalidOperationException("Current implementation does not manage KNetKTable generated from Count methods of KNetKGroupedTable"); + + if (arg0 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; + return new KNetKTable(_factory, _inner.MapValues(arg0, arg1)); + } + /// + /// + /// + /// + /// + /// + /// + /// + public KNetKTable MapValues(KNetValueMapper arg0) where Arg0objectSuperV : V where Arg0ExtendsVR : VR + { + if (_inner == null && _inner2 != null) throw new InvalidOperationException("Current implementation does not manage KNetKTable generated from Count methods of KNetKGroupedTable"); + + if (arg0 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; + return new KNetKTable(_factory, _inner.MapValues(arg0)); + } + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public KNetKTable MapValues(KNetValueMapperWithKey arg0, KNetMaterialized arg1) where Arg0objectSuperK : K where Arg0objectSuperV : V where Arg0ExtendsVR : VR + { + if (_inner == null && _inner2 != null) throw new InvalidOperationException("Current implementation does not manage KNetKTable generated from Count methods of KNetKGroupedTable"); + + if (arg0 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; + if (arg1 is IGenericSerDesFactoryApplier applier1) applier1.Factory = _factory; + return new KNetKTable(_factory, _inner.MapValues(arg0, arg1)); + } + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public KNetKTable MapValues(KNetValueMapperWithKey arg0, Org.Apache.Kafka.Streams.Kstream.Named arg1, KNetMaterialized arg2) where Arg0objectSuperK : K where Arg0objectSuperV : V where Arg0ExtendsVR : VR + { + if (_inner == null && _inner2 != null) throw new InvalidOperationException("Current implementation does not manage KNetKTable generated from Count methods of KNetKGroupedTable"); + + if (arg0 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; + if (arg2 is IGenericSerDesFactoryApplier applier2) applier2.Factory = _factory; + return new KNetKTable(_factory, _inner.MapValues(arg0, arg1, arg2)); + } + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public KNetKTable MapValues(KNetValueMapperWithKey arg0, Org.Apache.Kafka.Streams.Kstream.Named arg1) where Arg0objectSuperK : K where Arg0objectSuperV : V where Arg0ExtendsVR : VR + { + if (_inner == null && _inner2 != null) throw new InvalidOperationException("Current implementation does not manage KNetKTable generated from Count methods of KNetKGroupedTable"); + + if (arg0 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; + return new KNetKTable(_factory, _inner.MapValues(arg0, arg1)); + } + /// + /// + /// + /// + /// + /// + /// + /// + /// + public KNetKTable MapValues(KNetValueMapperWithKey arg0) where Arg0objectSuperK : K where Arg0objectSuperV : V where Arg0ExtendsVR : VR + { + if (_inner == null && _inner2 != null) throw new InvalidOperationException("Current implementation does not manage KNetKTable generated from Count methods of KNetKGroupedTable"); + + if (arg0 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; + return new KNetKTable(_factory, _inner.MapValues(arg0)); + } + /// + /// + /// + /// + public string QueryableStoreName => _inner.QueryableStoreName(); + /// + /// + /// + /// + public KNetKStream ToStream() + { + if (_inner == null && _inner2 != null) throw new InvalidOperationException("Current implementation does not manage KNetKTable generated from Count methods of KNetKGroupedTable"); + + return new KNetKStream(_factory, _inner.ToStream()); + } + /// + /// + /// + /// + /// + public KNetKStream ToStream(Org.Apache.Kafka.Streams.Kstream.Named arg0) + { + if (_inner == null && _inner2 != null) throw new InvalidOperationException("Current implementation does not manage KNetKTable generated from Count methods of KNetKGroupedTable"); + + return new KNetKStream(_factory, _inner.ToStream(arg0)); + } + /// + /// + /// + /// + /// + /// + /// + /// + public KNetKTable Filter(KNetPredicate arg0, KNetMaterialized arg1) where Arg0objectSuperK : K where Arg0objectSuperV : V + { + if (_inner == null && _inner2 != null) throw new InvalidOperationException("Current implementation does not manage KNetKTable generated from Count methods of KNetKGroupedTable"); + + if (arg0 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; + if (arg1 is IGenericSerDesFactoryApplier applier1) applier1.Factory = _factory; + return new KNetKTable(_factory, _inner.Filter(arg0, arg1)); + } + /// + /// + /// + /// + /// + /// + /// + /// + /// + public KNetKTable Filter(KNetPredicate arg0, Org.Apache.Kafka.Streams.Kstream.Named arg1, KNetMaterialized arg2) where Arg0objectSuperK : K where Arg0objectSuperV : V + { + if (_inner == null && _inner2 != null) throw new InvalidOperationException("Current implementation does not manage KNetKTable generated from Count methods of KNetKGroupedTable"); + + if (arg0 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; + if (arg2 is IGenericSerDesFactoryApplier applier2) applier2.Factory = _factory; + return new KNetKTable(_factory, _inner.Filter(arg0, arg1, arg2)); + } + /// + /// + /// + /// + /// + /// + /// + /// + public KNetKTable Filter(KNetPredicate arg0, Org.Apache.Kafka.Streams.Kstream.Named arg1) where Arg0objectSuperK : K where Arg0objectSuperV : V + { + if (_inner == null && _inner2 != null) throw new InvalidOperationException("Current implementation does not manage KNetKTable generated from Count methods of KNetKGroupedTable"); + + if (arg0 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; + return new KNetKTable(_factory, _inner.Filter(arg0, arg1)); + } + /// + /// + /// + /// + /// + /// + /// + public KNetKTable Filter(KNetPredicate arg0) where Arg0objectSuperK : K where Arg0objectSuperV : V + { + if (_inner == null && _inner2 != null) throw new InvalidOperationException("Current implementation does not manage KNetKTable generated from Count methods of KNetKGroupedTable"); + + if (arg0 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; + return new KNetKTable(_factory, _inner.Filter(arg0)); + } + /// + /// + /// + /// + /// + /// + /// + /// + public KNetKTable FilterNot(KNetPredicate arg0, KNetMaterialized arg1) where Arg0objectSuperK : K where Arg0objectSuperV : V + { + if (_inner == null && _inner2 != null) throw new InvalidOperationException("Current implementation does not manage KNetKTable generated from Count methods of KNetKGroupedTable"); + + if (arg0 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; + if (arg1 is IGenericSerDesFactoryApplier applier1) applier1.Factory = _factory; + return new KNetKTable(_factory, _inner.FilterNot(arg0, arg1)); + } + /// + /// + /// + /// + /// + /// + /// + /// + /// + public KNetKTable FilterNot(KNetPredicate arg0, Org.Apache.Kafka.Streams.Kstream.Named arg1, KNetMaterialized arg2) where Arg0objectSuperK : K where Arg0objectSuperV : V + { + if (_inner == null && _inner2 != null) throw new InvalidOperationException("Current implementation does not manage KNetKTable generated from Count methods of KNetKGroupedTable"); + + if (arg0 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; + if (arg2 is IGenericSerDesFactoryApplier applier2) applier2.Factory = _factory; + return new KNetKTable(_factory, _inner.FilterNot(arg0, arg1, arg2)); + } + /// + /// + /// + /// + /// + /// + /// + /// + public KNetKTable FilterNot(KNetPredicate arg0, Org.Apache.Kafka.Streams.Kstream.Named arg1) where Arg0objectSuperK : K where Arg0objectSuperV : V + { + if (_inner == null && _inner2 != null) throw new InvalidOperationException("Current implementation does not manage KNetKTable generated from Count methods of KNetKGroupedTable"); + + if (arg0 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; + return new KNetKTable(_factory, _inner.FilterNot(arg0, arg1)); + } + /// + /// + /// + /// + /// + /// + /// + public KNetKTable FilterNot(KNetPredicate arg0) where Arg0objectSuperK : K where Arg0objectSuperV : V + { + if (_inner == null && _inner2 != null) throw new InvalidOperationException("Current implementation does not manage KNetKTable generated from Count methods of KNetKGroupedTable"); + + if (arg0 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; + return new KNetKTable(_factory, _inner.FilterNot(arg0)); + } + /// + /// + /// + /// + /// + /// + public KNetKTable Suppress(KNetSuppressed arg0) where Arg0objectSuperK : K + { + if (_inner == null && _inner2 != null) throw new InvalidOperationException("Current implementation does not manage KNetKTable generated from Count methods of KNetKGroupedTable"); + + if (arg0 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; + return new KNetKTable(_factory, _inner.Suppress(arg0)); + } } } diff --git a/src/net/KNet/Specific/Streams/Kstream/KNetMaterialized.cs b/src/net/KNet/Specific/Streams/Kstream/KNetMaterialized.cs index 0f3a70e43b..3f6cb9e108 100644 --- a/src/net/KNet/Specific/Streams/Kstream/KNetMaterialized.cs +++ b/src/net/KNet/Specific/Streams/Kstream/KNetMaterialized.cs @@ -18,6 +18,7 @@ using MASES.JCOBridge.C2JBridge; using MASES.KNet.Serialization; +using Org.Apache.Kafka.Common.Serialization; namespace MASES.KNet.Streams.Kstream { @@ -28,6 +29,7 @@ namespace MASES.KNet.Streams.Kstream /// public class KNetMaterialized : IGenericSerDesFactoryApplier { + readonly Org.Apache.Kafka.Streams.Kstream.Materialized> _countKeyStore; readonly Org.Apache.Kafka.Streams.Kstream.Materialized> _keyStore; readonly Org.Apache.Kafka.Streams.Kstream.Materialized> _sessionStore; readonly Org.Apache.Kafka.Streams.Kstream.Materialized> _windowStore; @@ -35,6 +37,11 @@ public class KNetMaterialized : IGenericSerDesFactoryApplier IGenericSerDesFactory _factory; IGenericSerDesFactory IGenericSerDesFactoryApplier.Factory { get => _factory; set { _factory = value; } } + KNetMaterialized(Org.Apache.Kafka.Streams.Kstream.Materialized> materialized) + { + _countKeyStore = materialized; + } + KNetMaterialized(Org.Apache.Kafka.Streams.Kstream.Materialized> materialized) { _keyStore = materialized; @@ -50,6 +57,11 @@ public class KNetMaterialized : IGenericSerDesFactoryApplier _windowStore = materialized; } + /// + /// Converter from to + /// + public static implicit operator Org.Apache.Kafka.Streams.Kstream.Materialized>(KNetMaterialized t) => t._countKeyStore; + /// /// Converter from to /// @@ -137,6 +149,7 @@ public static KNetMaterialized As(Org.Apache.Kafka.Streams.State.WindowByt /// public KNetMaterialized WithCachingDisabled() { + _countKeyStore?.WithCachingDisabled(); _keyStore?.WithCachingDisabled(); _sessionStore?.WithCachingDisabled(); _windowStore?.WithCachingDisabled(); @@ -148,6 +161,7 @@ public KNetMaterialized WithCachingDisabled() /// public KNetMaterialized WithCachingEnabled() { + _countKeyStore?.WithCachingEnabled(); _keyStore?.WithCachingEnabled(); _sessionStore?.WithCachingEnabled(); _windowStore?.WithCachingEnabled(); @@ -160,6 +174,7 @@ public KNetMaterialized WithCachingEnabled() /// public KNetMaterialized WithKeySerde(IKNetSerDes arg0) { + _countKeyStore?.WithKeySerde(arg0.KafkaSerde); _keyStore?.WithKeySerde(arg0.KafkaSerde); _sessionStore?.WithKeySerde(arg0.KafkaSerde); _windowStore?.WithKeySerde(arg0.KafkaSerde); @@ -171,6 +186,7 @@ public KNetMaterialized WithKeySerde(IKNetSerDes arg0) /// public KNetMaterialized WithLoggingDisabled() { + _countKeyStore?.WithLoggingDisabled(); _keyStore?.WithLoggingDisabled(); _sessionStore?.WithLoggingDisabled(); _windowStore?.WithLoggingDisabled(); @@ -183,6 +199,7 @@ public KNetMaterialized WithLoggingDisabled() /// public KNetMaterialized WithLoggingEnabled(Java.Util.Map arg0) { + _countKeyStore?.WithLoggingEnabled(arg0); _keyStore?.WithLoggingEnabled(arg0); _sessionStore?.WithLoggingEnabled(arg0); _windowStore?.WithLoggingEnabled(arg0); @@ -196,6 +213,7 @@ public KNetMaterialized WithLoggingEnabled(Java.Util.Map a /// public KNetMaterialized WithRetention(Java.Time.Duration arg0) { + _countKeyStore?.WithRetention(arg0); _keyStore?.WithRetention(arg0); _sessionStore?.WithRetention(arg0); _windowStore?.WithRetention(arg0); @@ -209,6 +227,7 @@ public KNetMaterialized WithRetention(Java.Time.Duration arg0) /// public KNetMaterialized WithStoreType(Org.Apache.Kafka.Streams.Kstream.Materialized.StoreType arg0) { + _countKeyStore?.WithStoreType(arg0); _keyStore?.WithStoreType(arg0); _sessionStore?.WithStoreType(arg0); _windowStore?.WithStoreType(arg0); @@ -221,6 +240,7 @@ public KNetMaterialized WithStoreType(Org.Apache.Kafka.Streams.Kstream.Mat /// public KNetMaterialized WithValueSerde(IKNetSerDes arg0) { + _countKeyStore?.WithValueSerde(Serdes.Long()); _keyStore?.WithValueSerde(arg0.KafkaSerde); _sessionStore?.WithValueSerde(arg0.KafkaSerde); _windowStore?.WithValueSerde(arg0.KafkaSerde); diff --git a/src/net/KNet/Specific/Streams/Kstream/KNetPredicateTester.cs b/src/net/KNet/Specific/Streams/Kstream/KNetPredicateTester.cs index c801f15a68..6945681f98 100644 --- a/src/net/KNet/Specific/Streams/Kstream/KNetPredicateTester.cs +++ b/src/net/KNet/Specific/Streams/Kstream/KNetPredicateTester.cs @@ -21,7 +21,7 @@ namespace MASES.KNet.Streams.Kstream { /// - /// KNet extension of + /// KNet extension of /// public class KNetPredicateTester : JVMBridgeBase { @@ -30,7 +30,7 @@ public class KNetPredicateTester : JVMBridgeBase /// public override string BridgeClassName => "org.mases.knet.streams.kstream.KNetPredicateTester"; /// - /// Converter from to + /// Converter from to /// public static implicit operator Org.Apache.Kafka.Streams.Kstream.Predicate(KNetPredicateTester t) => t.Cast(); /// diff --git a/src/net/KNet/Specific/Streams/Kstream/KNetPrinted.cs b/src/net/KNet/Specific/Streams/Kstream/KNetPrinted.cs index 67cd379996..2a2e2c04cf 100644 --- a/src/net/KNet/Specific/Streams/Kstream/KNetPrinted.cs +++ b/src/net/KNet/Specific/Streams/Kstream/KNetPrinted.cs @@ -41,6 +41,6 @@ public class KNetPrinted : IGenericSerDesFactoryApplier /// public static implicit operator Org.Apache.Kafka.Streams.Kstream.Printed(KNetPrinted t) => t._inner; -#warning shall be completed +#warning till now it is only an empty class shall be completed with the method of inner class } } diff --git a/src/net/KNet/Specific/Streams/Kstream/KNetProduced.cs b/src/net/KNet/Specific/Streams/Kstream/KNetProduced.cs index 4ad8b499e4..32a5b96d1a 100644 --- a/src/net/KNet/Specific/Streams/Kstream/KNetProduced.cs +++ b/src/net/KNet/Specific/Streams/Kstream/KNetProduced.cs @@ -28,19 +28,29 @@ namespace MASES.KNet.Streams.Kstream /// public class KNetProduced : IGenericSerDesFactoryApplier { - readonly Org.Apache.Kafka.Streams.Kstream.Produced _produced; + KNetStreamPartitioner _streamPartitioner = null; + readonly Org.Apache.Kafka.Streams.Kstream.Produced _inner; IGenericSerDesFactory _factory; - IGenericSerDesFactory IGenericSerDesFactoryApplier.Factory { get => _factory; set { _factory = value; } } + IGenericSerDesFactory IGenericSerDesFactoryApplier.Factory + { + get => _factory; + set + { + _factory = value; + if (_streamPartitioner is IGenericSerDesFactoryApplier applier) applier.Factory = value; + } + } - KNetProduced(Org.Apache.Kafka.Streams.Kstream.Produced produced) + KNetProduced(Org.Apache.Kafka.Streams.Kstream.Produced inner, KNetStreamPartitioner streamPartitioner = null) { - _produced = produced; + _inner = inner; + _streamPartitioner = streamPartitioner; } /// /// Converter from to /// - public static implicit operator Org.Apache.Kafka.Streams.Kstream.Produced(KNetProduced t) => t._produced; + public static implicit operator Org.Apache.Kafka.Streams.Kstream.Produced(KNetProduced t) => t._inner; #region Static methods /// @@ -70,10 +80,10 @@ public static KNetProduced KeySerde(IKNetSerDes arg0) /// /// /// - public static KNetProduced StreamPartitioner(KNetStreamPartitioner arg0) where Arg0objectSuperK : K where Arg0objectSuperV : V + public static KNetProduced StreamPartitioner(KNetStreamPartitioner arg0) { var cons = Org.Apache.Kafka.Streams.Kstream.Produced.StreamPartitioner(arg0); - return new KNetProduced(cons); + return new KNetProduced(cons, arg0); } /// /// @@ -91,13 +101,11 @@ public static KNetProduced ValueSerde(IKNetSerDes arg0) /// /// /// - /// - /// /// - public static KNetProduced With(IKNetSerDes arg0, IKNetSerDes arg1, KNetStreamPartitioner arg2) where Arg2objectSuperK : K where Arg2objectSuperV : V + public static KNetProduced With(IKNetSerDes arg0, IKNetSerDes arg1, KNetStreamPartitioner arg2) { var cons = Org.Apache.Kafka.Streams.Kstream.Produced.With(arg0.KafkaSerde, arg1.KafkaSerde, arg2); - return new KNetProduced(cons); + return new KNetProduced(cons, arg2); } /// /// @@ -121,20 +129,19 @@ public static KNetProduced With(IKNetSerDes arg0, IKNetSerDes arg1) /// public KNetProduced WithKeySerde(IKNetSerDes arg0) { - _produced?.WithKeySerde(arg0.KafkaSerde); + _inner?.WithKeySerde(arg0.KafkaSerde); return this; } /// /// /// - /// - /// - /// + /// /// - public KNetProduced WithStreamPartitioner(KNetStreamPartitioner arg0) where Arg0objectSuperK : K where Arg0objectSuperV : V + public KNetProduced WithStreamPartitioner(KNetStreamPartitioner arg0) { if (arg0 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; - _produced?.WithStreamPartitioner(arg0); + _streamPartitioner = arg0; + _inner?.WithStreamPartitioner(arg0); return this; } /// @@ -144,7 +151,7 @@ public KNetProduced WithStreamPartitioner public KNetProduced WithValueSerde(IKNetSerDes arg0) { - _produced?.WithValueSerde(arg0.KafkaSerde); + _inner?.WithValueSerde(arg0.KafkaSerde); return this; } diff --git a/src/net/KNet/Specific/Streams/Kstream/KNetReducer.cs b/src/net/KNet/Specific/Streams/Kstream/KNetReducer.cs new file mode 100644 index 0000000000..8a563bd638 --- /dev/null +++ b/src/net/KNet/Specific/Streams/Kstream/KNetReducer.cs @@ -0,0 +1,59 @@ +/* +* Copyright 2023 MASES s.r.l. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +* Refer to LICENSE for more information. +*/ + +using MASES.KNet.Serialization; + +namespace MASES.KNet.Streams.Kstream +{ + /// + /// KNet extension of + /// + /// value type + public class KNetReducer : Org.Apache.Kafka.Streams.Kstream.Reducer, IGenericSerDesFactoryApplier + { + IGenericSerDesFactory _factory; + IGenericSerDesFactory IGenericSerDesFactoryApplier.Factory { get => _factory; set { _factory = value; } } + + /// + /// Handler for + /// + /// If has a value it takes precedence over corresponding class method + public new System.Func OnApply { get; set; } = null; + + /// + public sealed override byte[] Apply(byte[] arg0, byte[] arg1) + { + IKNetSerDes vSerializer = _factory.BuildValueSerDes(); + + var methodToExecute = (OnApply != null) ? OnApply : Apply; + var res = methodToExecute(vSerializer.Deserialize(null, arg0), vSerializer.Deserialize(null, arg1)); + return vSerializer.Serialize(null, res); + } + + /// + /// + /// + /// + /// + /// + public virtual V Apply(V arg0, V arg1) + { + return default; + } + } +} diff --git a/src/net/KNet/Specific/Streams/Kstream/KNetRepartitioned.cs b/src/net/KNet/Specific/Streams/Kstream/KNetRepartitioned.cs index 2a3da1e407..f38d966255 100644 --- a/src/net/KNet/Specific/Streams/Kstream/KNetRepartitioned.cs +++ b/src/net/KNet/Specific/Streams/Kstream/KNetRepartitioned.cs @@ -29,19 +29,29 @@ namespace MASES.KNet.Streams.Kstream /// public class KNetRepartitioned : IGenericSerDesFactoryApplier { - readonly Org.Apache.Kafka.Streams.Kstream.Repartitioned _repartitioned; + KNetStreamPartitioner _streamPartitioner = null; + readonly Org.Apache.Kafka.Streams.Kstream.Repartitioned _inner; IGenericSerDesFactory _factory; - IGenericSerDesFactory IGenericSerDesFactoryApplier.Factory { get => _factory; set { _factory = value; } } + IGenericSerDesFactory IGenericSerDesFactoryApplier.Factory + { + get => _factory; + set + { + _factory = value; + if (_streamPartitioner is IGenericSerDesFactoryApplier applier) applier.Factory = value; + } + } - KNetRepartitioned(Org.Apache.Kafka.Streams.Kstream.Repartitioned repartitioned) + KNetRepartitioned(Org.Apache.Kafka.Streams.Kstream.Repartitioned inner, KNetStreamPartitioner streamPartitioner = null) { - _repartitioned = repartitioned; + _inner = inner; + _streamPartitioner = streamPartitioner; } /// /// Converter from to /// - public static implicit operator Org.Apache.Kafka.Streams.Kstream.Repartitioned(KNetRepartitioned t) => t._repartitioned; + public static implicit operator Org.Apache.Kafka.Streams.Kstream.Repartitioned(KNetRepartitioned t) => t._inner; #region Static methods /// @@ -72,7 +82,7 @@ public static KNetRepartitioned NumberOfPartitions(int arg0) public static KNetRepartitioned StreamPartitioner(KNetStreamPartitioner arg0) { var cons = Org.Apache.Kafka.Streams.Kstream.Repartitioned.StreamPartitioner(arg0); - return new KNetRepartitioned(cons); + return new KNetRepartitioned(cons, arg0); } /// /// @@ -96,7 +106,7 @@ public static KNetRepartitioned With(IKNetSerDes arg0, IKNetSerDes a /// public KNetRepartitioned WithKeySerde(IKNetSerDes arg0) { - _repartitioned?.WithKeySerde(arg0.KafkaSerde); + _inner?.WithKeySerde(arg0.KafkaSerde); return this; } /// @@ -106,7 +116,7 @@ public KNetRepartitioned WithKeySerde(IKNetSerDes arg0) /// public KNetRepartitioned WithNumberOfPartitions(int arg0) { - _repartitioned?.WithNumberOfPartitions(arg0); + _inner?.WithNumberOfPartitions(arg0); return this; } /// @@ -117,7 +127,8 @@ public KNetRepartitioned WithNumberOfPartitions(int arg0) public KNetRepartitioned WithStreamPartitioner(KNetStreamPartitioner arg0) { if (arg0 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; - _repartitioned?.WithStreamPartitioner(arg0); + _streamPartitioner = arg0; + _inner?.WithStreamPartitioner(arg0); return this; } /// @@ -127,7 +138,7 @@ public KNetRepartitioned WithStreamPartitioner(KNetStreamPartitioner /// public KNetRepartitioned WithValueSerde(IKNetSerDes arg0) { - _repartitioned?.WithValueSerde(arg0.KafkaSerde); + _inner?.WithValueSerde(arg0.KafkaSerde); return this; } diff --git a/src/net/KNet/Specific/Streams/Kstream/KNetStreamJoined.cs b/src/net/KNet/Specific/Streams/Kstream/KNetStreamJoined.cs index b9dca3f732..88e73decdd 100644 --- a/src/net/KNet/Specific/Streams/Kstream/KNetStreamJoined.cs +++ b/src/net/KNet/Specific/Streams/Kstream/KNetStreamJoined.cs @@ -42,6 +42,6 @@ public class KNetStreamJoined : IGenericSerDesFactoryApplier /// public static implicit operator Org.Apache.Kafka.Streams.Kstream.StreamJoined(KNetStreamJoined t) => t._inner; -#warning shall be completed +#warning till now it is only an empty class shall be completed with the method of inner class } } diff --git a/src/net/KNet/Specific/Streams/Kstream/KNetSuppressed.cs b/src/net/KNet/Specific/Streams/Kstream/KNetSuppressed.cs new file mode 100644 index 0000000000..fa5d7ad351 --- /dev/null +++ b/src/net/KNet/Specific/Streams/Kstream/KNetSuppressed.cs @@ -0,0 +1,45 @@ +/* +* Copyright 2023 MASES s.r.l. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +* Refer to LICENSE for more information. +*/ + +using MASES.KNet.Serialization; + +namespace MASES.KNet.Streams.Kstream +{ + /// + /// KNet extension of + /// + /// + public class KNetSuppressed : IGenericSerDesFactoryApplier + { + readonly Org.Apache.Kafka.Streams.Kstream.Suppressed _inner; + IGenericSerDesFactory _factory; + IGenericSerDesFactory IGenericSerDesFactoryApplier.Factory { get => _factory; set { _factory = value; } } + + KNetSuppressed(Org.Apache.Kafka.Streams.Kstream.Suppressed inner) + { + _inner = inner; + } + + /// + /// Converter from to + /// + public static implicit operator Org.Apache.Kafka.Streams.Kstream.Suppressed(KNetSuppressed t) => t._inner; + +#warning till now it is only an empty class shall be completed with the method of inner class + } +} diff --git a/src/net/KNet/Specific/Streams/Kstream/KNetTableJoined.cs b/src/net/KNet/Specific/Streams/Kstream/KNetTableJoined.cs new file mode 100644 index 0000000000..ed8fa00163 --- /dev/null +++ b/src/net/KNet/Specific/Streams/Kstream/KNetTableJoined.cs @@ -0,0 +1,46 @@ +/* +* Copyright 2023 MASES s.r.l. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +* Refer to LICENSE for more information. +*/ + +using MASES.KNet.Serialization; + +namespace MASES.KNet.Streams.Kstream +{ + /// + /// KNet extension of + /// + /// + /// + public class KNetTableJoined : IGenericSerDesFactoryApplier + { + readonly Org.Apache.Kafka.Streams.Kstream.TableJoined _inner; + IGenericSerDesFactory _factory; + IGenericSerDesFactory IGenericSerDesFactoryApplier.Factory { get => _factory; set { _factory = value; } } + + KNetTableJoined(Org.Apache.Kafka.Streams.Kstream.TableJoined inner) + { + _inner = inner; + } + + /// + /// Converter from to + /// + public static implicit operator Org.Apache.Kafka.Streams.Kstream.TableJoined(KNetTableJoined t) => t._inner; + +#warning till now it is only an empty class shall be completed with the method of inner class + } +} diff --git a/src/net/KNet/Specific/Streams/Kstream/KNetWindowed.cs b/src/net/KNet/Specific/Streams/Kstream/KNetWindowed.cs index 364a646731..085afb6b80 100644 --- a/src/net/KNet/Specific/Streams/Kstream/KNetWindowed.cs +++ b/src/net/KNet/Specific/Streams/Kstream/KNetWindowed.cs @@ -26,7 +26,7 @@ namespace MASES.KNet.Streams.Kstream /// The key type public class KNetWindowed : IGenericSerDesFactoryApplier { - readonly Org.Apache.Kafka.Streams.Kstream.Windowed _windowed; + readonly Org.Apache.Kafka.Streams.Kstream.Windowed _inner; readonly IKNetSerDes _keySerDes; IGenericSerDesFactory _factory; IGenericSerDesFactory IGenericSerDesFactoryApplier.Factory { get => _factory; set { _factory = value; } } @@ -35,18 +35,23 @@ internal KNetWindowed(IGenericSerDesFactory factory, Org.Apache.Kafka.Streams.Ks { _factory = factory; _keySerDes = _factory.BuildKeySerDes(); - _windowed = windowed; + _inner = windowed; } + /// + /// Converter from to + /// + public static implicit operator Org.Apache.Kafka.Streams.Kstream.Windowed(KNetWindowed t) => t._inner; + /// /// KNet implementation of /// /// - public TKey Key => _keySerDes.Deserialize(null, _windowed.Key()); + public TKey Key => _keySerDes.Deserialize(null, _inner.Key()); /// /// KNet implementation of /// /// - public Org.Apache.Kafka.Streams.Kstream.Window Window => _windowed.Window(); + public Org.Apache.Kafka.Streams.Kstream.Window Window => _inner.Window(); } } diff --git a/src/net/KNet/Specific/Streams/Utils/KNetFunction.cs b/src/net/KNet/Specific/Streams/Utils/KNetFunction.cs new file mode 100644 index 0000000000..3f1ccb4e6c --- /dev/null +++ b/src/net/KNet/Specific/Streams/Utils/KNetFunction.cs @@ -0,0 +1,57 @@ +/* +* Copyright 2023 MASES s.r.l. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +* Refer to LICENSE for more information. +*/ + +using MASES.KNet.Serialization; +using System; + +namespace MASES.KNet.Streams.Utils +{ + /// + /// KNet implementation of + /// + /// The key type + /// The value type + public class KNetFunction: Java.Util.Function.Function, IGenericSerDesFactoryApplier + { + IGenericSerDesFactory _factory; + IGenericSerDesFactory IGenericSerDesFactoryApplier.Factory { get => _factory; set { _factory = value; } } + + /// + /// The to be executed + /// + public new virtual Func OnApply { get; set; } + + /// + public override byte[] Apply(byte[] arg0) + { + IKNetSerDes keySerializer = _factory.BuildKeySerDes(); + IKNetSerDes valueSerializer = _factory.BuildValueSerDes(); + var methodToExecute = (OnApply != null) ? OnApply : Apply; + var res = methodToExecute(valueSerializer.Deserialize(null, arg0)); + + return keySerializer.Serialize(null, res); + } + + /// + /// Executes the Function action in the CLR + /// + /// The object + /// The apply + public virtual KO Apply(V obj) { return default; } + } +} From 49f8881a63ba0175fce5cedad60952c4d311aa1c Mon Sep 17 00:00:00 2001 From: masesdevelopers <94312179+masesdevelopers@users.noreply.github.com> Date: Mon, 15 Jan 2024 22:49:51 +0100 Subject: [PATCH 13/18] Some updates --- .../Streams/Kstream/KNetKGroupedTable.cs | 4 +- .../Streams/Kstream/KNetKeyValueMapper.cs | 1 - .../Streams/Kstream/KNetMaterialized.cs | 236 +++++++++++------- 3 files changed, 142 insertions(+), 99 deletions(-) diff --git a/src/net/KNet/Specific/Streams/Kstream/KNetKGroupedTable.cs b/src/net/KNet/Specific/Streams/Kstream/KNetKGroupedTable.cs index 1e7aa84771..f210536ccd 100644 --- a/src/net/KNet/Specific/Streams/Kstream/KNetKGroupedTable.cs +++ b/src/net/KNet/Specific/Streams/Kstream/KNetKGroupedTable.cs @@ -138,7 +138,7 @@ public KNetKTable Count() /// /// /// - public KNetKTable Count(KNetMaterialized arg0) + public KNetKTable Count(KNetCountingMaterialized arg0) { if (arg0 is IGenericSerDesFactoryApplier applier) applier.Factory = _factory; return new KNetKTable(_factory, _inner.Count(arg0)); @@ -149,7 +149,7 @@ public KNetKTable Count(KNetMaterialized arg0) /// /// /// - public KNetKTable Count(Org.Apache.Kafka.Streams.Kstream.Named arg0, KNetMaterialized arg1) + public KNetKTable Count(Org.Apache.Kafka.Streams.Kstream.Named arg0, KNetCountingMaterialized arg1) { if (arg1 is IGenericSerDesFactoryApplier applier1) applier1.Factory = _factory; return new KNetKTable(_factory, _inner.Count(arg0, arg1)); diff --git a/src/net/KNet/Specific/Streams/Kstream/KNetKeyValueMapper.cs b/src/net/KNet/Specific/Streams/Kstream/KNetKeyValueMapper.cs index d7448bab7e..867782d94d 100644 --- a/src/net/KNet/Specific/Streams/Kstream/KNetKeyValueMapper.cs +++ b/src/net/KNet/Specific/Streams/Kstream/KNetKeyValueMapper.cs @@ -18,7 +18,6 @@ using Java.Util; using MASES.KNet.Serialization; -using System.Collections; using System.Collections.Generic; namespace MASES.KNet.Streams.Kstream diff --git a/src/net/KNet/Specific/Streams/Kstream/KNetMaterialized.cs b/src/net/KNet/Specific/Streams/Kstream/KNetMaterialized.cs index 3f6cb9e108..36155b3416 100644 --- a/src/net/KNet/Specific/Streams/Kstream/KNetMaterialized.cs +++ b/src/net/KNet/Specific/Streams/Kstream/KNetMaterialized.cs @@ -19,125 +19,189 @@ using MASES.JCOBridge.C2JBridge; using MASES.KNet.Serialization; using Org.Apache.Kafka.Common.Serialization; +using System; namespace MASES.KNet.Streams.Kstream { /// - /// KNet extension of + /// KNet extension of + /// + /// + public class KNetCountingMaterialized : KNetMaterialized> + { + internal KNetCountingMaterialized(Org.Apache.Kafka.Streams.Kstream.Materialized> materialized) + : base(materialized) + { + } + + /// + /// + /// + /// + /// + public static KNetCountingMaterialized With(IKNetSerDes arg0) + { + var mat = Org.Apache.Kafka.Streams.Kstream.Materialized>.With(arg0.KafkaSerde, Serdes.Long()); + return new KNetCountingMaterialized(mat.Cast>>()); + } + + /// + /// + /// + /// + /// + public KNetCountingMaterialized WithValueSerde(IKNetSerDes arg0) + { + _keyStore?.WithValueSerde(Serdes.Long()); + return this; + } + } + + /// + /// KNet extension of /// /// /// - public class KNetMaterialized : IGenericSerDesFactoryApplier + public class KNetMaterialized : KNetMaterialized> { - readonly Org.Apache.Kafka.Streams.Kstream.Materialized> _countKeyStore; - readonly Org.Apache.Kafka.Streams.Kstream.Materialized> _keyStore; - readonly Org.Apache.Kafka.Streams.Kstream.Materialized> _sessionStore; - readonly Org.Apache.Kafka.Streams.Kstream.Materialized> _windowStore; + internal KNetMaterialized(Org.Apache.Kafka.Streams.Kstream.Materialized> materialized) + : base(materialized) + { + } - IGenericSerDesFactory _factory; - IGenericSerDesFactory IGenericSerDesFactoryApplier.Factory { get => _factory; set { _factory = value; } } + internal KNetMaterialized(Org.Apache.Kafka.Streams.Kstream.Materialized> materialized) + : base(materialized) + { + } - KNetMaterialized(Org.Apache.Kafka.Streams.Kstream.Materialized> materialized) + internal KNetMaterialized(Org.Apache.Kafka.Streams.Kstream.Materialized> materialized) + : base(materialized) + { + } + + /// + /// + /// + /// + /// + /// + public static KNetMaterialized With(IKNetSerDes arg0, IKNetSerDes arg1) { - _countKeyStore = materialized; + var mat = Org.Apache.Kafka.Streams.Kstream.Materialized>.With(arg0.KafkaSerde, arg1.KafkaSerde); + return new KNetMaterialized(mat.Cast>>()); } - KNetMaterialized(Org.Apache.Kafka.Streams.Kstream.Materialized> materialized) + /// + /// + /// + /// + /// + public KNetMaterialized WithValueSerde(IKNetSerDes arg0) + { + _keyStore?.WithValueSerde(arg0.KafkaSerde); + _sessionStore?.WithValueSerde(arg0.KafkaSerde); + _windowStore?.WithValueSerde(arg0.KafkaSerde); + return this; + } + } + + /// + /// KNet base extension of + /// + /// Key type + /// Value type + /// Backend JVM type + /// The implementing class, see or + public abstract class KNetMaterialized : IGenericSerDesFactoryApplier where TContainer : class + { + internal readonly Org.Apache.Kafka.Streams.Kstream.Materialized> _keyStore; + internal readonly Org.Apache.Kafka.Streams.Kstream.Materialized> _sessionStore; + internal readonly Org.Apache.Kafka.Streams.Kstream.Materialized> _windowStore; + + IGenericSerDesFactory _factory; + IGenericSerDesFactory IGenericSerDesFactoryApplier.Factory { get => _factory; set { _factory = value; } } + + internal KNetMaterialized(Org.Apache.Kafka.Streams.Kstream.Materialized> materialized) { _keyStore = materialized; } - KNetMaterialized(Org.Apache.Kafka.Streams.Kstream.Materialized> materialized) + internal KNetMaterialized(Org.Apache.Kafka.Streams.Kstream.Materialized> materialized) { _sessionStore = materialized; } - KNetMaterialized(Org.Apache.Kafka.Streams.Kstream.Materialized> materialized) + internal KNetMaterialized(Org.Apache.Kafka.Streams.Kstream.Materialized> materialized) { _windowStore = materialized; } /// - /// Converter from to - /// - public static implicit operator Org.Apache.Kafka.Streams.Kstream.Materialized>(KNetMaterialized t) => t._countKeyStore; - - /// - /// Converter from to + /// Converter from to /// - public static implicit operator Org.Apache.Kafka.Streams.Kstream.Materialized>(KNetMaterialized t) => t._keyStore; + public static implicit operator Org.Apache.Kafka.Streams.Kstream.Materialized>(KNetMaterialized t) => t._keyStore; /// - /// Converter from to + /// Converter from to /// - public static implicit operator Org.Apache.Kafka.Streams.Kstream.Materialized>(KNetMaterialized t) => t._sessionStore; + public static implicit operator Org.Apache.Kafka.Streams.Kstream.Materialized>(KNetMaterialized t) => t._sessionStore; /// - /// Converter from to + /// Converter from to /// - public static implicit operator Org.Apache.Kafka.Streams.Kstream.Materialized>(KNetMaterialized t) => t._windowStore; + public static implicit operator Org.Apache.Kafka.Streams.Kstream.Materialized>(KNetMaterialized t) => t._windowStore; #region Static methods /// /// /// /// - /// - public static KNetMaterialized As(string arg0) + /// + public static TContainer As(string arg0) { - var mat = Org.Apache.Kafka.Streams.Kstream.Materialized>.As(arg0); - return new KNetMaterialized(mat.Cast>>()); + var mat = Org.Apache.Kafka.Streams.Kstream.Materialized>.As(arg0); + return Activator.CreateInstance(typeof(TContainer), mat.Cast>>()) as TContainer; } /// /// /// /// - /// - public static KNetMaterialized As(Org.Apache.Kafka.Streams.Kstream.Materialized.StoreType arg0) + /// + public static TContainer As(Org.Apache.Kafka.Streams.Kstream.Materialized.StoreType arg0) { - var mat = Org.Apache.Kafka.Streams.Kstream.Materialized>.As(arg0); - return new KNetMaterialized(mat.Cast>>()); - } - /// - /// - /// - /// - /// - /// - public static KNetMaterialized With(IKNetSerDes arg0, IKNetSerDes arg1) - { - var mat = Org.Apache.Kafka.Streams.Kstream.Materialized>.With(arg0.KafkaSerde, arg1.KafkaSerde); - return new KNetMaterialized(mat.Cast>>()); + var mat = Org.Apache.Kafka.Streams.Kstream.Materialized>.As(arg0); + return Activator.CreateInstance(typeof(TContainer), mat.Cast>>()) as TContainer; } + /// /// /// /// - /// - public static KNetMaterialized As(Org.Apache.Kafka.Streams.State.KeyValueBytesStoreSupplier arg0) + /// + public static TContainer As(Org.Apache.Kafka.Streams.State.KeyValueBytesStoreSupplier arg0) { - var mat = Org.Apache.Kafka.Streams.Kstream.Materialized>.As(arg0); - return new KNetMaterialized(mat); + var mat = Org.Apache.Kafka.Streams.Kstream.Materialized>.As(arg0); + return Activator.CreateInstance(typeof(TContainer), mat) as TContainer; } /// /// /// /// - /// - public static KNetMaterialized As(Org.Apache.Kafka.Streams.State.SessionBytesStoreSupplier arg0) + /// + public static TContainer As(Org.Apache.Kafka.Streams.State.SessionBytesStoreSupplier arg0) { - var mat = Org.Apache.Kafka.Streams.Kstream.Materialized>.As(arg0); - return new KNetMaterialized(mat); + var mat = Org.Apache.Kafka.Streams.Kstream.Materialized>.As(arg0); + return Activator.CreateInstance(typeof(TContainer), mat) as TContainer; } /// /// /// /// - /// - public static KNetMaterialized As(Org.Apache.Kafka.Streams.State.WindowBytesStoreSupplier arg0) + /// + public static TContainer As(Org.Apache.Kafka.Streams.State.WindowBytesStoreSupplier arg0) { - var mat = Org.Apache.Kafka.Streams.Kstream.Materialized>.As(arg0); - return new KNetMaterialized(mat); + var mat = Org.Apache.Kafka.Streams.Kstream.Materialized>.As(arg0); + return Activator.CreateInstance(typeof(TContainer), mat) as TContainer; } #endregion @@ -146,105 +210,85 @@ public static KNetMaterialized As(Org.Apache.Kafka.Streams.State.WindowByt /// /// /// - /// - public KNetMaterialized WithCachingDisabled() + /// + public TContainer WithCachingDisabled() { - _countKeyStore?.WithCachingDisabled(); _keyStore?.WithCachingDisabled(); _sessionStore?.WithCachingDisabled(); _windowStore?.WithCachingDisabled(); - return this; + return this as TContainer; } /// /// /// - /// - public KNetMaterialized WithCachingEnabled() + /// + public TContainer WithCachingEnabled() { - _countKeyStore?.WithCachingEnabled(); _keyStore?.WithCachingEnabled(); _sessionStore?.WithCachingEnabled(); _windowStore?.WithCachingEnabled(); - return this; + return this as TContainer; } /// /// /// /// - /// - public KNetMaterialized WithKeySerde(IKNetSerDes arg0) + /// + public TContainer WithKeySerde(IKNetSerDes arg0) { - _countKeyStore?.WithKeySerde(arg0.KafkaSerde); _keyStore?.WithKeySerde(arg0.KafkaSerde); _sessionStore?.WithKeySerde(arg0.KafkaSerde); _windowStore?.WithKeySerde(arg0.KafkaSerde); - return this; + return this as TContainer; } /// /// /// - /// - public KNetMaterialized WithLoggingDisabled() + /// + public TContainer WithLoggingDisabled() { - _countKeyStore?.WithLoggingDisabled(); _keyStore?.WithLoggingDisabled(); _sessionStore?.WithLoggingDisabled(); _windowStore?.WithLoggingDisabled(); - return this; + return this as TContainer; } /// /// /// /// - /// - public KNetMaterialized WithLoggingEnabled(Java.Util.Map arg0) + /// + public TContainer WithLoggingEnabled(Java.Util.Map arg0) { - _countKeyStore?.WithLoggingEnabled(arg0); _keyStore?.WithLoggingEnabled(arg0); _sessionStore?.WithLoggingEnabled(arg0); _windowStore?.WithLoggingEnabled(arg0); - return this; + return this as TContainer; } /// /// /// /// - /// + /// /// - public KNetMaterialized WithRetention(Java.Time.Duration arg0) + public TContainer WithRetention(Java.Time.Duration arg0) { - _countKeyStore?.WithRetention(arg0); _keyStore?.WithRetention(arg0); _sessionStore?.WithRetention(arg0); _windowStore?.WithRetention(arg0); - return this; + return this as TContainer; } /// /// /// /// - /// + /// /// - public KNetMaterialized WithStoreType(Org.Apache.Kafka.Streams.Kstream.Materialized.StoreType arg0) + public TContainer WithStoreType(Org.Apache.Kafka.Streams.Kstream.Materialized.StoreType arg0) { - _countKeyStore?.WithStoreType(arg0); _keyStore?.WithStoreType(arg0); _sessionStore?.WithStoreType(arg0); _windowStore?.WithStoreType(arg0); - return this; - } - /// - /// - /// - /// - /// - public KNetMaterialized WithValueSerde(IKNetSerDes arg0) - { - _countKeyStore?.WithValueSerde(Serdes.Long()); - _keyStore?.WithValueSerde(arg0.KafkaSerde); - _sessionStore?.WithValueSerde(arg0.KafkaSerde); - _windowStore?.WithValueSerde(arg0.KafkaSerde); - return this; + return this as TContainer; } #endregion From a5d1d5421f98e872fea04a8bc6f84551c58143bc Mon Sep 17 00:00:00 2001 From: masesdevelopers <94312179+masesdevelopers@users.noreply.github.com> Date: Tue, 16 Jan 2024 15:20:29 +0100 Subject: [PATCH 14/18] Many fixes on classes --- src/net/KNet/Specific/Streams/KNetKeyValue.cs | 29 +++-- src/net/KNet/Specific/Streams/KNetStreams.cs | 39 +++---- .../Streams/Kstream/KNetMaterialized.cs | 102 +++++++++++------- .../Streams/State/KNetKeyValueIterator.cs | 13 ++- .../Streams/State/KNetManagedStore.cs | 31 +++++- .../Streams/State/KNetQueryableStoreTypes.cs | 2 +- .../State/KNetReadOnlyKeyValueStore.cs | 23 ++-- .../Streams/State/KNetReadOnlySessionStore.cs | 48 ++++++--- .../Streams/State/KNetReadOnlyWindowStore.cs | 28 +++-- .../State/KNetTimestampedKeyValueIterator.cs | 9 +- .../State/KNetTimestampedKeyValueStore.cs | 24 ++--- .../State/KNetTimestampedWindowStore.cs | 39 ++++--- ...KNetTimestampedWindowedKeyValueIterator.cs | 7 +- .../Streams/State/KNetWindowStoreIterator.cs | 2 +- .../State/KNetWindowedKeyValueIterator.cs | 7 +- 15 files changed, 240 insertions(+), 163 deletions(-) diff --git a/src/net/KNet/Specific/Streams/KNetKeyValue.cs b/src/net/KNet/Specific/Streams/KNetKeyValue.cs index aba29bd772..d220885956 100644 --- a/src/net/KNet/Specific/Streams/KNetKeyValue.cs +++ b/src/net/KNet/Specific/Streams/KNetKeyValue.cs @@ -17,6 +17,7 @@ */ using MASES.KNet.Serialization; +using System; namespace MASES.KNet.Streams { @@ -27,8 +28,9 @@ namespace MASES.KNet.Streams /// The value type public class KNetKeyValue : IGenericSerDesFactoryApplier { - readonly Org.Apache.Kafka.Streams.KeyValue _value = null; - readonly Org.Apache.Kafka.Streams.KeyValue _value2 = null; + readonly byte[] _key = null; + readonly long? _keyLong = null; + readonly byte[] _value = null; readonly IKNetSerDes _keySerDes; readonly IKNetSerDes _valueSerDes; IGenericSerDesFactory _factory; @@ -36,18 +38,28 @@ public class KNetKeyValue : IGenericSerDesFactoryApplier internal KNetKeyValue(IGenericSerDesFactory factory, Org.Apache.Kafka.Streams.KeyValue value) { +#pragma warning disable CA1816 + GC.SuppressFinalize(value); +#pragma warning restore CA1816 _factory = factory; _keySerDes = _factory.BuildKeySerDes(); _valueSerDes = _factory.BuildValueSerDes(); - _value = value; + _key = value.key; + _value = value.value; + GC.ReRegisterForFinalize(value); } - internal KNetKeyValue(IGenericSerDesFactory factory, Org.Apache.Kafka.Streams.KeyValue value) + internal KNetKeyValue(IGenericSerDesFactory factory, Org.Apache.Kafka.Streams.KeyValue value) { +#pragma warning disable CA1816 + GC.SuppressFinalize(value); +#pragma warning restore CA1816 _factory = factory; _keySerDes = _factory.BuildKeySerDes(); _valueSerDes = _factory.BuildValueSerDes(); - _value2 = value; + _keyLong = value.key?.LongValue(); + _value = value.value; + GC.ReRegisterForFinalize(value); } /// @@ -57,9 +69,7 @@ public TKey Key { get { - if (_value2 != null) return (TKey)(object)_value2.key; - var kk = _value.key; - return _keySerDes.Deserialize(null, kk); + return _key != null ? _keySerDes.Deserialize(null, _key) : (TKey)(object)_keyLong; } } /// @@ -69,8 +79,7 @@ public TValue Value { get { - var kk = _value.value; - return _valueSerDes.Deserialize(null, kk); + return _valueSerDes.Deserialize(null, _value); } } } diff --git a/src/net/KNet/Specific/Streams/KNetStreams.cs b/src/net/KNet/Specific/Streams/KNetStreams.cs index 26f6bc6311..57515b2ec2 100644 --- a/src/net/KNet/Specific/Streams/KNetStreams.cs +++ b/src/net/KNet/Specific/Streams/KNetStreams.cs @@ -32,15 +32,11 @@ public class KNetStreams : Org.Apache.Kafka.Streams.KafkaStreams, IGenericSerDes IGenericSerDesFactory _factory; IGenericSerDesFactory IGenericSerDesFactoryApplier.Factory { get => _factory; set { _factory = value; } } - Org.Apache.Kafka.Streams.Processor.StateRestoreListener _stateRestoreListener; - StateListener _stateListener; - Org.Apache.Kafka.Streams.Errors.StreamsUncaughtExceptionHandler _streamsUncaughtExceptionHandler; + Org.Apache.Kafka.Streams.Processor.StateRestoreListener _stateRestoreListener; // used to avoid GC recall + StateListener _stateListener; // used to avoid GC recall + Org.Apache.Kafka.Streams.Errors.StreamsUncaughtExceptionHandler _streamsUncaughtExceptionHandler; // used to avoid GC recall #region Constructors - /// - public KNetStreams() : base() { } - /// - public KNetStreams(params object[] args) : base(args) { } /// /// KNet override of /// @@ -125,11 +121,15 @@ public Org.Apache.Kafka.Streams.KeyQueryMetadata QueryMetadataForKey(strin /// /// public TKNetManagedStore Store(Org.Apache.Kafka.Streams.StoreQueryParameters arg0) - where TKNetManagedStore : KNetManagedStore, IGenericSerDesFactoryApplier + where TKNetManagedStore : KNetManagedStore, IGenericSerDesFactoryApplier, new() { - var t = typeof(TKNetManagedStore); + TKNetManagedStore store = new TKNetManagedStore(); var substore = Store(arg0); - return Activator.CreateInstance(t, _factory, substore) as TKNetManagedStore; + if (store is IKNetManagedStore knetManagedStore) + { + knetManagedStore.SetData(_factory, substore); + } + return store; } /// @@ -141,12 +141,16 @@ public TKNetManagedStore Store(Org.Apache.Kafka.Strea /// /// public TKNetManagedStore Store(string storageId, KNetQueryableStoreTypes.StoreType storeType) - where TKNetManagedStore : KNetManagedStore, IGenericSerDesFactoryApplier + where TKNetManagedStore : KNetManagedStore, IGenericSerDesFactoryApplier, new() { var sqp = Org.Apache.Kafka.Streams.StoreQueryParameters.FromNameAndType(storageId, storeType.Store); - var t = typeof(TKNetManagedStore); + TKNetManagedStore store = new TKNetManagedStore(); var substore = Store(sqp); - return Activator.CreateInstance(t, _factory, substore) as TKNetManagedStore; + if (store is IKNetManagedStore knetManagedStore) + { + knetManagedStore.SetData(_factory, substore); + } + return store; } /// @@ -172,9 +176,8 @@ public string RemoveStreamThread(TimeSpan arg0) /// public new void SetGlobalStateRestoreListener(Org.Apache.Kafka.Streams.Processor.StateRestoreListener arg0) { - base.SetGlobalStateRestoreListener(null); - _stateRestoreListener = arg0; base.SetGlobalStateRestoreListener(arg0); + _stateRestoreListener = arg0; } /// /// @@ -182,9 +185,8 @@ public string RemoveStreamThread(TimeSpan arg0) /// public new void SetStateListener(Org.Apache.Kafka.Streams.KafkaStreams.StateListener arg0) { - base.SetStateListener(null); - _stateListener = arg0; base.SetStateListener(arg0); + _stateListener = arg0; } /// /// @@ -192,9 +194,8 @@ public string RemoveStreamThread(TimeSpan arg0) /// public new void SetUncaughtExceptionHandler(Org.Apache.Kafka.Streams.Errors.StreamsUncaughtExceptionHandler arg0) { - base.SetUncaughtExceptionHandler(null); - _streamsUncaughtExceptionHandler = arg0; base.SetUncaughtExceptionHandler(arg0); + _streamsUncaughtExceptionHandler = arg0; } #endregion diff --git a/src/net/KNet/Specific/Streams/Kstream/KNetMaterialized.cs b/src/net/KNet/Specific/Streams/Kstream/KNetMaterialized.cs index 36155b3416..5424d79b0c 100644 --- a/src/net/KNet/Specific/Streams/Kstream/KNetMaterialized.cs +++ b/src/net/KNet/Specific/Streams/Kstream/KNetMaterialized.cs @@ -16,6 +16,7 @@ * Refer to LICENSE for more information. */ +using Java.Security; using MASES.JCOBridge.C2JBridge; using MASES.KNet.Serialization; using Org.Apache.Kafka.Common.Serialization; @@ -27,13 +28,8 @@ namespace MASES.KNet.Streams.Kstream /// KNet extension of /// /// - public class KNetCountingMaterialized : KNetMaterialized> + public sealed class KNetCountingMaterialized : KNetMaterialized> { - internal KNetCountingMaterialized(Org.Apache.Kafka.Streams.Kstream.Materialized> materialized) - : base(materialized) - { - } - /// /// /// @@ -42,7 +38,12 @@ internal KNetCountingMaterialized(Org.Apache.Kafka.Streams.Kstream.Materialized< public static KNetCountingMaterialized With(IKNetSerDes arg0) { var mat = Org.Apache.Kafka.Streams.Kstream.Materialized>.With(arg0.KafkaSerde, Serdes.Long()); - return new KNetCountingMaterialized(mat.Cast>>()); + KNetCountingMaterialized cont = new(); + if (cont is IKNetMaterialized setStore) + { + setStore.SetStore(mat.Cast>>()); + } + return cont; } /// @@ -62,23 +63,8 @@ public KNetCountingMaterialized WithValueSerde(IKNetSerDes arg0) /// /// /// - public class KNetMaterialized : KNetMaterialized> + public sealed class KNetMaterialized : KNetMaterialized> { - internal KNetMaterialized(Org.Apache.Kafka.Streams.Kstream.Materialized> materialized) - : base(materialized) - { - } - - internal KNetMaterialized(Org.Apache.Kafka.Streams.Kstream.Materialized> materialized) - : base(materialized) - { - } - - internal KNetMaterialized(Org.Apache.Kafka.Streams.Kstream.Materialized> materialized) - : base(materialized) - { - } - /// /// /// @@ -88,7 +74,12 @@ internal KNetMaterialized(Org.Apache.Kafka.Streams.Kstream.Materialized With(IKNetSerDes arg0, IKNetSerDes arg1) { var mat = Org.Apache.Kafka.Streams.Kstream.Materialized>.With(arg0.KafkaSerde, arg1.KafkaSerde); - return new KNetMaterialized(mat.Cast>>()); + KNetMaterialized cont = new(); + if (cont is IKNetMaterialized setStore) + { + setStore.SetStore(mat.Cast>>()); + } + return cont; } /// @@ -104,6 +95,18 @@ public KNetMaterialized WithValueSerde(IKNetSerDes arg0) return this; } } + /// + /// Supporting interface for + /// + /// + public interface IKNetMaterialized + { + void SetStore(Org.Apache.Kafka.Streams.Kstream.Materialized> materialized); + + void SetStore(Org.Apache.Kafka.Streams.Kstream.Materialized> materialized); + + void SetStore(Org.Apache.Kafka.Streams.Kstream.Materialized> materialized); + } /// /// KNet base extension of @@ -112,26 +115,26 @@ public KNetMaterialized WithValueSerde(IKNetSerDes arg0) /// Value type /// Backend JVM type /// The implementing class, see or - public abstract class KNetMaterialized : IGenericSerDesFactoryApplier where TContainer : class + public abstract class KNetMaterialized : IGenericSerDesFactoryApplier, IKNetMaterialized where TContainer : class, new() { - internal readonly Org.Apache.Kafka.Streams.Kstream.Materialized> _keyStore; - internal readonly Org.Apache.Kafka.Streams.Kstream.Materialized> _sessionStore; - internal readonly Org.Apache.Kafka.Streams.Kstream.Materialized> _windowStore; + internal Org.Apache.Kafka.Streams.Kstream.Materialized> _keyStore; + internal Org.Apache.Kafka.Streams.Kstream.Materialized> _sessionStore; + internal Org.Apache.Kafka.Streams.Kstream.Materialized> _windowStore; IGenericSerDesFactory _factory; IGenericSerDesFactory IGenericSerDesFactoryApplier.Factory { get => _factory; set { _factory = value; } } - internal KNetMaterialized(Org.Apache.Kafka.Streams.Kstream.Materialized> materialized) + void IKNetMaterialized.SetStore(Org.Apache.Kafka.Streams.Kstream.Materialized> materialized) { _keyStore = materialized; } - internal KNetMaterialized(Org.Apache.Kafka.Streams.Kstream.Materialized> materialized) + void IKNetMaterialized.SetStore(Org.Apache.Kafka.Streams.Kstream.Materialized> materialized) { _sessionStore = materialized; } - internal KNetMaterialized(Org.Apache.Kafka.Streams.Kstream.Materialized> materialized) + void IKNetMaterialized.SetStore(Org.Apache.Kafka.Streams.Kstream.Materialized> materialized) { _windowStore = materialized; } @@ -160,7 +163,12 @@ internal KNetMaterialized(Org.Apache.Kafka.Streams.Kstream.Materialized>.As(arg0); - return Activator.CreateInstance(typeof(TContainer), mat.Cast>>()) as TContainer; + TContainer cont = new(); + if (cont is IKNetMaterialized setStore) + { + setStore.SetStore(mat.Cast>>()); + } + return cont; } /// /// @@ -170,9 +178,14 @@ public static TContainer As(string arg0) public static TContainer As(Org.Apache.Kafka.Streams.Kstream.Materialized.StoreType arg0) { var mat = Org.Apache.Kafka.Streams.Kstream.Materialized>.As(arg0); - return Activator.CreateInstance(typeof(TContainer), mat.Cast>>()) as TContainer; + TContainer cont = new(); + if (cont is IKNetMaterialized setStore) + { + setStore.SetStore(mat.Cast>>()); + } + return cont; } - + /// /// /// @@ -181,7 +194,12 @@ public static TContainer As(Org.Apache.Kafka.Streams.Kstream.Materialized.StoreT public static TContainer As(Org.Apache.Kafka.Streams.State.KeyValueBytesStoreSupplier arg0) { var mat = Org.Apache.Kafka.Streams.Kstream.Materialized>.As(arg0); - return Activator.CreateInstance(typeof(TContainer), mat) as TContainer; + TContainer cont = new(); + if (cont is IKNetMaterialized setStore) + { + setStore.SetStore(mat); + } + return cont; } /// /// @@ -191,7 +209,12 @@ public static TContainer As(Org.Apache.Kafka.Streams.State.KeyValueBytesStoreSup public static TContainer As(Org.Apache.Kafka.Streams.State.SessionBytesStoreSupplier arg0) { var mat = Org.Apache.Kafka.Streams.Kstream.Materialized>.As(arg0); - return Activator.CreateInstance(typeof(TContainer), mat) as TContainer; + TContainer cont = new(); + if (cont is IKNetMaterialized setStore) + { + setStore.SetStore(mat); + } + return cont; } /// /// @@ -201,7 +224,12 @@ public static TContainer As(Org.Apache.Kafka.Streams.State.SessionBytesStoreSupp public static TContainer As(Org.Apache.Kafka.Streams.State.WindowBytesStoreSupplier arg0) { var mat = Org.Apache.Kafka.Streams.Kstream.Materialized>.As(arg0); - return Activator.CreateInstance(typeof(TContainer), mat) as TContainer; + TContainer cont = new(); + if (cont is IKNetMaterialized setStore) + { + setStore.SetStore(mat); + } + return cont; } #endregion diff --git a/src/net/KNet/Specific/Streams/State/KNetKeyValueIterator.cs b/src/net/KNet/Specific/Streams/State/KNetKeyValueIterator.cs index ddfc879933..5e455ec625 100644 --- a/src/net/KNet/Specific/Streams/State/KNetKeyValueIterator.cs +++ b/src/net/KNet/Specific/Streams/State/KNetKeyValueIterator.cs @@ -20,6 +20,7 @@ using MASES.JCOBridge.C2JBridge; using MASES.JCOBridge.C2JBridge.JVMInterop; using MASES.KNet.Serialization; +using System; using System.Collections.Generic; namespace MASES.KNet.Streams.State @@ -38,13 +39,17 @@ class LocalEnumerator(bool isVersion2, IGenericSerDesFactory factory, IJavaObjec protected override object ConvertObject(object input) { - return isVersion2 ? new KNetKeyValue(_factory, input as Org.Apache.Kafka.Streams.KeyValue) - : new KNetKeyValue(_factory, input as Org.Apache.Kafka.Streams.KeyValue); + if (input is IJavaObject obj) + { + return isVersion2 ? new KNetKeyValue(_factory, JVMBridgeBase.Wraps>(obj)) + : new KNetKeyValue(_factory, JVMBridgeBase.Wraps>(obj)); + } + throw new InvalidCastException($"input is not a valid IJavaObject"); } } readonly Org.Apache.Kafka.Streams.State.KeyValueIterator _iterator; - readonly Org.Apache.Kafka.Streams.State.KeyValueIterator _iterator2; + readonly Org.Apache.Kafka.Streams.State.KeyValueIterator _iterator2; readonly IKNetSerDes _keySerDes; IGenericSerDesFactory _factory; IGenericSerDesFactory IGenericSerDesFactoryApplier.Factory { get => _factory; set { _factory = value; } } @@ -56,7 +61,7 @@ internal KNetKeyValueIterator(IGenericSerDesFactory factory, Org.Apache.Kafka.St _iterator = iterator; } - internal KNetKeyValueIterator(IGenericSerDesFactory factory, Org.Apache.Kafka.Streams.State.KeyValueIterator iterator) + internal KNetKeyValueIterator(IGenericSerDesFactory factory, Org.Apache.Kafka.Streams.State.KeyValueIterator iterator) { _factory = factory; _keySerDes = _factory.BuildKeySerDes(); diff --git a/src/net/KNet/Specific/Streams/State/KNetManagedStore.cs b/src/net/KNet/Specific/Streams/State/KNetManagedStore.cs index a976a36598..ab524491ad 100644 --- a/src/net/KNet/Specific/Streams/State/KNetManagedStore.cs +++ b/src/net/KNet/Specific/Streams/State/KNetManagedStore.cs @@ -16,9 +16,38 @@ * Refer to LICENSE for more information. */ +using MASES.KNet.Serialization; + namespace MASES.KNet.Streams.State { - public class KNetManagedStore + /// + /// Supporting interface for + /// + /// The Apache Kafka store type + public interface IKNetManagedStore : IGenericSerDesFactoryApplier { + /// + /// Sets store data + /// + /// + /// + void SetData(IGenericSerDesFactory factory, TStore store); + } + + /// + /// Base class for stores managed from KNet + /// + /// The Apache Kafka store type + public class KNetManagedStore : IKNetManagedStore, IGenericSerDesFactoryApplier + { + internal TStore _store; + internal IGenericSerDesFactory _factory; + IGenericSerDesFactory IGenericSerDesFactoryApplier.Factory { get => _factory; set { _factory = value; } } + + void IKNetManagedStore.SetData(IGenericSerDesFactory factory, TStore store) + { + _factory = factory; + _store = store; + } } } diff --git a/src/net/KNet/Specific/Streams/State/KNetQueryableStoreTypes.cs b/src/net/KNet/Specific/Streams/State/KNetQueryableStoreTypes.cs index 58696ad3c8..4b7363279a 100644 --- a/src/net/KNet/Specific/Streams/State/KNetQueryableStoreTypes.cs +++ b/src/net/KNet/Specific/Streams/State/KNetQueryableStoreTypes.cs @@ -30,7 +30,7 @@ public static class KNetQueryableStoreTypes /// /// /// - public class StoreType where TKNetManagedStore : KNetManagedStore, IGenericSerDesFactoryApplier + public class StoreType where TKNetManagedStore : KNetManagedStore, IGenericSerDesFactoryApplier, new() { internal StoreType(Org.Apache.Kafka.Streams.State.QueryableStoreType store) { Store = store; } internal Org.Apache.Kafka.Streams.State.QueryableStoreType Store; diff --git a/src/net/KNet/Specific/Streams/State/KNetReadOnlyKeyValueStore.cs b/src/net/KNet/Specific/Streams/State/KNetReadOnlyKeyValueStore.cs index abefab5e66..6237cb9d15 100644 --- a/src/net/KNet/Specific/Streams/State/KNetReadOnlyKeyValueStore.cs +++ b/src/net/KNet/Specific/Streams/State/KNetReadOnlyKeyValueStore.cs @@ -25,22 +25,8 @@ namespace MASES.KNet.Streams.State /// /// The key type /// The value type - public class KNetReadOnlyKeyValueStore : KNetManagedStore>, IGenericSerDesFactoryApplier + public class KNetReadOnlyKeyValueStore : KNetManagedStore> { - readonly Org.Apache.Kafka.Streams.State.ReadOnlyKeyValueStore _store; - readonly IKNetSerDes _keySerDes; - readonly IKNetSerDes _valueSerDes; - IGenericSerDesFactory _factory; - IGenericSerDesFactory IGenericSerDesFactoryApplier.Factory { get => _factory; set { _factory = value; } } - - internal KNetReadOnlyKeyValueStore(IGenericSerDesFactory factory, Org.Apache.Kafka.Streams.State.ReadOnlyKeyValueStore store) - { - _factory = factory; - _keySerDes = _factory.BuildKeySerDes(); - _valueSerDes = _factory.BuildValueSerDes(); - _store = store; - } - /// /// KNet implementation of /// @@ -59,6 +45,8 @@ internal KNetReadOnlyKeyValueStore(IGenericSerDesFactory factory, Org.Apache.Kaf /// public KNetKeyValueIterator Range(TKey arg0, TKey arg1) { + var _keySerDes = _factory.BuildKeySerDes(); + var r0 = _keySerDes.Serialize(null, arg0); var r1 = _keySerDes.Serialize(null, arg1); @@ -71,6 +59,9 @@ public KNetKeyValueIterator Range(TKey arg0, TKey arg1) /// public TValue Get(TKey arg0) { + var _keySerDes = _factory.BuildKeySerDes(); + var _valueSerDes = _factory.BuildValueSerDes(); + var r0 = _keySerDes.Serialize(null, arg0); var res = _store.Get(r0); return _valueSerDes.Deserialize(null, res); @@ -88,6 +79,8 @@ public TValue Get(TKey arg0) /// public KNetKeyValueIterator ReverseRange(TKey arg0, TKey arg1) { + var _keySerDes = _factory.BuildKeySerDes(); + var r0 = _keySerDes.Serialize(null, arg0); var r1 = _keySerDes.Serialize(null, arg1); diff --git a/src/net/KNet/Specific/Streams/State/KNetReadOnlySessionStore.cs b/src/net/KNet/Specific/Streams/State/KNetReadOnlySessionStore.cs index 923ccebf25..1318be465e 100644 --- a/src/net/KNet/Specific/Streams/State/KNetReadOnlySessionStore.cs +++ b/src/net/KNet/Specific/Streams/State/KNetReadOnlySessionStore.cs @@ -16,8 +16,6 @@ * Refer to LICENSE for more information. */ -using MASES.KNet.Serialization; - namespace MASES.KNet.Streams.State { /// @@ -25,22 +23,8 @@ namespace MASES.KNet.Streams.State /// /// The key type /// The value type - public class KNetReadOnlySessionStore : KNetManagedStore>, IGenericSerDesFactoryApplier + public class KNetReadOnlySessionStore : KNetManagedStore> { - readonly Org.Apache.Kafka.Streams.State.ReadOnlySessionStore _store; - readonly IKNetSerDes _keySerDes; - readonly IKNetSerDes _valueSerDes; - IGenericSerDesFactory _factory; - IGenericSerDesFactory IGenericSerDesFactoryApplier.Factory { get => _factory; set { _factory = value; } } - - internal KNetReadOnlySessionStore(IGenericSerDesFactory factory, Org.Apache.Kafka.Streams.State.ReadOnlySessionStore store) - { - _factory = factory; - _keySerDes = _factory.BuildKeySerDes(); - _valueSerDes = _factory.BuildValueSerDes(); - _store = store; - } - /// /// /// @@ -49,6 +33,8 @@ internal KNetReadOnlySessionStore(IGenericSerDesFactory factory, Org.Apache.Kafk /// public KNetWindowedKeyValueIterator Fetch(K arg0, K arg1) { + var _keySerDes = _factory.BuildKeySerDes(); + var r0 = _keySerDes.Serialize(null, arg0); var r1 = _keySerDes.Serialize(null, arg1); return new KNetWindowedKeyValueIterator(_factory, _store.Fetch(r0, r1)); @@ -60,6 +46,8 @@ public KNetWindowedKeyValueIterator Fetch(K arg0, K arg1) /// public KNetWindowedKeyValueIterator Fetch(K arg0) { + var _keySerDes = _factory.BuildKeySerDes(); + var r0 = _keySerDes.Serialize(null, arg0); return new KNetWindowedKeyValueIterator(_factory, _store.Fetch(r0)); } @@ -72,6 +60,9 @@ public KNetWindowedKeyValueIterator Fetch(K arg0) /// public AGG FetchSession(K arg0, Java.Time.Instant arg1, Java.Time.Instant arg2) { + var _keySerDes = _factory.BuildKeySerDes(); + var _valueSerDes = _factory.BuildValueSerDes(); + var r0 = _keySerDes.Serialize(null, arg0); var agg = _store.FetchSession(r0, arg1, arg2); return _valueSerDes.Deserialize(null, agg); @@ -85,6 +76,9 @@ public AGG FetchSession(K arg0, Java.Time.Instant arg1, Java.Time.Instant arg2) /// public AGG FetchSession(K arg0, long arg1, long arg2) { + var _keySerDes = _factory.BuildKeySerDes(); + var _valueSerDes = _factory.BuildValueSerDes(); + var r0 = _keySerDes.Serialize(null, arg0); var agg = _store.FetchSession(r0, arg1, arg2); return _valueSerDes.Deserialize(null, agg); @@ -97,6 +91,8 @@ public AGG FetchSession(K arg0, long arg1, long arg2) /// public KNetWindowedKeyValueIterator BackwardFetch(K arg0, K arg1) { + var _keySerDes = _factory.BuildKeySerDes(); + var r0 = _keySerDes.Serialize(null, arg0); var r1 = _keySerDes.Serialize(null, arg1); return new KNetWindowedKeyValueIterator(_factory, _store.BackwardFetch(r0, r1)); @@ -108,6 +104,8 @@ public KNetWindowedKeyValueIterator BackwardFetch(K arg0, K arg1) /// public KNetWindowedKeyValueIterator BackwardFetch(K arg0) { + var _keySerDes = _factory.BuildKeySerDes(); + var r0 = _keySerDes.Serialize(null, arg0); return new KNetWindowedKeyValueIterator(_factory, _store.BackwardFetch(r0)); } @@ -120,6 +118,8 @@ public KNetWindowedKeyValueIterator BackwardFetch(K arg0) /// public KNetWindowedKeyValueIterator BackwardFindSessions(K arg0, Java.Time.Instant arg1, Java.Time.Instant arg2) { + var _keySerDes = _factory.BuildKeySerDes(); + var r0 = _keySerDes.Serialize(null, arg0); return new KNetWindowedKeyValueIterator(_factory, _store.BackwardFindSessions(r0, arg1, arg2)); } @@ -133,6 +133,8 @@ public KNetWindowedKeyValueIterator BackwardFindSessions(K arg0, Java.Ti /// public KNetWindowedKeyValueIterator BackwardFindSessions(K arg0, K arg1, Java.Time.Instant arg2, Java.Time.Instant arg3) { + var _keySerDes = _factory.BuildKeySerDes(); + var r0 = _keySerDes.Serialize(null, arg0); var r1 = _keySerDes.Serialize(null, arg1); return new KNetWindowedKeyValueIterator(_factory, _store.BackwardFindSessions(r0, r1, arg2, arg3)); @@ -147,6 +149,8 @@ public KNetWindowedKeyValueIterator BackwardFindSessions(K arg0, K arg1, /// public KNetWindowedKeyValueIterator BackwardFindSessions(K arg0, K arg1, long arg2, long arg3) { + var _keySerDes = _factory.BuildKeySerDes(); + var r0 = _keySerDes.Serialize(null, arg0); var r1 = _keySerDes.Serialize(null, arg1); return new KNetWindowedKeyValueIterator(_factory, _store.BackwardFindSessions(r0, r1, arg2, arg3)); @@ -160,6 +164,8 @@ public KNetWindowedKeyValueIterator BackwardFindSessions(K arg0, K arg1, /// public KNetWindowedKeyValueIterator BackwardFindSessions(K arg0, long arg1, long arg2) { + var _keySerDes = _factory.BuildKeySerDes(); + var r0 = _keySerDes.Serialize(null, arg0); return new KNetWindowedKeyValueIterator(_factory, _store.BackwardFindSessions(r0, arg1, arg2)); } @@ -172,6 +178,8 @@ public KNetWindowedKeyValueIterator BackwardFindSessions(K arg0, long ar /// public KNetWindowedKeyValueIterator FindSessions(K arg0, Java.Time.Instant arg1, Java.Time.Instant arg2) { + var _keySerDes = _factory.BuildKeySerDes(); + var r0 = _keySerDes.Serialize(null, arg0); return new KNetWindowedKeyValueIterator(_factory, _store.BackwardFindSessions(r0, arg1, arg2)); } @@ -185,6 +193,8 @@ public KNetWindowedKeyValueIterator FindSessions(K arg0, Java.Time.Insta /// public KNetWindowedKeyValueIterator FindSessions(K arg0, K arg1, Java.Time.Instant arg2, Java.Time.Instant arg3) { + var _keySerDes = _factory.BuildKeySerDes(); + var r0 = _keySerDes.Serialize(null, arg0); var r1 = _keySerDes.Serialize(null, arg1); return new KNetWindowedKeyValueIterator(_factory, _store.FindSessions(r0, r1, arg2, arg3)); @@ -199,6 +209,8 @@ public KNetWindowedKeyValueIterator FindSessions(K arg0, K arg1, Java.Ti /// public KNetWindowedKeyValueIterator FindSessions(K arg0, K arg1, long arg2, long arg3) { + var _keySerDes = _factory.BuildKeySerDes(); + var r0 = _keySerDes.Serialize(null, arg0); var r1 = _keySerDes.Serialize(null, arg1); return new KNetWindowedKeyValueIterator(_factory, _store.FindSessions(r0, r1, arg2, arg3)); @@ -212,6 +224,8 @@ public KNetWindowedKeyValueIterator FindSessions(K arg0, K arg1, long ar /// public KNetWindowedKeyValueIterator FindSessions(K arg0, long arg1, long arg2) { + var _keySerDes = _factory.BuildKeySerDes(); + var r0 = _keySerDes.Serialize(null, arg0); return new KNetWindowedKeyValueIterator(_factory, _store.FindSessions(r0, arg1, arg2)); } diff --git a/src/net/KNet/Specific/Streams/State/KNetReadOnlyWindowStore.cs b/src/net/KNet/Specific/Streams/State/KNetReadOnlyWindowStore.cs index fa1dcd00ff..d330bacf64 100644 --- a/src/net/KNet/Specific/Streams/State/KNetReadOnlyWindowStore.cs +++ b/src/net/KNet/Specific/Streams/State/KNetReadOnlyWindowStore.cs @@ -16,8 +16,6 @@ * Refer to LICENSE for more information. */ -using MASES.KNet.Serialization; - namespace MASES.KNet.Streams.State { /// @@ -25,21 +23,8 @@ namespace MASES.KNet.Streams.State /// /// The key type /// The value type - public class KNetReadOnlyWindowStore : KNetManagedStore>, IGenericSerDesFactoryApplier + public class KNetReadOnlyWindowStore : KNetManagedStore> { - readonly Org.Apache.Kafka.Streams.State.ReadOnlyWindowStore _store; - readonly IKNetSerDes _keySerDes; - readonly IKNetSerDes _valueSerDes; - IGenericSerDesFactory _factory; - IGenericSerDesFactory IGenericSerDesFactoryApplier.Factory { get => _factory; set { _factory = value; } } - - internal KNetReadOnlyWindowStore(IGenericSerDesFactory factory, Org.Apache.Kafka.Streams.State.ReadOnlyWindowStore store) - { - _factory = factory; - _keySerDes = _factory.BuildKeySerDes(); - _valueSerDes = _factory.BuildValueSerDes(); - _store = store; - } /// /// /// @@ -56,6 +41,8 @@ internal KNetReadOnlyWindowStore(IGenericSerDesFactory factory, Org.Apache.Kafka /// public KNetWindowedKeyValueIterator Fetch(TKey arg0, TKey arg1, Java.Time.Instant arg2, Java.Time.Instant arg3) { + var _keySerDes = _factory.BuildKeySerDes(); + var r0 = _keySerDes.Serialize(null, arg0); var r1 = _keySerDes.Serialize(null, arg1); return new KNetWindowedKeyValueIterator(_factory, _store.Fetch(r0, r1, arg2, arg3)); @@ -81,6 +68,8 @@ public KNetWindowedKeyValueIterator FetchAll(Java.Time.Instant arg /// public KNetWindowStoreIterator Fetch(TKey arg0, Java.Time.Instant arg1, Java.Time.Instant arg2) { + var _keySerDes = _factory.BuildKeySerDes(); + var r0 = _keySerDes.Serialize(null, arg0); return new KNetWindowStoreIterator(_factory, _store.Fetch(r0, arg1, arg2)); } @@ -92,6 +81,9 @@ public KNetWindowStoreIterator Fetch(TKey arg0, Java.Time.Instant arg1, /// public TValue Fetch(TKey arg0, long arg1) { + var _keySerDes = _factory.BuildKeySerDes(); + var _valueSerDes = _factory.BuildValueSerDes(); + var r0 = _keySerDes.Serialize(null, arg0); var agg = _store.Fetch(r0, arg1); return _valueSerDes.Deserialize(null, agg); @@ -112,6 +104,8 @@ public TValue Fetch(TKey arg0, long arg1) /// public KNetWindowedKeyValueIterator BackwardFetch(TKey arg0, TKey arg1, Java.Time.Instant arg2, Java.Time.Instant arg3) { + var _keySerDes = _factory.BuildKeySerDes(); + var r0 = _keySerDes.Serialize(null, arg0); var r1 = _keySerDes.Serialize(null, arg1); return new KNetWindowedKeyValueIterator(_factory, _store.BackwardFetch(r0, r1, arg2, arg3)); @@ -137,6 +131,8 @@ public KNetWindowedKeyValueIterator BackwardFetchAll(Java.Time.Ins /// public KNetWindowStoreIterator BackwardFetch(TKey arg0, Java.Time.Instant arg1, Java.Time.Instant arg2) { + var _keySerDes = _factory.BuildKeySerDes(); + var r0 = _keySerDes.Serialize(null, arg0); return new KNetWindowStoreIterator(_factory, _store.BackwardFetch(r0, arg1, arg2)); } diff --git a/src/net/KNet/Specific/Streams/State/KNetTimestampedKeyValueIterator.cs b/src/net/KNet/Specific/Streams/State/KNetTimestampedKeyValueIterator.cs index d1dc1953e9..e57c8e7778 100644 --- a/src/net/KNet/Specific/Streams/State/KNetTimestampedKeyValueIterator.cs +++ b/src/net/KNet/Specific/Streams/State/KNetTimestampedKeyValueIterator.cs @@ -20,6 +20,7 @@ using MASES.JCOBridge.C2JBridge; using MASES.JCOBridge.C2JBridge.JVMInterop; using MASES.KNet.Serialization; +using System; using System.Collections.Generic; namespace MASES.KNet.Streams.State @@ -38,8 +39,12 @@ class LocalEnumerator(bool isVersion2, IGenericSerDesFactory factory, IJavaObjec protected override object ConvertObject(object input) { - return isVersion2 ? new KNetTimestampedKeyValue(_factory, input as Org.Apache.Kafka.Streams.KeyValue>) - : new KNetTimestampedKeyValue(_factory, input as Org.Apache.Kafka.Streams.KeyValue>); + if (input is IJavaObject obj) + { + return isVersion2 ? new KNetTimestampedKeyValue(_factory, JVMBridgeBase.Wraps>>(obj)) + : new KNetTimestampedKeyValue(_factory, JVMBridgeBase.Wraps>>(obj)); + } + throw new InvalidCastException($"input is not a valid IJavaObject"); } } diff --git a/src/net/KNet/Specific/Streams/State/KNetTimestampedKeyValueStore.cs b/src/net/KNet/Specific/Streams/State/KNetTimestampedKeyValueStore.cs index a349063ae8..cf4dd74174 100644 --- a/src/net/KNet/Specific/Streams/State/KNetTimestampedKeyValueStore.cs +++ b/src/net/KNet/Specific/Streams/State/KNetTimestampedKeyValueStore.cs @@ -16,8 +16,6 @@ * Refer to LICENSE for more information. */ -using MASES.KNet.Serialization; - namespace MASES.KNet.Streams.State { /// @@ -25,22 +23,8 @@ namespace MASES.KNet.Streams.State /// /// The key type /// The value type - public class KNetTimestampedKeyValueStore : KNetManagedStore>>, IGenericSerDesFactoryApplier + public class KNetTimestampedKeyValueStore : KNetManagedStore>> { - readonly Org.Apache.Kafka.Streams.State.ReadOnlyKeyValueStore> _store; - readonly IKNetSerDes _keySerDes; - readonly IKNetSerDes _valueSerDes; - IGenericSerDesFactory _factory; - IGenericSerDesFactory IGenericSerDesFactoryApplier.Factory { get => _factory; set { _factory = value; } } - - internal KNetTimestampedKeyValueStore(IGenericSerDesFactory factory, Org.Apache.Kafka.Streams.State.ReadOnlyKeyValueStore> store) - { - _factory = factory; - _keySerDes = _factory.BuildKeySerDes(); - _valueSerDes = _factory.BuildValueSerDes(); - _store = store; - } - /// /// KNet implementation of /// @@ -59,6 +43,8 @@ internal KNetTimestampedKeyValueStore(IGenericSerDesFactory factory, Org.Apache. /// public KNetTimestampedKeyValueIterator Range(TKey arg0, TKey arg1) { + var _keySerDes = _factory.BuildKeySerDes(); + var r0 = _keySerDes.Serialize(null, arg0); var r1 = _keySerDes.Serialize(null, arg1); @@ -71,6 +57,8 @@ public KNetTimestampedKeyValueIterator Range(TKey arg0, TKey arg1) /// public KNetValueAndTimestamp Get(TKey arg0) { + var _keySerDes = _factory.BuildKeySerDes(); + var r0 = _keySerDes.Serialize(null, arg0); var res = _store.Get(r0); return new KNetValueAndTimestamp(_factory, res); @@ -88,6 +76,8 @@ public KNetValueAndTimestamp Get(TKey arg0) /// public KNetTimestampedKeyValueIterator ReverseRange(TKey arg0, TKey arg1) { + var _keySerDes = _factory.BuildKeySerDes(); + var r0 = _keySerDes.Serialize(null, arg0); var r1 = _keySerDes.Serialize(null, arg1); diff --git a/src/net/KNet/Specific/Streams/State/KNetTimestampedWindowStore.cs b/src/net/KNet/Specific/Streams/State/KNetTimestampedWindowStore.cs index 9760810212..7255203c7c 100644 --- a/src/net/KNet/Specific/Streams/State/KNetTimestampedWindowStore.cs +++ b/src/net/KNet/Specific/Streams/State/KNetTimestampedWindowStore.cs @@ -27,19 +27,6 @@ namespace MASES.KNet.Streams.State /// The value type public class KNetTimestampedWindowStore : KNetManagedStore>>, IGenericSerDesFactoryApplier { - readonly Org.Apache.Kafka.Streams.State.ReadOnlyWindowStore> _store; - readonly IKNetSerDes _keySerDes; - readonly IKNetSerDes _valueSerDes; - IGenericSerDesFactory _factory; - IGenericSerDesFactory IGenericSerDesFactoryApplier.Factory { get => _factory; set { _factory = value; } } - - internal KNetTimestampedWindowStore(IGenericSerDesFactory factory, Org.Apache.Kafka.Streams.State.ReadOnlyWindowStore> store) - { - _factory = factory; - _keySerDes = _factory.BuildKeySerDes(); - _valueSerDes = _factory.BuildValueSerDes(); - _store = store; - } /// /// /// @@ -48,14 +35,16 @@ internal KNetTimestampedWindowStore(IGenericSerDesFactory factory, Org.Apache.Ka /// /// /// - /// - /// + /// + /// /// /// /// /// public KNetTimestampedWindowedKeyValueIterator Fetch(TKey arg0, TKey arg1, Java.Time.Instant arg2, Java.Time.Instant arg3) { + var _keySerDes = _factory.BuildKeySerDes(); + var r0 = _keySerDes.Serialize(null, arg0); var r1 = _keySerDes.Serialize(null, arg1); @@ -75,24 +64,28 @@ public KNetTimestampedWindowedKeyValueIterator FetchAll(Java.Time. /// /// /// - /// + /// /// /// - /// + /// /// public KNetTimestampedWindowStoreIterator Fetch(TKey arg0, Java.Time.Instant arg1, Java.Time.Instant arg2) { + var _keySerDes = _factory.BuildKeySerDes(); + var r0 = _keySerDes.Serialize(null, arg0); return new(_factory, _store.Fetch(r0, arg1, arg2)); } /// /// /// - /// + /// /// - /// + /// public KNetValueAndTimestamp Fetch(TKey arg0, long arg1) { + var _keySerDes = _factory.BuildKeySerDes(); + var r0 = _keySerDes.Serialize(null, arg0); var agg = _store.Fetch(r0, arg1); return new KNetValueAndTimestamp(_factory, agg); @@ -105,14 +98,16 @@ public KNetValueAndTimestamp Fetch(TKey arg0, long arg1) /// /// /// - /// - /// + /// + /// /// /// /// /// public KNetTimestampedWindowedKeyValueIterator BackwardFetch(TKey arg0, TKey arg1, Java.Time.Instant arg2, Java.Time.Instant arg3) { + var _keySerDes = _factory.BuildKeySerDes(); + var r0 = _keySerDes.Serialize(null, arg0); var r1 = _keySerDes.Serialize(null, arg1); @@ -139,6 +134,8 @@ public KNetTimestampedWindowedKeyValueIterator BackwardFetchAll(Ja /// public KNetTimestampedWindowStoreIterator BackwardFetch(TKey arg0, Java.Time.Instant arg1, Java.Time.Instant arg2) { + var _keySerDes = _factory.BuildKeySerDes(); + var r0 = _keySerDes.Serialize(null, arg0); return new(_factory, _store.BackwardFetch(r0, arg1, arg2)); diff --git a/src/net/KNet/Specific/Streams/State/KNetTimestampedWindowedKeyValueIterator.cs b/src/net/KNet/Specific/Streams/State/KNetTimestampedWindowedKeyValueIterator.cs index 84acca4aab..3eb44589cb 100644 --- a/src/net/KNet/Specific/Streams/State/KNetTimestampedWindowedKeyValueIterator.cs +++ b/src/net/KNet/Specific/Streams/State/KNetTimestampedWindowedKeyValueIterator.cs @@ -21,6 +21,7 @@ using MASES.JCOBridge.C2JBridge.JVMInterop; using MASES.KNet.Serialization; using MASES.KNet.Streams.Kstream; +using System; using System.Collections.Generic; namespace MASES.KNet.Streams.State @@ -39,7 +40,11 @@ class LocalEnumerator(IGenericSerDesFactory factory, IJavaObject obj) : JVMBridg protected override object ConvertObject(object input) { - return new KNetTimestampedWindowedKeyValue(_factory, input as Org.Apache.Kafka.Streams.KeyValue, Org.Apache.Kafka.Streams.State.ValueAndTimestamp>); + if (input is IJavaObject obj) + { + return new KNetTimestampedWindowedKeyValue(_factory, JVMBridgeBase.Wraps, Org.Apache.Kafka.Streams.State.ValueAndTimestamp>>(obj)); + } + throw new InvalidCastException($"input is not a valid IJavaObject"); } } diff --git a/src/net/KNet/Specific/Streams/State/KNetWindowStoreIterator.cs b/src/net/KNet/Specific/Streams/State/KNetWindowStoreIterator.cs index 2cf381bd7d..e2408cc59d 100644 --- a/src/net/KNet/Specific/Streams/State/KNetWindowStoreIterator.cs +++ b/src/net/KNet/Specific/Streams/State/KNetWindowStoreIterator.cs @@ -40,7 +40,7 @@ internal KNetWindowStoreIterator(IGenericSerDesFactory factory, Org.Apache.Kafka /// /// Converter from to /// - public static implicit operator KNetKeyValueIterator(KNetWindowStoreIterator t) => new KNetKeyValueIterator(t._factory, t._iterator.Cast>()); + public static implicit operator KNetKeyValueIterator(KNetWindowStoreIterator t) => new KNetKeyValueIterator(t._factory, t._iterator.Cast>()); /// /// KNet implementation of diff --git a/src/net/KNet/Specific/Streams/State/KNetWindowedKeyValueIterator.cs b/src/net/KNet/Specific/Streams/State/KNetWindowedKeyValueIterator.cs index 2e86ef463e..455578550e 100644 --- a/src/net/KNet/Specific/Streams/State/KNetWindowedKeyValueIterator.cs +++ b/src/net/KNet/Specific/Streams/State/KNetWindowedKeyValueIterator.cs @@ -22,6 +22,7 @@ using MASES.KNet.Serialization; using MASES.KNet.Streams.Kstream; using System.Collections.Generic; +using System; namespace MASES.KNet.Streams.State { @@ -39,7 +40,11 @@ class LocalEnumerator(IGenericSerDesFactory factory, IJavaObject obj) : JVMBridg protected override object ConvertObject(object input) { - return new KNetWindowedKeyValue(_factory, input as Org.Apache.Kafka.Streams.KeyValue, byte[]>); + if (input is IJavaObject obj) + { + return new KNetWindowedKeyValue(_factory, JVMBridgeBase.Wraps, byte[]>>(obj)); + } + throw new InvalidCastException($"input is not a valid IJavaObject"); } } From 8d12e6c8b054a62edccfed0a81802d3a56ccef20 Mon Sep 17 00:00:00 2001 From: masesdevelopers <94312179+masesdevelopers@users.noreply.github.com> Date: Tue, 16 Jan 2024 16:16:50 +0100 Subject: [PATCH 15/18] Bump version --- .../KNet.Serialization.Protobuf.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/net/KNet.Serialization.Protobuf/KNet.Serialization.Protobuf.csproj b/src/net/KNet.Serialization.Protobuf/KNet.Serialization.Protobuf.csproj index 723886de39..081256b5fb 100644 --- a/src/net/KNet.Serialization.Protobuf/KNet.Serialization.Protobuf.csproj +++ b/src/net/KNet.Serialization.Protobuf/KNet.Serialization.Protobuf.csproj @@ -18,7 +18,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive From 20fb1413b07df84231da1b643bbf8e984d151a76 Mon Sep 17 00:00:00 2001 From: masesdevelopers <94312179+masesdevelopers@users.noreply.github.com> Date: Tue, 16 Jan 2024 16:43:35 +0100 Subject: [PATCH 16/18] Compilation update --- src/net/KNet/Specific/Streams/KNetKeyValue.cs | 16 +------ .../Streams/KNetTimestampedKeyValue.cs | 44 ++++++++----------- .../Streams/State/KNetKeyValueIterator.cs | 15 +++++-- .../State/KNetTimestampedKeyValueIterator.cs | 19 +++++--- .../KNetTimestampedWindowStoreIterator.cs | 2 +- ...KNetTimestampedWindowedKeyValueIterator.cs | 11 ++++- .../State/KNetWindowedKeyValueIterator.cs | 11 ++++- 7 files changed, 64 insertions(+), 54 deletions(-) diff --git a/src/net/KNet/Specific/Streams/KNetKeyValue.cs b/src/net/KNet/Specific/Streams/KNetKeyValue.cs index d220885956..31e05dc47e 100644 --- a/src/net/KNet/Specific/Streams/KNetKeyValue.cs +++ b/src/net/KNet/Specific/Streams/KNetKeyValue.cs @@ -65,22 +65,10 @@ internal KNetKeyValue(IGenericSerDesFactory factory, Org.Apache.Kafka.Streams.Ke /// /// KNet implementation of /// - public TKey Key - { - get - { - return _key != null ? _keySerDes.Deserialize(null, _key) : (TKey)(object)_keyLong; - } - } + public TKey Key => _key != null ? _keySerDes.Deserialize(null, _key) : (TKey)(object)_keyLong; /// /// KNet implementation of /// - public TValue Value - { - get - { - return _valueSerDes.Deserialize(null, _value); - } - } + public TValue Value => _valueSerDes.Deserialize(null, _value); } } diff --git a/src/net/KNet/Specific/Streams/KNetTimestampedKeyValue.cs b/src/net/KNet/Specific/Streams/KNetTimestampedKeyValue.cs index 6bbe23ddaa..ddb4391506 100644 --- a/src/net/KNet/Specific/Streams/KNetTimestampedKeyValue.cs +++ b/src/net/KNet/Specific/Streams/KNetTimestampedKeyValue.cs @@ -18,6 +18,7 @@ using MASES.KNet.Serialization; using MASES.KNet.Streams.State; +using System; namespace MASES.KNet.Streams { @@ -28,51 +29,44 @@ namespace MASES.KNet.Streams /// The value type public class KNetTimestampedKeyValue : IGenericSerDesFactoryApplier { - readonly Org.Apache.Kafka.Streams.KeyValue> _value; - readonly Org.Apache.Kafka.Streams.KeyValue> _value2; + readonly byte[] _key = null; + readonly long? _keyLong = null; + readonly Org.Apache.Kafka.Streams.State.ValueAndTimestamp _value = null; readonly IKNetSerDes _keySerDes; - readonly IKNetSerDes _valueSerDes; IGenericSerDesFactory _factory; IGenericSerDesFactory IGenericSerDesFactoryApplier.Factory { get => _factory; set { _factory = value; } } internal KNetTimestampedKeyValue(IGenericSerDesFactory factory, Org.Apache.Kafka.Streams.KeyValue> value) { +#pragma warning disable CA1816 + GC.SuppressFinalize(value); +#pragma warning restore CA1816 _factory = factory; _keySerDes = _factory.BuildKeySerDes(); - _valueSerDes = _factory.BuildValueSerDes(); - _value = value; + _key = value.key; + _value = value.value; + GC.ReRegisterForFinalize(value); } - internal KNetTimestampedKeyValue(IGenericSerDesFactory factory, Org.Apache.Kafka.Streams.KeyValue> value) + internal KNetTimestampedKeyValue(IGenericSerDesFactory factory, Org.Apache.Kafka.Streams.KeyValue> value) { +#pragma warning disable CA1816 + GC.SuppressFinalize(value); +#pragma warning restore CA1816 _factory = factory; _keySerDes = _factory.BuildKeySerDes(); - _valueSerDes = _factory.BuildValueSerDes(); - _value2 = value; + _keyLong = value.key?.LongValue(); + _value = value.value; + GC.ReRegisterForFinalize(value); } /// /// KNet implementation of /// - public TKey Key - { - get - { - if (_value2 != null) return (TKey)(object)_value2.key; - var kk = _value.key; - return _keySerDes.Deserialize(null, kk); - } - } + public TKey Key => _key != null ? _keySerDes.Deserialize(null, _key) : (TKey)(object)_keyLong; /// /// KNet implementation of /// - public KNetValueAndTimestamp Value - { - get - { - var kk = _value.value; - return new KNetValueAndTimestamp(_factory, kk); - } - } + public KNetValueAndTimestamp Value => new KNetValueAndTimestamp(_factory, _value); } } diff --git a/src/net/KNet/Specific/Streams/State/KNetKeyValueIterator.cs b/src/net/KNet/Specific/Streams/State/KNetKeyValueIterator.cs index 5e455ec625..b5ea2fbdff 100644 --- a/src/net/KNet/Specific/Streams/State/KNetKeyValueIterator.cs +++ b/src/net/KNet/Specific/Streams/State/KNetKeyValueIterator.cs @@ -32,17 +32,24 @@ namespace MASES.KNet.Streams.State /// The value type public class KNetKeyValueIterator : IGenericSerDesFactoryApplier { - class LocalEnumerator(bool isVersion2, IGenericSerDesFactory factory, IJavaObject obj) : JVMBridgeBaseEnumerator>(obj), IGenericSerDesFactoryApplier + class LocalEnumerator : JVMBridgeBaseEnumerator>, IGenericSerDesFactoryApplier { - IGenericSerDesFactory _factory = factory; + readonly bool _isVersion2; + IGenericSerDesFactory _factory; IGenericSerDesFactory IGenericSerDesFactoryApplier.Factory { get => _factory; set { _factory = value; } } + public LocalEnumerator(bool isVersion2, IGenericSerDesFactory factory, IJavaObject obj) : base(obj) + { + _isVersion2 = isVersion2; + _factory = factory; + } + protected override object ConvertObject(object input) { if (input is IJavaObject obj) { - return isVersion2 ? new KNetKeyValue(_factory, JVMBridgeBase.Wraps>(obj)) - : new KNetKeyValue(_factory, JVMBridgeBase.Wraps>(obj)); + return _isVersion2 ? new KNetKeyValue(_factory, JVMBridgeBase.Wraps>(obj)) + : new KNetKeyValue(_factory, JVMBridgeBase.Wraps>(obj)); } throw new InvalidCastException($"input is not a valid IJavaObject"); } diff --git a/src/net/KNet/Specific/Streams/State/KNetTimestampedKeyValueIterator.cs b/src/net/KNet/Specific/Streams/State/KNetTimestampedKeyValueIterator.cs index e57c8e7778..096a7d9606 100644 --- a/src/net/KNet/Specific/Streams/State/KNetTimestampedKeyValueIterator.cs +++ b/src/net/KNet/Specific/Streams/State/KNetTimestampedKeyValueIterator.cs @@ -32,24 +32,31 @@ namespace MASES.KNet.Streams.State /// The value type public class KNetTimestampedKeyValueIterator : IGenericSerDesFactoryApplier { - class LocalEnumerator(bool isVersion2, IGenericSerDesFactory factory, IJavaObject obj) : JVMBridgeBaseEnumerator>(obj), IGenericSerDesFactoryApplier + class LocalEnumerator : JVMBridgeBaseEnumerator>, IGenericSerDesFactoryApplier { - IGenericSerDesFactory _factory = factory; + readonly bool _isVersion2; + IGenericSerDesFactory _factory; IGenericSerDesFactory IGenericSerDesFactoryApplier.Factory { get => _factory; set { _factory = value; } } + public LocalEnumerator(bool isVersion2, IGenericSerDesFactory factory, IJavaObject obj) : base(obj) + { + _isVersion2 = isVersion2; + _factory = factory; + } + protected override object ConvertObject(object input) { if (input is IJavaObject obj) { - return isVersion2 ? new KNetTimestampedKeyValue(_factory, JVMBridgeBase.Wraps>>(obj)) - : new KNetTimestampedKeyValue(_factory, JVMBridgeBase.Wraps>>(obj)); + return _isVersion2 ? new KNetTimestampedKeyValue(_factory, JVMBridgeBase.Wraps>>(obj)) + : new KNetTimestampedKeyValue(_factory, JVMBridgeBase.Wraps>>(obj)); } throw new InvalidCastException($"input is not a valid IJavaObject"); } } readonly Org.Apache.Kafka.Streams.State.KeyValueIterator> _iterator = null; - readonly Org.Apache.Kafka.Streams.State.KeyValueIterator> _iterator2 = null; + readonly Org.Apache.Kafka.Streams.State.KeyValueIterator> _iterator2 = null; readonly IKNetSerDes _keySerDes; IGenericSerDesFactory _factory; IGenericSerDesFactory IGenericSerDesFactoryApplier.Factory { get => _factory; set { _factory = value; } } @@ -61,7 +68,7 @@ internal KNetTimestampedKeyValueIterator(IGenericSerDesFactory factory, Org.Apac _iterator = iterator; } - internal KNetTimestampedKeyValueIterator(IGenericSerDesFactory factory, Org.Apache.Kafka.Streams.State.KeyValueIterator> iterator) + internal KNetTimestampedKeyValueIterator(IGenericSerDesFactory factory, Org.Apache.Kafka.Streams.State.KeyValueIterator> iterator) { _factory = factory; _keySerDes = _factory.BuildKeySerDes(); diff --git a/src/net/KNet/Specific/Streams/State/KNetTimestampedWindowStoreIterator.cs b/src/net/KNet/Specific/Streams/State/KNetTimestampedWindowStoreIterator.cs index 952f777f7e..6a96b78ee4 100644 --- a/src/net/KNet/Specific/Streams/State/KNetTimestampedWindowStoreIterator.cs +++ b/src/net/KNet/Specific/Streams/State/KNetTimestampedWindowStoreIterator.cs @@ -40,7 +40,7 @@ internal KNetTimestampedWindowStoreIterator(IGenericSerDesFactory factory, Org.A /// /// Converter from to /// - public static implicit operator KNetTimestampedKeyValueIterator(KNetTimestampedWindowStoreIterator t) => new KNetTimestampedKeyValueIterator(t._factory, t._iterator.Cast>>()); + public static implicit operator KNetTimestampedKeyValueIterator(KNetTimestampedWindowStoreIterator t) => new KNetTimestampedKeyValueIterator(t._factory, t._iterator.Cast>>()); /// /// KNet implementation of diff --git a/src/net/KNet/Specific/Streams/State/KNetTimestampedWindowedKeyValueIterator.cs b/src/net/KNet/Specific/Streams/State/KNetTimestampedWindowedKeyValueIterator.cs index 3eb44589cb..f07802fb78 100644 --- a/src/net/KNet/Specific/Streams/State/KNetTimestampedWindowedKeyValueIterator.cs +++ b/src/net/KNet/Specific/Streams/State/KNetTimestampedWindowedKeyValueIterator.cs @@ -33,11 +33,18 @@ namespace MASES.KNet.Streams.State /// The value type public class KNetTimestampedWindowedKeyValueIterator : IGenericSerDesFactoryApplier { - class LocalEnumerator(IGenericSerDesFactory factory, IJavaObject obj) : JVMBridgeBaseEnumerator>(obj), IGenericSerDesFactoryApplier + class LocalEnumerator : JVMBridgeBaseEnumerator>, IGenericSerDesFactoryApplier { - IGenericSerDesFactory _factory = factory; + readonly bool _isVersion2; + IGenericSerDesFactory _factory; IGenericSerDesFactory IGenericSerDesFactoryApplier.Factory { get => _factory; set { _factory = value; } } + public LocalEnumerator(bool isVersion2, IGenericSerDesFactory factory, IJavaObject obj) : base(obj) + { + _isVersion2 = isVersion2; + _factory = factory; + } + protected override object ConvertObject(object input) { if (input is IJavaObject obj) diff --git a/src/net/KNet/Specific/Streams/State/KNetWindowedKeyValueIterator.cs b/src/net/KNet/Specific/Streams/State/KNetWindowedKeyValueIterator.cs index 455578550e..cf74fe8213 100644 --- a/src/net/KNet/Specific/Streams/State/KNetWindowedKeyValueIterator.cs +++ b/src/net/KNet/Specific/Streams/State/KNetWindowedKeyValueIterator.cs @@ -33,11 +33,18 @@ namespace MASES.KNet.Streams.State /// The value type public class KNetWindowedKeyValueIterator : IGenericSerDesFactoryApplier { - class LocalEnumerator(IGenericSerDesFactory factory, IJavaObject obj) : JVMBridgeBaseEnumerator>(obj), IGenericSerDesFactoryApplier + class LocalEnumerator : JVMBridgeBaseEnumerator>, IGenericSerDesFactoryApplier { - IGenericSerDesFactory _factory = factory; + readonly bool _isVersion2; + IGenericSerDesFactory _factory; IGenericSerDesFactory IGenericSerDesFactoryApplier.Factory { get => _factory; set { _factory = value; } } + public LocalEnumerator(bool isVersion2, IGenericSerDesFactory factory, IJavaObject obj) : base(obj) + { + _isVersion2 = isVersion2; + _factory = factory; + } + protected override object ConvertObject(object input) { if (input is IJavaObject obj) From 8b1e4177aae403aa92c7e0572e9aaf8da86bbfa0 Mon Sep 17 00:00:00 2001 From: masesdevelopers <94312179+masesdevelopers@users.noreply.github.com> Date: Tue, 16 Jan 2024 16:49:42 +0100 Subject: [PATCH 17/18] Other fixes --- .../Streams/State/KNetTimestampedWindowedKeyValueIterator.cs | 4 +--- .../Specific/Streams/State/KNetWindowedKeyValueIterator.cs | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/src/net/KNet/Specific/Streams/State/KNetTimestampedWindowedKeyValueIterator.cs b/src/net/KNet/Specific/Streams/State/KNetTimestampedWindowedKeyValueIterator.cs index f07802fb78..4f29e2dcf0 100644 --- a/src/net/KNet/Specific/Streams/State/KNetTimestampedWindowedKeyValueIterator.cs +++ b/src/net/KNet/Specific/Streams/State/KNetTimestampedWindowedKeyValueIterator.cs @@ -35,13 +35,11 @@ public class KNetTimestampedWindowedKeyValueIterator : IGenericSer { class LocalEnumerator : JVMBridgeBaseEnumerator>, IGenericSerDesFactoryApplier { - readonly bool _isVersion2; IGenericSerDesFactory _factory; IGenericSerDesFactory IGenericSerDesFactoryApplier.Factory { get => _factory; set { _factory = value; } } - public LocalEnumerator(bool isVersion2, IGenericSerDesFactory factory, IJavaObject obj) : base(obj) + public LocalEnumerator(IGenericSerDesFactory factory, IJavaObject obj) : base(obj) { - _isVersion2 = isVersion2; _factory = factory; } diff --git a/src/net/KNet/Specific/Streams/State/KNetWindowedKeyValueIterator.cs b/src/net/KNet/Specific/Streams/State/KNetWindowedKeyValueIterator.cs index cf74fe8213..d4aad690ab 100644 --- a/src/net/KNet/Specific/Streams/State/KNetWindowedKeyValueIterator.cs +++ b/src/net/KNet/Specific/Streams/State/KNetWindowedKeyValueIterator.cs @@ -35,13 +35,11 @@ public class KNetWindowedKeyValueIterator : IGenericSerDesFactoryA { class LocalEnumerator : JVMBridgeBaseEnumerator>, IGenericSerDesFactoryApplier { - readonly bool _isVersion2; IGenericSerDesFactory _factory; IGenericSerDesFactory IGenericSerDesFactoryApplier.Factory { get => _factory; set { _factory = value; } } - public LocalEnumerator(bool isVersion2, IGenericSerDesFactory factory, IJavaObject obj) : base(obj) + public LocalEnumerator(IGenericSerDesFactory factory, IJavaObject obj) : base(obj) { - _isVersion2 = isVersion2; _factory = factory; } From aafab86f83271b8a4528275aa5838b3576d15436 Mon Sep 17 00:00:00 2001 From: masesdevelopers <94312179+masesdevelopers@users.noreply.github.com> Date: Tue, 16 Jan 2024 17:21:40 +0100 Subject: [PATCH 18/18] namespace cleanup --- .../Specific/Streams/KNetClientSupplier.cs | 26 ++++++++----------- .../Specific/Streams/KNetWindowedKeyValue.cs | 2 +- .../Streams/Kstream/KNetMaterialized.cs | 8 +++--- 3 files changed, 15 insertions(+), 21 deletions(-) diff --git a/src/net/KNet/Specific/Streams/KNetClientSupplier.cs b/src/net/KNet/Specific/Streams/KNetClientSupplier.cs index 0c9e96d1ef..e02d52603b 100644 --- a/src/net/KNet/Specific/Streams/KNetClientSupplier.cs +++ b/src/net/KNet/Specific/Streams/KNetClientSupplier.cs @@ -19,23 +19,19 @@ using Java.Util; using MASES.KNet.Consumer; using MASES.KNet.Producer; -using Org.Apache.Kafka.Clients.Admin; -using Org.Apache.Kafka.Clients.Consumer; -using Org.Apache.Kafka.Clients.Producer; -using Org.Apache.Kafka.Streams; namespace MASES.KNet.Streams { /// - /// KNet implementation of + /// KNet implementation of /// - /// The default used from allocates both and . - /// uses and , the instance shall be disposed when no more in use, but still be alive still is alive. - public class KNetClientSupplier : KafkaClientSupplier + /// The default used from allocates both and . + /// uses and , the instance shall be disposed when no more in use, but still be alive still is alive. + public class KNetClientSupplier : Org.Apache.Kafka.Streams.KafkaClientSupplier { private readonly System.Collections.Generic.List _admins = new(); - private readonly System.Collections.Generic.List> _consumers = new(); - private readonly System.Collections.Generic.List> _producers = new(); + private readonly System.Collections.Generic.List> _consumers = new(); + private readonly System.Collections.Generic.List> _producers = new(); /// /// Default initializer /// @@ -45,12 +41,12 @@ public KNetClientSupplier() /// public override Org.Apache.Kafka.Clients.Admin.Admin GetAdmin(Map arg0) { - var admin = AdminClient.Create(arg0); + var admin = Org.Apache.Kafka.Clients.Admin.Admin.Create(arg0); _admins.Add(admin); return admin; } /// - public override Consumer GetConsumer(Map arg0) + public override Org.Apache.Kafka.Clients.Consumer.Consumer GetConsumer(Map arg0) { Properties properties = new(); properties.PutAll(arg0); @@ -60,7 +56,7 @@ public override Consumer GetConsumer(Map arg0) return consumer; } /// - public override Consumer GetGlobalConsumer(Map arg0) + public override Org.Apache.Kafka.Clients.Consumer.Consumer GetGlobalConsumer(Map arg0) { Properties properties = new(); properties.PutAll(arg0); @@ -70,7 +66,7 @@ public override Consumer GetGlobalConsumer(Map a return consumer; } /// - public override Producer GetProducer(Map arg0) + public override Org.Apache.Kafka.Clients.Producer.Producer GetProducer(Map arg0) { Properties properties = new(); properties.PutAll(arg0); @@ -80,7 +76,7 @@ public override Producer GetProducer(Map arg0) return producer; } /// - public override Consumer GetRestoreConsumer(Map arg0) + public override Org.Apache.Kafka.Clients.Consumer.Consumer GetRestoreConsumer(Map arg0) { Properties properties = new(); properties.PutAll(arg0); diff --git a/src/net/KNet/Specific/Streams/KNetWindowedKeyValue.cs b/src/net/KNet/Specific/Streams/KNetWindowedKeyValue.cs index 565d6da8a3..0e456437fa 100644 --- a/src/net/KNet/Specific/Streams/KNetWindowedKeyValue.cs +++ b/src/net/KNet/Specific/Streams/KNetWindowedKeyValue.cs @@ -22,7 +22,7 @@ namespace MASES.KNet.Streams { /// - /// KNet implementation of + /// KNet implementation of where the key is /// /// The key type /// The value type diff --git a/src/net/KNet/Specific/Streams/Kstream/KNetMaterialized.cs b/src/net/KNet/Specific/Streams/Kstream/KNetMaterialized.cs index 5424d79b0c..94847be333 100644 --- a/src/net/KNet/Specific/Streams/Kstream/KNetMaterialized.cs +++ b/src/net/KNet/Specific/Streams/Kstream/KNetMaterialized.cs @@ -16,11 +16,9 @@ * Refer to LICENSE for more information. */ -using Java.Security; + using MASES.JCOBridge.C2JBridge; using MASES.KNet.Serialization; -using Org.Apache.Kafka.Common.Serialization; -using System; namespace MASES.KNet.Streams.Kstream { @@ -37,7 +35,7 @@ public sealed class KNetCountingMaterialized : KNetMaterialized public static KNetCountingMaterialized With(IKNetSerDes arg0) { - var mat = Org.Apache.Kafka.Streams.Kstream.Materialized>.With(arg0.KafkaSerde, Serdes.Long()); + var mat = Org.Apache.Kafka.Streams.Kstream.Materialized>.With(arg0.KafkaSerde, Org.Apache.Kafka.Common.Serialization.Serdes.Long()); KNetCountingMaterialized cont = new(); if (cont is IKNetMaterialized setStore) { @@ -53,7 +51,7 @@ public static KNetCountingMaterialized With(IKNetSerDes arg0) /// public KNetCountingMaterialized WithValueSerde(IKNetSerDes arg0) { - _keyStore?.WithValueSerde(Serdes.Long()); + _keyStore?.WithValueSerde(Org.Apache.Kafka.Common.Serialization.Serdes.Long()); return this; } }