You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ta...@apache.org on 2021/07/29 08:34:23 UTC

[iotdb] branch master updated: Add a testcase of dataApplier about batch insert. (#3645)

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

tanxinyu 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 868821c  Add a testcase of dataApplier about batch insert. (#3645)
868821c is described below

commit 868821c84e789801642087960c038b8b7cb968a8
Author: MrQuansy <50...@users.noreply.github.com>
AuthorDate: Thu Jul 29 16:34:01 2021 +0800

    Add a testcase of dataApplier about batch insert. (#3645)
    
    * add testcase of data applier about batch insert
---
 .../cluster/log/applier/DataLogApplierTest.java    | 36 ++++++++++++++++++++++
 1 file changed, 36 insertions(+)

diff --git a/cluster/src/test/java/org/apache/iotdb/cluster/log/applier/DataLogApplierTest.java b/cluster/src/test/java/org/apache/iotdb/cluster/log/applier/DataLogApplierTest.java
index cd90c7b..b55bd9b 100644
--- a/cluster/src/test/java/org/apache/iotdb/cluster/log/applier/DataLogApplierTest.java
+++ b/cluster/src/test/java/org/apache/iotdb/cluster/log/applier/DataLogApplierTest.java
@@ -59,6 +59,7 @@ import org.apache.iotdb.db.metadata.PartialPath;
 import org.apache.iotdb.db.metadata.mnode.MeasurementMNode;
 import org.apache.iotdb.db.qp.physical.crud.DeletePlan;
 import org.apache.iotdb.db.qp.physical.crud.InsertRowPlan;
+import org.apache.iotdb.db.qp.physical.crud.InsertRowsPlan;
 import org.apache.iotdb.db.qp.physical.sys.ClearCachePlan;
 import org.apache.iotdb.db.qp.physical.sys.CreateMultiTimeSeriesPlan;
 import org.apache.iotdb.db.qp.physical.sys.FlushPlan;
@@ -305,6 +306,41 @@ public class DataLogApplierTest extends IoTDBTest {
   }
 
   @Test
+  public void testApplyBatchInsert()
+      throws MetadataException, QueryProcessException, StorageEngineException, IOException,
+          InterruptedException, QueryFilterOptimizationException {
+    InsertRowsPlan insertRowsPlan = new InsertRowsPlan();
+    PhysicalPlanLog log = new PhysicalPlanLog();
+    log.setPlan(insertRowsPlan);
+
+    for (int i = 1; i <= 4; i++) {
+      InsertRowPlan insertPlan = new InsertRowPlan();
+      insertPlan.setPrefixPath(new PartialPath(TestUtils.getTestSg(i)));
+      insertPlan.setTime(1);
+      insertPlan.setNeedInferType(true);
+      insertPlan.setMeasurements(new String[] {TestUtils.getTestMeasurement(0)});
+      insertPlan.setDataTypes(new TSDataType[insertPlan.getMeasurements().length]);
+      insertPlan.setValues(new Object[] {"1.0"});
+      insertPlan.setNeedInferType(true);
+      insertPlan.setMeasurementMNodes(
+          new MeasurementMNode[] {TestUtils.getTestMeasurementMNode(0)});
+      insertRowsPlan.addOneInsertRowPlan(insertPlan, i - 1);
+    }
+
+    applier.apply(log);
+
+    for (int i = 1; i <= 4; i++) {
+      QueryDataSet dataSet = query(Collections.singletonList(TestUtils.getTestSeries(i, 0)), null);
+      assertTrue(dataSet.hasNext());
+      RowRecord record = dataSet.next();
+      assertEquals(1, record.getTimestamp());
+      assertEquals(1, record.getFields().size());
+      assertEquals(1.0, record.getFields().get(0).getDoubleV(), 0.00001);
+      assertFalse(dataSet.hasNext());
+    }
+  }
+
+  @Test
   public void testApplyDeletion()
       throws QueryProcessException, MetadataException, QueryFilterOptimizationException,
           StorageEngineException, IOException, InterruptedException {