sashapolo commented on a change in pull request #425:
URL: https://github.com/apache/ignite-3/pull/425#discussion_r748054521



##########
File path: modules/configuration/README.md
##########
@@ -59,6 +147,8 @@ public static class ChildConfigurationSchema {
   * `rootName` property assigns a _key_ to the root node of the tree that will 
represent 
     the corresponding configuration schema;
 * `@Config` is similar to the `@ConfigurationRoot` but represents an inner 
configuration node;
+* `@PolymorphicConfig` is similar to the `@Config` and abstract class in java 
i.e. cannot be instantiated, but they can be subclassed;

Review comment:
       ```suggestion
   * `@PolymorphicConfig` is similar to the `@Config` and an abstract class in 
java, i.e. it cannot be instantiated, but it can be subclassed;
   ```

##########
File path: modules/configuration/README.md
##########
@@ -59,6 +147,8 @@ public static class ChildConfigurationSchema {
   * `rootName` property assigns a _key_ to the root node of the tree that will 
represent 
     the corresponding configuration schema;
 * `@Config` is similar to the `@ConfigurationRoot` but represents an inner 
configuration node;
+* `@PolymorphicConfig` is similar to the `@Config` and abstract class in java 
i.e. cannot be instantiated, but they can be subclassed;
+* `@PolymorphicConfigInstance` marks the inheritor of a polymorphic 
configuration, has the only property `value`, which is a unique identifier;

Review comment:
       ```suggestion
   * `@PolymorphicConfigInstance` marks an inheritor of a polymorphic 
configuration. This annotation has a single property called `value`, which is a 
unique identifier;
   ```

##########
File path: modules/configuration/README.md
##########
@@ -68,6 +158,7 @@ public static class ChildConfigurationSchema {
   has been provided explicitly. This annotation can only be present on fields 
of the Java primitive or `String` type.
     
   All _leaves_ must be public and corresponding configuration values **must 
not be null**;
+* `@PolymorphicId` is similar to the `@Value` but is used to storing the type 
of polymorphic configuration (`@PolymorphicConfigInstance#value`), must be 
`String` and first in the schema;

Review comment:
       ```suggestion
   * `@PolymorphicId` is similar to the `@Value`, but is used to store the type 
of polymorphic configuration (`@PolymorphicConfigInstance#value`), must be a 
`String` and placed as the first field in a schema;
   ```

##########
File path: modules/configuration/README.md
##########
@@ -14,6 +14,79 @@ internal implementations to avoid writing boilerplate code.
 
 All schema classes must end with the `ConfigurationSchema` suffix.
 
+### Polymorphic configuration
+
+This is the ability to create various forms of the same configuration. 
+
+Let's take an example of a sql column configuration, suppose it can be of the 
following types:
+* varchar(max) - string with the maximum length;

Review comment:
       ```suggestion
   * varchar(max) - string with a maximum length;
   ```

##########
File path: modules/configuration/README.md
##########
@@ -14,6 +14,79 @@ internal implementations to avoid writing boilerplate code.
 
 All schema classes must end with the `ConfigurationSchema` suffix.
 
+### Polymorphic configuration

Review comment:
       Actually, when working with this type of configuration I found out that 
you also need to explicitly pass a list of all polymorphic extensions to the 
`ConfigurationRegistry`. This is not documented anywhere, as far as I know

##########
File path: modules/configuration/README.md
##########
@@ -153,6 +281,17 @@ ChildConfiguration childCfg = parentCfg.child();
 childCfg.changeStr("newStr2").get();
 ```
 
+Example of changing the type of polymorphic configuration:

Review comment:
       ```suggestion
   Example of changing the type of a polymorphic configuration:
   ```

##########
File path: modules/configuration/README.md
##########
@@ -59,6 +147,8 @@ public static class ChildConfigurationSchema {
   * `rootName` property assigns a _key_ to the root node of the tree that will 
represent 
     the corresponding configuration schema;
 * `@Config` is similar to the `@ConfigurationRoot` but represents an inner 
configuration node;
+* `@PolymorphicConfig` is similar to the `@Config` and abstract class in java 
i.e. cannot be instantiated, but they can be subclassed;
+* `@PolymorphicConfigInstance` marks the inheritor of a polymorphic 
configuration, has the only property `value`, which is a unique identifier;

Review comment:
       It will be useful to describe how is this identifier going to be used 
and how unique it actually need to be (e.g. is it universally unique or only 
among subclasses of a single schema?)

##########
File path: modules/configuration/README.md
##########
@@ -14,6 +14,79 @@ internal implementations to avoid writing boilerplate code.
 
 All schema classes must end with the `ConfigurationSchema` suffix.
 
+### Polymorphic configuration
+
+This is the ability to create various forms of the same configuration. 
+
+Let's take an example of a sql column configuration, suppose it can be of the 
following types:
+* varchar(max) - string with the maximum length;
+* decimal(p,s) - decimal number with fixed precision(p) and scale(s);
+* datetime(fsp) - date and time with fractional seconds precision(fsp).
+
+If you do not use polymorphic configuration, then the scheme will be something 
like this:
+
+```java
+@Config
+public static class ColumnConfigurationSchema { 
+    @Value
+    public String type;
+
+    @Value
+    public String name;
+    
+    @Value
+    public int maxLength;
+
+    @Value
+    public int precision;
+
+    @Value
+    public int scale;
+
+    @Value
+    public int fsp;
+}
+```
+
+Such a scheme is redundant and can be confusing when using it, since it is not 
obvious which fields 
+are needed for each type of column, to solve these problems, you can use a 
polymorphic configuration 

Review comment:
       ```suggestion
   are needed for each type of column. Instead, one can use a polymorphic 
configuration 
   ```

##########
File path: modules/configuration/README.md
##########
@@ -14,6 +14,79 @@ internal implementations to avoid writing boilerplate code.
 
 All schema classes must end with the `ConfigurationSchema` suffix.
 
+### Polymorphic configuration
+
+This is the ability to create various forms of the same configuration. 
+
+Let's take an example of a sql column configuration, suppose it can be of the 
following types:
+* varchar(max) - string with the maximum length;
+* decimal(p,s) - decimal number with fixed precision(p) and scale(s);
+* datetime(fsp) - date and time with fractional seconds precision(fsp).

Review comment:
       ```suggestion
   * datetime(fsp) - date and time with a fractional seconds precision (fsp).
   ```

##########
File path: modules/configuration/README.md
##########
@@ -112,37 +218,59 @@ public interface ParentView {
     NamedListView<? extends NamedElementView> elements();
 
     ChildView child();
+
+    PolymorphicView polymorphicChild();
 }
 
 public interface ChildView {
     String str();
 }
+
+public interface PolymorphicView {
+    String typeId();
+}
+
+public interface FirstPolymorphicInstanceView extends PolymorphicView {
+    int intVal();
+}
 ```
 
+`ParentView#polymorphicChild()` will return a view of a specific type of 
polymorphic configuration, for example `FirstPolymorphicInstanceView`.
+
 ### Changing the configuration
 
 To modify the configuration tree, one should use the `change` method, which 
executes the update requests 
 asynchronously and in a transactional manner. Update requests are represented 
by a set of `Change` interfaces.
 For the example above, the following interfaces would be generated:
 
 ```java
-public interface ParentChange {
+public interface ParentChange extends ParentView { 
     ParentChange changeElements(Consumer<NamedListChange<NamedElementChange>> 
elements);
 
     ParentChange changeChild(Consumer<ChildChange> child);
+
+    ParentChange changePolymorphicChild(Consumer<PolymorphicChange> 
polymorphicChild);
 }
 
-public interface ChildChange {
+public interface ChildChange extends ChildView {
     ChildChange changeStr(String str);
 }
+
+public interface PolymorphicChange extends FirstPolymorphicView {
+    <T extends PolymorphicChange> T convert(Class<T> changeClass);
+}
+
+public interface FirstPolymorphicInstanceChange extends 
FirstPolymorphicInstanceView, PolymorphicChange {
+    FirstPolymorphicInstanceChange changeIntVal(int intVal);
+}
 ```
 
-For example, to update all child nodes of the parent configuration in a single 
transaction:
+Example of updating of all child nodes of the parent configuration in a single 
transaction:

Review comment:
       ```suggestion
   Example of updating all child nodes of the parent configuration in a single 
transaction:
   ```

##########
File path: modules/configuration/README.md
##########
@@ -14,6 +14,79 @@ internal implementations to avoid writing boilerplate code.
 
 All schema classes must end with the `ConfigurationSchema` suffix.
 
+### Polymorphic configuration
+
+This is the ability to create various forms of the same configuration. 
+
+Let's take an example of a sql column configuration, suppose it can be of the 
following types:

Review comment:
       ```suggestion
   Let's take an example of an SQL column configuration, suppose it can be one 
of the following types:
   ```

##########
File path: modules/configuration/README.md
##########
@@ -14,6 +14,79 @@ internal implementations to avoid writing boilerplate code.
 
 All schema classes must end with the `ConfigurationSchema` suffix.
 
+### Polymorphic configuration
+
+This is the ability to create various forms of the same configuration. 
+
+Let's take an example of a sql column configuration, suppose it can be of the 
following types:
+* varchar(max) - string with the maximum length;
+* decimal(p,s) - decimal number with fixed precision(p) and scale(s);

Review comment:
       ```suggestion
   * decimal(p,s) - decimal number with a fixed precision (p) and a scale (s);
   ```

##########
File path: modules/configuration/README.md
##########
@@ -14,6 +14,79 @@ internal implementations to avoid writing boilerplate code.
 
 All schema classes must end with the `ConfigurationSchema` suffix.
 
+### Polymorphic configuration
+
+This is the ability to create various forms of the same configuration. 
+
+Let's take an example of a sql column configuration, suppose it can be of the 
following types:
+* varchar(max) - string with the maximum length;
+* decimal(p,s) - decimal number with fixed precision(p) and scale(s);
+* datetime(fsp) - date and time with fractional seconds precision(fsp).
+
+If you do not use polymorphic configuration, then the scheme will be something 
like this:

Review comment:
       ```suggestion
   If you do not use polymorphic configuration, then the scheme will look 
something like this:
   ```




-- 
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]


Reply via email to