-
Notifications
You must be signed in to change notification settings - Fork 360
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CELEBORN-1374] Refactor SortBuffer and PartitionSortedBuffer
- Loading branch information
1 parent
186899f
commit 31e1087
Showing
17 changed files
with
374 additions
and
373 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
.../common/src/main/java/org/apache/celeborn/plugin/flink/buffer/BufferWithSubpartition.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* 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.celeborn.plugin.flink.buffer; | ||
|
||
import static org.apache.flink.util.Preconditions.checkNotNull; | ||
|
||
import org.apache.flink.runtime.io.network.buffer.Buffer; | ||
|
||
/** Buffer and the corresponding subpartition index. */ | ||
public class BufferWithSubpartition { | ||
|
||
private final Buffer buffer; | ||
|
||
private final int subpartitionIndex; | ||
|
||
public BufferWithSubpartition(Buffer buffer, int subpartitionIndex) { | ||
this.buffer = checkNotNull(buffer); | ||
this.subpartitionIndex = subpartitionIndex; | ||
} | ||
|
||
public Buffer getBuffer() { | ||
return buffer; | ||
} | ||
|
||
public int getSubpartitionIndex() { | ||
return subpartitionIndex; | ||
} | ||
} |
74 changes: 74 additions & 0 deletions
74
client-flink/common/src/main/java/org/apache/celeborn/plugin/flink/buffer/DataBuffer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
/* | ||
* 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.celeborn.plugin.flink.buffer; | ||
|
||
import java.io.IOException; | ||
import java.nio.ByteBuffer; | ||
|
||
import javax.annotation.Nullable; | ||
|
||
import org.apache.flink.core.memory.MemorySegment; | ||
import org.apache.flink.runtime.io.network.buffer.Buffer; | ||
import org.apache.flink.runtime.io.network.buffer.BufferRecycler; | ||
|
||
/** | ||
* Data of different subpartitions can be appended to a {@link DataBuffer} and after the {@link | ||
* DataBuffer} is full or finished, the appended data can be copied from it in subpartition index | ||
* order. | ||
* | ||
* <p>The lifecycle of a {@link DataBuffer} can be: new, write, [read, reset, write], finish, read, | ||
* release. There can be multiple [read, reset, write] operations before finish. | ||
*/ | ||
public interface DataBuffer { | ||
|
||
/** | ||
* Appends data of the specified subpartition to this {@link DataBuffer} and returns true if this | ||
* {@link DataBuffer} is full. | ||
*/ | ||
boolean append(ByteBuffer source, int targetSubpartition, Buffer.DataType dataType) | ||
throws IOException; | ||
|
||
/** | ||
* Copies data in this {@link DataBuffer} to the target {@link MemorySegment} in subpartition | ||
* index order and returns {@link BufferWithSubpartition} which contains the copied data and the | ||
* corresponding subpartition index. | ||
*/ | ||
BufferWithSubpartition getNextBuffer( | ||
@Nullable MemorySegment transitBuffer, BufferRecycler recycler, int offset); | ||
|
||
/** Returns the total number of records written to this {@link DataBuffer}. */ | ||
long numTotalRecords(); | ||
|
||
/** Returns the total number of bytes written to this {@link DataBuffer}. */ | ||
long numTotalBytes(); | ||
|
||
/** Returns true if not all data appended to this {@link DataBuffer} is consumed. */ | ||
boolean hasRemaining(); | ||
|
||
/** Finishes this {@link DataBuffer} which means no record can be appended anymore. */ | ||
void finish(); | ||
|
||
/** Whether this {@link DataBuffer} is finished or not. */ | ||
boolean isFinished(); | ||
|
||
/** Releases this {@link DataBuffer} which releases all resources. */ | ||
void release(); | ||
|
||
/** Whether this {@link DataBuffer} is released or not. */ | ||
boolean isReleased(); | ||
} |
Oops, something went wrong.