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/04 13:32:01 UTC

[GitHub] [incubator-iotdb] 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_r262057951
 
 

 ##########
 File path: iotdb/src/main/java/org/apache/iotdb/db/query/reader/unsequence/EngineChunkReaderByTimestamp.java
 ##########
 @@ -0,0 +1,84 @@
+/**
+ * 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.unsequence;
+
+import java.io.IOException;
+import org.apache.iotdb.db.query.reader.merge.EngineReaderByTimeStamp;
+import org.apache.iotdb.tsfile.read.TsFileSequenceReader;
+import org.apache.iotdb.tsfile.read.common.BatchData;
+import org.apache.iotdb.tsfile.read.reader.chunk.ChunkReaderByTimestamp;
+
+public class EngineChunkReaderByTimestamp implements EngineReaderByTimeStamp {
+
+  private ChunkReaderByTimestamp chunkReader;
+  private BatchData data;
+
+  /**
+   * Each EngineChunkReader has a corresponding UnClosedTsFileReader, when EngineChunkReader is
+   * closed, UnClosedTsFileReader also should be closed in meanwhile.
+   */
+  private TsFileSequenceReader unClosedTsFileReader;
+
+  public EngineChunkReaderByTimestamp(ChunkReaderByTimestamp chunkReader,
+      TsFileSequenceReader unClosedTsFileReader) {
+    this.chunkReader = chunkReader;
+    this.unClosedTsFileReader = unClosedTsFileReader;
+  }
+
+  /**
+   * get value with time equals timestamp. If there is no such point, return null.
+   */
+  @Override
+  public Object getValueInTimestamp(long timestamp) throws IOException {
+
+    while (data != null) {
+      Object value = data.getValueInTimestamp(timestamp);
+      if (value != null) {
+        return value;
+      }
+      if (data.hasNext()) {
+        return null;
+      } else {
+        chunkReader.setCurrentTimestamp(timestamp);
+        if (chunkReader.hasNextBatch()) {
+          data = chunkReader.nextBatch();
+        } else {
+          return null;
+        }
+      }
+    }
+
+    return null;
+  }
+
+  @Override
+  public boolean hasNext() throws IOException {
+    if (data != null & data.hasNext()) {
 
 Review comment:
   fixed

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