bbejeck commented on code in PR #22323: URL: https://github.com/apache/kafka/pull/22323#discussion_r3352238601
########## streams/src/main/java/org/apache/kafka/streams/state/internals/AbstractTransactionBuffer.java: ########## @@ -0,0 +1,172 @@ +/* + * 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 org.apache.kafka.streams.state.internals; + +import java.util.NavigableMap; +import java.util.Optional; +import java.util.TreeMap; +import java.util.concurrent.ConcurrentSkipListMap; +import java.util.concurrent.locks.ReentrantReadWriteLock; + +/** + * Base class for {@link TransactionBuffer} implementations. Provides the shared two-layer + * staging design: a thread-safe {@link ConcurrentSkipListMap} for reads (any thread) and + * backend-specific write accumulation for atomic commit. + * <p> + * Point lookups ({@link #get(Comparable)}) are lock-free. Scan methods automatically detect the + * owner thread and use a lock-free fast path; non-owner threads acquire a read lock to + * snapshot the staging map atomically with base iterator creation. + * + * @param <K> the key type, must be {@link Comparable} + */ +abstract class AbstractTransactionBuffer<K extends Comparable<K>> implements TransactionBuffer<K> { Review Comment: Could we get some tests for the concrete methods in this class? I realize it's an `abstract` class - but not a blocker as long as we get coverage with testing in subsequent PRs -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
