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/03/01 11:47:45 UTC

[GitHub] little-emotion commented on a change in pull request #79: [IOTDB-6]Value filter query optimization

little-emotion commented on a change in pull request #79: [IOTDB-6]Value filter query optimization
URL: https://github.com/apache/incubator-iotdb/pull/79#discussion_r261574495
 
 

 ##########
 File path: iotdb/src/main/java/org/apache/iotdb/db/query/reader/sequence/SealedTsFilesReaderByTimestamp.java
 ##########
 @@ -0,0 +1,130 @@
+/**
+ * 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.sequence;
+
+import java.io.IOException;
+import java.util.List;
+import org.apache.iotdb.db.engine.filenode.IntervalFileNode;
+import org.apache.iotdb.db.engine.modification.Modification;
+import org.apache.iotdb.db.query.context.QueryContext;
+import org.apache.iotdb.db.query.control.FileReaderManager;
+import org.apache.iotdb.db.query.reader.merge.EngineReaderByTimeStamp;
+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.Path;
+import org.apache.iotdb.tsfile.read.controller.ChunkLoader;
+import org.apache.iotdb.tsfile.read.controller.ChunkLoaderImpl;
+import org.apache.iotdb.tsfile.read.controller.MetadataQuerierByFileImpl;
+import org.apache.iotdb.tsfile.read.reader.series.SeriesReaderByTimestamp;
+
+public class SealedTsFilesReaderByTimestamp implements EngineReaderByTimeStamp {
+
+  private Path seriesPath;
+  private List<IntervalFileNode> sealedTsFiles;
+  private int usedIntervalFileIndex;
+  private SeriesReaderByTimestamp seriesReader;
+  private QueryContext context;
+
+  /**
+   * init with seriesPath and sealedTsFiles.
+   */
+  public SealedTsFilesReaderByTimestamp(Path seriesPath, List<IntervalFileNode> sealedTsFiles,
+      QueryContext context) {
+    this.seriesPath = seriesPath;
+    this.sealedTsFiles = sealedTsFiles;
+    this.usedIntervalFileIndex = 0;
+    this.seriesReader = null;
+    this.context = context;
+  }
+
+  @Override
+  public Object getValueInTimestamp(long timestamp) throws IOException {
+    Object value = null;
+    if (seriesReader != null) {
+      value = seriesReader.getValueInTimestamp(timestamp);
+      if (value != null || seriesReader.hasNext()) {
+        return value;
+      }
+    }
+    constructReader(timestamp);
+    if (seriesReader != null) {
+      value = seriesReader.getValueInTimestamp(timestamp);
+      if (value != null || seriesReader.hasNext()) {
+        return value;
+      }
+    }
+
+    return value;
+  }
+
+  @Override
+  public boolean hasNext() throws IOException {
+    if (seriesReader != null && seriesReader.hasNext()) {
+      return true;
+    }
+    return usedIntervalFileIndex + 1 < sealedTsFiles.size();
 
 Review comment:
   hasNext() method is used to judge whether to skip this reader.  If there is no data in 5th file, it will not skip. But when you get a larger timestamp point next time, it finds no data in 5th file, then it will skip this reader.Although it works,  I have changed it to make the procedure more rigorous.
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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