You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ja...@apache.org on 2020/08/24 10:42:29 UTC
[incubator-iotdb] branch OptimizeValueFilterQuery created (now
598af39)
This is an automated email from the ASF dual-hosted git repository.
jackietien pushed a change to branch OptimizeValueFilterQuery
in repository https://gitbox.apache.org/repos/asf/incubator-iotdb.git.
at 598af39 optimize the value filter query process
This branch includes the following new commits:
new b99cfee optimize the value filter query process
new 598af39 optimize the value filter query process
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
[incubator-iotdb] 01/02: optimize the value filter query process
Posted by ja...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
jackietien pushed a commit to branch OptimizeValueFilterQuery
in repository https://gitbox.apache.org/repos/asf/incubator-iotdb.git
commit b99cfee84008d0b010c0dcc85febb5c39977368c
Author: JackieTien97 <Ja...@foxmail.com>
AuthorDate: Mon Aug 24 18:41:27 2020 +0800
optimize the value filter query process
---
.../main/java/org/apache/iotdb/SessionExample.java | 4 +--
.../query/timegenerator/ServerTimeGenerator.java | 39 ++++++++++++++++++----
2 files changed, 34 insertions(+), 9 deletions(-)
diff --git a/example/session/src/main/java/org/apache/iotdb/SessionExample.java b/example/session/src/main/java/org/apache/iotdb/SessionExample.java
index 038b62a..51c03fe 100644
--- a/example/session/src/main/java/org/apache/iotdb/SessionExample.java
+++ b/example/session/src/main/java/org/apache/iotdb/SessionExample.java
@@ -60,8 +60,8 @@ public class SessionExample {
nonQuery();
query();
queryByIterator();
- deleteData();
- deleteTimeseries();
+// deleteData();
+// deleteTimeseries();
session.close();
}
diff --git a/server/src/main/java/org/apache/iotdb/db/query/timegenerator/ServerTimeGenerator.java b/server/src/main/java/org/apache/iotdb/db/query/timegenerator/ServerTimeGenerator.java
index ee1cf91..118716b 100644
--- a/server/src/main/java/org/apache/iotdb/db/query/timegenerator/ServerTimeGenerator.java
+++ b/server/src/main/java/org/apache/iotdb/db/query/timegenerator/ServerTimeGenerator.java
@@ -18,6 +18,7 @@
*/
package org.apache.iotdb.db.query.timegenerator;
+import java.io.IOException;
import org.apache.iotdb.db.engine.querycontext.QueryDataSource;
import org.apache.iotdb.db.exception.StorageEngineException;
import org.apache.iotdb.db.qp.physical.crud.RawDataQueryPlan;
@@ -30,11 +31,12 @@ import org.apache.iotdb.tsfile.read.common.Path;
import org.apache.iotdb.tsfile.read.expression.IExpression;
import org.apache.iotdb.tsfile.read.expression.impl.SingleSeriesExpression;
import org.apache.iotdb.tsfile.read.filter.basic.Filter;
+import org.apache.iotdb.tsfile.read.filter.basic.UnaryFilter;
+import org.apache.iotdb.tsfile.read.filter.factory.FilterType;
+import org.apache.iotdb.tsfile.read.filter.operator.AndFilter;
import org.apache.iotdb.tsfile.read.query.timegenerator.TimeGenerator;
import org.apache.iotdb.tsfile.read.reader.IBatchReader;
-import java.io.IOException;
-
/**
* A timestamp generator for query with filter. e.g. For query clause "select s1, s2 from root where
* s3 < 0 and time > 100", this class can iterate back to every timestamp of the query.
@@ -65,19 +67,42 @@ public class ServerTimeGenerator extends TimeGenerator {
@Override
protected IBatchReader generateNewBatchReader(SingleSeriesExpression expression)
throws IOException {
- Filter filter = expression.getFilter();
+ Filter valueFilter = expression.getFilter();
Path path = expression.getSeriesPath();
TSDataType dataType;
QueryDataSource queryDataSource;
try {
dataType = IoTDB.metaManager.getSeriesType(path.getFullPath());
- queryDataSource = QueryResourceManager.getInstance().getQueryDataSource(path, context, filter);
- // update filter by TTL
- filter = queryDataSource.updateFilterUsingTTL(filter);
+ queryDataSource = QueryResourceManager.getInstance().getQueryDataSource(path, context, valueFilter);
+ // update valueFilter by TTL
+ valueFilter = queryDataSource.updateFilterUsingTTL(valueFilter);
} catch (Exception e) {
throw new IOException(e);
}
- return new SeriesRawDataBatchReader(path, queryPlan.getAllMeasurementsInDevice(path.getDevice()), dataType, context, queryDataSource, null, filter, null);
+ // get the TimeFilter part in SingleSeriesExpression
+ Filter timeFilter = getTimeFilter(valueFilter);
+
+ return new SeriesRawDataBatchReader(path, queryPlan.getAllMeasurementsInDevice(path.getDevice()), dataType, context, queryDataSource, timeFilter, valueFilter, null);
+ }
+
+ /**
+ * extract time filter from a value filter
+ */
+ private Filter getTimeFilter(Filter filter) {
+ if (filter instanceof UnaryFilter && ((UnaryFilter) filter).getFilterType() == FilterType.TIME_FILTER) {
+ return filter;
+ }
+ if (filter instanceof AndFilter) {
+ Filter leftTimeFilter = getTimeFilter(((AndFilter) filter).getLeft());
+ Filter rightTimeFilter = getTimeFilter(((AndFilter) filter).getRight());
+ if (leftTimeFilter != null && rightTimeFilter != null) {
+ return filter;
+ } else if (leftTimeFilter != null) {
+ return leftTimeFilter;
+ } else
+ return rightTimeFilter;
+ }
+ return null;
}
}
[incubator-iotdb] 02/02: optimize the value filter query process
Posted by ja...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
jackietien pushed a commit to branch OptimizeValueFilterQuery
in repository https://gitbox.apache.org/repos/asf/incubator-iotdb.git
commit 598af392633a5b17eee7c429f08919912b3ed06a
Author: JackieTien97 <Ja...@foxmail.com>
AuthorDate: Mon Aug 24 18:42:05 2020 +0800
optimize the value filter query process
---
example/session/src/main/java/org/apache/iotdb/SessionExample.java | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/example/session/src/main/java/org/apache/iotdb/SessionExample.java b/example/session/src/main/java/org/apache/iotdb/SessionExample.java
index 51c03fe..038b62a 100644
--- a/example/session/src/main/java/org/apache/iotdb/SessionExample.java
+++ b/example/session/src/main/java/org/apache/iotdb/SessionExample.java
@@ -60,8 +60,8 @@ public class SessionExample {
nonQuery();
query();
queryByIterator();
-// deleteData();
-// deleteTimeseries();
+ deleteData();
+ deleteTimeseries();
session.close();
}