// Path: core/src/main/java/com/github/fhuss/kafka/streams/cep/core/Event.java
// public class Event<K, V> implements Comparable<Event<K, V>> {
// 
//     private final K key;
// 
//     private final V value;
// 
//     private final long timestamp;
// 
//     private final String topic;
// 
//     private final int partition;
// 
//     private long offset;
// 
//     /**
//      * Creates a new {@link Event} instance.
//      *
//      * @param key       the record key
//      * @param value     the record value
//      * @param timestamp the record timestamp
//      * @param topic     the record topic
//      * @param partition the record partition
//      * @param offset    the record offset
//      */
//     public Event(final K key,
//                  final V value,
//                  final long timestamp,
//                  final String topic,
//                  final int partition,
//                  final long offset) {
//         this.key = key;
//         this.value = value;
//         this.timestamp = timestamp;
//         this.topic = topic;
//         this.partition = partition;
//         this.offset = offset;
//     }
// 
//     public K key() {
//         return this.key;
//     }
// 
//     public V value() {
//         return this.value;
//     }
// 
//     public long timestamp() {
//         return this.timestamp;
//     }
// 
//     public String topic() {
//         return this.topic;
//     }
// 
//     public int partition() {
//         return this.partition;
//     }
// 
//     public long offset() {
//         return this.offset;
//     }
// 
//     @Override
//     public boolean equals(Object o) {
//         if (this == o) return true;
//         if (o == null || getClass() != o.getClass()) return false;
//         Event<?, ?> event = (Event<?, ?>) o;
//         return partition == event.partition &&
//                 offset == event.offset &&
//                 Objects.equals(topic, event.topic);
//     }
// 
//     @Override
//     public int hashCode() {
//         return Objects.hash(topic, partition, offset);
//     }
// 
//     @Override
//     public String toString() {
//         final StringBuilder sb = new StringBuilder("Event{");
//         sb.append("key=").append(key);
//         sb.append(", value=").append(value);
//         sb.append(", timestamp=").append(timestamp);
//         sb.append(", topic='").append(topic).append('\'');
//         sb.append(", partition=").append(partition);
//         sb.append(", offset=").append(offset);
//         sb.append('}');
//         return sb.toString();
//     }
// 
//     @Override
//     public int compareTo(Event<K, V> that) {
//         if (!this.topic.equals(that.topic) || this.partition != that.partition)
//             return Long.compare(this.timestamp, that.timestamp);
//         return Long.compare(this.offset, that.offset);
//     }
// }


import com.github.fhuss.kafka.streams.cep.core.Event;
import java.util.List;

/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements. See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You 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.
 */
package com.github.fhuss.kafka.streams.cep.core.nfa;



/**
 * The implementation is based on the paper "Efficient Pattern Matching over Event Streams".
 * @see <a href="https://people.cs.umass.edu/~yanlei/publications/sase-sigmod08.pdf">
 *      https://people.cs.umass.edu/~yanlei/publications/sase-sigmod08.pdf
 *      </a>
 *
 * @param <K> the type of keys
 * @param <V> the type of values
 */
public class ComputationStage<K, V> {

    /**
     * The stage.
     */
    private final Stage<K , V> stage;

    /**
     * The pointer to the most recent event into the share buffer.
     */

// Path: core/src/main/java/com/github/fhuss/kafka/streams/cep/core/Event.java
// public class Event<K, V> implements Comparable<Event<K, V>> {
// 
//     private final K key;
// 
//     private final V value;
// 
//     private final long timestamp;
// 
//     private final String topic;
// 
//     private final int partition;
// 
//     private long offset;
// 
//     /**
//      * Creates a new {@link Event} instance.
//      *
//      * @param key       the record key
//      * @param value     the record value
//      * @param timestamp the record timestamp
//      * @param topic     the record topic
//      * @param partition the record partition
//      * @param offset    the record offset
//      */
//     public Event(final K key,
//                  final V value,
//                  final long timestamp,
//                  final String topic,
//                  final int partition,
//                  final long offset) {
//         this.key = key;
//         this.value = value;
//         this.timestamp = timestamp;
//         this.topic = topic;
//         this.partition = partition;
//         this.offset = offset;
//     }
// 
//     public K key() {
//         return this.key;
//     }
// 
//     public V value() {
//         return this.value;
//     }
// 
//     public long timestamp() {
//         return this.timestamp;
//     }
// 
//     public String topic() {
//         return this.topic;
//     }
// 
//     public int partition() {
//         return this.partition;
//     }
// 
//     public long offset() {
//         return this.offset;
//     }
// 
//     @Override
//     public boolean equals(Object o) {
//         if (this == o) return true;
//         if (o == null || getClass() != o.getClass()) return false;
//         Event<?, ?> event = (Event<?, ?>) o;
//         return partition == event.partition &&
//                 offset == event.offset &&
//                 Objects.equals(topic, event.topic);
//     }
// 
//     @Override
//     public int hashCode() {
//         return Objects.hash(topic, partition, offset);
//     }
// 
//     @Override
//     public String toString() {
//         final StringBuilder sb = new StringBuilder("Event{");
//         sb.append("key=").append(key);
//         sb.append(", value=").append(value);
//         sb.append(", timestamp=").append(timestamp);
//         sb.append(", topic='").append(topic).append('\'');
//         sb.append(", partition=").append(partition);
//         sb.append(", offset=").append(offset);
//         sb.append('}');
//         return sb.toString();
//     }
// 
//     @Override
//     public int compareTo(Event<K, V> that) {
//         if (!this.topic.equals(that.topic) || this.partition != that.partition)
//             return Long.compare(this.timestamp, that.timestamp);
//         return Long.compare(this.offset, that.offset);
//     }
// }


// Path: core/src/main/java/com/github/fhuss/kafka/streams/cep/core/nfa/ComputationStage.java
import com.github.fhuss.kafka.streams.cep.core.Event;
import java.util.List;

/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements. See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You 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.
 */
package com.github.fhuss.kafka.streams.cep.core.nfa;



/**
 * The implementation is based on the paper "Efficient Pattern Matching over Event Streams".
 * @see <a href="https://people.cs.umass.edu/~yanlei/publications/sase-sigmod08.pdf">
 *      https://people.cs.umass.edu/~yanlei/publications/sase-sigmod08.pdf
 *      </a>
 *
 * @param <K> the type of keys
 * @param <V> the type of values
 */
public class ComputationStage<K, V> {

    /**
     * The stage.
     */
    private final Stage<K , V> stage;

    /**
     * The pointer to the most recent event into the share buffer.
     */

    private final Event<K, V> lastEvent;
