You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ja...@apache.org on 2023/08/18 07:01:17 UTC
[iotdb] 01/01: Make View Portable
This is an automated email from the ASF dual-hosted git repository.
jackietien pushed a commit to branch MakeViewPortable
in repository https://gitbox.apache.org/repos/asf/iotdb.git
commit 920af6454eab3afa71c93e882af4d7e18c30181a
Author: JackieTien97 <ja...@gmail.com>
AuthorDate: Fri Aug 18 15:01:04 2023 +0800
Make View Portable
---
.../mtree/loader/MNodeFactoryLoader.java | 21 ++++++++++++++++++---
.../commons/schema/node/utils/MNodeFactory.java | 7 +++++++
2 files changed, 25 insertions(+), 3 deletions(-)
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/schemaregion/mtree/loader/MNodeFactoryLoader.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/schemaregion/mtree/loader/MNodeFactoryLoader.java
index 4c492aa860e..bad8700b398 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/schemaregion/mtree/loader/MNodeFactoryLoader.java
+++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/schemaregion/mtree/loader/MNodeFactoryLoader.java
@@ -87,27 +87,42 @@ public class MNodeFactoryLoader {
new Reflections(
new ConfigurationBuilder().forPackages(scanPackages.toArray(new String[0])));
Set<Class<?>> nodeFactorySet = reflections.getTypesAnnotatedWith(MNodeFactory.class);
+ IMNodeFactory res = null;
+ int priority = Integer.MIN_VALUE;
for (Class<?> nodeFactory : nodeFactorySet) {
if (isGenericMatch(nodeFactory, nodeType) && isEnvMatch(nodeFactory, env)) {
try {
- return (IMNodeFactory) nodeFactory.getDeclaredConstructor().newInstance();
+ MNodeFactory annotationInfo = nodeFactory.getAnnotation(MNodeFactory.class);
+ if (annotationInfo.priority() > priority) {
+ res = (IMNodeFactory) nodeFactory.getDeclaredConstructor().newInstance();
+ }
} catch (Exception e) {
throw new SchemaExecutionException(e);
}
}
}
+ if (res != null) {
+ return res;
+ }
// if no satisfied MNodeFactory in customer env found, use default env
for (Class<?> nodeFactory : nodeFactorySet) {
if (isGenericMatch(nodeFactory, nodeType)
&& isEnvMatch(nodeFactory, SchemaConstant.DEFAULT_MNODE_FACTORY_ENV)) {
try {
- return (IMNodeFactory) nodeFactory.getDeclaredConstructor().newInstance();
+ MNodeFactory annotationInfo = nodeFactory.getAnnotation(MNodeFactory.class);
+ if (annotationInfo.priority() > priority) {
+ res = (IMNodeFactory) nodeFactory.getDeclaredConstructor().newInstance();
+ }
} catch (Exception e) {
throw new SchemaExecutionException(e);
}
}
}
- throw new SchemaExecutionException("No satisfied MNodeFactory found");
+ if (res != null) {
+ return res;
+ } else {
+ throw new SchemaExecutionException("No satisfied MNodeFactory found");
+ }
}
public boolean isGenericMatch(Class<?> factory, Class<?> targetType) {
diff --git a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/schema/node/utils/MNodeFactory.java b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/schema/node/utils/MNodeFactory.java
index 7da691a05ab..8b9674d42b9 100644
--- a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/schema/node/utils/MNodeFactory.java
+++ b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/schema/node/utils/MNodeFactory.java
@@ -28,4 +28,11 @@ import java.lang.annotation.Target;
@Target(ElementType.TYPE)
public @interface MNodeFactory {
String env() default "IoTDB";
+
+ /**
+ * The higher the number, the higher the priority.
+ *
+ * @return the priority of this class.
+ */
+ int priority() default 0;
}