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 2021/12/23 03:40:18 UTC

[GitHub] [iotdb] zyk990424 commented on a change in pull request #4603: [IOTDB-2083] ID table implementation

zyk990424 commented on a change in pull request #4603:
URL: https://github.com/apache/iotdb/pull/4603#discussion_r774295990



##########
File path: cluster/src/main/java/org/apache/iotdb/cluster/query/LocalQueryExecutor.java
##########
@@ -1043,7 +1044,12 @@ public ByteBuffer last(LastQueryRequest request)
 
     List<Pair<Boolean, TimeValuePair>> timeValuePairs =
         LastQueryExecutor.calculateLastPairForSeriesLocally(
-            partialPaths, dataTypes, queryContext, expression, request.getDeviceMeasurements());
+            partialPaths,
+            dataTypes,
+            queryContext,
+            expression,
+            request.getDeviceMeasurements(),
+            IoTDBDescriptor.getInstance().getConfig().isEnableIDTable());

Review comment:
       Is there any test based on this parameter? Maybe the function implement could access the config via IoTDB global  variables.

##########
File path: server/src/main/java/org/apache/iotdb/db/metadata/idtable/DiskSchemaManager.java
##########
@@ -0,0 +1,48 @@
+/*
+ * 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.metadata.idtable;
+
+import org.apache.iotdb.db.metadata.idtable.entry.DiskSchemaEntry;
+import org.apache.iotdb.db.utils.TestOnly;
+
+import java.io.IOException;
+import java.util.Collection;
+
+/** This class manages IO of id table's schema entry */
+public interface DiskSchemaManager {
+

Review comment:
       Maybe we should stick to the naming notations and rename this to IDiskShemaManager

##########
File path: server/src/main/java/org/apache/iotdb/db/metadata/idtable/AppendOnlyDiskSchemaManager.java
##########
@@ -0,0 +1,125 @@
+/*
+ * 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.metadata.idtable;
+
+import org.apache.iotdb.db.metadata.idtable.entry.DiskSchemaEntry;
+import org.apache.iotdb.db.utils.TestOnly;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+/** store id table schema in append only file */
+public class AppendOnlyDiskSchemaManager implements DiskSchemaManager {
+
+  private static final String FILE_NAME = "SeriesKeyMapping.meta";
+
+  File dataFile;
+
+  OutputStream outputStream;
+
+  long loc;
+
+  private static final Logger logger = LoggerFactory.getLogger(AppendOnlyDiskSchemaManager.class);
+
+  public AppendOnlyDiskSchemaManager(File dir) {
+
+    try {
+      initFile(dir);
+      outputStream = new FileOutputStream(dataFile);
+    } catch (IOException e) {
+      logger.error(e.getMessage());
+    }
+  }
+
+  private void initFile(File dir) throws IOException {
+    // create dirs
+    if (dir.mkdirs()) {
+      logger.info(
+          "ID table create storage group system dir {} doesn't exist, create it",
+          dir.getParentFile());
+    }
+
+    dataFile = new File(dir, FILE_NAME);
+    if (dataFile.exists()) {
+      loc = dataFile.length();
+    } else {
+      logger.debug("create new file for id table: " + dir.getName());
+      boolean createRes = dataFile.createNewFile();
+      if (!createRes) {
+        throw new IOException(
+            "create new file for id table failed. Path is: " + dataFile.getPath());
+      }
+
+      loc = 0;
+    }
+  }

Review comment:
       Maybe last entry check while restarting is necessary here. It should be ensured that there's no file corruption.




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

To unsubscribe, e-mail: reviews-unsubscribe@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org