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 2020/03/25 02:19:09 UTC

[GitHub] [incubator-iotdb] qiaojialin commented on a change in pull request #938: add system design eng

qiaojialin commented on a change in pull request #938: add system design eng
URL: https://github.com/apache/incubator-iotdb/pull/938#discussion_r397572109
 
 

 ##########
 File path: docs/Documentation/SystemDesign/5-DataQuery/6-LastQuery.md
 ##########
 @@ -0,0 +1,122 @@
+<!--
+
+    Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+    
+        http://www.apache.org/licenses/LICENSE-2.0
+    
+    Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+
+-->
+
+# Last query
+
+The main logic of Last query is in LastQueryExecutor
+
+* org.apache.iotdb.db.query.executor.LastQueryExecutor
+
+The Last query executes the `calculateLastPairForOneSeries` method for each specified time series.
+
+## Read MNode cache data
+
+We add a Last data cache to the MNode structure corresponding to the time series that needs to be queried.
+
+`calculateLastPairForOneSeries` method For the last query of a certain time series, first try to read the cached data in the MNode.
+
+```
+try {
+  node = MManager.getInstance().getDeviceNodeWithAutoCreateStorageGroup(seriesPath.toString());
+} catch (MetadataException e) {
+  throw new QueryProcessException(e);
+}
+if (((LeafMNode) node).getCachedLast() != null) {
+  return ((LeafMNode) node).getCachedLast();
+}
+```
+If it is found that the cache has not been written, execute the following standard query process to read the TsFile data.
+
+## Last standard query process
+
+Last standard query process needs to traverse all sequential files and out-of-order files to get query results, and finally write the query results back to the MNode cache.  In the algorithm, sequential files and out-of-order files are processed separately.
 
 Review comment:
   ```suggestion
   Last standard query process needs to traverse all sequential files and unsequential files to get query results, and finally write the query results back to the MNode cache.  In the algorithm, sequential files and out-of-order files are processed separately.
   ```

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