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

jiangtian pushed a commit to branch auto_compressor
in repository https://gitbox.apache.org/repos/asf/iotdb.git


The following commit(s) were added to refs/heads/auto_compressor by this push:
     new a5053662da4 add comment
a5053662da4 is described below

commit a5053662da452e65ee6eeb1485d3ebe9eee8e36e
Author: Tian Jiang <[email protected]>
AuthorDate: Mon May 29 11:03:02 2023 +0800

    add comment
---
 .../java/org/apache/iotdb/tsfile/compress/auto/AutoCompressor.java  | 4 ++++
 .../org/apache/iotdb/tsfile/compress/auto/CompressionSampler.java   | 6 +++++-
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git 
a/tsfile/src/main/java/org/apache/iotdb/tsfile/compress/auto/AutoCompressor.java
 
b/tsfile/src/main/java/org/apache/iotdb/tsfile/compress/auto/AutoCompressor.java
index 62f2877a534..a349aaa098a 100644
--- 
a/tsfile/src/main/java/org/apache/iotdb/tsfile/compress/auto/AutoCompressor.java
+++ 
b/tsfile/src/main/java/org/apache/iotdb/tsfile/compress/auto/AutoCompressor.java
@@ -62,6 +62,7 @@ public class AutoCompressor implements ICompressor {
     byte[] compress = preferredSampler.compress(data);
     byte[] result = new byte[compress.length + 1];
     System.arraycopy(compress, 0, result, 0, compress.length);
+    // the last byte is for the real compression type
     result[compress.length] = preferredSampler.getType().serialize();
     return result;
   }
@@ -75,6 +76,7 @@ public class AutoCompressor implements ICompressor {
     byte[] compress = preferredSampler.compress(data, offset, length);
     byte[] result = new byte[compress.length + 1];
     System.arraycopy(compress, 0, result, 0, compress.length);
+    // the last byte is for the real compression type
     result[compress.length] = preferredSampler.getType().serialize();
     return result;
   }
@@ -86,6 +88,7 @@ public class AutoCompressor implements ICompressor {
     }
     ICompressor preferredSampler = sampler.getPreferredSampler();
     int compressedLength = preferredSampler.compress(data, offset, length, 
compressed);
+    // the last byte is for the real compression type
     compressed[compressedLength] = preferredSampler.getType().serialize();
     return compressedLength + 1;
   }
@@ -97,6 +100,7 @@ public class AutoCompressor implements ICompressor {
     }
     ICompressor preferredSampler = sampler.getPreferredSampler();
     int compressedLength = preferredSampler.compress(data, compressed);
+    // the last byte is for the real compression type
     compressed.mark();
     compressed.position(compressed.position() + compressedLength);
     compressed.put(preferredSampler.getType().serialize());
diff --git 
a/tsfile/src/main/java/org/apache/iotdb/tsfile/compress/auto/CompressionSampler.java
 
b/tsfile/src/main/java/org/apache/iotdb/tsfile/compress/auto/CompressionSampler.java
index 8358c4896e5..1bdd6505306 100644
--- 
a/tsfile/src/main/java/org/apache/iotdb/tsfile/compress/auto/CompressionSampler.java
+++ 
b/tsfile/src/main/java/org/apache/iotdb/tsfile/compress/auto/CompressionSampler.java
@@ -93,6 +93,7 @@ public class CompressionSampler {
     lastSampleTimeMS = System.currentTimeMillis();
     updatePreferredIndex();
 
+    // the last byte is for the real compression type
     byte[] result = new byte[bestResult.length + 1];
     System.arraycopy(bestResult, 0, result, 0, bestResult.length);
     result[bestResult.length] = bestType.serialize();
@@ -121,6 +122,7 @@ public class CompressionSampler {
     lastSampleTimeMS = System.currentTimeMillis();
     updatePreferredIndex();
 
+    // the last byte is for the real compression type
     compressed[smallestLength] = bestType.serialize();
     return smallestLength + 1;
   }
@@ -147,6 +149,7 @@ public class CompressionSampler {
     lastSampleTimeMS = System.currentTimeMillis();
     updatePreferredIndex();
 
+    // the last byte is for the real compression type
     compressed.mark();
     compressed.position(compressed.position() + smallestLength);
     compressed.put(bestType.serialize());
@@ -159,7 +162,8 @@ public class CompressionSampler {
     for (ICompressor compressor : compressors) {
       maxBytes = Math.max(maxBytes, 
compressor.getMaxBytesForCompression(uncompressedDataSize));
     }
-    return maxBytes;
+    // the last byte is for the real compression type
+    return maxBytes + 1;
   }
 
 

Reply via email to