zhijiangW commented on a change in pull request #13595: URL: https://github.com/apache/flink/pull/13595#discussion_r509983937
########## File path: flink-runtime/src/main/java/org/apache/flink/runtime/io/network/partition/SortBuffer.java ########## @@ -0,0 +1,96 @@ +/* + * 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.flink.runtime.io.network.partition; + +import org.apache.flink.core.memory.MemorySegment; +import org.apache.flink.runtime.io.network.buffer.Buffer; + +import java.io.IOException; +import java.nio.ByteBuffer; + +import static org.apache.flink.util.Preconditions.checkNotNull; + +/** + * Data of different channels can be appended to a {@link SortBuffer} and after the {@link SortBuffer} is + * finished, the appended data can be copied from it in channel index order. + */ +public interface SortBuffer { + + /** + * Appends data of the specified channel to this {@link SortBuffer} and returns true if all bytes of + * the source buffer is copied to this {@link SortBuffer} successfully, otherwise if returns false, + * nothing will be copied. + */ + boolean append(ByteBuffer source, int targetChannel, Buffer.DataType dataType) throws IOException; + + /** + * Copies data in this {@link SortBuffer} to the target {@link MemorySegment} in channel index order + * and returns {@link BufferWithChannel} which contains the copied data and the corresponding channel + * index. + */ + BufferWithChannel copyData(MemorySegment target); Review comment: nit: rename as `copyIntoSegment` for better readable, otherwise I might be a bit confused whether `copyDataTo` or `copyDataFrom` in internal processes. ---------------------------------------------------------------- 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: [email protected]
