MarcosZyk commented on code in PR #9243: URL: https://github.com/apache/iotdb/pull/9243#discussion_r1131873583
########## node-commons/src/main/java/org/apache/iotdb/commons/schema/node/common/AbstractMeasurementMNode.java: ########## @@ -0,0 +1,256 @@ +/* + * 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.commons.schema.node.common; + +import org.apache.iotdb.commons.path.MeasurementPath; +import org.apache.iotdb.commons.path.PartialPath; +import org.apache.iotdb.commons.schema.node.IMNode; +import org.apache.iotdb.commons.schema.node.MNodeType; +import org.apache.iotdb.commons.schema.node.info.IMeasurementInfo; +import org.apache.iotdb.commons.schema.node.role.IDatabaseMNode; +import org.apache.iotdb.commons.schema.node.role.IDeviceMNode; +import org.apache.iotdb.commons.schema.node.role.IMeasurementMNode; Review Comment: The device and measurement related code seems only being used in server package. ########## server/src/main/java/org/apache/iotdb/db/metadata/mnode/config/IConfigMNode.java: ########## @@ -0,0 +1,36 @@ +/* + * 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.mnode.config; + +import org.apache.iotdb.commons.schema.node.IMNode; + +public interface IConfigMNode extends IMNode<IConfigMNode> { Review Comment: Should this class placed in confignode package? ########## node-commons/src/main/java/org/apache/iotdb/commons/schema/node/role/IMeasurementMNode.java: ########## @@ -16,23 +16,21 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.iotdb.db.metadata.mnode; +package org.apache.iotdb.commons.schema.node.role; import org.apache.iotdb.commons.path.MeasurementPath; +import org.apache.iotdb.commons.schema.node.IMNode; import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType; import org.apache.iotdb.tsfile.write.schema.IMeasurementSchema; /** This interface defines a MeasurementMNode's operation interfaces. */ -public interface IMeasurementMNode extends IMNode { - - @Override - IEntityMNode getParent(); - - MeasurementPath getMeasurementPath(); +public interface IMeasurementMNode<N extends IMNode<N>> extends IMNode<N> { IMeasurementSchema getSchema(); - TSDataType getDataType(String measurementId); + void setSchema(IMeasurementSchema schema); Review Comment: We assume the schema is immutable. Is this interface necessary? ########## server/src/main/java/org/apache/iotdb/db/metadata/mtree/store/IMTreeStore.java: ########## @@ -61,33 +61,33 @@ public interface IMTreeStore { * @param name name or alias * @return child node */ - IMNode getChild(IMNode parent, String name) throws MetadataException; + N getChild(N parent, String name) throws MetadataException; - IMNodeIterator getChildrenIterator(IMNode parent) throws MetadataException; + IMNodeIterator<N> getChildrenIterator(N parent) throws MetadataException; - IMNodeIterator getTraverserIterator( - IMNode parent, Map<Integer, Template> templateMap, boolean skipPreDeletedSchema) + IMNodeIterator<N> getTraverserIterator( + N parent, Map<Integer, Template> templateMap, boolean skipPreDeletedSchema) throws MetadataException; - IMNode addChild(IMNode parent, String childName, IMNode child); + N addChild(N parent, String childName, N child); - void deleteChild(IMNode parent, String childName) throws MetadataException; + void deleteChild(N parent, String childName) throws MetadataException; - void updateMNode(IMNode node) throws MetadataException; + void updateMNode(N node) throws MetadataException; - IEntityMNode setToEntity(IMNode node) throws MetadataException; + IDeviceMNode<N> setToEntity(N node) throws MetadataException; - IMNode setToInternal(IEntityMNode entityMNode) throws MetadataException; + N setToInternal(IDeviceMNode<N> entityMNode) throws MetadataException; - void setAlias(IMeasurementMNode measurementMNode, String alias) throws MetadataException; + void setAlias(IMeasurementMNode<N> measurementMNode, String alias) throws MetadataException; - void pin(IMNode node) throws MetadataException; + void pin(N node) throws MetadataException; - void unPin(IMNode node); + void unPin(N node); - void unPinPath(IMNode node); + void unPinPath(N node); Review Comment: Maybe these interfaces should only be behavior of CachdMTreeStore. The common behavior are releaseNode and releasePath, which only used in Traverser. ########## server/src/main/java/org/apache/iotdb/db/metadata/mtree/ConfigMTree.java: ########## @@ -74,12 +74,14 @@ public class ConfigMTree { private final Logger logger = LoggerFactory.getLogger(ConfigMTree.class); - private IMNode root; + private IConfigMNode root; // this store is only used for traverser invoking - private MemMTreeStore store; + private final ConfigMTreeStore store; Review Comment: Move ConfigMTree to confignode pacakge. ########## server/src/main/java/org/apache/iotdb/db/metadata/mtree/IMTreeBelowSG.java: ########## @@ -33,7 +33,7 @@ import java.util.Map; import java.util.Set; -public interface IMTreeBelowSG { +public interface IMTreeBelowSG<N extends IMNode<N>> { Review Comment: Should this class be eliminated? Seems useless. ########## server/src/main/java/org/apache/iotdb/db/metadata/mtree/traverser/Traverser.java: ########## @@ -49,17 +50,18 @@ * <li>collector: to collect customized results of the matched node or measurement * </ol> */ -public abstract class Traverser<R> extends AbstractTreeVisitor<IMNode, R> { +public abstract class Traverser<R, N extends IMNode<N>> extends AbstractTreeVisitor<N, R> { private static final Logger logger = LoggerFactory.getLogger(Traverser.class); - protected IMTreeStore store; + protected IMTreeStore<N> store; - protected IMNode startNode; + protected N startNode; protected String[] nodes; // measurement in template should be processed only if templateMap is not null protected Map<Integer, Template> templateMap; + protected IMNodeFactory<N> nodeFactory; Review Comment: This can be pushed down to MeasurementTraverser. This class will act as a common traverser and will be placed in package node-commons. ########## server/src/main/java/org/apache/iotdb/db/metadata/mnode/schemafile/ICacheMNode.java: ########## @@ -16,13 +16,13 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.iotdb.db.metadata.mtree.multimode; +package org.apache.iotdb.db.metadata.mnode.schemafile; -import org.apache.iotdb.db.conf.IoTDBDescriptor; +import org.apache.iotdb.commons.schema.node.IMNode; +import org.apache.iotdb.db.metadata.mtree.store.disk.cache.CacheEntry; -public class MTreeFullMemoryTest extends MTreeDiskModeTest { - @Override - protected void setMemSize() { - IoTDBDescriptor.getInstance().getConfig().setCachedMNodeSizeInSchemaFileMode(10000); - } +public interface ICacheMNode extends IMNode<ICacheMNode> { Review Comment: Rename to ```ICachedMNode```. ########## server/src/main/java/org/apache/iotdb/db/metadata/mtree/traverser/collector/DatabaseCollector.java: ########## @@ -20,25 +20,25 @@ import org.apache.iotdb.commons.exception.MetadataException; import org.apache.iotdb.commons.path.PartialPath; -import org.apache.iotdb.db.metadata.mnode.IMNode; -import org.apache.iotdb.db.metadata.mnode.IStorageGroupMNode; +import org.apache.iotdb.commons.schema.node.IMNode; +import org.apache.iotdb.commons.schema.node.role.IDatabaseMNode; import org.apache.iotdb.db.metadata.mtree.store.IMTreeStore; import org.apache.iotdb.db.metadata.mtree.traverser.basic.DatabaseTraverser; // This class implements database path collection function. -public abstract class DatabaseCollector<R> extends DatabaseTraverser<R> { +public abstract class DatabaseCollector<R, N extends IMNode<N>> extends DatabaseTraverser<R, N> { Review Comment: Seems only used in ConfigMTree. -- 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]
