kr11 commented on a change in pull request #1890:
URL: https://github.com/apache/iotdb/pull/1890#discussion_r514743214



##########
File path: 
tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/encoder/DiffEncoder.java
##########
@@ -0,0 +1,324 @@
+/*
+ * 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.iotdb.tsfile.encoding.encoder;
+
+import org.apache.iotdb.tsfile.file.metadata.enums.TSEncoding;
+import org.apache.iotdb.tsfile.utils.BytesUtils;
+import org.apache.iotdb.tsfile.utils.ReadWriteIOUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+
+/**
+ * <p>
+ * DiffEncoder is a encoder for compressing data in type of INT32(integer) and
+ * INT64(long). It is based in delta-encoding arithmetic.We adapt a hypothesis
+ * that contiguous data points have similar values.Thus the difference value of
+ * two adjacent points is smaller than those two point values. One integer in
+ * java takes 32-bits. If a positive number is less than 2^m, the bits of this
+ * integer which index from m to 31 are all 0. Given an array which length is 
n,
+ * if all values in input data array are all positive and less than 2^m, we 
need
+ * actually m*n, but not 32*n bits to store the array.
+ * </p>
+ * <p>
+ * DiffEncoder calculates difference between two adjacent. Then it saves the 
delta
+ * value. Then it statistics the longest bit length {@code m} it takes for each
+ * delta value, which means the bit length that maximum delta value takes. Only
+ * the low m bits are saved into result byte array for all delta values.

Review comment:
       m -> {@code m}
   It's better to be consistent with the above.




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