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/14 08:37:00 UTC

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

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

tanxinyu pushed a commit to branch rel/0.12
in repository https://gitbox.apache.org/repos/asf/iotdb.git


The following commit(s) were added to refs/heads/rel/0.12 by this push:
     new 4495ed3  [IOTDB-1629] fix the NPE when using value fill in cluster mode (#3913) (#3957)
4495ed3 is described below

commit 4495ed3bd81591ecdff56394478f6a3cc21ef3e8
Author: Zhong Wang <wa...@alibaba-inc.com>
AuthorDate: Tue Sep 14 16:35:57 2021 +0800

    [IOTDB-1629] fix the NPE when using value fill in cluster mode (#3913) (#3957)
---
 .../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 1dc1363..08cf2f2 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 5c8c176..35543f5 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.setDeduplicatedPaths(
+        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());
+    }
+  }
 }