Github user QiangCai commented on a diff in the pull request:

    https://github.com/apache/carbondata/pull/1059#discussion_r123139222
  
    --- Diff: 
core/src/main/java/org/apache/carbondata/core/datastore/page/UnsafeFixLengthColumnPage.java
 ---
    @@ -326,9 +327,17 @@ public void encode(PrimitiveCodec codec) {
       }
     
       @Override
    -  public byte[] compress(Compressor compressor) {
    -    // TODO: use zero-copy raw compression
    -    return super.compress(compressor);
    +  public byte[] compress(Compressor compressor) throws MemoryException, 
IOException {
    +    // use raw compression and copy to byte[]
    +    int inputSize = pageSize << dataType.getSizeBits();
    +    int compressedMaxSize = compressor.maxCompressedLength(inputSize);
    +    MemoryBlock compressed = 
UnsafeMemoryManager.allocateMemoryWithRetry(compressedMaxSize);
    +    long outSize = compressor.rawCompress(baseOffset, inputSize, 
compressed.getBaseOffset());
    +    assert outSize < Integer.MAX_VALUE;
    +    byte[] output = new byte[(int) outSize];
    +    CarbonUnsafe.unsafe.copyMemory(compressed.getBaseObject(), 
compressed.getBaseOffset(),
    --- End diff --
    
    if we use UnsafeMemoryAllocator,  need to copyMemory(long, long, long).


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to