You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@iotdb.apache.org by GitBox <gi...@apache.org> on 2020/10/29 11:48:39 UTC

[GitHub] [iotdb] 5Reasons commented on a change in pull request #1890: Finish DIFF encoding algorithm which is reserved in enum before

5Reasons commented on a change in pull request #1890:
URL: https://github.com/apache/iotdb/pull/1890#discussion_r514197949



##########
File path: tsfile/src/test/java/org/apache/iotdb/tsfile/encoding/decoder/delta/DiffEncoderIntegerTest.java
##########
@@ -0,0 +1,132 @@
+/*
+ * 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.decoder.delta;
+
+import org.apache.iotdb.tsfile.encoding.decoder.DiffDecoder;
+import org.apache.iotdb.tsfile.encoding.encoder.DiffEncoder;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.util.Random;
+
+import static org.junit.Assert.assertEquals;
+
+public class DiffEncoderIntegerTest {
+
+  private static final int ROW_NUM = 100_000_00;//行数,数组的大小
+  ByteArrayOutputStream out;
+  private DiffEncoder writer;
+  private DiffDecoder reader;
+  private Random ran = new Random();
+  private ByteBuffer buffer;
+
+  @Before
+  public void test() {
+    writer = new DiffEncoder.IntDeltaEncoder();
+    reader = new DiffDecoder.IntDeltaDecoder();
+  }
+
+  @Test
+  public void testBasic() throws IOException {
+    int data[] = new int[ROW_NUM];
+    for (int i = 0; i < ROW_NUM; i++) {
+      data[i] = i * i;
+    }
+    shouldReadAndWrite(data, ROW_NUM);
+  }
+
+  @Test
+  public void testBoundInt() throws IOException {
+    int data[] = new int[ROW_NUM];
+    for (int i = 0; i < 10; i++) {
+      boundInt(i, data);
+    }
+  }
+
+  private void boundInt(int power, int[] data) throws IOException {
+    for (int i = 0; i < ROW_NUM; i++) {
+      data[i] = ran.nextInt((int) Math.pow(2, power));
+    }
+    shouldReadAndWrite(data, ROW_NUM);
+  }
+
+  @Test
+  public void testRandom() throws IOException {
+    int data[] = new int[ROW_NUM];
+    for (int i = 0; i < ROW_NUM; i++) {
+      data[i] = ran.nextInt();
+      System.out.printf("%d ",data[i]);

Review comment:
       Sorry for not finding the problems before submitting. I will fix them.




----------------------------------------------------------------
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:
users@infra.apache.org