zhijiangW commented on a change in pull request #10375: [FLINK-14845][runtime] 
Introduce data compression to reduce disk and network IO of shuffle.
URL: https://github.com/apache/flink/pull/10375#discussion_r353581747
 
 

 ##########
 File path: 
flink-runtime/src/main/java/org/apache/flink/runtime/io/network/buffer/BufferDecompressor.java
 ##########
 @@ -0,0 +1,106 @@
+/*
+ * 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.buffer;
+
+import org.apache.flink.core.memory.MemorySegment;
+import org.apache.flink.core.memory.MemorySegmentFactory;
+import org.apache.flink.runtime.io.compression.BlockCompressionFactory;
+import org.apache.flink.runtime.io.compression.BlockDecompressor;
+
+import java.nio.ByteBuffer;
+
+import static org.apache.flink.util.Preconditions.checkArgument;
+
+/**
+ * Decompressor for compressed {@link Buffer}.
+ */
+public class BufferDecompressor {
+
+       /** The intermediate heap buffer for the decompressed data. */
+       private final byte[] heapBuffer;
 
 Review comment:
   I prefer to maintaining the `NetworkBuffer` instead of byte[] directly if 
possible. There are two benefits:
   
   1.  Avoid constructing this buffer wrapper every time during 
`decompressToInternalBuffer`.
   
   2. We can judge whether the maintained `NetworkBuffer` was recycled before 
when calling `decompressToInternalBuffer` every time, then we can find the 
potential risk beforehand to avoid data inconsistent. Now we only explain to 
guarantee that the previous buffer should be recycled before calling next one, 
but have not any checks to guarantee this assumption.
   
   Even we can support the buffer level decompression in 
`BlockDecompressor.decompress` instead of current `byte[]` and `ByteBuffer` 
ways, then we can hide all these details inside `NetworkBuffer`.

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


With regards,
Apache Git Services

Reply via email to