You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by xi...@apache.org on 2022/03/01 12:07:05 UTC

[iotdb] branch xingtanzjr/operator-design created (now ded718f)

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

xingtanzjr pushed a change to branch xingtanzjr/operator-design
in repository https://gitbox.apache.org/repos/asf/iotdb.git.


      at ded718f  add basic operators

This branch includes the following new commits:

     new ded718f  add basic operators

The 1 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.


[iotdb] 01/01: add basic operators

Posted by xi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

xingtanzjr pushed a commit to branch xingtanzjr/operator-design
in repository https://gitbox.apache.org/repos/asf/iotdb.git

commit ded718f31b6e541db6c2cd45efe2057b4bfaa9b5
Author: Jinrui.Zhang <xi...@gmail.com>
AuthorDate: Tue Mar 1 20:06:07 2022 +0800

    add basic operators
---
 .../query/distribution/common/SeriesBatchData.java | 14 +++++++
 .../query/distribution/common/TraversalOrder.java  |  9 +++++
 .../db/query/distribution/common/TreeNode.java     | 23 +++++++++++
 .../query/distribution/operator/ExecOperator.java  | 18 +++++++++
 .../distribution/operator/SeriesScanOperator.java  | 46 ++++++++++++++++++++++
 .../distribution/operator/TimeJoinOperator.java    | 23 +++++++++++
 6 files changed, 133 insertions(+)

diff --git a/server/src/main/java/org/apache/iotdb/db/query/distribution/common/SeriesBatchData.java b/server/src/main/java/org/apache/iotdb/db/query/distribution/common/SeriesBatchData.java
new file mode 100644
index 0000000..7a9ae65
--- /dev/null
+++ b/server/src/main/java/org/apache/iotdb/db/query/distribution/common/SeriesBatchData.java
@@ -0,0 +1,14 @@
+package org.apache.iotdb.db.query.distribution.common;
+
+import org.apache.iotdb.tsfile.read.common.BatchData;
+
+/**
+ * @author xingtanzjr
+ * TODO: currently we only use it to describe the result set of SeriesScanOperator
+ * The BatchData is suitable as the encapsulation of part of result set of SeriesScanOperator
+ * BatchData is the class defined and generally used in single-node IoTDB
+ * We leverage it as the `batch` here. We can consider a more general name or make some modifications for it.
+ */
+public class SeriesBatchData extends BatchData {
+
+}
diff --git a/server/src/main/java/org/apache/iotdb/db/query/distribution/common/TraversalOrder.java b/server/src/main/java/org/apache/iotdb/db/query/distribution/common/TraversalOrder.java
new file mode 100644
index 0000000..6b00372
--- /dev/null
+++ b/server/src/main/java/org/apache/iotdb/db/query/distribution/common/TraversalOrder.java
@@ -0,0 +1,9 @@
+package org.apache.iotdb.db.query.distribution.common;
+
+/**
+ * The traversal order for operators by timestamp
+ */
+public enum TraversalOrder {
+    ASC,
+    DESC
+}
diff --git a/server/src/main/java/org/apache/iotdb/db/query/distribution/common/TreeNode.java b/server/src/main/java/org/apache/iotdb/db/query/distribution/common/TreeNode.java
new file mode 100644
index 0000000..9cf2dd3
--- /dev/null
+++ b/server/src/main/java/org/apache/iotdb/db/query/distribution/common/TreeNode.java
@@ -0,0 +1,23 @@
+package org.apache.iotdb.db.query.distribution.common;
+
+import java.util.List;
+
+/**
+ * @author A simple class to describe the tree style structure of query executable operators
+ * @param <T>
+ */
+public class TreeNode<T extends TreeNode<T>> {
+    protected List<T> children;
+
+    public T getChild(int i) {
+        return hasChild(i) ? children.get(i) : null;
+    }
+
+    public boolean hasChild(int i) {
+        return children.size() > i;
+    }
+
+    public void addChild(T n) {
+        children.add(n);
+    }
+}
diff --git a/server/src/main/java/org/apache/iotdb/db/query/distribution/operator/ExecOperator.java b/server/src/main/java/org/apache/iotdb/db/query/distribution/operator/ExecOperator.java
new file mode 100644
index 0000000..b9a1691
--- /dev/null
+++ b/server/src/main/java/org/apache/iotdb/db/query/distribution/operator/ExecOperator.java
@@ -0,0 +1,18 @@
+package org.apache.iotdb.db.query.distribution.operator;
+
+import org.apache.iotdb.db.query.distribution.common.TreeNode;
+
+/**
+ * @author xingtanzjr
+ * The base class of query executable operators, which is used to compose logical query plan.
+ * TODO: consider how to restrict the children type for each type of ExecOperator
+ */
+public abstract class ExecOperator<T> extends TreeNode<ExecOperator<?>> {
+
+    // Judge whether current operator has more result
+    public abstract boolean hasNext();
+
+    // Get next result batch of this operator
+    // Return null if there is no more result to return
+    public abstract T getNextBatch();
+}
diff --git a/server/src/main/java/org/apache/iotdb/db/query/distribution/operator/SeriesScanOperator.java b/server/src/main/java/org/apache/iotdb/db/query/distribution/operator/SeriesScanOperator.java
new file mode 100644
index 0000000..ebbc03d
--- /dev/null
+++ b/server/src/main/java/org/apache/iotdb/db/query/distribution/operator/SeriesScanOperator.java
@@ -0,0 +1,46 @@
+package org.apache.iotdb.db.query.distribution.operator;
+
+import org.apache.iotdb.db.query.distribution.common.SeriesBatchData;
+import org.apache.iotdb.db.query.distribution.common.TraversalOrder;
+import org.apache.iotdb.tsfile.read.common.Path;
+import org.apache.iotdb.tsfile.read.filter.basic.Filter;
+
+/**
+ * SeriesScanOperator is responsible for read data and pre-aggregated statistic for a specific series.
+ * When reading data, the SeriesScanOperator can read the raw data batch by batch. And also, it can leverage
+ * the filter and other info to decrease the result set.
+ * Besides, the SeriesScanOperator can read the pre-aggregated statistic in TsFile. And return the statistic with
+ * a fix time range one by one. If the time range is narrower than the smallest pre-aggregated statistic or has overlap
+ * with pre-aggregated statistic, the SeriesScanOperator will read the raw data and calculate the aggregation result for
+ * specific time range.
+ *
+ * Children type: []
+ */
+public class SeriesScanOperator extends ExecOperator<SeriesBatchData> {
+
+    // The path of the target series which will be scanned.
+    private Path seriesPath;
+
+    // The order to traverse the series by timestamp.
+    // The default order is ASC, which means "order by timestamp asc"
+    private TraversalOrder scanOrder = TraversalOrder.ASC;
+
+    // Filter data in current series.
+    private Filter filter;
+
+    // Limit for result set. The default value is -1, which means no limit
+    private int limit = -1;
+
+    // offset for result set. The default value is 0
+    private int offset;
+
+    @Override
+    public boolean hasNext() {
+        return false;
+    }
+
+    @Override
+    public SeriesBatchData getNextBatch() {
+        return null;
+    }
+}
diff --git a/server/src/main/java/org/apache/iotdb/db/query/distribution/operator/TimeJoinOperator.java b/server/src/main/java/org/apache/iotdb/db/query/distribution/operator/TimeJoinOperator.java
new file mode 100644
index 0000000..8361276
--- /dev/null
+++ b/server/src/main/java/org/apache/iotdb/db/query/distribution/operator/TimeJoinOperator.java
@@ -0,0 +1,23 @@
+package org.apache.iotdb.db.query.distribution.operator;
+
+import org.apache.iotdb.tsfile.read.common.RowRecord;
+
+/**
+ * TimeJoinOperator is responsible for join two or more series.
+ * The join algorithm is like outer join by timestamp column.
+ * The output result of TimeJoinOperator is sorted by timestamp
+ *
+ * Children type: [SeriesScanOperator]
+ */
+public class TimeJoinOperator extends ExecOperator<RowRecord> {
+
+    @Override
+    public boolean hasNext() {
+        return false;
+    }
+
+    @Override
+    public RowRecord getNextBatch() {
+        return null;
+    }
+}