little-emotion commented on a change in pull request #241:  Refactor the reader 
package for readability
URL: https://github.com/apache/incubator-iotdb/pull/241#discussion_r303700567
 
 

 ##########
 File path: 
iotdb/src/main/java/org/apache/iotdb/db/query/reader/resourceRelated/UnseqResourceReaderByTimestamp.java
 ##########
 @@ -0,0 +1,94 @@
+/**
+ * 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.
+ */
+package org.apache.iotdb.db.query.reader.resourceRelated;
+
+import java.io.IOException;
+import java.util.List;
+import org.apache.iotdb.db.engine.modification.Modification;
+import org.apache.iotdb.db.engine.storagegroup.TsFileResource;
+import org.apache.iotdb.db.query.context.QueryContext;
+import org.apache.iotdb.db.query.control.FileReaderManager;
+import 
org.apache.iotdb.db.query.reader.chunkRelated.DiskChunkReaderByTimestamp;
+import org.apache.iotdb.db.query.reader.chunkRelated.MemChunkReaderByTimestamp;
+import 
org.apache.iotdb.db.query.reader.universal.PriorityMergeReaderByTimestamp;
+import org.apache.iotdb.db.utils.QueryUtils;
+import org.apache.iotdb.tsfile.file.metadata.ChunkMetaData;
+import org.apache.iotdb.tsfile.read.TsFileSequenceReader;
+import org.apache.iotdb.tsfile.read.common.Chunk;
+import org.apache.iotdb.tsfile.read.common.Path;
+import org.apache.iotdb.tsfile.read.controller.ChunkLoaderImpl;
+import org.apache.iotdb.tsfile.read.controller.MetadataQuerierByFileImpl;
+import org.apache.iotdb.tsfile.read.reader.chunk.ChunkReaderByTimestamp;
+
+/**
+ * To read a list of unsequence TsFiles by timestamp, this class extends {@link
+ * PriorityMergeReaderByTimestamp} to implement 
<code>IReaderByTimestamp</code> for the TsFiles.
+ * <p>
+ * Note that an unsequence TsFile can be either closed or unclosed. An 
unclosed unsequence TsFile
+ * consists of data on disk and data in memtables that will be flushed to this 
unclosed TsFile.
+ * <p>
+ * This class is used in {@link 
org.apache.iotdb.db.query.reader.seriesRelated.SeriesReaderByTimestamp}.
+ */
+public class UnseqResourceReaderByTimestamp extends 
PriorityMergeReaderByTimestamp {
+
+  public UnseqResourceReaderByTimestamp(Path seriesPath,
+      List<TsFileResource> unseqResources, QueryContext context) throws 
IOException {
+    int priorityValue = 1;
+
+    for (TsFileResource tsFileResource : unseqResources) {
+      TsFileSequenceReader tsFileReader = FileReaderManager.getInstance()
+          .get(tsFileResource.getFile().getPath(), tsFileResource.isClosed());
+
+      // prepare metaDataList
+      List<ChunkMetaData> metaDataList;
+      if (tsFileResource.isClosed()) {
+        MetadataQuerierByFileImpl metadataQuerier = new 
MetadataQuerierByFileImpl(tsFileReader);
+        metaDataList = metadataQuerier.getChunkMetaDataList(seriesPath);
 
 Review comment:
   filter with time range in tsFileResource

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

Reply via email to