emkornfield commented on a change in pull request #7326:
URL: https://github.com/apache/arrow/pull/7326#discussion_r479868414



##########
File path: 
java/vector/src/main/java/org/apache/arrow/vector/compression/CompressionCodec.java
##########
@@ -0,0 +1,51 @@
+/*
+ * 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.arrow.vector.compression;
+
+import org.apache.arrow.memory.ArrowBuf;
+import org.apache.arrow.memory.BufferAllocator;
+
+/**
+ * The codec for compression/decompression.
+ */
+public interface CompressionCodec {
+
+  /**
+   * Compress a buffer.
+   * @param allocator the allocator for allocating memory for compressed 
buffer.
+   * @param unCompressedBuffer the buffer to compress.
+   *                           Implementation of this method should take care 
of releasing this buffer.
+   * @return the compressed buffer.
+   */
+  ArrowBuf compress(BufferAllocator allocator, ArrowBuf unCompressedBuffer);

Review comment:
       In thinking through this interface, something occurred to me.  Given the 
way the current Message serialization code works is it forces a copy from an 
underlying channel.  Given this, it seem like we would now have two copy like 
operations:
   1.  Copy from channel to compressed buffer
   2.  Uncompress the buffer when loading VectorSchemaRoot.
   
   I was wondering what you thought about deferring compression until writing 
out the  batch and doing decompression eagerly when reading in the batch to 
avoid one of these copies.  I think one thing that would potentially help us 
decide on the course to take would be look at the possible libraries we would 
use for compression/decompression and whether they support off-heap, 
InputStream or some other interface for accomplishing the compression
   
   @liyafan82 have you done more research in this area?
   
   @rymurr do you have anything thoughts on this?




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


Reply via email to