JackieTien97 commented on a change in pull request #818: [IOTDB-482] Vectorized
TimeGenerator
URL: https://github.com/apache/incubator-iotdb/pull/818#discussion_r380155582
##########
File path:
tsfile/src/main/java/org/apache/iotdb/tsfile/read/query/timegenerator/node/AndNode.java
##########
@@ -41,46 +46,90 @@ public AndNode(Node leftChild, Node rightChild) {
}
@Override
- public boolean hasNext() throws IOException {
+ public boolean hasNextTimeColumn() throws IOException {
if (hasCachedValue) {
return true;
}
- if (leftChild.hasNext() && rightChild.hasNext()) {
- long leftValue = leftChild.next();
- long rightValue = rightChild.next();
- while (true) {
- if (leftValue == rightValue) {
- this.hasCachedValue = true;
- this.cachedValue = leftValue;
- return true;
- } else if (leftValue > rightValue) {
- if (rightChild.hasNext()) {
- rightValue = rightChild.next();
- } else {
- return false;
- }
- } else { // leftValue < rightValue
- if (leftChild.hasNext()) {
- leftValue = leftChild.next();
- } else {
- return false;
- }
+ cachedTimeColumn = new TimeColumn(1000);
+ //fill data
+ fillLeftData();
+ fillRightData();
+ /*
+ * [1,2,3,4,5] <- that was stopBatchTime mean
+ * [1,2,3,4,5,6]
+ */
+ long stopBatchTime = getStopBatchTime();
+
+ while (leftTimeColumn.hasMoreData() && rightTimeColumn.hasMoreData()) {
+ long leftValue = leftTimeColumn.currentTime();
+ long rightValue = rightTimeColumn.currentTime();
+
+ if (leftValue == rightValue) {
+ this.hasCachedValue = true;
+ this.cachedTimeColumn.add(leftValue);
+ leftTimeColumn.next();
+ rightTimeColumn.next();
+ } else if (leftValue > rightValue) {
+ rightTimeColumn.next();
+ } else { // leftValue < rightValue
+ leftTimeColumn.next();
+ }
+
+ if (leftValue == stopBatchTime || rightValue == stopBatchTime) {
+ if (hasCachedValue) {
+ break;
}
}
+ /*
+ * [1,2,3,4,5] <- reFill data and cal stopBatchTime
+ * [6,7,8,9,10,11]
+ */
+ fillLeftData();
+ fillRightData();
+ stopBatchTime = getStopBatchTime();
+ }
+ return hasCachedValue;
+ }
+
+ private long getStopBatchTime() {
+ long rMax = Long.MAX_VALUE;
+ long lMax = Long.MAX_VALUE;
+ if (leftTimeColumn.hasMoreData()) {
+ lMax = leftTimeColumn.getLastTime();
}
- return false;
+ if (rightTimeColumn.hasMoreData()) {
+ rMax = rightTimeColumn.getLastTime();
+ }
+ return rMax > lMax ? lMax : rMax;
Review comment:
Here can be replaced by Math.min(); It will be more readable
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services