MarcosZyk commented on code in PR #7137: URL: https://github.com/apache/iotdb/pull/7137#discussion_r956670121
########## server/src/main/java/org/apache/iotdb/db/metadata/idtable/deviceID/StandAloneAutoIncDeviceID.java: ########## @@ -0,0 +1,310 @@ +/* + * 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.deviceID; + +import org.apache.iotdb.commons.consensus.SchemaRegionId; +import org.apache.iotdb.commons.exception.IllegalPathException; +import org.apache.iotdb.commons.exception.MetadataException; +import org.apache.iotdb.commons.path.PartialPath; +import org.apache.iotdb.commons.utils.TestOnly; +import org.apache.iotdb.db.localconfignode.LocalConfigNode; +import org.apache.iotdb.db.metadata.idtable.IDTable; +import org.apache.iotdb.db.metadata.idtable.IDTableManager; +import org.apache.iotdb.tsfile.utils.ReadWriteIOUtils; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.nio.ByteBuffer; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +/** + * Using auto-incrementing id as device id,A complete auto-increment id consists of schemaRegionID + * and autoIncrementID, where the upper 32 bits are schemaRegionID and the lower 32 bits are + * autoIncrementID + */ +public class StandAloneAutoIncDeviceID extends SHA256DeviceID { + + /** logger */ + private static Logger logger = LoggerFactory.getLogger(IDTable.class); + + // stand-alone auto-increment id uses LocalConfigNode to obtain schemaRegionId + private static LocalConfigNode configManager; + + // using map to maintain the mapping from schemaRegionId to list<deviceID>, each list<deviceID> + // maintains the auto-increment id of the schemaRegion + private static Map<Integer, List<IDeviceID>> deviceIDsMap; + + // if the device represented by devicePath is not written to the metadata module, use this + // constant instead of devicePath to generate a sha266 value of StandAloneAutoIncDeviceID instance + private static final String INVALID_DEVICE_PATH = "invalid.device.path"; + + // if the schemaRegionId==-1 of a StandAloneAutoIncDeviceID instance, it means that the device + // corresponding to the StandAloneAutoIncDeviceID instance does not exist + // return the deviceIdOfNonExistentDevice object for all devicePaths of unmanaged devices in the + // metadata module, which can avoid unnecessary object creation while ensuring correctness + private static StandAloneAutoIncDeviceID deviceIdOfNonExistentDevice; Review Comment: All the static attributes and methods in this class should be implemented as an independent ```IDTableAutoIncImpl```. This class should be a simple entity class. -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
