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/07/05 01:36:32 UTC

[GitHub] [incubator-iotdb] jt2594838 commented on a change in pull request #217: New Storage Engine

jt2594838 commented on a change in pull request #217: New Storage Engine
URL: https://github.com/apache/incubator-iotdb/pull/217#discussion_r300518651
 
 

 ##########
 File path: iotdb/src/main/java/org/apache/iotdb/db/engine/memtable/AbstractMemTable.java
 ##########
 @@ -104,30 +137,49 @@ public boolean isEmpty() {
   @Override
   public ReadOnlyMemChunk query(String deviceId, String measurement, TSDataType dataType,
       Map<String, String> props) {
-    return new ReadOnlyMemChunk(dataType, getSeriesData(deviceId, measurement, dataType), props);
+    TimeValuePairSorter sorter;
+    if (!checkPath(deviceId, measurement)) {
+      return null;
+    } else {
+      long undeletedTime = findUndeletedTime(deviceId, measurement);
+      IWritableMemChunk memChunk = memTableMap.get(deviceId).get(measurement);
+      IWritableMemChunk chunkCopy = new WritableMemChunk(dataType, memChunk.getTVList().clone());
+      chunkCopy.setTimeOffset(undeletedTime);
+      sorter = chunkCopy;
+    }
+    return new ReadOnlyMemChunk(dataType, sorter, props);
   }
 
-  private TimeValuePairSorter getSeriesData(String deviceId, String measurement, TSDataType dataType) {
-    if (!checkPath(deviceId, measurement)) {
-      return new WritableMemChunk(dataType);
+
+  private long findUndeletedTime(String deviceId, String measurement) {
+    String path = deviceId + PATH_SEPARATOR + measurement;
+    long undeletedTime = Long.MIN_VALUE;
+    for (Modification modification : modifications) {
+      if (modification instanceof  Deletion) {
+        Deletion deletion = (Deletion) modification;
+        if (deletion.getPathString().equals(path) && deletion.getTimestamp() > undeletedTime) {
 
 Review comment:
   The full path is concatenated during construction, so this change does not make sense.

----------------------------------------------------------------
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