You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@iotdb.apache.org by GitBox <gi...@apache.org> on 2019/11/29 12:21:28 UTC

[GitHub] [incubator-iotdb] jixuan1989 commented on a change in pull request #587: [IOTDB-325] Refactor Statistics

jixuan1989 commented on a change in pull request #587: [IOTDB-325] Refactor Statistics
URL: https://github.com/apache/incubator-iotdb/pull/587#discussion_r352033615
 
 

 ##########
 File path: tsfile/src/main/java/org/apache/iotdb/tsfile/file/metadata/statistics/Statistics.java
 ##########
 @@ -152,433 +149,277 @@ public void mergeStatistics(Statistics<?> stats) {
       LOG.warn("tsfile-file parameter stats is null");
       return;
     }
-    if (this.getClass() == stats.getClass()) {
-      if (!stats.isEmpty) {
-        mergeStatisticsValue(stats);
-        isEmpty = false;
+    if (this.getClass() == stats.getClass() && !stats.isEmpty) {
+      if (stats.startTime < this.startTime) {
+        this.startTime = stats.startTime;
+      }
+      if (stats.endTime > this.endTime) {
+        this.endTime = stats.endTime;
       }
+      // must be sure no overlap between two statistics
+      this.count += stats.count;
+      mergeStatisticsValue(stats);
+      isEmpty = false;
     } else {
       String thisClass = this.getClass().toString();
       String statsClass = stats.getClass().toString();
-      LOG.warn("tsfile-file Statistics classes mismatched,no merge: {} v.s. {}",
+      LOG.warn("Statistics classes mismatched,no merge: {} v.s. {}",
           thisClass, statsClass);
 
       throw new StatisticsClassException(this.getClass(), stats.getClass());
     }
   }
 
-  protected abstract void mergeStatisticsValue(Statistics<?> stats);
+  public void update(long time, boolean value) {
+    if (time < this.startTime) {
+      startTime = time;
+    }
+    if (time > this.endTime) {
+      endTime = time;
+    }
+    count++;
+    updateStats(value);
+  }
 
-  public boolean isEmpty() {
-    return isEmpty;
+  public void update(long time, int value) {
+    if (time < this.startTime) {
+      startTime = time;
+    }
+    if (time > this.endTime) {
+      endTime = time;
+    }
+    count++;
+    updateStats(value);
   }
 
-  public void setEmpty(boolean empty) {
-    isEmpty = empty;
+  public void update(long time, long value) {
+    if (time < this.startTime) {
+      startTime = time;
+    }
+    if (time > this.endTime) {
+      endTime = time;
+    }
+    count++;
+    updateStats(value);
   }
 
-  public void updateStats(boolean value) {
-    throw new UnsupportedOperationException();
+  public void update(long time, float value) {
+    if (time < this.startTime) {
+      startTime = time;
+    }
+    if (time > this.endTime) {
+      endTime = time;
+    }
+    count++;
+    updateStats(value);
   }
 
-  public void updateStats(int value) {
-    throw new UnsupportedOperationException();
+  public void update(long time, double value) {
+    if (time < this.startTime) {
+      startTime = time;
+    } else if (time > this.endTime) {
+      endTime = time;
+    }
+    count++;
+    updateStats(value);
   }
 
-  public void updateStats(long value) {
-    throw new UnsupportedOperationException();
+  public void update(long time, Binary value) {
+    if (time < startTime) {
+      startTime = time;
+    } else if (time > endTime) {
+      endTime = time;
+    }
+    count++;
+    updateStats(value);
   }
 
-  /**
-   * This method with two parameters is only used by {@code unsequence} which
-   * updates/inserts/deletes timestamp.
-   *
-   * @param min min timestamp
-   * @param max max timestamp
-   */
-  public void updateStats(long min, long max) {
-    throw new UnsupportedOperationException();
+  public void update(long[] time, boolean[] values, int batchSize) {
+    if (time[0] < startTime) {
+      startTime = time[0];
+    }
+    if (time[batchSize-1] > this.endTime) {
+      endTime = time[batchSize-1];
+    }
+    count += batchSize;
+    updateStats(values, batchSize);
   }
 
-  public void updateStats(float value) {
-    throw new UnsupportedOperationException();
+  public void update(long[] time, int[] values, int batchSize) {
 
 Review comment:
   javadoc is needed: users must guarantee long[] time is a ordered array.
   

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services