korlov42 commented on a change in pull request #194:
URL: https://github.com/apache/ignite-3/pull/194#discussion_r670380842
##########
File path:
modules/schema/src/main/java/org/apache/ignite/internal/schema/registry/SchemaRegistryImpl.java
##########
@@ -106,9 +114,37 @@ public SchemaRegistryImpl(int initialVer,
Function<Integer, SchemaDescriptor> hi
if (curSchema.version() == rowSchema.version())
return new Row(rowSchema, row);
- assert rowSchema.version() == curSchema.version() + 1; // TODO:
IGNITE-14864 implement merged mapper for arbitraty schema versions.
+ assert curSchema.version() >= rowSchema.version();
+
+ ColumnMapper mapping = resolveMapping(rowSchema, curSchema);
+
+ return new UpgradingRowAdapter(curSchema, row, mapping);
+ }
+
+ /**
+ * @param rowSchema Row schema.
+ * @param curSchema Target schema.
+ * @return Column mapper for target schema.
+ */
+ public ColumnMapper resolveMapping(SchemaDescriptor rowSchema,
SchemaDescriptor curSchema) {
Review comment:
why do we need it public?
##########
File path:
modules/schema/src/main/java/org/apache/ignite/internal/schema/registry/SchemaRegistryImpl.java
##########
@@ -106,9 +114,37 @@ public SchemaRegistryImpl(int initialVer,
Function<Integer, SchemaDescriptor> hi
if (curSchema.version() == rowSchema.version())
return new Row(rowSchema, row);
- assert rowSchema.version() == curSchema.version() + 1; // TODO:
IGNITE-14864 implement merged mapper for arbitraty schema versions.
+ assert curSchema.version() >= rowSchema.version();
+
+ ColumnMapper mapping = resolveMapping(rowSchema, curSchema);
+
+ return new UpgradingRowAdapter(curSchema, row, mapping);
+ }
+
+ /**
+ * @param rowSchema Row schema.
+ * @param curSchema Target schema.
+ * @return Column mapper for target schema.
+ */
+ public ColumnMapper resolveMapping(SchemaDescriptor rowSchema,
SchemaDescriptor curSchema) {
+ if (curSchema.version() == rowSchema.version() + 1)
+ return curSchema.columnMapping();
+
+ final long mappingKey = (((long)curSchema.version()) << 32) &
(rowSchema.version());
+
+ ColumnMapper mapping;
+
+ if ((mapping = mappingCache.get(mappingKey)) != null)
+ return mapping;
+
+ mapping = schema(rowSchema.version() + 1).columnMapping();
+
+ for (int i = rowSchema.version() + 2; i <= curSchema.version(); i++)
+ mapping = ColumnMapping.mergeMapping(mapping, schema(i));
+
+ mappingCache.putIfAbsent(mappingKey, mapping);
Review comment:
we need to remove corresponding mappings when old schema is dropped
##########
File path:
modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/AbstractSchemaChangeTest.java
##########
@@ -93,6 +98,96 @@ void afterEach() throws Exception {
IgniteUtils.closeAll(clusterNodes);
}
+ /**
+ * Check unsupported column type change.
+ */
+ @Disabled("https://issues.apache.org/jira/browse/IGNITE-15056")
+ @Test
+ public void testChangeColumnType() {
+ List<Ignite> grid = startGrid();
+
+ createTable(grid);
+
+ SchemaBuilders.column("valInt", ColumnType.string()).build();
Review comment:
here and below result of this line is ignored
##########
File path:
modules/schema/src/main/java/org/apache/ignite/internal/schema/registry/SchemaRegistryImpl.java
##########
@@ -106,9 +114,37 @@ public SchemaRegistryImpl(int initialVer,
Function<Integer, SchemaDescriptor> hi
if (curSchema.version() == rowSchema.version())
return new Row(rowSchema, row);
- assert rowSchema.version() == curSchema.version() + 1; // TODO:
IGNITE-14864 implement merged mapper for arbitraty schema versions.
+ assert curSchema.version() >= rowSchema.version();
+
+ ColumnMapper mapping = resolveMapping(rowSchema, curSchema);
+
+ return new UpgradingRowAdapter(curSchema, row, mapping);
+ }
+
+ /**
+ * @param rowSchema Row schema.
+ * @param curSchema Target schema.
+ * @return Column mapper for target schema.
+ */
+ public ColumnMapper resolveMapping(SchemaDescriptor rowSchema,
SchemaDescriptor curSchema) {
Review comment:
to make this method complete it worth to handle case when both versions
are equal:
```
if (curSchema.version() == rowSchema.version())
return ColumnMapping.identityMapping();
```
--
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]