use of org.apache.ignite.internal.schema.definition.TableDefinitionImpl in project ignite-3 by apache.
the class SchemaConfigurationConverter method convert.
/**
* Convert table configuration view to table schema.
*
* @param tblView TableView to convert.
* @return Table schema.
*/
public static TableDefinitionImpl convert(TableView tblView) {
String canonicalName = tblView.name();
int sepPos = canonicalName.indexOf('.');
String schemaName = canonicalName.substring(0, sepPos);
String tableName = canonicalName.substring(sepPos + 1);
NamedListView<? extends ColumnView> colsView = tblView.columns();
var columns = new LinkedHashMap<String, ColumnDefinition>(capacity(colsView.size()));
for (String key : colsView.namedListKeys()) {
ColumnView colView = colsView.get(key);
if (colView != null) {
ColumnDefinition definition = convert(colView);
columns.put(definition.name(), definition);
}
}
NamedListView<? extends TableIndexView> idxsView = tblView.indices();
var indices = new HashMap<String, IndexDefinition>(capacity(idxsView.size()));
for (String key : idxsView.namedListKeys()) {
IndexDefinition definition = convert(idxsView.get(key));
indices.put(definition.name(), definition);
}
PrimaryKeyDefinition primaryKey = convert(tblView.primaryKey());
return new TableDefinitionImpl(schemaName, tableName, columns, primaryKey, indices);
}
use of org.apache.ignite.internal.schema.definition.TableDefinitionImpl in project ignite-3 by apache.
the class TableValidatorImpl method validate.
/**
* {@inheritDoc}
*/
@Override
public void validate(TableValidator annotation, ValidationContext<NamedListView<TableView>> ctx) {
NamedListView<TableView> oldTables = ctx.getOldValue();
NamedListView<TableView> newTables = ctx.getNewValue();
for (String tableName : newTables.namedListKeys()) {
TableView newTable = newTables.get(tableName);
try {
TableDefinitionImpl tbl = SchemaConfigurationConverter.convert(newTable);
assert !tbl.keyColumns().isEmpty();
assert !tbl.colocationColumns().isEmpty();
TableDefinitionBuilderImpl.validateIndices(tbl.indices(), tbl.columns(), tbl.colocationColumns());
} catch (IllegalArgumentException e) {
ctx.addIssue(new ValidationIssue("Validator works success by key " + ctx.currentKey() + ". Found " + newTable.columns().size() + " columns"));
}
validateDataRegion(oldTables == null ? null : oldTables.get(tableName), newTable, ctx);
validateNamedListKeys(newTable, ctx);
}
}
Aggregations