Search in sources :

Example 1 with TableIndexView

use of org.apache.ignite.configuration.schemas.table.TableIndexView in project ignite-3 by apache.

the class TableValidatorImpl method validateNamedListKeys.

/**
 * Checks that columns and indices are stored under their names in the corresponding Named Lists, i.e. their Named List keys and names
 * are the same.
 *
 * @param table Table configuration view.
 * @param ctx Validation context.
 */
private static void validateNamedListKeys(TableView table, ValidationContext<NamedListView<TableView>> ctx) {
    NamedListView<? extends ColumnView> columns = table.columns();
    for (String key : columns.namedListKeys()) {
        ColumnView column = columns.get(key);
        if (!column.name().equals(key)) {
            var issue = new ValidationIssue(String.format("Column name \"%s\" does not match its Named List key: \"%s\"", column.name(), key));
            ctx.addIssue(issue);
        }
    }
    NamedListView<? extends TableIndexView> indices = table.indices();
    for (String key : indices.namedListKeys()) {
        TableIndexView index = indices.get(key);
        if (!index.name().equals(key)) {
            var issue = new ValidationIssue(String.format("Index name \"%s\" does not match its Named List key: \"%s\"", index.name(), key));
            ctx.addIssue(issue);
        }
    }
}
Also used : ColumnView(org.apache.ignite.configuration.schemas.table.ColumnView) TableIndexView(org.apache.ignite.configuration.schemas.table.TableIndexView) ValidationIssue(org.apache.ignite.configuration.validation.ValidationIssue)

Aggregations

ColumnView (org.apache.ignite.configuration.schemas.table.ColumnView)1 TableIndexView (org.apache.ignite.configuration.schemas.table.TableIndexView)1 ValidationIssue (org.apache.ignite.configuration.validation.ValidationIssue)1