You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by qi...@apache.org on 2019/11/18 13:54:36 UTC

[incubator-iotdb] branch rel/0.9 updated: fix rewrite page when compression=snappy (#567)

This is an automated email from the ASF dual-hosted git repository.

qiaojialin pushed a commit to branch rel/0.9
in repository https://gitbox.apache.org/repos/asf/incubator-iotdb.git


The following commit(s) were added to refs/heads/rel/0.9 by this push:
     new d79ad95  fix rewrite page when compression=snappy (#567)
d79ad95 is described below

commit d79ad959601eb4cf70cbefa49090f30ea9ac7cde
Author: gwmh <16...@qq.com>
AuthorDate: Mon Nov 18 21:54:25 2019 +0800

    fix rewrite page when compression=snappy (#567)
    
    * [fix] fix rewrite page when compression=snappy
---
 .../tsfile/tool/upgrade/TsfileUpgradeToolV0_8_0.java      | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/tsfile/src/main/java/org/apache/iotdb/tsfile/tool/upgrade/TsfileUpgradeToolV0_8_0.java b/tsfile/src/main/java/org/apache/iotdb/tsfile/tool/upgrade/TsfileUpgradeToolV0_8_0.java
index 16b2f30..57a1019 100644
--- a/tsfile/src/main/java/org/apache/iotdb/tsfile/tool/upgrade/TsfileUpgradeToolV0_8_0.java
+++ b/tsfile/src/main/java/org/apache/iotdb/tsfile/tool/upgrade/TsfileUpgradeToolV0_8_0.java
@@ -29,6 +29,7 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import org.apache.iotdb.tsfile.common.conf.TSFileConfig;
+import org.apache.iotdb.tsfile.compress.ICompressor.SnappyCompressor;
 import org.apache.iotdb.tsfile.compress.IUnCompressor.SnappyUnCompressor;
 import org.apache.iotdb.tsfile.exception.compress.CompressionTypeNotSupportedException;
 import org.apache.iotdb.tsfile.exception.write.PageException;
@@ -547,7 +548,19 @@ public class TsfileUpgradeToolV0_8_0 implements AutoCloseable {
         }
         break;
     }
-    modifiedPage.clear();
+    switch (compressionType) {
+      case UNCOMPRESSED:
+        modifiedPage.flip();
+        break;
+      case SNAPPY:
+        SnappyCompressor snappyCompressor = new SnappyCompressor();
+        try {
+          modifiedPage = ByteBuffer.wrap(snappyCompressor.compress(modifiedPage.array()));
+        } catch (IOException e) {
+          logger.error("failed to compress page as snappy", e);
+        }
+        break;
+    }
     return modifiedPage;
   }
 }
\ No newline at end of file