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/09/13 14:45:50 UTC

[iotdb] branch master updated: [IOTDB-1629] fix the NPE when using value fill in cluster mode (#3913)

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 177913d  [IOTDB-1629] fix the NPE when using value fill in cluster mode (#3913)
177913d is described below

commit 177913d2650c6f3ff95d6646d0cd4c72266c2943
Author: Zhong Wang <wa...@alibaba-inc.com>
AuthorDate: Mon Sep 13 22:45:25 2021 +0800

    [IOTDB-1629] fix the NPE when using value fill in cluster mode (#3913)
---
 .../cluster/query/fill/ClusterFillExecutor.java    |  4 +-
 .../query/{ => fill}/ClusterFillExecutorTest.java  | 47 +++++++++++++++++++++-
 2 files changed, 48 insertions(+), 3 deletions(-)

diff --git a/cluster/src/main/java/org/apache/iotdb/cluster/query/fill/ClusterFillExecutor.java b/cluster/src/main/java/org/apache/iotdb/cluster/query/fill/ClusterFillExecutor.java
index c02b0db..8315dd5 100644
--- a/cluster/src/main/java/org/apache/iotdb/cluster/query/fill/ClusterFillExecutor.java
+++ b/cluster/src/main/java/org/apache/iotdb/cluster/query/fill/ClusterFillExecutor.java
@@ -67,8 +67,10 @@ public class ClusterFillExecutor extends FillQueryExecutor {
       IFill clusterFill = new ClusterPreviousFill((PreviousFill) fill, metaGroupMember);
       clusterFill.configureFill(path, dataType, queryTime, deviceMeasurements, context);
       return clusterFill;
+    } else {
+      fill.configureFill(path, dataType, queryTime, deviceMeasurements, context);
+      return fill;
     }
-    return null;
   }
 
   @Override
diff --git a/cluster/src/test/java/org/apache/iotdb/cluster/query/ClusterFillExecutorTest.java b/cluster/src/test/java/org/apache/iotdb/cluster/query/fill/ClusterFillExecutorTest.java
similarity index 74%
rename from cluster/src/test/java/org/apache/iotdb/cluster/query/ClusterFillExecutorTest.java
rename to cluster/src/test/java/org/apache/iotdb/cluster/query/fill/ClusterFillExecutorTest.java
index 6e1aa82..430c456 100644
--- a/cluster/src/test/java/org/apache/iotdb/cluster/query/ClusterFillExecutorTest.java
+++ b/cluster/src/test/java/org/apache/iotdb/cluster/query/fill/ClusterFillExecutorTest.java
@@ -17,10 +17,11 @@
  * under the License.
  */
 
-package org.apache.iotdb.cluster.query;
+package org.apache.iotdb.cluster.query.fill;
 
 import org.apache.iotdb.cluster.common.TestUtils;
-import org.apache.iotdb.cluster.query.fill.ClusterFillExecutor;
+import org.apache.iotdb.cluster.query.BaseQueryTest;
+import org.apache.iotdb.cluster.query.RemoteQueryContext;
 import org.apache.iotdb.db.conf.IoTDBDescriptor;
 import org.apache.iotdb.db.exception.StorageEngineException;
 import org.apache.iotdb.db.exception.metadata.IllegalPathException;
@@ -32,6 +33,7 @@ import org.apache.iotdb.db.query.control.QueryResourceManager;
 import org.apache.iotdb.db.query.executor.fill.IFill;
 import org.apache.iotdb.db.query.executor.fill.LinearFill;
 import org.apache.iotdb.db.query.executor.fill.PreviousFill;
+import org.apache.iotdb.db.query.executor.fill.ValueFill;
 import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
 import org.apache.iotdb.tsfile.read.query.dataset.QueryDataSet;
 
@@ -127,4 +129,45 @@ public class ClusterFillExecutorTest extends BaseQueryTest {
       QueryResourceManager.getInstance().endQuery(context.getQueryId());
     }
   }
+
+  @Test
+  public void testValueFill()
+      throws QueryProcessException, StorageEngineException, IOException, IllegalPathException {
+    FillQueryPlan plan = new FillQueryPlan();
+    plan.setDeduplicatedPathsAndUpdate(
+        Collections.singletonList(new PartialPath(TestUtils.getTestSeries(0, 10))));
+    plan.setDeduplicatedDataTypes(Collections.singletonList(TSDataType.DOUBLE));
+    plan.setPaths(plan.getDeduplicatedPaths());
+    plan.setDataTypes(plan.getDeduplicatedDataTypes());
+    double fillValue = 1.0D;
+    Map<TSDataType, IFill> tsDataTypeIFillMap =
+        Collections.singletonMap(
+            TSDataType.DOUBLE, new ValueFill(Double.toString(fillValue), TSDataType.DOUBLE));
+    plan.setFillType(tsDataTypeIFillMap);
+    QueryContext context =
+        new RemoteQueryContext(QueryResourceManager.getInstance().assignQueryId(true));
+
+    try {
+      ClusterFillExecutor fillExecutor;
+      QueryDataSet queryDataSet;
+      long[] queryTimes = new long[] {-1, 0, 5, 10, 20};
+      Object[][] answers =
+          new Object[][] {
+            new Object[] {1.0D},
+            new Object[] {0.0D},
+            new Object[] {1.0D},
+            new Object[] {10.0D},
+            new Object[] {1.0D},
+          };
+      for (int i = 0; i < queryTimes.length; i++) {
+        plan.setQueryTime(queryTimes[i]);
+        fillExecutor = new ClusterFillExecutor(plan, testMetaMember);
+        queryDataSet = fillExecutor.execute(context);
+        checkDoubleDataset(queryDataSet, answers[i]);
+        assertFalse(queryDataSet.hasNext());
+      }
+    } finally {
+      QueryResourceManager.getInstance().endQuery(context.getQueryId());
+    }
+  }
 }