You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ro...@apache.org on 2022/02/14 07:33:14 UTC
[iotdb] branch iotdb-2538 created (now a2200a0)
This is an automated email from the ASF dual-hosted git repository.
rong pushed a change to branch iotdb-2538
in repository https://gitbox.apache.org/repos/asf/iotdb.git.
at a2200a0 add windowStartTime() and windowEndTime()
This branch includes the following new commits:
new a2200a0 add windowStartTime() and windowEndTime()
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 windowStartTime() and windowEndTime()
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rong pushed a commit to branch iotdb-2538
in repository https://gitbox.apache.org/repos/asf/iotdb.git
commit a2200a02bc5162cdfb8e9b7d198970a0e7c7eb63
Author: Steve Yurong Su <ro...@apache.org>
AuthorDate: Mon Feb 14 15:30:59 2022 +0800
add windowStartTime() and windowEndTime()
---
.../iotdb/db/query/udf/api/access/RowWindow.java | 38 ++++++++++++++++++++++
...izableRowRecordListBackedMultiColumnWindow.java | 18 +++++++++-
...SerializableTVListBackedSingleColumnWindow.java | 18 +++++++++-
.../layer/MultiInputColumnIntermediateLayer.java | 14 ++++++--
...InputColumnMultiReferenceIntermediateLayer.java | 11 +++++--
...nputColumnSingleReferenceIntermediateLayer.java | 11 +++++--
6 files changed, 99 insertions(+), 11 deletions(-)
diff --git a/server/src/main/java/org/apache/iotdb/db/query/udf/api/access/RowWindow.java b/server/src/main/java/org/apache/iotdb/db/query/udf/api/access/RowWindow.java
index fbba005..10bcbc7 100644
--- a/server/src/main/java/org/apache/iotdb/db/query/udf/api/access/RowWindow.java
+++ b/server/src/main/java/org/apache/iotdb/db/query/udf/api/access/RowWindow.java
@@ -19,6 +19,8 @@
package org.apache.iotdb.db.query.udf.api.access;
+import org.apache.iotdb.db.query.udf.api.customizer.strategy.SlidingSizeWindowAccessStrategy;
+import org.apache.iotdb.db.query.udf.api.customizer.strategy.SlidingTimeWindowAccessStrategy;
import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
import java.io.IOException;
@@ -59,4 +61,40 @@ public interface RowWindow {
* @return an iterator used to access this window
*/
RowIterator getRowIterator();
+
+ /**
+ * For different types of windows, the definition of the window start time is different.
+ *
+ * <p>For sliding size window: the window start time is equal to the timestamp of the first row.
+ *
+ * <p>For sliding time window: The window start time is determined by displayWindowBegin {@link
+ * SlidingTimeWindowAccessStrategy#getDisplayWindowBegin()} and slidingStep {@link
+ * SlidingTimeWindowAccessStrategy#getSlidingStep()}. <br>
+ * The window start time for the i-th window (i starts at 0) can be calculated as {@code
+ * displayWindowBegin + i * slidingStep}.
+ *
+ * @see SlidingSizeWindowAccessStrategy
+ * @see SlidingTimeWindowAccessStrategy
+ * @return the start time of the window
+ */
+ long windowStartTime();
+
+ /**
+ * For different types of windows, the definition of the window end time is different.
+ *
+ * <p>For sliding size window: the window end time is equal to the timestamp of the last row.
+ *
+ * <p>For sliding time window: The window end time is determined by displayWindowBegin {@link
+ * SlidingTimeWindowAccessStrategy#getDisplayWindowBegin()}, timeInterval {@link
+ * SlidingTimeWindowAccessStrategy#getTimeInterval()} and slidingStep {@link
+ * SlidingTimeWindowAccessStrategy#getSlidingStep()}. <br>
+ * The window end time for the i-th window (i starts at 0) can be calculated as {@code
+ * displayWindowBegin + timeInterval + i * slidingStep - 1} or {@code windowStartTime() +
+ * timeInterval - 1}.
+ *
+ * @see SlidingSizeWindowAccessStrategy
+ * @see SlidingTimeWindowAccessStrategy
+ * @return the end time of the window
+ */
+ long windowEndTime();
}
diff --git a/server/src/main/java/org/apache/iotdb/db/query/udf/core/access/ElasticSerializableRowRecordListBackedMultiColumnWindow.java b/server/src/main/java/org/apache/iotdb/db/query/udf/core/access/ElasticSerializableRowRecordListBackedMultiColumnWindow.java
index 486120a..d384267 100644
--- a/server/src/main/java/org/apache/iotdb/db/query/udf/core/access/ElasticSerializableRowRecordListBackedMultiColumnWindow.java
+++ b/server/src/main/java/org/apache/iotdb/db/query/udf/core/access/ElasticSerializableRowRecordListBackedMultiColumnWindow.java
@@ -36,6 +36,9 @@ public class ElasticSerializableRowRecordListBackedMultiColumnWindow implements
private int endIndex;
private int size;
+ private long startTime;
+ private long endTime;
+
private final ElasticSerializableRowRecordListBackedMultiColumnRow row;
private ElasticSerializableRowRecordListBackedMultiColumnWindowIterator rowIterator;
@@ -78,11 +81,24 @@ public class ElasticSerializableRowRecordListBackedMultiColumnWindow implements
return rowIterator;
}
- public void seek(int beginIndex, int endIndex) {
+ @Override
+ public long windowStartTime() {
+ return startTime;
+ }
+
+ @Override
+ public long windowEndTime() {
+ return endTime;
+ }
+
+ public void seek(int beginIndex, int endIndex, long startTime, long endTime) {
this.beginIndex = beginIndex;
this.endIndex = endIndex;
size = endIndex - beginIndex;
+ this.startTime = startTime;
+ this.endTime = endTime;
+
rowIterator = null;
}
}
diff --git a/server/src/main/java/org/apache/iotdb/db/query/udf/core/access/ElasticSerializableTVListBackedSingleColumnWindow.java b/server/src/main/java/org/apache/iotdb/db/query/udf/core/access/ElasticSerializableTVListBackedSingleColumnWindow.java
index 3296d5b..f8fcf92 100644
--- a/server/src/main/java/org/apache/iotdb/db/query/udf/core/access/ElasticSerializableTVListBackedSingleColumnWindow.java
+++ b/server/src/main/java/org/apache/iotdb/db/query/udf/core/access/ElasticSerializableTVListBackedSingleColumnWindow.java
@@ -32,6 +32,9 @@ public class ElasticSerializableTVListBackedSingleColumnWindow implements RowWin
private int endIndex;
private int size;
+ private long startTime;
+ private long endTime;
+
private final ElasticSerializableTVListBackedSingleColumnRow row;
private ElasticSerializableTVListBackedSingleColumnWindowIterator rowIterator;
@@ -72,11 +75,24 @@ public class ElasticSerializableTVListBackedSingleColumnWindow implements RowWin
return rowIterator;
}
- public void seek(int beginIndex, int endIndex) {
+ @Override
+ public long windowStartTime() {
+ return startTime;
+ }
+
+ @Override
+ public long windowEndTime() {
+ return endTime;
+ }
+
+ public void seek(int beginIndex, int endIndex, long startTime, long endTime) {
this.beginIndex = beginIndex;
this.endIndex = endIndex;
size = endIndex - beginIndex;
+ this.startTime = startTime;
+ this.endTime = endTime;
+
row.seek(beginIndex);
rowIterator = null;
}
diff --git a/server/src/main/java/org/apache/iotdb/db/query/udf/core/layer/MultiInputColumnIntermediateLayer.java b/server/src/main/java/org/apache/iotdb/db/query/udf/core/layer/MultiInputColumnIntermediateLayer.java
index f920424..8421ec7 100644
--- a/server/src/main/java/org/apache/iotdb/db/query/udf/core/layer/MultiInputColumnIntermediateLayer.java
+++ b/server/src/main/java/org/apache/iotdb/db/query/udf/core/layer/MultiInputColumnIntermediateLayer.java
@@ -234,9 +234,17 @@ public class MultiInputColumnIntermediateLayer extends IntermediateLayer
return false;
}
- window.seek(beginIndex, rowRecordList.size());
+ window.seek(
+ beginIndex,
+ rowRecordList.size(),
+ rowRecordList.getTime(beginIndex),
+ rowRecordList.getTime(rowRecordList.size() - 1));
} else {
- window.seek(beginIndex, endIndex);
+ window.seek(
+ beginIndex,
+ endIndex,
+ rowRecordList.getTime(beginIndex),
+ rowRecordList.getTime(endIndex - 1));
}
hasCached = true;
@@ -329,7 +337,7 @@ public class MultiInputColumnIntermediateLayer extends IntermediateLayer
break;
}
}
- window.seek(nextIndexBegin, nextIndexEnd);
+ window.seek(nextIndexBegin, nextIndexEnd, nextWindowTimeBegin, nextWindowTimeEnd - 1);
hasCached = nextIndexBegin != nextIndexEnd;
return hasCached;
diff --git a/server/src/main/java/org/apache/iotdb/db/query/udf/core/layer/SingleInputColumnMultiReferenceIntermediateLayer.java b/server/src/main/java/org/apache/iotdb/db/query/udf/core/layer/SingleInputColumnMultiReferenceIntermediateLayer.java
index 7c56de5..43404e5 100644
--- a/server/src/main/java/org/apache/iotdb/db/query/udf/core/layer/SingleInputColumnMultiReferenceIntermediateLayer.java
+++ b/server/src/main/java/org/apache/iotdb/db/query/udf/core/layer/SingleInputColumnMultiReferenceIntermediateLayer.java
@@ -229,9 +229,14 @@ public class SingleInputColumnMultiReferenceIntermediateLayer extends Intermedia
return false;
}
- window.seek(beginIndex, tvList.size());
+ window.seek(
+ beginIndex,
+ tvList.size(),
+ tvList.getTime(beginIndex),
+ tvList.getTime(tvList.size() - 1));
} else {
- window.seek(beginIndex, endIndex);
+ window.seek(
+ beginIndex, endIndex, tvList.getTime(beginIndex), tvList.getTime(endIndex - 1));
}
hasCached = true;
@@ -322,7 +327,7 @@ public class SingleInputColumnMultiReferenceIntermediateLayer extends Intermedia
break;
}
}
- window.seek(nextIndexBegin, nextIndexEnd);
+ window.seek(nextIndexBegin, nextIndexEnd, nextWindowTimeBegin, nextWindowTimeEnd - 1);
hasCached = nextIndexBegin != nextIndexEnd;
return hasCached;
diff --git a/server/src/main/java/org/apache/iotdb/db/query/udf/core/layer/SingleInputColumnSingleReferenceIntermediateLayer.java b/server/src/main/java/org/apache/iotdb/db/query/udf/core/layer/SingleInputColumnSingleReferenceIntermediateLayer.java
index c4ede3e..dc5c347 100644
--- a/server/src/main/java/org/apache/iotdb/db/query/udf/core/layer/SingleInputColumnSingleReferenceIntermediateLayer.java
+++ b/server/src/main/java/org/apache/iotdb/db/query/udf/core/layer/SingleInputColumnSingleReferenceIntermediateLayer.java
@@ -141,9 +141,14 @@ public class SingleInputColumnSingleReferenceIntermediateLayer extends Intermedi
return false;
}
- window.seek(beginIndex, tvList.size());
+ window.seek(
+ beginIndex,
+ tvList.size(),
+ tvList.getTime(beginIndex),
+ tvList.getTime(tvList.size() - 1));
} else {
- window.seek(beginIndex, endIndex);
+ window.seek(
+ beginIndex, endIndex, tvList.getTime(beginIndex), tvList.getTime(endIndex - 1));
}
hasCached = true;
@@ -235,7 +240,7 @@ public class SingleInputColumnSingleReferenceIntermediateLayer extends Intermedi
break;
}
}
- window.seek(nextIndexBegin, nextIndexEnd);
+ window.seek(nextIndexBegin, nextIndexEnd, nextWindowTimeBegin, nextWindowTimeEnd - 1);
hasCached = nextIndexBegin != nextIndexEnd;
return hasCached;