You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by zy...@apache.org on 2022/12/22 11:16:58 UTC
[iotdb] branch eliminate_mtree_useless_code created (now 9771dc9be3)
This is an automated email from the ASF dual-hosted git repository.
zyk pushed a change to branch eliminate_mtree_useless_code
in repository https://gitbox.apache.org/repos/asf/iotdb.git
at 9771dc9be3 eliminate useless code in schemaRegion and MTree
This branch includes the following new commits:
new 9771dc9be3 eliminate useless code in schemaRegion and MTree
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
[iotdb] 01/01: eliminate useless code in schemaRegion and MTree
Posted by zy...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
zyk pushed a commit to branch eliminate_mtree_useless_code
in repository https://gitbox.apache.org/repos/asf/iotdb.git
commit 9771dc9be33b45defe32ca5318dcdaea6296ad89
Author: Marccos <15...@qq.com>
AuthorDate: Thu Dec 22 19:15:16 2022 +0800
eliminate useless code in schemaRegion and MTree
---
.../iotdb/db/metadata/mtree/IMTreeBelowSG.java | 55 ------
.../db/metadata/mtree/MTreeBelowSGCachedImpl.java | 138 -------------
.../db/metadata/mtree/MTreeBelowSGMemoryImpl.java | 126 ------------
.../schemaregion/SchemaRegionMemoryImpl.java | 37 ----
.../schemaregion/SchemaRegionSchemaFileImpl.java | 57 ------
.../iotdb/db/metadata/mtree/MTreeBelowSGTest.java | 216 ++-------------------
6 files changed, 21 insertions(+), 608 deletions(-)
diff --git a/server/src/main/java/org/apache/iotdb/db/metadata/mtree/IMTreeBelowSG.java b/server/src/main/java/org/apache/iotdb/db/metadata/mtree/IMTreeBelowSG.java
index e9a459fb5b..b81ffecd3a 100644
--- a/server/src/main/java/org/apache/iotdb/db/metadata/mtree/IMTreeBelowSG.java
+++ b/server/src/main/java/org/apache/iotdb/db/metadata/mtree/IMTreeBelowSG.java
@@ -22,7 +22,6 @@ import org.apache.iotdb.common.rpc.thrift.TSchemaNode;
import org.apache.iotdb.commons.exception.MetadataException;
import org.apache.iotdb.commons.path.MeasurementPath;
import org.apache.iotdb.commons.path.PartialPath;
-import org.apache.iotdb.db.metadata.mnode.IEntityMNode;
import org.apache.iotdb.db.metadata.mnode.IMNode;
import org.apache.iotdb.db.metadata.mnode.IMeasurementMNode;
import org.apache.iotdb.db.metadata.plan.schemaregion.read.IShowDevicesPlan;
@@ -130,15 +129,6 @@ public interface IMTreeBelowSG {
*/
IMNode getDeviceNodeWithAutoCreating(PartialPath deviceId) throws MetadataException;
- IEntityMNode setToEntity(IMNode node) throws MetadataException;
-
- /**
- * Check whether the given path exists.
- *
- * @param path a full path or a prefix path
- */
- boolean isPathExist(PartialPath path) throws MetadataException;
-
/**
* Get all devices matching the given path pattern. If isPrefixMatch, then the devices under the
* paths matching given path pattern will be collected too.
@@ -150,8 +140,6 @@ public interface IMTreeBelowSG {
Pair<List<ShowDevicesResult>, Integer> getDevices(IShowDevicesPlan plan) throws MetadataException;
- Set<PartialPath> getDevicesByTimeseries(PartialPath timeseries) throws MetadataException;
-
/**
* Get all measurement paths matching the given path pattern. If using prefix match, the path
* pattern is used to match prefix path. All timeseries start with the matched prefix path will be
@@ -163,13 +151,6 @@ public interface IMTreeBelowSG {
List<MeasurementPath> getMeasurementPaths(PartialPath pathPattern, boolean isPrefixMatch)
throws MetadataException;
- /**
- * Get all measurement paths matching the given path pattern
- *
- * @param pathPattern a path pattern or a full path, may contain wildcard.
- */
- List<MeasurementPath> getMeasurementPaths(PartialPath pathPattern) throws MetadataException;
-
/**
* Get all measurement paths matching the given path pattern If using prefix match, the path
* pattern is used to match prefix path. All timeseries start with the matched prefix path will be
@@ -221,20 +202,6 @@ public interface IMTreeBelowSG {
*/
Set<TSchemaNode> getChildNodePathInNextLevel(PartialPath pathPattern) throws MetadataException;
- /**
- * Get child node in the next level of the given path.
- *
- * <p>e.g., MTree has [root.sg1.d1.s1, root.sg1.d1.s2, root.sg1.d2.s1] given path = root.sg1,
- * return [d1, d2]
- *
- * <p>e.g., MTree has [root.sg1.d1.s1, root.sg1.d1.s2, root.sg1.d2.s1] given path = root.sg1.d1
- * return [s1, s2]
- *
- * @param pathPattern Path
- * @return All child nodes' seriesPath(s) of given seriesPath.
- */
- Set<String> getChildNodeNameInNextLevel(PartialPath pathPattern) throws MetadataException;
-
/** Get all paths from root to the given level */
List<PartialPath> getNodesListInGivenLevel(
PartialPath pathPattern, int nodeLevel, boolean isPrefixMatch) throws MetadataException;
@@ -259,13 +226,6 @@ public interface IMTreeBelowSG {
PartialPath pathPattern, Map<Integer, Template> templateMap, boolean isPrefixMatch)
throws MetadataException;
- /**
- * Get the count of timeseries matching the given path.
- *
- * @param pathPattern a path pattern or a full path, may contain wildcard
- */
- long getAllTimeseriesCount(PartialPath pathPattern) throws MetadataException;
-
/**
* Get the count of timeseries matching the given path by tag.
*
@@ -284,21 +244,6 @@ public interface IMTreeBelowSG {
*/
long getDevicesNum(PartialPath pathPattern, boolean isPrefixMatch) throws MetadataException;
- /**
- * Get the count of devices matching the given path.
- *
- * @param pathPattern a path pattern or a full path, may contain wildcard
- */
- long getDevicesNum(PartialPath pathPattern) throws MetadataException;
-
- /**
- * Get the count of nodes in the given level matching the given path. If using prefix match, the
- * path pattern is used to match prefix path. All timeseries start with the matched prefix path
- * will be counted.
- */
- long getNodesCountInGivenLevel(PartialPath pathPattern, int level, boolean isPrefixMatch)
- throws MetadataException;
-
Map<PartialPath, Long> getMeasurementCountGroupByLevel(
PartialPath pathPattern, int level, boolean isPrefixMatch) throws MetadataException;
diff --git a/server/src/main/java/org/apache/iotdb/db/metadata/mtree/MTreeBelowSGCachedImpl.java b/server/src/main/java/org/apache/iotdb/db/metadata/mtree/MTreeBelowSGCachedImpl.java
index aaf7c8310e..960f110232 100644
--- a/server/src/main/java/org/apache/iotdb/db/metadata/mtree/MTreeBelowSGCachedImpl.java
+++ b/server/src/main/java/org/apache/iotdb/db/metadata/mtree/MTreeBelowSGCachedImpl.java
@@ -47,7 +47,6 @@ import org.apache.iotdb.db.metadata.mtree.traverser.collector.MNodeCollector;
import org.apache.iotdb.db.metadata.mtree.traverser.collector.MeasurementCollector;
import org.apache.iotdb.db.metadata.mtree.traverser.counter.CounterTraverser;
import org.apache.iotdb.db.metadata.mtree.traverser.counter.EntityCounter;
-import org.apache.iotdb.db.metadata.mtree.traverser.counter.MNodeLevelCounter;
import org.apache.iotdb.db.metadata.mtree.traverser.counter.MeasurementCounter;
import org.apache.iotdb.db.metadata.mtree.traverser.counter.MeasurementGroupByLevelCounter;
import org.apache.iotdb.db.metadata.plan.schemaregion.read.IShowDevicesPlan;
@@ -654,50 +653,9 @@ public class MTreeBelowSGCachedImpl implements IMTreeBelowSG {
unPinPath(cur);
}
}
-
- @Override
- public IEntityMNode setToEntity(IMNode node) throws MetadataException {
- // synchronize check and replace, we need replaceChild become atomic operation
- // only write on mtree will be synchronized
- synchronized (this) {
- IEntityMNode entityMNode = store.setToEntity(node);
- if (entityMNode.isStorageGroup()) {
- this.storageGroupMNode = entityMNode.getAsStorageGroupMNode();
- }
- return entityMNode;
- }
- }
// endregion
// region Interfaces and Implementation for metadata info Query
- /**
- * Check whether the given path exists.
- *
- * @param path a full path or a prefix path
- */
- @Override
- public boolean isPathExist(PartialPath path) throws MetadataException {
- String[] nodeNames = path.getNodes();
- IMNode cur = storageGroupMNode;
- IMNode child;
- try {
- for (int i = levelOfSG + 1; i < nodeNames.length; i++) {
- child = store.getChild(cur, nodeNames[i]);
- if (child == null) {
- return false;
- } else {
- if (child.isMeasurement()) {
- cur = child;
- return i == nodeNames.length - 1;
- }
- }
- cur = child;
- }
- return true;
- } finally {
- unPinPath(cur);
- }
- }
// region Interfaces for Device info Query
/**
@@ -748,21 +706,6 @@ public class MTreeBelowSGCachedImpl implements IMTreeBelowSG {
return new Pair<>(res, collector.getCurOffset() + 1);
}
-
- @Override
- public Set<PartialPath> getDevicesByTimeseries(PartialPath timeseries) throws MetadataException {
- Set<PartialPath> result = new HashSet<>();
- MeasurementCollector<Set<PartialPath>> collector =
- new MeasurementCollector<Set<PartialPath>>(storageGroupMNode, timeseries, store) {
- @Override
- protected void collectMeasurement(IMeasurementMNode node) {
- result.add(getCurrentPartialPath(node).getDevicePath());
- }
- };
- collector.traverse();
- return result;
- }
-
// endregion
// region Interfaces for timeseries, measurement and schema info Query
@@ -780,17 +723,6 @@ public class MTreeBelowSGCachedImpl implements IMTreeBelowSG {
return getMeasurementPathsWithAlias(pathPattern, 0, 0, isPrefixMatch, false).left;
}
- /**
- * Get all measurement paths matching the given path pattern
- *
- * @param pathPattern a path pattern or a full path, may contain wildcard.
- */
- @Override
- public List<MeasurementPath> getMeasurementPaths(PartialPath pathPattern)
- throws MetadataException {
- return getMeasurementPaths(pathPattern, false);
- }
-
/**
* Get all measurement paths matching the given path pattern If using prefix match, the path
* pattern is used to match prefix path. All timeseries start with the matched prefix path will be
@@ -909,37 +841,6 @@ public class MTreeBelowSGCachedImpl implements IMTreeBelowSG {
}
}
- /**
- * Get child node in the next level of the given path.
- *
- * <p>e.g., MTree has [root.sg1.d1.s1, root.sg1.d1.s2, root.sg1.d2.s1] given path = root.sg1,
- * return [d1, d2]
- *
- * <p>e.g., MTree has [root.sg1.d1.s1, root.sg1.d1.s2, root.sg1.d2.s1] given path = root.sg1.d1
- * return [s1, s2]
- *
- * @param pathPattern Path
- * @return All child nodes' seriesPath(s) of given seriesPath.
- */
- @Override
- public Set<String> getChildNodeNameInNextLevel(PartialPath pathPattern) throws MetadataException {
- try {
- MNodeCollector<Set<String>> collector =
- new MNodeCollector<Set<String>>(
- storageGroupMNode, pathPattern.concatNode(ONE_LEVEL_PATH_WILDCARD), store) {
- @Override
- protected void transferToResult(IMNode node) {
- resultSet.add(node.getName());
- }
- };
- collector.setResultSet(new TreeSet<>());
- collector.traverse();
- return collector.getResult();
- } catch (IllegalPathException e) {
- throw new IllegalPathException(pathPattern.getFullPath());
- }
- }
-
/** Get all paths from root to the given level */
@Override
public List<PartialPath> getNodesListInGivenLevel(
@@ -985,16 +886,6 @@ public class MTreeBelowSGCachedImpl implements IMTreeBelowSG {
return counter.getCount();
}
- /**
- * Get the count of timeseries matching the given path.
- *
- * @param pathPattern a path pattern or a full path, may contain wildcard
- */
- @Override
- public long getAllTimeseriesCount(PartialPath pathPattern) throws MetadataException {
- return getAllTimeseriesCount(pathPattern, false);
- }
-
@Override
public long getAllTimeseriesCount(
PartialPath pathPattern, boolean isPrefixMatch, List<String> timeseries, boolean hasTag)
@@ -1022,30 +913,6 @@ public class MTreeBelowSGCachedImpl implements IMTreeBelowSG {
return counter.getCount();
}
- /**
- * Get the count of devices matching the given path.
- *
- * @param pathPattern a path pattern or a full path, may contain wildcard
- */
- @Override
- public long getDevicesNum(PartialPath pathPattern) throws MetadataException {
- return getDevicesNum(pathPattern, false);
- }
-
- /**
- * Get the count of nodes in the given level matching the given path. If using prefix match, the
- * path pattern is used to match prefix path. All timeseries start with the matched prefix path
- * will be counted.
- */
- @Override
- public long getNodesCountInGivenLevel(PartialPath pathPattern, int level, boolean isPrefixMatch)
- throws MetadataException {
- MNodeLevelCounter counter = new MNodeLevelCounter(storageGroupMNode, pathPattern, store, level);
- counter.setPrefixMatch(isPrefixMatch);
- counter.traverse();
- return counter.getCount();
- }
-
@Override
public Map<PartialPath, Long> getMeasurementCountGroupByLevel(
PartialPath pathPattern, int level, boolean isPrefixMatch) throws MetadataException {
@@ -1389,11 +1256,6 @@ public class MTreeBelowSGCachedImpl implements IMTreeBelowSG {
store.updateMNode(node);
}
- public IMNode getChildFromPinnedMNode(IMNode parent, String measurement)
- throws MetadataException {
- return store.getChild(parent, measurement);
- }
-
// endregion
}
diff --git a/server/src/main/java/org/apache/iotdb/db/metadata/mtree/MTreeBelowSGMemoryImpl.java b/server/src/main/java/org/apache/iotdb/db/metadata/mtree/MTreeBelowSGMemoryImpl.java
index e288ce1ac8..2bd6ecc68f 100644
--- a/server/src/main/java/org/apache/iotdb/db/metadata/mtree/MTreeBelowSGMemoryImpl.java
+++ b/server/src/main/java/org/apache/iotdb/db/metadata/mtree/MTreeBelowSGMemoryImpl.java
@@ -47,7 +47,6 @@ import org.apache.iotdb.db.metadata.mtree.traverser.collector.MNodeCollector;
import org.apache.iotdb.db.metadata.mtree.traverser.collector.MeasurementCollector;
import org.apache.iotdb.db.metadata.mtree.traverser.counter.CounterTraverser;
import org.apache.iotdb.db.metadata.mtree.traverser.counter.EntityCounter;
-import org.apache.iotdb.db.metadata.mtree.traverser.counter.MNodeLevelCounter;
import org.apache.iotdb.db.metadata.mtree.traverser.counter.MeasurementCounter;
import org.apache.iotdb.db.metadata.mtree.traverser.counter.MeasurementGroupByLevelCounter;
import org.apache.iotdb.db.metadata.plan.schemaregion.read.IShowDevicesPlan;
@@ -572,43 +571,9 @@ public class MTreeBelowSGMemoryImpl implements IMTreeBelowSG {
}
return cur;
}
-
- @Override
- public IEntityMNode setToEntity(IMNode node) throws MetadataException {
- // synchronize check and replace, we need replaceChild become atomic operation
- // only write on mtree will be synchronized
- synchronized (this) {
- IEntityMNode entityMNode = store.setToEntity(node);
- if (entityMNode.isStorageGroup()) {
- this.storageGroupMNode = entityMNode.getAsStorageGroupMNode();
- }
- return entityMNode;
- }
- }
// endregion
// region Interfaces and Implementation for metadata info Query
- /**
- * Check whether the given path exists.
- *
- * @param path a full path or a prefix path
- */
- @Override
- public boolean isPathExist(PartialPath path) throws MetadataException {
- String[] nodeNames = path.getNodes();
- IMNode cur = storageGroupMNode;
- IMNode child;
- for (int i = levelOfSG + 1; i < nodeNames.length; i++) {
- child = cur.getChild(nodeNames[i]);
- if (child == null) {
- return false;
- } else if (child.isMeasurement()) {
- return i == nodeNames.length - 1;
- }
- cur = child;
- }
- return true;
- }
// region Interfaces for Device info Query
/**
@@ -659,21 +624,6 @@ public class MTreeBelowSGMemoryImpl implements IMTreeBelowSG {
return new Pair<>(res, collector.getCurOffset() + 1);
}
-
- @Override
- public Set<PartialPath> getDevicesByTimeseries(PartialPath timeseries) throws MetadataException {
- Set<PartialPath> result = new HashSet<>();
- MeasurementCollector<Set<PartialPath>> collector =
- new MeasurementCollector<Set<PartialPath>>(storageGroupMNode, timeseries, store) {
- @Override
- protected void collectMeasurement(IMeasurementMNode node) {
- result.add(getCurrentPartialPath(node).getDevicePath());
- }
- };
- collector.traverse();
- return result;
- }
-
// endregion
// region Interfaces for timeseries, measurement and schema info Query
@@ -691,17 +641,6 @@ public class MTreeBelowSGMemoryImpl implements IMTreeBelowSG {
return getMeasurementPathsWithAlias(pathPattern, 0, 0, isPrefixMatch, false).left;
}
- /**
- * Get all measurement paths matching the given path pattern
- *
- * @param pathPattern a path pattern or a full path, may contain wildcard.
- */
- @Override
- public List<MeasurementPath> getMeasurementPaths(PartialPath pathPattern)
- throws MetadataException {
- return getMeasurementPaths(pathPattern, false);
- }
-
/**
* Get all measurement paths matching the given path pattern If using prefix match, the path
* pattern is used to match prefix path. All timeseries start with the matched prefix path will be
@@ -845,37 +784,6 @@ public class MTreeBelowSGMemoryImpl implements IMTreeBelowSG {
}
}
- /**
- * Get child node in the next level of the given path.
- *
- * <p>e.g., MTree has [root.sg1.d1.s1, root.sg1.d1.s2, root.sg1.d2.s1] given path = root.sg1,
- * return [d1, d2]
- *
- * <p>e.g., MTree has [root.sg1.d1.s1, root.sg1.d1.s2, root.sg1.d2.s1] given path = root.sg1.d1
- * return [s1, s2]
- *
- * @param pathPattern Path
- * @return All child nodes' seriesPath(s) of given seriesPath.
- */
- @Override
- public Set<String> getChildNodeNameInNextLevel(PartialPath pathPattern) throws MetadataException {
- try {
- MNodeCollector<Set<String>> collector =
- new MNodeCollector<Set<String>>(
- storageGroupMNode, pathPattern.concatNode(ONE_LEVEL_PATH_WILDCARD), store) {
- @Override
- protected void transferToResult(IMNode node) {
- resultSet.add(node.getName());
- }
- };
- collector.setResultSet(new TreeSet<>());
- collector.traverse();
- return collector.getResult();
- } catch (IllegalPathException e) {
- throw new IllegalPathException(pathPattern.getFullPath());
- }
- }
-
/** Get all paths from root to the given level */
@Override
public List<PartialPath> getNodesListInGivenLevel(
@@ -921,16 +829,6 @@ public class MTreeBelowSGMemoryImpl implements IMTreeBelowSG {
return counter.getCount();
}
- /**
- * Get the count of timeseries matching the given path.
- *
- * @param pathPattern a path pattern or a full path, may contain wildcard
- */
- @Override
- public long getAllTimeseriesCount(PartialPath pathPattern) throws MetadataException {
- return getAllTimeseriesCount(pathPattern, false);
- }
-
@Override
public long getAllTimeseriesCount(
PartialPath pathPattern, boolean isPrefixMatch, List<String> timeseries, boolean hasTag)
@@ -958,30 +856,6 @@ public class MTreeBelowSGMemoryImpl implements IMTreeBelowSG {
return counter.getCount();
}
- /**
- * Get the count of devices matching the given path.
- *
- * @param pathPattern a path pattern or a full path, may contain wildcard
- */
- @Override
- public long getDevicesNum(PartialPath pathPattern) throws MetadataException {
- return getDevicesNum(pathPattern, false);
- }
-
- /**
- * Get the count of nodes in the given level matching the given path. If using prefix match, the
- * path pattern is used to match prefix path. All timeseries start with the matched prefix path
- * will be counted.
- */
- @Override
- public long getNodesCountInGivenLevel(PartialPath pathPattern, int level, boolean isPrefixMatch)
- throws MetadataException {
- MNodeLevelCounter counter = new MNodeLevelCounter(storageGroupMNode, pathPattern, store, level);
- counter.setPrefixMatch(isPrefixMatch);
- counter.traverse();
- return counter.getCount();
- }
-
@Override
public Map<PartialPath, Long> getMeasurementCountGroupByLevel(
PartialPath pathPattern, int level, boolean isPrefixMatch) throws MetadataException {
diff --git a/server/src/main/java/org/apache/iotdb/db/metadata/schemaregion/SchemaRegionMemoryImpl.java b/server/src/main/java/org/apache/iotdb/db/metadata/schemaregion/SchemaRegionMemoryImpl.java
index 353b25e46d..7053d732e3 100644
--- a/server/src/main/java/org/apache/iotdb/db/metadata/schemaregion/SchemaRegionMemoryImpl.java
+++ b/server/src/main/java/org/apache/iotdb/db/metadata/schemaregion/SchemaRegionMemoryImpl.java
@@ -30,7 +30,6 @@ import org.apache.iotdb.commons.utils.FileUtils;
import org.apache.iotdb.consensus.ConsensusFactory;
import org.apache.iotdb.db.conf.IoTDBConfig;
import org.apache.iotdb.db.conf.IoTDBDescriptor;
-import org.apache.iotdb.db.exception.metadata.PathAlreadyExistException;
import org.apache.iotdb.db.exception.metadata.SchemaDirCreationFailureException;
import org.apache.iotdb.db.exception.metadata.SeriesNumberOverflowException;
import org.apache.iotdb.db.exception.metadata.SeriesOverflowException;
@@ -120,9 +119,7 @@ import static org.apache.iotdb.tsfile.common.constant.TsFileConstant.PATH_SEPARA
* <li>Interfaces for Entity/Device info Query
* <li>Interfaces for timeseries, measurement and schema info Query
* </ol>
- * <li>Interfaces and methods for MNode query
* <li>Interfaces for alias and tag/attribute operations
- * <li>Interfaces and Implementation for InsertPlan process
* <li>Interfaces and Implementation for Template operations
* </ol>
*/
@@ -1013,18 +1010,6 @@ public class SchemaRegionMemoryImpl implements ISchemaRegion {
return getMeasurementPathsWithAlias(pathPattern, 0, 0, isPrefixMatch, withTags).left;
}
- /**
- * Return all measurement paths for given path if the path is abstract. Or return the path itself.
- * Regular expression in this method is formed by the amalgamation of seriesPath and the character
- * '*'.
- *
- * @param pathPattern can be a pattern or a full path of timeseries.
- */
- public List<MeasurementPath> getMeasurementPaths(PartialPath pathPattern)
- throws MetadataException {
- return getMeasurementPaths(pathPattern, false, false);
- }
-
/**
* Similar to method getMeasurementPaths(), but return Path with alias and filter the result by
* limit and offset. If using prefix match, the path pattern is used to match prefix path. All
@@ -1151,28 +1136,6 @@ public class SchemaRegionMemoryImpl implements ISchemaRegion {
// endregion
// endregion
- // region Interfaces and methods for MNode query
-
- /**
- * Invoked during insertPlan process. Get target MeasurementMNode from given EntityMNode. If the
- * result is not null and is not MeasurementMNode, it means a timeseries with same path cannot be
- * created thus throw PathAlreadyExistException.
- */
- protected IMeasurementMNode getMeasurementMNode(IMNode deviceMNode, String measurementName)
- throws MetadataException {
- IMNode result = deviceMNode.getChild(measurementName);
- if (result == null) {
- return null;
- }
- if (result.isMeasurement()) {
- return result.getAsMeasurementMNode();
- } else {
- throw new PathAlreadyExistException(
- deviceMNode.getFullPath() + PATH_SEPARATOR + measurementName);
- }
- }
- // endregion
-
// region Interfaces for alias and tag/attribute operations
/**
* Set the new offset of a timeseries. Only used for Recover. When creating tags/attributes for a
diff --git a/server/src/main/java/org/apache/iotdb/db/metadata/schemaregion/SchemaRegionSchemaFileImpl.java b/server/src/main/java/org/apache/iotdb/db/metadata/schemaregion/SchemaRegionSchemaFileImpl.java
index 8fc8cf6795..e8b26f737f 100644
--- a/server/src/main/java/org/apache/iotdb/db/metadata/schemaregion/SchemaRegionSchemaFileImpl.java
+++ b/server/src/main/java/org/apache/iotdb/db/metadata/schemaregion/SchemaRegionSchemaFileImpl.java
@@ -28,8 +28,6 @@ import org.apache.iotdb.commons.path.PathPatternTree;
import org.apache.iotdb.consensus.ConsensusFactory;
import org.apache.iotdb.db.conf.IoTDBConfig;
import org.apache.iotdb.db.conf.IoTDBDescriptor;
-import org.apache.iotdb.db.exception.metadata.AliasAlreadyExistException;
-import org.apache.iotdb.db.exception.metadata.PathAlreadyExistException;
import org.apache.iotdb.db.exception.metadata.SchemaDirCreationFailureException;
import org.apache.iotdb.db.exception.metadata.SeriesNumberOverflowException;
import org.apache.iotdb.db.exception.metadata.SeriesOverflowException;
@@ -115,9 +113,7 @@ import static org.apache.iotdb.tsfile.common.constant.TsFileConstant.PATH_SEPARA
* <li>Interfaces for Entity/Device info Query
* <li>Interfaces for timeseries, measurement and schema info Query
* </ol>
- * <li>Interfaces and methods for MNode query
* <li>Interfaces for alias and tag/attribute operations
- * <li>Interfaces and Implementation for InsertPlan process
* <li>Interfaces and Implementation for Template operations
* </ol>
*/
@@ -606,35 +602,6 @@ public class SchemaRegionSchemaFileImpl implements ISchemaRegion {
}
}
- /**
- * Add one timeseries to metadata tree, if the timeseries already exists, throw exception
- *
- * @param path the timeseries path
- * @param dataType the dateType {@code DataType} of the timeseries
- * @param encoding the encoding function {@code Encoding} of the timeseries
- * @param compressor the compressor function {@code Compressor} of the time series
- */
- private void createTimeseries(
- PartialPath path,
- TSDataType dataType,
- TSEncoding encoding,
- CompressionType compressor,
- Map<String, String> props)
- throws MetadataException {
- try {
- createTimeseries(
- SchemaRegionWritePlanFactory.getCreateTimeSeriesPlan(
- path, dataType, encoding, compressor, props, null, null, null));
- } catch (PathAlreadyExistException | AliasAlreadyExistException e) {
- if (logger.isDebugEnabled()) {
- logger.debug(
- "Ignore PathAlreadyExistException and AliasAlreadyExistException when Concurrent inserting"
- + " a non-exist time series {}",
- path);
- }
- }
- }
-
public void createAlignedTimeSeries(
PartialPath prefixPath,
List<String> measurements,
@@ -1226,30 +1193,6 @@ public class SchemaRegionSchemaFileImpl implements ISchemaRegion {
// endregion
// endregion
- // region Interfaces and methods for MNode query
-
- /**
- * Invoked during insertPlan process. Get target MeasurementMNode from given EntityMNode. If the
- * result is not null and is not MeasurementMNode, it means a timeseries with same path cannot be
- * created thus throw PathAlreadyExistException.
- */
- protected IMeasurementMNode getMeasurementMNode(IMNode deviceMNode, String measurementName)
- throws MetadataException {
- IMNode result = mtree.getChildFromPinnedMNode(deviceMNode, measurementName);
- if (result == null) {
- return null;
- }
-
- mtree.unPinMNode(result);
- if (result.isMeasurement()) {
- return result.getAsMeasurementMNode();
- } else {
- throw new PathAlreadyExistException(
- deviceMNode.getFullPath() + PATH_SEPARATOR + measurementName);
- }
- }
- // endregion
-
// region Interfaces for alias and tag/attribute operations
/**
* Set the new offset of a timeseries. Only used for Recover. When creating tags/attributes for a
diff --git a/server/src/test/java/org/apache/iotdb/db/metadata/mtree/MTreeBelowSGTest.java b/server/src/test/java/org/apache/iotdb/db/metadata/mtree/MTreeBelowSGTest.java
index b89306282b..359ab39ff5 100644
--- a/server/src/test/java/org/apache/iotdb/db/metadata/mtree/MTreeBelowSGTest.java
+++ b/server/src/test/java/org/apache/iotdb/db/metadata/mtree/MTreeBelowSGTest.java
@@ -40,7 +40,6 @@ import org.junit.Before;
import org.junit.Test;
import java.io.IOException;
-import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashSet;
@@ -130,26 +129,6 @@ public abstract class MTreeBelowSGTest {
}
}
- @Test
- public void testAddAndPathExist() throws MetadataException {
- storageGroup = getStorageGroup(new PartialPath("root.laptop"));
- assertFalse(storageGroup.isPathExist(new PartialPath("root.laptop.d1")));
- try {
- storageGroup.createTimeseries(
- new PartialPath("root.laptop.d1.s1"),
- TSDataType.INT32,
- TSEncoding.RLE,
- TSFileDescriptor.getInstance().getConfig().getCompressor(),
- Collections.emptyMap(),
- null);
- } catch (MetadataException e1) {
- fail(e1.getMessage());
- }
- assertTrue(storageGroup.isPathExist(new PartialPath("root.laptop.d1")));
- assertTrue(storageGroup.isPathExist(new PartialPath("root.laptop")));
- assertFalse(storageGroup.isPathExist(new PartialPath("root.laptop.d1.s2")));
- }
-
@Test
public void testAddAndQueryPath() {
try {
@@ -202,13 +181,13 @@ public abstract class MTreeBelowSGTest {
try {
assertNotNull(storageGroup);
List<MeasurementPath> result =
- storageGroup.getMeasurementPaths(new PartialPath("root.a.*.s0"));
+ storageGroup.getMeasurementPaths(new PartialPath("root.a.*.s0"), false);
result.sort(Comparator.comparing(MeasurementPath::getFullPath));
assertEquals(2, result.size());
assertEquals("root.a.d0.s0", result.get(0).getFullPath());
assertEquals("root.a.d1.s0", result.get(1).getFullPath());
- result = storageGroup.getMeasurementPaths(new PartialPath("root.a.*.*.s0"));
+ result = storageGroup.getMeasurementPaths(new PartialPath("root.a.*.*.s0"), false);
assertEquals("root.a.b.d0.s0", result.get(0).getFullPath());
} catch (MetadataException e) {
e.printStackTrace();
@@ -269,13 +248,13 @@ public abstract class MTreeBelowSGTest {
assertNotNull(storageGroup);
List<MeasurementPath> result =
- storageGroup.getMeasurementPaths(new PartialPath("root.a.*.s0"));
+ storageGroup.getMeasurementPaths(new PartialPath("root.a.*.s0"), false);
result.sort(Comparator.comparing(MeasurementPath::getFullPath));
assertEquals(2, result.size());
assertEquals("root.a.d0.s0", result.get(0).getFullPath());
assertEquals("root.a.d1.s0", result.get(1).getFullPath());
- result = storageGroup.getMeasurementPaths(new PartialPath("root.a.*.temperature"));
+ result = storageGroup.getMeasurementPaths(new PartialPath("root.a.*.temperature"), false);
result.sort(Comparator.comparing(MeasurementPath::getFullPath));
assertEquals(2, result.size());
assertEquals("root.a.d0.s0", result.get(0).getFullPath());
@@ -313,50 +292,6 @@ public abstract class MTreeBelowSGTest {
}
}
- @Test
- public void testGetAllChildNodeNamesByPath() {
- try {
- storageGroup = getStorageGroup(new PartialPath("root.a"));
-
- storageGroup.createTimeseries(
- new PartialPath("root.a.d0.s0"),
- TSDataType.INT32,
- TSEncoding.RLE,
- TSFileDescriptor.getInstance().getConfig().getCompressor(),
- Collections.emptyMap(),
- null);
- storageGroup.createTimeseries(
- new PartialPath("root.a.d0.s1"),
- TSDataType.INT32,
- TSEncoding.RLE,
- TSFileDescriptor.getInstance().getConfig().getCompressor(),
- Collections.emptyMap(),
- null);
- storageGroup.createTimeseries(
- new PartialPath("root.a.d5"),
- TSDataType.INT32,
- TSEncoding.RLE,
- TSFileDescriptor.getInstance().getConfig().getCompressor(),
- Collections.emptyMap(),
- null);
-
- // getChildNodeByPath
- Set<String> result1 = storageGroup.getChildNodeNameInNextLevel(new PartialPath("root.a.d0"));
- Set<String> result2 = storageGroup.getChildNodeNameInNextLevel(new PartialPath("root.a"));
- assertEquals(new HashSet<>(Arrays.asList("s0", "s1")), result1);
- assertEquals(new HashSet<>(Arrays.asList("d0", "d5")), result2);
-
- // if child node is nll will return null HashSet
- Set<String> result3 = storageGroup.getChildNodeNameInNextLevel(new PartialPath("root.a.d5"));
- assertEquals(result3, new HashSet<>(Collections.emptyList()));
-
- Set<String> result4 = storageGroup.getChildNodeNameInNextLevel(new PartialPath("root"));
- assertEquals(new HashSet<>(Collections.singletonList("a")), result4);
- } catch (MetadataException e1) {
- e1.printStackTrace();
- }
- }
-
@Test
public void testSetStorageGroup() throws MetadataException {
try {
@@ -371,7 +306,6 @@ public abstract class MTreeBelowSGTest {
"root.laptop.d1",
root.getBelongedStorageGroup(new PartialPath("root.laptop.d1.s1")).getFullPath());
- assertFalse(storageGroup.isPathExist(new PartialPath("root.laptop.d1.s1")));
} catch (MetadataException e) {
e.printStackTrace();
fail(e.getMessage());
@@ -382,9 +316,6 @@ public abstract class MTreeBelowSGTest {
Assert.assertEquals(
"some children of root.laptop have already been created as database", e.getMessage());
}
- // check timeseries
- assertFalse(storageGroup.isPathExist(new PartialPath("root.laptop.d1.s0")));
- assertFalse(storageGroup.isPathExist(new PartialPath("root.laptop.d1.s1")));
try {
assertEquals(
@@ -417,7 +348,7 @@ public abstract class MTreeBelowSGTest {
e.printStackTrace();
fail(e.getMessage());
}
- assertFalse(storageGroup.isPathExist(new PartialPath("root.laptop.d1.s0")));
+
try {
root.deleteStorageGroup(new PartialPath("root.laptop.d1"));
} catch (MetadataException e) {
@@ -429,69 +360,6 @@ public abstract class MTreeBelowSGTest {
assertFalse(root.isStorageGroupAlreadySet(new PartialPath("root.laptop")));
}
- @Test
- public void testGetAllTimeseriesCount() {
- try {
- storageGroup = getStorageGroup(new PartialPath("root.laptop"));
- storageGroup.createTimeseries(
- new PartialPath("root.laptop.d1.s1"),
- TSDataType.INT32,
- TSEncoding.PLAIN,
- CompressionType.GZIP,
- null,
- null);
- storageGroup.createTimeseries(
- new PartialPath("root.laptop.d1.s2"),
- TSDataType.INT32,
- TSEncoding.PLAIN,
- CompressionType.GZIP,
- null,
- null);
- storageGroup.createTimeseries(
- new PartialPath("root.laptop.d2.s1"),
- TSDataType.INT32,
- TSEncoding.PLAIN,
- CompressionType.GZIP,
- null,
- null);
- storageGroup.createTimeseries(
- new PartialPath("root.laptop.d2.s2"),
- TSDataType.INT32,
- TSEncoding.PLAIN,
- CompressionType.GZIP,
- null,
- null);
-
- assertEquals(4, storageGroup.getAllTimeseriesCount(new PartialPath("root.laptop.**")));
- assertEquals(2, storageGroup.getAllTimeseriesCount(new PartialPath("root.laptop.*.s1")));
- assertEquals(0, storageGroup.getAllTimeseriesCount(new PartialPath("root.laptop.d1.s3")));
-
- assertEquals(
- 1,
- storageGroup.getNodesCountInGivenLevel(new PartialPath("root.laptop.**.s1"), 1, false));
- assertEquals(
- 1, storageGroup.getNodesCountInGivenLevel(new PartialPath("root.laptop.*.*"), 1, false));
- assertEquals(
- 2, storageGroup.getNodesCountInGivenLevel(new PartialPath("root.laptop.*.*"), 2, false));
- assertEquals(
- 2, storageGroup.getNodesCountInGivenLevel(new PartialPath("root.laptop.*"), 2, false));
- assertEquals(
- 4, storageGroup.getNodesCountInGivenLevel(new PartialPath("root.laptop.*.*"), 3, false));
- assertEquals(
- 2, storageGroup.getNodesCountInGivenLevel(new PartialPath("root.laptop.**"), 2, false));
- assertEquals(
- 4, storageGroup.getNodesCountInGivenLevel(new PartialPath("root.laptop.**"), 3, false));
- assertEquals(
- 2, storageGroup.getNodesCountInGivenLevel(new PartialPath("root.laptop.d1.*"), 3, false));
- assertEquals(
- 0,
- storageGroup.getNodesCountInGivenLevel(new PartialPath("root.laptop.d1.**"), 4, false));
- } catch (MetadataException e) {
- e.printStackTrace();
- fail(e.getMessage());
- }
- }
-
@Test
public void testAddSubDevice() throws MetadataException {
storageGroup = getStorageGroup(new PartialPath("root.laptop"));
@@ -512,8 +380,6 @@ public abstract class MTreeBelowSGTest {
assertEquals(2, storageGroup.getDevices(new PartialPath("root"), true).size());
assertEquals(2, storageGroup.getDevices(new PartialPath("root.**"), false).size());
- assertEquals(2, storageGroup.getAllTimeseriesCount(new PartialPath("root.**")));
- assertEquals(2, storageGroup.getMeasurementPaths(new PartialPath("root.**")).size());
assertEquals(
2,
storageGroup
@@ -621,22 +487,22 @@ public abstract class MTreeBelowSGTest {
null,
null);
- Assert.assertEquals(0, storageGroup.getDevicesNum(new PartialPath("root")));
- Assert.assertEquals(1, storageGroup.getDevicesNum(new PartialPath("root.laptop")));
- Assert.assertEquals(0, storageGroup.getDevicesNum(new PartialPath("root.laptop.s1")));
- Assert.assertEquals(1, storageGroup.getDevicesNum(new PartialPath("root.laptop.d1")));
- Assert.assertEquals(2, storageGroup.getDevicesNum(new PartialPath("root.laptop.*")));
- Assert.assertEquals(2, storageGroup.getDevicesNum(new PartialPath("root.laptop.*.*")));
- Assert.assertEquals(0, storageGroup.getDevicesNum(new PartialPath("root.laptop.*.*.*")));
- Assert.assertEquals(4, storageGroup.getDevicesNum(new PartialPath("root.laptop.**")));
- Assert.assertEquals(5, storageGroup.getDevicesNum(new PartialPath("root.**")));
- Assert.assertEquals(4, storageGroup.getDevicesNum(new PartialPath("root.**.*")));
- Assert.assertEquals(4, storageGroup.getDevicesNum(new PartialPath("root.*.**")));
- Assert.assertEquals(2, storageGroup.getDevicesNum(new PartialPath("root.**.d1")));
- Assert.assertEquals(1, storageGroup.getDevicesNum(new PartialPath("root.laptop.*.d1")));
- Assert.assertEquals(3, storageGroup.getDevicesNum(new PartialPath("root.**.d*")));
- Assert.assertEquals(1, storageGroup.getDevicesNum(new PartialPath("root.laptop.**.s1")));
- Assert.assertEquals(1, storageGroup.getDevicesNum(new PartialPath("root.*.d2.*")));
+ Assert.assertEquals(0, storageGroup.getDevicesNum(new PartialPath("root"), false));
+ Assert.assertEquals(1, storageGroup.getDevicesNum(new PartialPath("root.laptop"), false));
+ Assert.assertEquals(0, storageGroup.getDevicesNum(new PartialPath("root.laptop.s1"), false));
+ Assert.assertEquals(1, storageGroup.getDevicesNum(new PartialPath("root.laptop.d1"), false));
+ Assert.assertEquals(2, storageGroup.getDevicesNum(new PartialPath("root.laptop.*"), false));
+ Assert.assertEquals(2, storageGroup.getDevicesNum(new PartialPath("root.laptop.*.*"), false));
+ Assert.assertEquals(0, storageGroup.getDevicesNum(new PartialPath("root.laptop.*.*.*"), false));
+ Assert.assertEquals(4, storageGroup.getDevicesNum(new PartialPath("root.laptop.**"), false));
+ Assert.assertEquals(5, storageGroup.getDevicesNum(new PartialPath("root.**"), false));
+ Assert.assertEquals(4, storageGroup.getDevicesNum(new PartialPath("root.**.*"), false));
+ Assert.assertEquals(4, storageGroup.getDevicesNum(new PartialPath("root.*.**"), false));
+ Assert.assertEquals(2, storageGroup.getDevicesNum(new PartialPath("root.**.d1"), false));
+ Assert.assertEquals(1, storageGroup.getDevicesNum(new PartialPath("root.laptop.*.d1"), false));
+ Assert.assertEquals(3, storageGroup.getDevicesNum(new PartialPath("root.**.d*"), false));
+ Assert.assertEquals(1, storageGroup.getDevicesNum(new PartialPath("root.laptop.**.s1"), false));
+ Assert.assertEquals(1, storageGroup.getDevicesNum(new PartialPath("root.*.d2.*"), false));
}
@Test
@@ -695,46 +561,6 @@ public abstract class MTreeBelowSGTest {
2, storageGroup.getNodesListInGivenLevel(new PartialPath("root.*.*.s1"), 2, false).size());
}
- @Test
- public void testGetDeviceForTimeseries() throws MetadataException {
- storageGroup = getStorageGroup(new PartialPath("root.sg"));
- storageGroup.createTimeseries(
- new PartialPath("root.sg.a1.d1.s1"),
- TSDataType.INT32,
- TSEncoding.PLAIN,
- CompressionType.GZIP,
- null,
- null);
- storageGroup.createTimeseries(
- new PartialPath("root.sg.a1.d1.s2"),
- TSDataType.INT32,
- TSEncoding.PLAIN,
- CompressionType.GZIP,
- null,
- null);
-
- storageGroup.createTimeseries(
- new PartialPath("root.sg.a2.d2.s1"),
- TSDataType.INT32,
- TSEncoding.PLAIN,
- CompressionType.GZIP,
- null,
- null);
- storageGroup.createTimeseries(
- new PartialPath("root.sg.a2.d2.s2"),
- TSDataType.INT32,
- TSEncoding.PLAIN,
- CompressionType.GZIP,
- null,
- null);
-
- Assert.assertEquals(2, storageGroup.getDevicesByTimeseries(new PartialPath("root.**")).size());
- Assert.assertEquals(
- 1, storageGroup.getDevicesByTimeseries(new PartialPath("root.*.*.d1.*")).size());
- Assert.assertEquals(
- 2, storageGroup.getDevicesByTimeseries(new PartialPath("root.*.*.d*.*")).size());
- }
-
@Test
public void testGetMeasurementCountGroupByLevel() throws Exception {
storageGroup = getStorageGroup(new PartialPath("root.sg"));