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 2020/12/18 14:10:39 UTC

[iotdb] branch master updated: Add Unit tests for Utils module (#2246)

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

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


The following commit(s) were added to refs/heads/master by this push:
     new f77b851  Add Unit tests for Utils module (#2246)
f77b851 is described below

commit f77b85131e654fd570b876fc14dd1ccff7df3265
Author: wshao08 <59...@users.noreply.github.com>
AuthorDate: Fri Dec 18 22:10:27 2020 +0800

    Add Unit tests for Utils module (#2246)
---
 .../cluster/partition/slot/SlotPartitionTable.java |   4 +-
 .../apache/iotdb/db/auth/entity/PathPrivilege.java |   4 +-
 .../org/apache/iotdb/db/utils/SerializeUtils.java  |  12 +-
 .../iotdb/db/utils/CopyOnReadLinkedListTest.java   |  67 +++++
 .../iotdb/db/utils/EncodingInferenceUtilsTest.java |  45 +++
 .../org/apache/iotdb/db/utils/MemUtilsTest.java    | 114 ++++++++
 .../org/apache/iotdb/db/utils/SchemaUtilsTest.java |  64 +++++
 .../apache/iotdb/db/utils/SerializeUtilsTest.java  | 312 +++++++++++++++++++++
 .../db/utils/datastructure/BinaryTVListTest.java   |  58 ++++
 .../db/utils/datastructure/BooleanTVListTest.java  |  62 ++++
 .../db/utils/datastructure/DoubleTVListTest.java   |  72 +++++
 .../db/utils/datastructure/FloatTVListTest.java    |  72 +++++
 .../db/utils/datastructure/IntTVListTest.java      |  71 +++++
 .../db/utils/datastructure/LongTVListTest.java     |  18 ++
 14 files changed, 966 insertions(+), 9 deletions(-)

diff --git a/cluster/src/main/java/org/apache/iotdb/cluster/partition/slot/SlotPartitionTable.java b/cluster/src/main/java/org/apache/iotdb/cluster/partition/slot/SlotPartitionTable.java
index ead856c..e9295f3 100644
--- a/cluster/src/main/java/org/apache/iotdb/cluster/partition/slot/SlotPartitionTable.java
+++ b/cluster/src/main/java/org/apache/iotdb/cluster/partition/slot/SlotPartitionTable.java
@@ -312,7 +312,7 @@ public class SlotPartitionTable implements PartitionTable {
       dataOutputStream.writeInt(nodeSlotMap.size());
       for (Entry<Node, List<Integer>> entry : nodeSlotMap.entrySet()) {
         SerializeUtils.serialize(entry.getKey(), dataOutputStream);
-        SerializeUtils.serialize(entry.getValue(), dataOutputStream);
+        SerializeUtils.serializeIntList(entry.getValue(), dataOutputStream);
       }
 
       dataOutputStream.writeInt(previousNodeMap.size());
@@ -345,7 +345,7 @@ public class SlotPartitionTable implements PartitionTable {
       Node node = new Node();
       List<Integer> slots = new ArrayList<>();
       SerializeUtils.deserialize(node, buffer);
-      SerializeUtils.deserialize(slots, buffer);
+      SerializeUtils.deserializeIntList(slots, buffer);
       nodeSlotMap.put(node, slots);
       idNodeMap.put(node.getNodeIdentifier(), node);
       for (Integer slot : slots) {
diff --git a/server/src/main/java/org/apache/iotdb/db/auth/entity/PathPrivilege.java b/server/src/main/java/org/apache/iotdb/db/auth/entity/PathPrivilege.java
index daf7206..019ff8c 100644
--- a/server/src/main/java/org/apache/iotdb/db/auth/entity/PathPrivilege.java
+++ b/server/src/main/java/org/apache/iotdb/db/auth/entity/PathPrivilege.java
@@ -116,7 +116,7 @@ public class PathPrivilege {
     ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
     DataOutputStream dataOutputStream = new DataOutputStream(byteArrayOutputStream);
 
-    SerializeUtils.serialize(privileges, dataOutputStream);
+    SerializeUtils.serializeIntSet(privileges, dataOutputStream);
     SerializeUtils.serialize(path, dataOutputStream);
 
     return ByteBuffer.wrap(byteArrayOutputStream.toByteArray());
@@ -124,7 +124,7 @@ public class PathPrivilege {
 
   public void deserialize(ByteBuffer buffer) {
     privileges = new HashSet<>();
-    SerializeUtils.deserialize(privileges, buffer);
+    SerializeUtils.deserializeIntSet(privileges, buffer);
     path = SerializeUtils.deserializeString(buffer);
   }
 }
diff --git a/server/src/main/java/org/apache/iotdb/db/utils/SerializeUtils.java b/server/src/main/java/org/apache/iotdb/db/utils/SerializeUtils.java
index 3c9bd9f..814bcf1 100644
--- a/server/src/main/java/org/apache/iotdb/db/utils/SerializeUtils.java
+++ b/server/src/main/java/org/apache/iotdb/db/utils/SerializeUtils.java
@@ -82,7 +82,7 @@ public class SerializeUtils {
     return result;
   }
 
-  public static void serialize(List<Integer> ints, DataOutputStream dataOutputStream) {
+  public static void serializeIntList(List<Integer> ints, DataOutputStream dataOutputStream) {
     try {
       dataOutputStream.writeInt(ints.size());
       for (Integer anInt : ints) {
@@ -93,14 +93,14 @@ public class SerializeUtils {
     }
   }
 
-  public static void deserialize(List<Integer> ints, ByteBuffer buffer) {
+  public static void deserializeIntList(List<Integer> ints, ByteBuffer buffer) {
     int length = buffer.getInt();
     for (int i = 0; i < length; i++) {
       ints.add(buffer.getInt());
     }
   }
 
-  public static void serialize(Set<Integer> ints, DataOutputStream dataOutputStream) {
+  public static void serializeIntSet(Set<Integer> ints, DataOutputStream dataOutputStream) {
     try {
       dataOutputStream.writeInt(ints.size());
       for (Integer anInt : ints) {
@@ -111,7 +111,7 @@ public class SerializeUtils {
     }
   }
 
-  public static void deserialize(Set<Integer> ints, ByteBuffer buffer) {
+  public static void deserializeIntSet(Set<Integer> ints, ByteBuffer buffer) {
     int length = buffer.getInt();
     for (int i = 0; i < length; i++) {
       ints.add(buffer.getInt());
@@ -321,6 +321,8 @@ public class SerializeUtils {
   public static void serializeTVPairs(List<TimeValuePair> timeValuePairs,
       DataOutputStream dataOutputStream) {
     try {
+      TSDataType dataType = timeValuePairs.get(0).getValue().getDataType();
+      dataOutputStream.write(dataType.ordinal());
       dataOutputStream.writeInt(timeValuePairs.size());
       switch (timeValuePairs.get(0).getValue().getDataType()) {
         case TEXT:
@@ -461,7 +463,7 @@ public class SerializeUtils {
         int bytesLen = buffer.getInt();
         byte[] bytes = new byte[bytesLen];
         buffer.get(bytes);
-        TsPrimitiveType primitiveType = TsPrimitiveType.getByType(dataType, bytes);
+        TsPrimitiveType primitiveType = TsPrimitiveType.getByType(dataType, new Binary(bytes));
         pair = new TimeValuePair(time, primitiveType);
       } else {
         pair = new TimeValuePair(time, null);
diff --git a/server/src/test/java/org/apache/iotdb/db/utils/CopyOnReadLinkedListTest.java b/server/src/test/java/org/apache/iotdb/db/utils/CopyOnReadLinkedListTest.java
new file mode 100644
index 0000000..214f59a
--- /dev/null
+++ b/server/src/test/java/org/apache/iotdb/db/utils/CopyOnReadLinkedListTest.java
@@ -0,0 +1,67 @@
+/*
+ * 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.db.utils;
+
+import java.util.Iterator;
+import java.util.List;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class CopyOnReadLinkedListTest {
+
+  @Test
+  public void modifyListTest() {
+    CopyOnReadLinkedList<String> slist = new CopyOnReadLinkedList<>();
+    String str1 = "aaa";
+    String str2 = "bbb";
+    slist.add(str1);
+    slist.add(str2);
+    Iterator<String> iterator = slist.iterator();
+    Assert.assertEquals(str1, iterator.next());
+    Assert.assertEquals(str2, iterator.next());
+
+    slist.reset();
+    if (slist.contains(str1)) {
+      slist.remove(str1);
+    }
+    Assert.assertEquals(1, slist.size());
+
+    str2 = "ddd";
+    // str2 in slist is not modified
+    iterator = slist.iterator();
+    Assert.assertNotEquals(str2, iterator.next());
+  }
+
+  @Test
+  public void cloneModifiedListTest() {
+    CopyOnReadLinkedList<String> slist = new CopyOnReadLinkedList<>();
+    String str1 = "aaa";
+    String str2 = "bbb";
+    slist.add(str1);
+    slist.add(str2);
+
+    str2 = "ddd";
+    // str2 in slist is not modified
+    List<String> clist = slist.cloneList();
+    Assert.assertEquals("aaa", clist.get(0));
+    Assert.assertEquals("bbb", clist.get(1));
+    Assert.assertFalse(clist.isEmpty());
+  }
+
+}
diff --git a/server/src/test/java/org/apache/iotdb/db/utils/EncodingInferenceUtilsTest.java b/server/src/test/java/org/apache/iotdb/db/utils/EncodingInferenceUtilsTest.java
new file mode 100644
index 0000000..210cd4b
--- /dev/null
+++ b/server/src/test/java/org/apache/iotdb/db/utils/EncodingInferenceUtilsTest.java
@@ -0,0 +1,45 @@
+/*
+ * 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.db.utils;
+
+import org.apache.iotdb.db.conf.IoTDBConfig;
+import org.apache.iotdb.db.conf.IoTDBDescriptor;
+import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class EncodingInferenceUtilsTest {
+  @Test
+  public void getDefaultEncodingTest() {
+    IoTDBConfig conf = IoTDBDescriptor.getInstance().getConfig();
+    Assert.assertEquals(conf.getDefaultBooleanEncoding(),
+        EncodingInferenceUtils.getDefaultEncoding(TSDataType.BOOLEAN));
+    Assert.assertEquals(conf.getDefaultInt32Encoding(),
+        EncodingInferenceUtils.getDefaultEncoding(TSDataType.INT32));
+    Assert.assertEquals(conf.getDefaultInt64Encoding(),
+        EncodingInferenceUtils.getDefaultEncoding(TSDataType.INT64));
+    Assert.assertEquals(conf.getDefaultFloatEncoding(),
+        EncodingInferenceUtils.getDefaultEncoding(TSDataType.FLOAT));
+    Assert.assertEquals(conf.getDefaultDoubleEncoding(),
+        EncodingInferenceUtils.getDefaultEncoding(TSDataType.DOUBLE));
+    Assert.assertEquals(conf.getDefaultTextEncoding(),
+        EncodingInferenceUtils.getDefaultEncoding(TSDataType.TEXT));
+
+  }
+}
diff --git a/server/src/test/java/org/apache/iotdb/db/utils/MemUtilsTest.java b/server/src/test/java/org/apache/iotdb/db/utils/MemUtilsTest.java
new file mode 100644
index 0000000..f5f83e7
--- /dev/null
+++ b/server/src/test/java/org/apache/iotdb/db/utils/MemUtilsTest.java
@@ -0,0 +1,114 @@
+/*
+ * 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.db.utils;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.iotdb.db.exception.metadata.IllegalPathException;
+import org.apache.iotdb.db.metadata.PartialPath;
+import org.apache.iotdb.db.qp.physical.crud.InsertTabletPlan;
+import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
+import org.apache.iotdb.tsfile.utils.Binary;
+import org.apache.iotdb.tsfile.write.record.TSRecord;
+import org.apache.iotdb.tsfile.write.record.datapoint.*;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class MemUtilsTest {
+
+  @Test
+  public void getRecordSizeTest() {
+    Assert.assertEquals(12, MemUtils.getRecordSize(TSDataType.INT32, 10, true));
+    Assert.assertEquals(16, MemUtils.getRecordSize(TSDataType.INT64, 10, true));
+    Assert.assertEquals(12, MemUtils.getRecordSize(TSDataType.FLOAT, 10.0, true));
+    Assert.assertEquals(16, MemUtils.getRecordSize(TSDataType.DOUBLE, 10.0, true));
+    Assert.assertEquals(8, MemUtils.getRecordSize(TSDataType.TEXT, "10", false));
+  }
+
+  @Test
+  public void getRecordSizeWithInsertPlanTest() throws IllegalPathException {
+    PartialPath device = new PartialPath("root.sg.d1");
+    String[] measurements = {"s1", "s2", "s3", "s4", "s5"};
+    List<Integer> dataTypes = new ArrayList<>();
+    int sizeSum = 0;
+    dataTypes.add(TSDataType.INT32.ordinal());
+    sizeSum += 8 + TSDataType.INT32.getDataTypeSize();
+    dataTypes.add(TSDataType.INT64.ordinal());
+    sizeSum += 8 + TSDataType.INT64.getDataTypeSize();
+    dataTypes.add(TSDataType.FLOAT.ordinal());
+    sizeSum += 8 + TSDataType.FLOAT.getDataTypeSize();
+    dataTypes.add(TSDataType.DOUBLE.ordinal());
+    sizeSum += 8 + TSDataType.DOUBLE.getDataTypeSize();
+    dataTypes.add(TSDataType.TEXT.ordinal());
+    sizeSum += TSDataType.TEXT.getDataTypeSize();
+    InsertTabletPlan insertPlan = new InsertTabletPlan(device, measurements, dataTypes);
+    Assert.assertEquals(sizeSum, MemUtils.getRecordSize(insertPlan, 0, 1, false));
+  }
+
+  /**
+   * This method tests MemUtils.getStringMem() and MemUtils.getDataPointMem()
+   */
+  @Test
+  public void getMemSizeTest() {
+    int totalSize = 0;
+    String device = "root.sg.d1";
+    TSRecord record = new TSRecord(0, device);
+
+    DataPoint point1 = new IntDataPoint("s1", 1);
+    Assert.assertEquals(MemUtils.getStringMem("s1") + 20, MemUtils.getDataPointMem(point1));
+    totalSize += MemUtils.getDataPointMem(point1);
+    record.addTuple(point1);
+
+    DataPoint point2 = new LongDataPoint("s2", 1);
+    Assert.assertEquals(MemUtils.getStringMem("s2") + 24, MemUtils.getDataPointMem(point2));
+    totalSize += MemUtils.getDataPointMem(point2);
+    record.addTuple(point2);
+
+    DataPoint point3 = new FloatDataPoint("s3", 1.0f);
+    Assert.assertEquals(MemUtils.getStringMem("s3") + 20, MemUtils.getDataPointMem(point3));
+    totalSize += MemUtils.getDataPointMem(point3);
+    record.addTuple(point3);
+
+    DataPoint point4 = new DoubleDataPoint("s4", 1.0d);
+    Assert.assertEquals(MemUtils.getStringMem("s4") + 24, MemUtils.getDataPointMem(point4));
+    totalSize += MemUtils.getDataPointMem(point4);
+    record.addTuple(point4);
+
+    DataPoint point5 = new BooleanDataPoint("s5", true);
+    Assert.assertEquals(MemUtils.getStringMem("s5") + 17, MemUtils.getDataPointMem(point5));
+    totalSize += MemUtils.getDataPointMem(point5);
+    record.addTuple(point5);
+
+    DataPoint point6 = new StringDataPoint("s5", Binary.valueOf("123"));
+    Assert.assertEquals(MemUtils.getStringMem("s6") + 129, MemUtils.getDataPointMem(point6));
+    totalSize += MemUtils.getDataPointMem(point6);
+    record.addTuple(point6);
+
+    totalSize += 8 * record.dataPointList.size() + MemUtils.getStringMem(device) + 16;
+
+    Assert.assertEquals(totalSize, MemUtils.getTsRecordMem(record));
+  }
+
+  @Test
+  public void bytesCntToStrTest() {
+    String r = "4 GB 877 MB 539 KB 903 B";
+    Assert.assertEquals(r, MemUtils.bytesCntToStr(5215121287L));
+  }
+
+}
diff --git a/server/src/test/java/org/apache/iotdb/db/utils/SchemaUtilsTest.java b/server/src/test/java/org/apache/iotdb/db/utils/SchemaUtilsTest.java
new file mode 100644
index 0000000..d25692b
--- /dev/null
+++ b/server/src/test/java/org/apache/iotdb/db/utils/SchemaUtilsTest.java
@@ -0,0 +1,64 @@
+/*
+ * 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.db.utils;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import org.apache.iotdb.db.exception.metadata.MetadataException;
+import org.apache.iotdb.db.metadata.MManager;
+import org.apache.iotdb.db.metadata.PartialPath;
+import org.apache.iotdb.db.qp.constant.SQLConstant;
+import org.apache.iotdb.db.service.IoTDB;
+import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
+import org.apache.iotdb.tsfile.write.schema.TimeseriesSchema;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class SchemaUtilsTest {
+  @Test
+  public void registerTimeseriesTest() throws MetadataException {
+    MManager mmanager = IoTDB.metaManager;
+    mmanager.init();
+
+    String tsPath = "root.sg.d1.s1";
+    TimeseriesSchema timeseriesSchema = new TimeseriesSchema(tsPath, TSDataType.INT32);
+    SchemaUtils.registerTimeseries(timeseriesSchema);
+    Assert.assertTrue(IoTDB.metaManager.isPathExist(new PartialPath(tsPath)));
+  }
+
+  @Test
+  public void getAggregatedDataTypesTest() throws MetadataException {
+    List<TSDataType> measurementTypes = new ArrayList<>();
+    measurementTypes.add(TSDataType.INT64);
+    measurementTypes.add(TSDataType.TEXT);
+    measurementTypes.add(TSDataType.BOOLEAN);
+    measurementTypes.add(TSDataType.DOUBLE);
+    Assert.assertEquals(Collections.nCopies(measurementTypes.size(), TSDataType.INT64),
+        SchemaUtils.getAggregatedDataTypes(measurementTypes, SQLConstant.MIN_TIME));
+    Assert.assertEquals(Collections.nCopies(measurementTypes.size(), TSDataType.INT64),
+        SchemaUtils.getAggregatedDataTypes(measurementTypes, SQLConstant.COUNT));
+    Assert.assertEquals(Collections.nCopies(measurementTypes.size(), TSDataType.DOUBLE),
+        SchemaUtils.getAggregatedDataTypes(measurementTypes, SQLConstant.SUM));
+    Assert.assertEquals(measurementTypes,
+        SchemaUtils.getAggregatedDataTypes(measurementTypes, SQLConstant.LAST_VALUE));
+    Assert.assertEquals(measurementTypes,
+        SchemaUtils.getAggregatedDataTypes(measurementTypes, SQLConstant.MAX_VALUE));
+  }
+}
diff --git a/server/src/test/java/org/apache/iotdb/db/utils/SerializeUtilsTest.java b/server/src/test/java/org/apache/iotdb/db/utils/SerializeUtilsTest.java
new file mode 100644
index 0000000..f38a845
--- /dev/null
+++ b/server/src/test/java/org/apache/iotdb/db/utils/SerializeUtilsTest.java
@@ -0,0 +1,312 @@
+/*
+ * 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.db.utils;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.DataOutputStream;
+import java.io.InputStream;
+import java.nio.ByteBuffer;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.Set;
+import java.util.TreeSet;
+import org.apache.iotdb.cluster.rpc.thrift.Node;
+import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
+import org.apache.iotdb.tsfile.read.TimeValuePair;
+import org.apache.iotdb.tsfile.read.common.BatchData;
+import org.apache.iotdb.tsfile.read.filter.TimeFilter;
+import org.apache.iotdb.tsfile.read.filter.basic.Filter;
+import org.apache.iotdb.tsfile.utils.Binary;
+import org.apache.iotdb.tsfile.utils.TsPrimitiveType;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class SerializeUtilsTest {
+  @Test
+  public void serdesStringTest() {
+    String str = "abcd%+/123\n\t";
+    ByteArrayOutputStream baos = new ByteArrayOutputStream();
+    DataOutputStream outputStream = new DataOutputStream(baos);
+    SerializeUtils.serialize(str, outputStream);
+    ByteBuffer buffer = ByteBuffer.wrap(baos.toByteArray());
+    Assert.assertEquals(str, SerializeUtils.deserializeString(buffer));
+  }
+
+  @Test
+  public void serdesStringListTest() {
+    List<String> slist = Arrays.asList("abc", "123", "y87@", "9+&d\n");
+    ByteArrayOutputStream baos = new ByteArrayOutputStream();
+    DataOutputStream outputStream = new DataOutputStream(baos);
+    SerializeUtils.serializeStringList(slist, outputStream);
+    ByteBuffer buffer = ByteBuffer.wrap(baos.toByteArray());
+    Assert.assertEquals(slist, SerializeUtils.deserializeStringList(buffer));
+  }
+
+  @Test
+  public void serdesIntListTest() {
+    List<Integer> intlist = Arrays.asList(12, 34, 567, 8910);
+    ByteArrayOutputStream baos = new ByteArrayOutputStream();
+    DataOutputStream outputStream = new DataOutputStream(baos);
+    SerializeUtils.serializeIntList(intlist, outputStream);
+    ByteBuffer buffer = ByteBuffer.wrap(baos.toByteArray());
+    List<Integer> anotherIntlist = new ArrayList<>();
+    SerializeUtils.deserializeIntList(anotherIntlist, buffer);
+    Assert.assertEquals(intlist, anotherIntlist);
+  }
+
+  @Test
+  public void serdesIntSetTest() {
+    List<Integer> intlist = Arrays.asList(12, 34, 567, 8910);
+    Set<Integer> intSet = new TreeSet<>(intlist);
+    ByteArrayOutputStream baos = new ByteArrayOutputStream();
+    DataOutputStream outputStream = new DataOutputStream(baos);
+    SerializeUtils.serializeIntSet(intSet, outputStream);
+    ByteBuffer buffer = ByteBuffer.wrap(baos.toByteArray());
+    Set<Integer> anotherIntlist = new TreeSet<>();
+    SerializeUtils.deserializeIntSet(anotherIntlist, buffer);
+    Assert.assertEquals(intSet, anotherIntlist);
+  }
+
+  @Test
+  public void serdesNodeTest() {
+    Node node = new Node("127.0.0.1", 6667, 1, 6535, 4678);
+    ByteArrayOutputStream baos = new ByteArrayOutputStream();
+    DataOutputStream outputStream = new DataOutputStream(baos);
+    SerializeUtils.serialize(node, outputStream);
+    ByteBuffer buffer = ByteBuffer.wrap(baos.toByteArray());
+    Node anotherNode = new Node("127.0.0.1", 6667, 1, 6535, 4678);
+    SerializeUtils.deserialize(anotherNode, buffer);
+    Assert.assertEquals(node, anotherNode);
+  }
+
+  @Test
+  public void serdesINT32BatchDataTest() {
+    BatchData batchData = new BatchData(TSDataType.INT32);
+    int ivalue = 0;
+    for (long time = 0; time < 10; time++) {
+      batchData.putAnObject(time, ivalue);
+      ivalue++;
+    }
+    ByteArrayOutputStream baos = new ByteArrayOutputStream();
+    DataOutputStream outputStream = new DataOutputStream(baos);
+    SerializeUtils.serializeBatchData(batchData, outputStream);
+    ByteBuffer buffer = ByteBuffer.wrap(baos.toByteArray());
+    BatchData anotherBatch = SerializeUtils.deserializeBatchData(buffer);
+    while (batchData.hasCurrent()) {
+      Assert.assertEquals(batchData.currentValue(), anotherBatch.currentValue());
+      batchData.next();
+      anotherBatch.next();
+    }
+  }
+
+  @Test
+  public void serdesINT64BatchDataTest() {
+    BatchData batchData = new BatchData(TSDataType.INT64);
+    long lvalue = 0;
+    for (long time = 0; time < 10; time++) {
+      batchData.putAnObject(time, lvalue);
+      lvalue++;
+    }
+    ByteArrayOutputStream baos = new ByteArrayOutputStream();
+    DataOutputStream outputStream = new DataOutputStream(baos);
+    SerializeUtils.serializeBatchData(batchData, outputStream);
+    ByteBuffer buffer = ByteBuffer.wrap(baos.toByteArray());
+    BatchData anotherBatch = SerializeUtils.deserializeBatchData(buffer);
+    while (batchData.hasCurrent()) {
+      Assert.assertEquals(batchData.currentValue(), anotherBatch.currentValue());
+      batchData.next();
+      anotherBatch.next();
+    }
+  }
+
+  @Test
+  public void serdesFLOATBatchDataTest() {
+    BatchData batchData = new BatchData(TSDataType.FLOAT);
+    float fvalue = 0f;
+    for (long time = 0; time < 10; time++) {
+      batchData.putAnObject(time, fvalue);
+      fvalue++;
+    }
+    ByteArrayOutputStream baos = new ByteArrayOutputStream();
+    DataOutputStream outputStream = new DataOutputStream(baos);
+    SerializeUtils.serializeBatchData(batchData, outputStream);
+    ByteBuffer buffer = ByteBuffer.wrap(baos.toByteArray());
+    BatchData anotherBatch = SerializeUtils.deserializeBatchData(buffer);
+    while (batchData.hasCurrent()) {
+      Assert.assertEquals(batchData.currentValue(), anotherBatch.currentValue());
+      batchData.next();
+      anotherBatch.next();
+    }
+  }
+
+  @Test
+  public void serdesDOUBLEBatchDataTest() {
+    BatchData batchData = new BatchData(TSDataType.DOUBLE);
+    double dvalue = 0d;
+    for (long time = 0; time < 10; time++) {
+      batchData.putAnObject(time, dvalue);
+      dvalue++;
+    }
+    ByteArrayOutputStream baos = new ByteArrayOutputStream();
+    DataOutputStream outputStream = new DataOutputStream(baos);
+    SerializeUtils.serializeBatchData(batchData, outputStream);
+    ByteBuffer buffer = ByteBuffer.wrap(baos.toByteArray());
+    BatchData anotherBatch = SerializeUtils.deserializeBatchData(buffer);
+    while (batchData.hasCurrent()) {
+      Assert.assertEquals(batchData.currentValue(), anotherBatch.currentValue());
+      batchData.next();
+      anotherBatch.next();
+    }
+  }
+
+  @Test
+  public void serdesBOOLEANBatchDataTest() {
+    BatchData batchData = new BatchData(TSDataType.BOOLEAN);
+    batchData.putAnObject(1, true);
+    batchData.putAnObject(2, false);
+    ByteArrayOutputStream baos = new ByteArrayOutputStream();
+    DataOutputStream outputStream = new DataOutputStream(baos);
+    SerializeUtils.serializeBatchData(batchData, outputStream);
+    ByteBuffer buffer = ByteBuffer.wrap(baos.toByteArray());
+    BatchData anotherBatch = SerializeUtils.deserializeBatchData(buffer);
+    while (batchData.hasCurrent()) {
+      Assert.assertEquals(batchData.currentValue(), anotherBatch.currentValue());
+      batchData.next();
+      anotherBatch.next();
+    }
+  }
+
+  @Test
+  public void serdesTEXTBatchDataTest() {
+    BatchData batchData = new BatchData(TSDataType.TEXT);
+    String svalue = "";
+    for (long time = 0; time < 10; time++) {
+      batchData.putAnObject(time, Binary.valueOf(svalue));
+      svalue += String.valueOf(time);
+    }
+    ByteArrayOutputStream baos = new ByteArrayOutputStream();
+    DataOutputStream outputStream = new DataOutputStream(baos);
+    SerializeUtils.serializeBatchData(batchData, outputStream);
+    ByteBuffer buffer = ByteBuffer.wrap(baos.toByteArray());
+    BatchData anotherBatch = SerializeUtils.deserializeBatchData(buffer);
+    while (batchData.hasCurrent()) {
+      Assert.assertEquals(batchData.currentValue(), anotherBatch.currentValue());
+      batchData.next();
+      anotherBatch.next();
+    }
+  }
+
+  /**
+   * This method tests SerializeUtils.serializeTVPair() and SerializeUtils.deserializeTVPair()
+   */
+  @Test
+  public void serdesTVPairTest() {
+    List<TimeValuePair> TVPairs = new ArrayList<>();
+    TimeValuePair p1 = new TimeValuePair(0, TsPrimitiveType.getByType(TSDataType.BOOLEAN, true));
+    TVPairs.add(p1);
+    TimeValuePair p2 = new TimeValuePair(0, TsPrimitiveType.getByType(TSDataType.INT32, 1));
+    TVPairs.add(p2);
+    TimeValuePair p3 = new TimeValuePair(0, TsPrimitiveType.getByType(TSDataType.INT64, 1L));
+    TVPairs.add(p3);
+    TimeValuePair p4 = new TimeValuePair(0, TsPrimitiveType.getByType(TSDataType.FLOAT, 1.0f));
+    TVPairs.add(p4);
+    TimeValuePair p5 = new TimeValuePair(0, TsPrimitiveType.getByType(TSDataType.DOUBLE, 1.0d));
+    TVPairs.add(p5);
+    TimeValuePair p6 = new TimeValuePair(0, TsPrimitiveType.getByType(TSDataType.TEXT, Binary.valueOf("a")));
+    TVPairs.add(p6);
+
+    ByteArrayOutputStream baos = new ByteArrayOutputStream();
+    DataOutputStream outputStream = new DataOutputStream(baos);
+    for (TimeValuePair tv : TVPairs) {
+      SerializeUtils.serializeTVPair(tv, outputStream);
+      ByteBuffer buffer = ByteBuffer.wrap(baos.toByteArray());
+      Assert.assertEquals(tv, SerializeUtils.deserializeTVPair(buffer));
+      baos.reset();
+    }
+
+  }
+
+  /**
+   * This method tests SerializeUtils.serializeTVPairs() and SerializeUtils.deserializeTVPairs()
+   */
+  @Test
+  public void serdesTVPairsTest() {
+    List<List<TimeValuePair>> TVPairs = new ArrayList<>();
+    TimeValuePair p1 = new TimeValuePair(0, TsPrimitiveType.getByType(TSDataType.BOOLEAN, true));
+    TVPairs.add(Collections.singletonList(p1));
+    TimeValuePair p2 = new TimeValuePair(0, TsPrimitiveType.getByType(TSDataType.INT32, 1));
+    TVPairs.add(Collections.singletonList(p2));
+    TimeValuePair p3 = new TimeValuePair(0, TsPrimitiveType.getByType(TSDataType.INT64, 1L));
+    TVPairs.add(Collections.singletonList(p3));
+    TimeValuePair p4 = new TimeValuePair(0, TsPrimitiveType.getByType(TSDataType.FLOAT, 1.0f));
+    TVPairs.add(Collections.singletonList(p4));
+    TimeValuePair p5 = new TimeValuePair(0, TsPrimitiveType.getByType(TSDataType.DOUBLE, 1.0d));
+    TVPairs.add(Collections.singletonList(p5));
+    TimeValuePair p6 = new TimeValuePair(0, TsPrimitiveType.getByType(TSDataType.TEXT, Binary.valueOf("a")));
+    TVPairs.add(Collections.singletonList(p6));
+
+    ByteArrayOutputStream baos = new ByteArrayOutputStream();
+    DataOutputStream outputStream = new DataOutputStream(baos);
+    for (List<TimeValuePair> tv : TVPairs) {
+      SerializeUtils.serializeTVPairs(tv, outputStream);
+      ByteBuffer buffer = ByteBuffer.wrap(baos.toByteArray());
+      Assert.assertEquals(tv, SerializeUtils.deserializeTVPairs(buffer));
+      baos.reset();
+    }
+  }
+
+  /**
+   * This method tests SerializeUtils.serializeObject() and SerializeUtils.deserializeObject()
+   */
+  @Test
+  public void serdesObjectTest() {
+    ByteArrayOutputStream baos = new ByteArrayOutputStream();
+    DataOutputStream outputStream = new DataOutputStream(baos);
+    SerializeUtils.serializeObject(1, outputStream);
+    ByteBuffer buffer = ByteBuffer.wrap(baos.toByteArray());
+    Assert.assertEquals(1, SerializeUtils.deserializeObject(buffer));
+  }
+
+  /**
+   * This method tests SerializeUtils.serializeObjects() and SerializeUtils.deserializeObjects()
+   */
+  @Test
+  public void serdesObjectsTest() {
+    Object[] objects = { 1, "2", 3d};
+    ByteArrayOutputStream baos = new ByteArrayOutputStream();
+    DataOutputStream outputStream = new DataOutputStream(baos);
+    SerializeUtils.serializeObjects(objects, outputStream);
+    ByteBuffer buffer = ByteBuffer.wrap(baos.toByteArray());
+    Assert.assertArrayEquals(objects, SerializeUtils.deserializeObjects(buffer));
+  }
+
+  /**
+   * This method tests SerializeUtils.serializeLongs() and SerializeUtils.deserializeLongs()
+   */
+  @Test
+  public void serdesLongsTest() {
+    long[] array = {1, 10, 100, 1000, 10000};
+    ByteBuffer buffer = SerializeUtils.serializeLongs(array);
+    Assert.assertArrayEquals(array, SerializeUtils.deserializeLongs(buffer));
+  }
+
+}
diff --git a/server/src/test/java/org/apache/iotdb/db/utils/datastructure/BinaryTVListTest.java b/server/src/test/java/org/apache/iotdb/db/utils/datastructure/BinaryTVListTest.java
new file mode 100644
index 0000000..851cfab
--- /dev/null
+++ b/server/src/test/java/org/apache/iotdb/db/utils/datastructure/BinaryTVListTest.java
@@ -0,0 +1,58 @@
+/*
+ * 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.db.utils.datastructure;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.commons.lang.ArrayUtils;
+import org.apache.iotdb.tsfile.utils.Binary;
+import org.apache.iotdb.tsfile.utils.BytesUtils;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class BinaryTVListTest {
+
+  @Test
+  public void testBinaryTVList() {
+    BinaryTVList tvList = new BinaryTVList();
+    for (int i = 0; i < 1000; i++) {
+      tvList.putBinary(i, Binary.valueOf(String.valueOf(i)));
+    }
+    for (int i = 0; i < tvList.size; i++) {
+      Assert.assertEquals(String.valueOf(i), tvList.getBinary(i).toString());
+      Assert.assertEquals(i, tvList.getTime(i));
+    }
+  }
+
+  @Test
+  public void testBinaryTVLists() {
+    BinaryTVList tvList = new BinaryTVList();
+    Binary[] binaryList = new Binary[1001];
+    List<Long> timeList = new ArrayList<>();
+    for (int i = 1000; i >= 0; i--) {
+      timeList.add((long)i);
+      binaryList[i] = Binary.valueOf(String.valueOf(i));
+    }
+    tvList.putBinaries(ArrayUtils.toPrimitive(timeList.toArray(new Long[0])),
+        binaryList, 0, 1000);
+    for (long i = 0; i < tvList.size; i++) {
+      Assert.assertEquals(tvList.size - i, tvList.getTime((int)i));
+    }
+  }
+}
diff --git a/server/src/test/java/org/apache/iotdb/db/utils/datastructure/BooleanTVListTest.java b/server/src/test/java/org/apache/iotdb/db/utils/datastructure/BooleanTVListTest.java
new file mode 100644
index 0000000..8428521
--- /dev/null
+++ b/server/src/test/java/org/apache/iotdb/db/utils/datastructure/BooleanTVListTest.java
@@ -0,0 +1,62 @@
+/*
+ * 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.db.utils.datastructure;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.commons.lang.ArrayUtils;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class BooleanTVListTest {
+  @Test
+  public void testBooleanTVList() {
+    BooleanTVList tvList = new BooleanTVList();
+    for (int i = 0; i < 50; i++) {
+      tvList.putBoolean(i, true);
+    }
+    for (int i = 50; i < 100; i++) {
+      tvList.putBoolean(i, false);
+    }
+    for (int i = 0; i < tvList.size / 2; i++) {
+      Assert.assertTrue(tvList.getBoolean(i));
+      Assert.assertEquals(i, tvList.getTime(i));
+    }
+    for (int i = tvList.size / 2 + 1; i < tvList.size; i++) {
+      Assert.assertFalse(tvList.getBoolean(i));
+      Assert.assertEquals(i, tvList.getTime(i));
+    }
+  }
+
+  @Test
+  public void testBooleanTVLists() {
+    BooleanTVList tvList = new BooleanTVList();
+    List<Boolean> booleanList = new ArrayList<>();
+    List<Long> timeList = new ArrayList<>();
+    for (long i = 1000; i >= 0; i--) {
+      timeList.add(i);
+      booleanList.add(i % 2 == 0);
+    }
+    tvList.putBooleans(ArrayUtils.toPrimitive(timeList.toArray(new Long[0])),
+        ArrayUtils.toPrimitive(booleanList.toArray(new Boolean[0])), 0, 1000);
+    for (long i = 0; i < tvList.size; i++) {
+      Assert.assertEquals(tvList.size - i, tvList.getTime((int)i));
+    }
+  }
+}
diff --git a/server/src/test/java/org/apache/iotdb/db/utils/datastructure/DoubleTVListTest.java b/server/src/test/java/org/apache/iotdb/db/utils/datastructure/DoubleTVListTest.java
new file mode 100644
index 0000000..78d9a9c
--- /dev/null
+++ b/server/src/test/java/org/apache/iotdb/db/utils/datastructure/DoubleTVListTest.java
@@ -0,0 +1,72 @@
+/*
+ * 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.db.utils.datastructure;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.commons.lang.ArrayUtils;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class DoubleTVListTest {
+  public static double delta = 0.001d;
+
+  @Test
+  public void testDoubleTVList1() {
+    DoubleTVList tvList = new DoubleTVList();
+    for (int i = 0; i < 1000; i++) {
+      tvList.putDouble(i, i);
+    }
+    tvList.sort();
+    for (int i = 0; i < tvList.size; i++) {
+      Assert.assertEquals(i, tvList.getDouble(i), delta);
+      Assert.assertEquals(i, tvList.getTime(i));
+    }
+  }
+
+  @Test
+  public void testDoubleTVList2() {
+    DoubleTVList tvList = new DoubleTVList();
+    for (int i = 1000; i >= 0; i--) {
+      tvList.putDouble(i, i);
+    }
+    tvList.sort();
+    for (int i = 0; i < tvList.size; i++) {
+      Assert.assertEquals(i, tvList.getDouble(i), delta);
+      Assert.assertEquals(i, tvList.getTime(i));
+    }
+  }
+
+  @Test
+  public void testDoubleTVLists() {
+    DoubleTVList tvList = new DoubleTVList();
+    List<Double> doubleList = new ArrayList<>();
+    List<Long> timeList = new ArrayList<>();
+    for (long i = 1000; i >= 0; i--) {
+      timeList.add(i);
+      doubleList.add((double) i);
+    }
+    tvList.putDoubles(ArrayUtils.toPrimitive(timeList.toArray(new Long[0])),
+        ArrayUtils.toPrimitive(doubleList.toArray(new Double[0]), 0.0d), 0, 1000);
+    for (long i = 0; i < tvList.size; i++) {
+      Assert.assertEquals((double) tvList.size - i, tvList.getDouble((int)i), delta);
+      Assert.assertEquals(tvList.size - i, tvList.getTime((int)i));
+    }
+  }
+}
diff --git a/server/src/test/java/org/apache/iotdb/db/utils/datastructure/FloatTVListTest.java b/server/src/test/java/org/apache/iotdb/db/utils/datastructure/FloatTVListTest.java
new file mode 100644
index 0000000..3d5af1d
--- /dev/null
+++ b/server/src/test/java/org/apache/iotdb/db/utils/datastructure/FloatTVListTest.java
@@ -0,0 +1,72 @@
+/*
+ * 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.db.utils.datastructure;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.commons.lang.ArrayUtils;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class FloatTVListTest {
+  public static float delta = 0.001f;
+
+  @Test
+  public void testFloatTVList1() {
+    FloatTVList tvList = new FloatTVList();
+    for (int i = 0; i < 1000; i++) {
+      tvList.putFloat(i, (float) i);
+    }
+    tvList.sort();
+    for (int i = 0; i < tvList.size; i++) {
+      Assert.assertEquals((float) i, tvList.getFloat(i), delta);
+      Assert.assertEquals(i, tvList.getTime(i));
+    }
+  }
+
+  @Test
+  public void testFloatTVList2() {
+    FloatTVList tvList = new FloatTVList();
+    for (int i = 1000; i >= 0; i--) {
+      tvList.putFloat(i, (float) i);
+    }
+    tvList.sort();
+    for (int i = 0; i < tvList.size; i++) {
+      Assert.assertEquals((float) i, tvList.getFloat(i), delta);
+      Assert.assertEquals(i, tvList.getTime(i));
+    }
+  }
+
+  @Test
+  public void testFloatTVLists() {
+    FloatTVList tvList = new FloatTVList();
+    List<Float> floatList = new ArrayList<>();
+    List<Long> timeList = new ArrayList<>();
+    for (long i = 1000; i >= 0; i--) {
+      timeList.add(i);
+      floatList.add((float) i);
+    }
+    tvList.putFloats(ArrayUtils.toPrimitive(timeList.toArray(new Long[0])),
+        ArrayUtils.toPrimitive(floatList.toArray(new Float[0]), 0.0F), 0, 1000);
+    for (long i = 0; i < tvList.size; i++) {
+      Assert.assertEquals((float) tvList.size - i, tvList.getFloat((int)i), delta);
+      Assert.assertEquals(tvList.size - i, tvList.getTime((int)i));
+    }
+  }
+}
diff --git a/server/src/test/java/org/apache/iotdb/db/utils/datastructure/IntTVListTest.java b/server/src/test/java/org/apache/iotdb/db/utils/datastructure/IntTVListTest.java
new file mode 100644
index 0000000..a76333c
--- /dev/null
+++ b/server/src/test/java/org/apache/iotdb/db/utils/datastructure/IntTVListTest.java
@@ -0,0 +1,71 @@
+/*
+ * 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.db.utils.datastructure;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.commons.lang.ArrayUtils;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class IntTVListTest {
+
+  @Test
+  public void testIntTVList1() {
+    IntTVList tvList = new IntTVList();
+    for (int i = 0; i < 1000; i++) {
+      tvList.putInt(i, i);
+    }
+    tvList.sort();
+    for (int i = 0; i < tvList.size; i++) {
+      Assert.assertEquals(i, tvList.getInt(i));
+      Assert.assertEquals(i, tvList.getTime(i));
+    }
+  }
+
+  @Test
+  public void testIntTVList2() {
+    IntTVList tvList = new IntTVList();
+    for (int i = 1000; i >= 0; i--) {
+      tvList.putInt(i, i);
+    }
+    tvList.sort();
+    for (int i = 0; i < tvList.size; i++) {
+      Assert.assertEquals(i, tvList.getInt(i));
+      Assert.assertEquals(i, tvList.getTime(i));
+    }
+  }
+
+  @Test
+  public void testIntTVLists() {
+    IntTVList tvList = new IntTVList();
+    List<Integer> intList = new ArrayList<>();
+    List<Long> timeList = new ArrayList<>();
+    for (int i = 1000; i >= 0; i--) {
+      timeList.add((long)i);
+      intList.add(i);
+    }
+    tvList.putInts(ArrayUtils.toPrimitive(timeList.toArray(new Long[0])),
+        ArrayUtils.toPrimitive(intList.toArray(new Integer[0])), 0, 1000);
+    for (long i = 0; i < tvList.size; i++) {
+      Assert.assertEquals(tvList.size - i, tvList.getInt((int)i));
+      Assert.assertEquals(tvList.size - i, tvList.getTime((int)i));
+    }
+  }
+}
diff --git a/server/src/test/java/org/apache/iotdb/db/utils/datastructure/LongTVListTest.java b/server/src/test/java/org/apache/iotdb/db/utils/datastructure/LongTVListTest.java
index 8be3429..99beace 100644
--- a/server/src/test/java/org/apache/iotdb/db/utils/datastructure/LongTVListTest.java
+++ b/server/src/test/java/org/apache/iotdb/db/utils/datastructure/LongTVListTest.java
@@ -22,6 +22,7 @@ import java.util.ArrayList;
 import java.util.List;
 import java.util.Random;
 
+import org.apache.commons.lang.ArrayUtils;
 import org.apache.iotdb.tsfile.read.TimeValuePair;
 import org.apache.iotdb.tsfile.utils.TsPrimitiveType.TsLong;
 import org.junit.Assert;
@@ -74,4 +75,21 @@ public class LongTVListTest {
       Assert.assertEquals(inputs.get((int)i).getValue().getLong(), tvList.getLong((int)i));
     }
   }
+
+  @Test
+  public void testLongTVLists() {
+    LongTVList tvList = new LongTVList();
+    List<Long> longList = new ArrayList<>();
+    List<Long> timeList = new ArrayList<>();
+    for (long i = 1000; i >= 0; i--) {
+      timeList.add(i);
+      longList.add(i);
+    }
+    tvList.putLongs(ArrayUtils.toPrimitive(timeList.toArray(new Long[0])),
+        ArrayUtils.toPrimitive(longList.toArray(new Long[0])), 0, 1000);
+    for (long i = 0; i < tvList.size; i++) {
+      Assert.assertEquals(tvList.size - i, tvList.getLong((int)i));
+      Assert.assertEquals(tvList.size - i, tvList.getTime((int)i));
+    }
+  }
 }
\ No newline at end of file