JingsongLi commented on code in PR #4034: URL: https://github.com/apache/paimon/pull/4034#discussion_r1726455227
########## paimon-common/src/main/java/org/apache/paimon/io/BatchRecords.java: ########## @@ -0,0 +1,27 @@ +/* + * 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.paimon.io; + +/** Interface of Batch records. */ +public interface BatchRecords { Review Comment: it is better to be an `Iterable<InternalRow>` ########## paimon-core/src/main/java/org/apache/paimon/utils/RecordWriter.java: ########## @@ -35,6 +36,11 @@ public interface RecordWriter<T> { /** Add a key-value element to the writer. */ void write(T record) throws Exception; + /** Add a batch elemens to the writer. */ + default void writeBatch(BatchRecords record) throws Exception { + throw new UnsupportedOperationException("Not supported"); Review Comment: should not throw exception ########## paimon-common/src/main/java/org/apache/paimon/format/FormatWriter.java: ########## @@ -47,6 +48,10 @@ public interface FormatWriter { */ void flush() throws IOException; + default void writeBatch(BatchRecords batchRecords) throws IOException { + throw new UnsupportedOperationException("Not supported."); Review Comment: create an interface: `BatchFormatWriter`. ########## paimon-core/src/main/java/org/apache/paimon/append/AppendOnlyWriter.java: ########## @@ -172,6 +173,14 @@ public void write(InternalRow rowData) throws Exception { } } + @Override + public void writeBatch(BatchRecords batchRecords) throws Exception { + if (sinkWriter instanceof BufferedSinkWriter) { + throw new RuntimeException("Not support BufferedSinkWriter."); Review Comment: never throw exception ########## paimon-core/src/main/java/org/apache/paimon/table/sink/BatchTableWrite.java: ########## @@ -36,4 +38,7 @@ public interface BatchTableWrite extends TableWrite { * @see BatchTableCommit#commit */ List<CommitMessage> prepareCommit() throws Exception; + + /** Write a batch records directly, not per row. */ + void writeBatch(BinaryRow partition, int bucket, BatchRecords batch) throws Exception; Review Comment: can be in `TableWrite`. ########## paimon-core/src/main/java/org/apache/paimon/io/SingleFileWriter.java: ########## @@ -94,6 +94,15 @@ public void write(T record) throws IOException { writeImpl(record); } + public void writeBatch(BatchRecords batchRecords) throws IOException { + if (closed) { + throw new RuntimeException("Writer has already closed!"); + } + + writer.writeBatch(batchRecords); Review Comment: why no try catch? -- 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]
