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 03:24:38 UTC

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

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