dengziming commented on a change in pull request #9819:
URL: https://github.com/apache/kafka/pull/9819#discussion_r561051913



##########
File path: 
raft/src/main/java/org/apache/kafka/snapshot/FileRawSnapshotWriter.java
##########
@@ -53,13 +56,20 @@ public long sizeInBytes() throws IOException {
     }
 
     @Override
-    public void append(ByteBuffer buffer) throws IOException {
+    public void append(BaseRecords records) throws IOException {
         if (frozen) {
             throw new IllegalStateException(
-                String.format("Append is not supported. Snapshot is already 
frozen: id = %s; temp path = %s", snapshotId, tempSnapshotPath)
+                    String.format("Append is not supported. Snapshot is 
already frozen: id = %s; temp path = %s", snapshotId, tempSnapshotPath)
             );
         }
-
+        ByteBuffer buffer;
+        if (records instanceof MemoryRecords) {
+            buffer = ((MemoryRecords) records).buffer();
+        } else {
+            buffer = ByteBuffer.allocate(records.sizeInBytes());
+            ((FileRecords) records).channel().read(buffer);
+            buffer.flip();
+        }

Review comment:
       In fact, I change the signature to keep consistent with 
`FileRawSnapshotReader`, I'm also a little wobbly to make these changes.




----------------------------------------------------------------
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


Reply via email to