jsancio commented on a change in pull request #9512: URL: https://github.com/apache/kafka/pull/9512#discussion_r519211721
########## File path: raft/src/main/java/org/apache/kafka/snapshot/RawSnapshotReader.java ########## @@ -0,0 +1,52 @@ +/* + * 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.snapshot; + +import java.io.Closeable; +import java.io.IOException; +import java.nio.ByteBuffer; +import org.apache.kafka.common.record.RecordBatch; +import org.apache.kafka.raft.OffsetAndEpoch; + +/** + * Interface for reading snapshots as a sequence of records. + */ +public interface RawSnapshotReader extends Closeable, Iterable<RecordBatch> { + /** + * Returns the end offset and epoch for the snapshot. + */ + public OffsetAndEpoch snapshotId(); + + /** + * Returns the number of bytes for the snapshot. + * + * @throws IOException for any IO error while reading the size + */ + public long sizeInBytes() throws IOException; + + /** + * Reads bytes from position into the given buffer. + * + * It is not guarantee that the given buffer will be filled. + * + * @param buffer byte buffer to put the read files + * @param position the starting position in the snapshot to read + * @return the number of bytes read + * @throws IOException for any IO error while reading the snapshot + */ + public int read(ByteBuffer buffer, long position) throws IOException; Review comment: As @hachikuji and I discussed offline, it is very like that this method will change to: ```java public BaseRecords slice(long position) throws IOException; ``` After we implement https://issues.apache.org/jira/browse/KAFKA-10694 ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org