Separate byte-level atomic-storage access
[controller.git] / atomix-storage / src / main / java / io / atomix / storage / journal / SegmentedCommitsByteBufReader.java
1 /*
2  * Copyright (c) 2024 PANTHEON.tech, s.r.o. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package io.atomix.storage.journal;
9
10 import io.netty.buffer.ByteBuf;
11
12 /**
13  * A {@link ByteBufReader} traversing only committed entries.
14  */
15 final class SegmentedCommitsByteBufReader extends SegmentedByteBufReader {
16     SegmentedCommitsByteBufReader(final SegmentedByteBufJournal journal, final JournalSegment segment) {
17         super(journal, segment);
18     }
19
20     @Override
21     ByteBuf tryAdvance(final long index) {
22         return index <= journal.getCommitIndex() ? super.tryAdvance(index) : null;
23     }
24 }