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/09/08 08:49:58 UTC

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

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