@Override
        public List<WriteBufferSegmentWithDbFallback> getReverseSegments(final long timestampFrom) {
            // head and not tail because the map is sorted in reverse order
            final long segmentFrom = segmentIdForTimestamp(timestampFrom);
            final List<WriteBufferSegmentWithDbFallback> bufferSegments =
                new ArrayList<>(segmentsWriteBuffer.headMap(segmentFrom, true).values());

            final List<LogicalKeyValueSegment> dbSegments = dbClient.getReverseSegments(timestampFrom);

            // merge segments from db with segments from write buffer
            final List<WriteBufferSegmentWithDbFallback> allSegments = new ArrayList<>();
            int dbIndex = 0;
            int bufferIndex = 0;
            while (dbIndex < dbSegments.size() && bufferIndex < bufferSegments.size()) {
                final LogicalKeyValueSegment dbSegment = dbSegments.get(dbIndex);
                final WriteBufferSegmentWithDbFallback bufferSegment = bufferSegments.get(bufferIndex);
                final long dbSegmentId = dbSegment.id();
                final long bufferSegmentId = bufferSegment.id();
                if (dbSegmentId > bufferSegmentId) {
                    // creating a new segment automatically registers it with the segments store
                    allSegments.add(new WriteBufferSegmentWithDbFallback(dbSegment));
                    dbIndex++;
                } else if (dbSegmentId < bufferSegmentId) {
                    allSegments.add(bufferSegment);
                    bufferIndex++;
                } else {
                    allSegments.add(bufferSegment);
                    dbIndex++;
                    bufferIndex++;
                }
            }
            while (dbIndex < dbSegments.size()) {
                // creating a new segment automatically registers it with the segments store
                allSegments.add(new WriteBufferSegmentWithDbFallback(dbSegments.get(dbIndex)));
                dbIndex++;
            }
            while (bufferIndex < bufferSegments.size()) {
                allSegments.add(bufferSegments.get(bufferIndex));
                bufferIndex++;
            }
            return allSegments;
        }
Client for writing to (and reading from) the write buffer as part of restore.
streams/src/main/java/org/apache/kafka/streams/state/internals/RocksDBVersionedStoreRestoreWriteBuffer.java