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/08/25 12:14:23 UTC

[GitHub] [incubator-iotdb] mychaow opened a new pull request #1652: add device time index interface

mychaow opened a new pull request #1652:
URL: https://github.com/apache/incubator-iotdb/pull/1652


   


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



[GitHub] [incubator-iotdb] Alima777 commented on pull request #1652: add device time index interface

Posted by GitBox <gi...@apache.org>.
Alima777 commented on pull request #1652:
URL: https://github.com/apache/incubator-iotdb/pull/1652#issuecomment-681822513


   Hi, could you add some description for this pr?


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



[GitHub] [incubator-iotdb] mychaow commented on a change in pull request #1652: [IOTDB-698] add device time index interface

Posted by GitBox <gi...@apache.org>.
mychaow commented on a change in pull request #1652:
URL: https://github.com/apache/incubator-iotdb/pull/1652#discussion_r489187411



##########
File path: server/src/main/java/org/apache/iotdb/db/timeIndex/TimeIndexer.java
##########
@@ -0,0 +1,121 @@
+/*
+ * 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.timeIndex;
+
+import org.apache.iotdb.db.engine.storagegroup.TsFileResource;
+import org.apache.iotdb.db.metadata.PartialPath;
+import org.apache.iotdb.tsfile.read.filter.basic.Filter;
+
+import java.util.List;
+import java.util.Map;
+
+public interface TimeIndexer {
+  /**
+   * init the Indexer when IoTDB start
+   * @return whether success
+   */
+  public boolean init();
+
+  /**
+   * may do some prepared work before operation
+   * @return whether success
+   */
+  public boolean begin();
+
+  /**
+   * may do some resource release after operation
+   * @return whether success
+   */
+  public boolean end();
+
+  /**
+   * add one index record for the path
+   * @param path
+   * @param startTime
+   * @param endTime
+   * @param tsFilePath
+   * @return
+   */
+  public boolean addIndexForPath(PartialPath path, long startTime, long endTime, String tsFilePath);

Review comment:
       not really sutiable, just add one index for the path, not the file.   We add index for a file by using `public boolean addIndexForPaths(Map<String, Integer> paths, long[] startTimes, long[] endTimes, String tsFilePath);`




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



[GitHub] [incubator-iotdb] mychaow commented on a change in pull request #1652: [IOTDB-698] add device time index interface

Posted by GitBox <gi...@apache.org>.
mychaow commented on a change in pull request #1652:
URL: https://github.com/apache/incubator-iotdb/pull/1652#discussion_r489173308



##########
File path: server/src/main/java/org/apache/iotdb/db/timeIndex/TimeIndex.java
##########
@@ -0,0 +1,63 @@
+/*
+ * 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.timeIndex;
+
+import org.apache.iotdb.db.metadata.PartialPath;
+
+/**
+ * Time Index, like deviceIndexer: [(deviceId, startTime, endTime, TsFilePath)] to accelerate query
+ */
+public class TimeIndex {

Review comment:
       not really suitable, it's a universal Index Entry, not only device




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



[GitHub] [incubator-iotdb] mychaow commented on a change in pull request #1652: add device time index interface

Posted by GitBox <gi...@apache.org>.
mychaow commented on a change in pull request #1652:
URL: https://github.com/apache/incubator-iotdb/pull/1652#discussion_r484756324



##########
File path: server/src/main/java/org/apache/iotdb/db/timeIndex/IndexerManager.java
##########
@@ -0,0 +1,144 @@
+/*
+ * 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.timeIndex;
+
+import org.apache.iotdb.db.conf.IoTDBDescriptor;
+import org.apache.iotdb.db.exception.metadata.IllegalPathException;
+import org.apache.iotdb.db.metadata.PartialPath;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.File;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.locks.ReentrantReadWriteLock;
+
+public class IndexerManager {
+  private String indexerFilePath;
+  private Map<PartialPath, DeviceTimeIndexer> seqIndexers;
+  private Map<PartialPath, DeviceTimeIndexer> unseqIndexers;
+  private ReentrantReadWriteLock lock;
+  private static final Logger logger = LoggerFactory.getLogger(IndexerManager.class);
+
+  private static class IndexerManagerHolder {
+
+    private IndexerManagerHolder() {
+      // allowed to do nothing
+    }
+
+    private static final IndexerManager INSTANCE = new IndexerManager();
+  }
+
+  public static IndexerManager getInstance() {
+    return IndexerManagerHolder.INSTANCE;
+  }
+
+  private IndexerManager() {
+    indexerFilePath = IoTDBDescriptor.getInstance().getConfig().getSchemaDir()
+      + File.pathSeparator + IndexConstants.IndexerFile;
+    seqIndexers = new ConcurrentHashMap<>();
+    unseqIndexers = new ConcurrentHashMap<>();
+    lock = new ReentrantReadWriteLock();
+  }
+
+  /**
+   * init all indexer
+   * @return whether success
+   */
+  public boolean init() {
+    //TODO
+    // 1. get all storage group from file
+    // 2. init indexer for the storage group
+    return true;
+  }
+
+  public void addSeqIndexer(PartialPath storageGroup, DeviceTimeIndexer deviceTimeIndexer) {
+    lock.writeLock().lock();
+    seqIndexers.put(storageGroup, deviceTimeIndexer);
+    lock.writeLock().unlock();

Review comment:
       Got it!

##########
File path: server/src/main/java/org/apache/iotdb/db/conf/IoTDBConfig.java
##########
@@ -645,6 +645,10 @@
   // time in nanosecond precision when starting up
   private long startUpNanosecond = System.nanoTime();
 
+  // enable new indexer
+  private boolean enableDeviceIndexer = false;
+  private int deviceIndexerType = 0;

Review comment:
       Thank you for you advise! 




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



[GitHub] [incubator-iotdb] mychaow commented on pull request #1652: [IOTDB-698] add device time index interface

Posted by GitBox <gi...@apache.org>.
mychaow commented on pull request #1652:
URL: https://github.com/apache/incubator-iotdb/pull/1652#issuecomment-693179924


   > Hi, please change this interface to FileIndexManager and make the default implementation as DeviceTimeIndexEntry
   
   ok


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



[GitHub] [incubator-iotdb] SilverNarcissus commented on a change in pull request #1652: add device time index interface

Posted by GitBox <gi...@apache.org>.
SilverNarcissus commented on a change in pull request #1652:
URL: https://github.com/apache/incubator-iotdb/pull/1652#discussion_r484628449



##########
File path: server/src/main/java/org/apache/iotdb/db/timeIndex/IndexerManager.java
##########
@@ -0,0 +1,144 @@
+/*
+ * 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.timeIndex;
+
+import org.apache.iotdb.db.conf.IoTDBDescriptor;
+import org.apache.iotdb.db.exception.metadata.IllegalPathException;
+import org.apache.iotdb.db.metadata.PartialPath;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.File;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.locks.ReentrantReadWriteLock;
+
+public class IndexerManager {
+  private String indexerFilePath;
+  private Map<PartialPath, DeviceTimeIndexer> seqIndexers;
+  private Map<PartialPath, DeviceTimeIndexer> unseqIndexers;
+  private ReentrantReadWriteLock lock;
+  private static final Logger logger = LoggerFactory.getLogger(IndexerManager.class);
+
+  private static class IndexerManagerHolder {
+
+    private IndexerManagerHolder() {
+      // allowed to do nothing
+    }
+
+    private static final IndexerManager INSTANCE = new IndexerManager();
+  }
+
+  public static IndexerManager getInstance() {
+    return IndexerManagerHolder.INSTANCE;
+  }
+
+  private IndexerManager() {
+    indexerFilePath = IoTDBDescriptor.getInstance().getConfig().getSchemaDir()
+      + File.pathSeparator + IndexConstants.IndexerFile;
+    seqIndexers = new ConcurrentHashMap<>();
+    unseqIndexers = new ConcurrentHashMap<>();
+    lock = new ReentrantReadWriteLock();
+  }
+
+  /**
+   * init all indexer
+   * @return whether success
+   */
+  public boolean init() {
+    //TODO
+    // 1. get all storage group from file
+    // 2. init indexer for the storage group
+    return true;
+  }
+
+  public void addSeqIndexer(PartialPath storageGroup, DeviceTimeIndexer deviceTimeIndexer) {
+    lock.writeLock().lock();
+    seqIndexers.put(storageGroup, deviceTimeIndexer);
+    lock.writeLock().unlock();

Review comment:
       unlock should in a finally block

##########
File path: server/src/main/java/org/apache/iotdb/db/timeIndex/IndexerManager.java
##########
@@ -0,0 +1,144 @@
+/*
+ * 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.timeIndex;
+
+import org.apache.iotdb.db.conf.IoTDBDescriptor;
+import org.apache.iotdb.db.exception.metadata.IllegalPathException;
+import org.apache.iotdb.db.metadata.PartialPath;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.File;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.locks.ReentrantReadWriteLock;
+
+public class IndexerManager {
+  private String indexerFilePath;
+  private Map<PartialPath, DeviceTimeIndexer> seqIndexers;
+  private Map<PartialPath, DeviceTimeIndexer> unseqIndexers;
+  private ReentrantReadWriteLock lock;
+  private static final Logger logger = LoggerFactory.getLogger(IndexerManager.class);
+
+  private static class IndexerManagerHolder {
+
+    private IndexerManagerHolder() {
+      // allowed to do nothing
+    }
+
+    private static final IndexerManager INSTANCE = new IndexerManager();
+  }
+
+  public static IndexerManager getInstance() {
+    return IndexerManagerHolder.INSTANCE;
+  }
+
+  private IndexerManager() {
+    indexerFilePath = IoTDBDescriptor.getInstance().getConfig().getSchemaDir()
+      + File.pathSeparator + IndexConstants.IndexerFile;
+    seqIndexers = new ConcurrentHashMap<>();
+    unseqIndexers = new ConcurrentHashMap<>();
+    lock = new ReentrantReadWriteLock();
+  }
+
+  /**
+   * init all indexer
+   * @return whether success
+   */
+  public boolean init() {
+    //TODO
+    // 1. get all storage group from file
+    // 2. init indexer for the storage group
+    return true;
+  }
+
+  public void addSeqIndexer(PartialPath storageGroup, DeviceTimeIndexer deviceTimeIndexer) {
+    lock.writeLock().lock();
+    seqIndexers.put(storageGroup, deviceTimeIndexer);
+    lock.writeLock().unlock();
+  }
+
+  public void addUnseqIndexer(PartialPath storageGroup, DeviceTimeIndexer deviceTimeIndexer) {
+    lock.writeLock().lock();
+    unseqIndexers.put(storageGroup, deviceTimeIndexer);
+    lock.writeLock().unlock();

Review comment:
       same as above

##########
File path: server/src/main/java/org/apache/iotdb/db/timeIndex/IndexerManager.java
##########
@@ -0,0 +1,144 @@
+/*
+ * 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.timeIndex;
+
+import org.apache.iotdb.db.conf.IoTDBDescriptor;
+import org.apache.iotdb.db.exception.metadata.IllegalPathException;
+import org.apache.iotdb.db.metadata.PartialPath;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.File;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.locks.ReentrantReadWriteLock;
+
+public class IndexerManager {
+  private String indexerFilePath;
+  private Map<PartialPath, DeviceTimeIndexer> seqIndexers;
+  private Map<PartialPath, DeviceTimeIndexer> unseqIndexers;
+  private ReentrantReadWriteLock lock;
+  private static final Logger logger = LoggerFactory.getLogger(IndexerManager.class);
+
+  private static class IndexerManagerHolder {
+
+    private IndexerManagerHolder() {
+      // allowed to do nothing
+    }
+
+    private static final IndexerManager INSTANCE = new IndexerManager();
+  }
+
+  public static IndexerManager getInstance() {
+    return IndexerManagerHolder.INSTANCE;
+  }
+
+  private IndexerManager() {
+    indexerFilePath = IoTDBDescriptor.getInstance().getConfig().getSchemaDir()
+      + File.pathSeparator + IndexConstants.IndexerFile;
+    seqIndexers = new ConcurrentHashMap<>();
+    unseqIndexers = new ConcurrentHashMap<>();
+    lock = new ReentrantReadWriteLock();
+  }
+
+  /**
+   * init all indexer
+   * @return whether success
+   */
+  public boolean init() {
+    //TODO
+    // 1. get all storage group from file
+    // 2. init indexer for the storage group
+    return true;
+  }
+
+  public void addSeqIndexer(PartialPath storageGroup, DeviceTimeIndexer deviceTimeIndexer) {
+    lock.writeLock().lock();
+    seqIndexers.put(storageGroup, deviceTimeIndexer);
+    lock.writeLock().unlock();
+  }
+
+  public void addUnseqIndexer(PartialPath storageGroup, DeviceTimeIndexer deviceTimeIndexer) {
+    lock.writeLock().lock();
+    unseqIndexers.put(storageGroup, deviceTimeIndexer);
+    lock.writeLock().unlock();
+  }
+
+  public void deleteSeqIndexer(PartialPath storageGroup) {
+    lock.writeLock().lock();
+    seqIndexers.remove(storageGroup);
+    lock.writeLock().unlock();

Review comment:
       same as above

##########
File path: server/src/main/java/org/apache/iotdb/db/conf/IoTDBConfig.java
##########
@@ -645,6 +645,10 @@
   // time in nanosecond precision when starting up
   private long startUpNanosecond = System.nanoTime();
 
+  // enable new indexer
+  private boolean enableDeviceIndexer = false;
+  private int deviceIndexerType = 0;

Review comment:
       I see that you only add these parameter in config but not in iotdb-engine.properties and IoTDBDescriptor.java. So our user can't see you config, please have a look~

##########
File path: server/src/main/java/org/apache/iotdb/db/conf/IoTDBConfig.java
##########
@@ -645,6 +645,10 @@
   // time in nanosecond precision when starting up
   private long startUpNanosecond = System.nanoTime();
 
+  // enable new indexer
+  private boolean enableDeviceIndexer = false;
+  private int deviceIndexerType = 0;

Review comment:
       At the same time, please don't forget update read me about config change

##########
File path: server/src/main/java/org/apache/iotdb/db/timeIndex/IndexerManager.java
##########
@@ -0,0 +1,144 @@
+/*
+ * 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.timeIndex;
+
+import org.apache.iotdb.db.conf.IoTDBDescriptor;
+import org.apache.iotdb.db.exception.metadata.IllegalPathException;
+import org.apache.iotdb.db.metadata.PartialPath;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.File;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.locks.ReentrantReadWriteLock;
+
+public class IndexerManager {
+  private String indexerFilePath;
+  private Map<PartialPath, DeviceTimeIndexer> seqIndexers;
+  private Map<PartialPath, DeviceTimeIndexer> unseqIndexers;
+  private ReentrantReadWriteLock lock;
+  private static final Logger logger = LoggerFactory.getLogger(IndexerManager.class);
+
+  private static class IndexerManagerHolder {
+
+    private IndexerManagerHolder() {
+      // allowed to do nothing
+    }
+
+    private static final IndexerManager INSTANCE = new IndexerManager();
+  }
+
+  public static IndexerManager getInstance() {
+    return IndexerManagerHolder.INSTANCE;
+  }
+
+  private IndexerManager() {
+    indexerFilePath = IoTDBDescriptor.getInstance().getConfig().getSchemaDir()
+      + File.pathSeparator + IndexConstants.IndexerFile;
+    seqIndexers = new ConcurrentHashMap<>();
+    unseqIndexers = new ConcurrentHashMap<>();
+    lock = new ReentrantReadWriteLock();
+  }
+
+  /**
+   * init all indexer
+   * @return whether success
+   */
+  public boolean init() {
+    //TODO
+    // 1. get all storage group from file
+    // 2. init indexer for the storage group
+    return true;
+  }
+
+  public void addSeqIndexer(PartialPath storageGroup, DeviceTimeIndexer deviceTimeIndexer) {
+    lock.writeLock().lock();
+    seqIndexers.put(storageGroup, deviceTimeIndexer);
+    lock.writeLock().unlock();
+  }
+
+  public void addUnseqIndexer(PartialPath storageGroup, DeviceTimeIndexer deviceTimeIndexer) {
+    lock.writeLock().lock();
+    unseqIndexers.put(storageGroup, deviceTimeIndexer);
+    lock.writeLock().unlock();
+  }
+
+  public void deleteSeqIndexer(PartialPath storageGroup) {
+    lock.writeLock().lock();
+    seqIndexers.remove(storageGroup);
+    lock.writeLock().unlock();
+  }
+
+  public void deleteUnseqIndexer(PartialPath storageGroup) {
+    lock.writeLock().lock();
+    unseqIndexers.remove(storageGroup);
+    lock.writeLock().unlock();

Review comment:
       same as above




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



[GitHub] [incubator-iotdb] mychaow commented on pull request #1652: add device time index interface

Posted by GitBox <gi...@apache.org>.
mychaow commented on pull request #1652:
URL: https://github.com/apache/incubator-iotdb/pull/1652#issuecomment-681825421


   > Hi, could you add some description for this pr?
   
   yes, you could see some description in jira [iotdb-698]( https://issues.apache.org/jira/browse/IOTDB-698?orderby=cf%5B12310310%5D+ASC%2C+priority+DESC%2C+updated+DESC)


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



[GitHub] [incubator-iotdb] qiaojialin commented on a change in pull request #1652: [IOTDB-698] add device time index interface

Posted by GitBox <gi...@apache.org>.
qiaojialin commented on a change in pull request #1652:
URL: https://github.com/apache/incubator-iotdb/pull/1652#discussion_r488380495



##########
File path: server/src/assembly/resources/conf/iotdb-engine.properties
##########
@@ -232,6 +232,11 @@ write_read_free_memory_proportion=6:3:1
 # primitive array size (length of each array) in array pool
 primitive_array_size=128
 
+# device time indexer
+enable_device_indexer=false

Review comment:
       enable_data_file_indexer?

##########
File path: server/src/assembly/resources/conf/iotdb-engine.properties
##########
@@ -232,6 +232,11 @@ write_read_free_memory_proportion=6:3:1
 # primitive array size (length of each array) in array pool
 primitive_array_size=128
 
+# device time indexer
+enable_device_indexer=false
+# 0, indexer base on file; 1, indexer base on rocksdb
+device_indexer_type=0

Review comment:
       data_file_indexer_manager=internal/rocksdb

##########
File path: server/src/main/java/org/apache/iotdb/db/timeIndex/IndexerManager.java
##########
@@ -0,0 +1,156 @@
+/*
+ * 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.timeIndex;
+
+import org.apache.iotdb.db.conf.IoTDBDescriptor;
+import org.apache.iotdb.db.exception.metadata.IllegalPathException;
+import org.apache.iotdb.db.metadata.PartialPath;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.File;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.locks.ReentrantReadWriteLock;
+
+public class IndexerManager {

Review comment:
       ```suggestion
   public class FileIndexManager {
   ```

##########
File path: server/src/main/java/org/apache/iotdb/db/timeIndex/TimeIndex.java
##########
@@ -0,0 +1,63 @@
+/*
+ * 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.timeIndex;
+
+import org.apache.iotdb.db.metadata.PartialPath;
+
+/**
+ * Time Index, like deviceIndexer: [(deviceId, startTime, endTime, TsFilePath)] to accelerate query
+ */
+public class TimeIndex {

Review comment:
       DeviceTimeIndexEntry

##########
File path: server/src/main/java/org/apache/iotdb/db/timeIndex/TimeIndexer.java
##########
@@ -0,0 +1,121 @@
+/*
+ * 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.timeIndex;
+
+import org.apache.iotdb.db.engine.storagegroup.TsFileResource;
+import org.apache.iotdb.db.metadata.PartialPath;
+import org.apache.iotdb.tsfile.read.filter.basic.Filter;
+
+import java.util.List;
+import java.util.Map;
+
+public interface TimeIndexer {
+  /**
+   * init the Indexer when IoTDB start
+   * @return whether success
+   */
+  public boolean init();
+
+  /**
+   * may do some prepared work before operation
+   * @return whether success
+   */
+  public boolean begin();
+
+  /**
+   * may do some resource release after operation
+   * @return whether success
+   */
+  public boolean end();
+
+  /**
+   * add one index record for the path
+   * @param path
+   * @param startTime
+   * @param endTime
+   * @param tsFilePath
+   * @return
+   */
+  public boolean addIndexForPath(PartialPath path, long startTime, long endTime, String tsFilePath);

Review comment:
       ```suggestion
     public boolean addIndexForFile(PartialPath path, long startTime, long endTime, String tsFilePath);
   ```

##########
File path: server/src/main/java/org/apache/iotdb/db/timeIndex/TimeIndexer.java
##########
@@ -0,0 +1,121 @@
+/*
+ * 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.timeIndex;
+
+import org.apache.iotdb.db.engine.storagegroup.TsFileResource;
+import org.apache.iotdb.db.metadata.PartialPath;
+import org.apache.iotdb.tsfile.read.filter.basic.Filter;
+
+import java.util.List;
+import java.util.Map;
+
+public interface TimeIndexer {

Review comment:
       ```suggestion
   public interface FileIndexer {
   ```




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