TanYuxin-tyx commented on code in PR #22804: URL: https://github.com/apache/flink/pull/22804#discussion_r1241094392
########## flink-runtime/src/main/java/org/apache/flink/runtime/io/network/partition/hybrid/tiered/file/PartitionFileWriter.java: ########## @@ -0,0 +1,107 @@ +/* + * 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.hybrid.tiered.file; + +import java.util.List; +import java.util.concurrent.CompletableFuture; + +/** + * The {@link PartitionFileWriter} interface defines the write logic for different types of shuffle + * files. + */ +public interface PartitionFileWriter { + + /** + * Write the {@link SpilledBufferContext}s to the partition file. The written buffers may belong + * to multiple subpartitions. + * + * @return the completable future indicating whether the writing file process has finished. If + * the {@link CompletableFuture} is completed, the written process is completed. + */ + CompletableFuture<Void> write(List<SubpartitionSpilledBufferContext> spilledBuffers); Review Comment: Fixed the comments and renamed the argument to `buffersToWrite` ########## flink-runtime/src/main/java/org/apache/flink/runtime/io/network/partition/hybrid/tiered/file/PartitionFileWriter.java: ########## @@ -0,0 +1,107 @@ +/* + * 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.hybrid.tiered.file; + +import java.util.List; +import java.util.concurrent.CompletableFuture; + +/** + * The {@link PartitionFileWriter} interface defines the write logic for different types of shuffle + * files. + */ +public interface PartitionFileWriter { + + /** + * Write the {@link SpilledBufferContext}s to the partition file. The written buffers may belong + * to multiple subpartitions. + * + * @return the completable future indicating whether the writing file process has finished. If + * the {@link CompletableFuture} is completed, the written process is completed. + */ + CompletableFuture<Void> write(List<SubpartitionSpilledBufferContext> spilledBuffers); + + /** Release all the resources of the {@link PartitionFileWriter}. */ + void release(); + + /** + * The {@link SubpartitionSpilledBufferContext} contains all the buffers that will be spilled in + * this subpartition. + */ + class SubpartitionSpilledBufferContext { + + /** The subpartition id. */ + private final int subpartitionId; + + /** he {@link SegmentSpilledBufferContext}s belonging to this subpartition. */ + private final List<SegmentSpilledBufferContext> segmentSpilledBufferContexts; + + public SubpartitionSpilledBufferContext( + int subpartitionId, + List<SegmentSpilledBufferContext> segmentSpilledBufferContexts) { + this.subpartitionId = subpartitionId; + this.segmentSpilledBufferContexts = segmentSpilledBufferContexts; + } + + public int getSubpartitionId() { + return subpartitionId; + } + + public List<SegmentSpilledBufferContext> getSegmentSpillBufferContexts() { + return segmentSpilledBufferContexts; + } + } + + /** + * The wrapper class {@link SegmentSpilledBufferContext} contains all the {@link + * SpilledBufferContext}s of the segment. Note that when this indicates the segment need to be + * finished, the field {@code spilledBufferContexts} should be empty. + */ + class SegmentSpilledBufferContext { + + /** The segment id. */ + private final int segmentId; + + /** The {@link SpilledBufferContext}s indicate the buffers to be spilled. */ + private final List<SpilledBufferContext> spilledBufferContexts; + + /** Whether it is necessary to finish the segment. */ + private final boolean needFinishSegment; Review Comment: Fixed. -- 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]
