tkalkirill commented on a change in pull request #290:
URL: https://github.com/apache/ignite-3/pull/290#discussion_r699018149
##########
File path:
modules/configuration/src/main/java/org/apache/ignite/internal/configuration/asm/ConfigurationAsmGenerator.java
##########
@@ -291,26 +318,44 @@ public synchronized void compileRootSchema(Class<?>
rootSchemaClass) {
}
}
- private ClassDefinition createNodeClass(Class<?> schemaClass) {
+ /**
+ * Construct a {@link InnerNode} definition for a configuration schema.
+ *
+ * @param schemaClass Configuration schema class.
+ * @param schemaFields Fields of the schema and its extensions.
+ * @param schemaExtensions Internal extensions of the configuration schema.
+ * @return Constructed {@link InnerNode} definition for the configuration
schema.
+ */
+ private ClassDefinition createNodeClass(
+ Class<?> schemaClass,
+ Set<Field> schemaFields,
+ Set<Class<?>> schemaExtensions
+ ) {
SchemaClassesInfo schemaClassInfo = schemasInfo.get(schemaClass);
+ ParameterizedType[] interfaces = union(schemaExtensions,
schemaClass).stream()
+ .flatMap(cls -> Stream.of(prefix(cls) + VIEW_CLASS_POSTFIX,
prefix(cls) + CHANGE_CLASS_POSTFIX))
+ .map(ParameterizedType::typeFromJavaClassName)
+ .toArray(ParameterizedType[]::new);
+
// Node class definition.
ClassDefinition classDef = new ClassDefinition(
of(PUBLIC, FINAL),
internalName(schemaClassInfo.nodeClassName),
type(InnerNode.class),
- typeFromJavaClassName(schemaClassInfo.viewClassName),
- typeFromJavaClassName(schemaClassInfo.changeClassName)
+ interfaces
);
- // Spec field.
- FieldDefinition specField = classDef.declareField(of(PRIVATE, FINAL),
"_spec", schemaClass);
+ // Spec fields.
+ Map<Class<?>, FieldDefinition> specFields = new HashMap<>();
- // org.apache.ignite.internal.configuration.tree.InnerNode#schemaType
- addNodeSchemaTypeMethod(classDef, specField);
+ int i = 0;
- // Cached array of reflected fields. Helps to avoid unnecessary
clonings.
- Field[] schemaFields = schemaClass.getDeclaredFields();
+ for (Class<?> schemaCls : union(schemaExtensions, schemaClass))
+ specFields.put(schemaCls, classDef.declareField(of(PRIVATE,
FINAL), "_spec" + i++, schemaCls));
Review comment:
I suggest leaving it as it is.
--
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]