use of org.apache.ignite.schema.definition.index.SortedIndexColumnDefinition in project ignite-3 by apache.
the class SchemaConfigurationConverter method convert.
/**
* Convert TableIndex to TableIndexChange.
*
* @param idx TableIndex.
* @param idxChg TableIndexChange to fulfill.
* @return TableIndexChange to get result from.
*/
public static TableIndexChange convert(IndexDefinition idx, TableIndexChange idxChg) {
idxChg.changeName(idx.name());
switch(idx.type().toUpperCase()) {
case HASH_INDEX_TYPE:
HashIndexDefinition hashIdx = (HashIndexDefinition) idx;
String[] colNames = hashIdx.columns().stream().map(IndexColumnDefinition::name).toArray(String[]::new);
return idxChg.convert(HashIndexChange.class).changeColNames(colNames);
case PARTIAL_INDEX_TYPE:
PartialIndexDefinition partIdx = (PartialIndexDefinition) idx;
return idxChg.changeUniq(partIdx.unique()).convert(PartialIndexChange.class).changeExpr(partIdx.expr()).changeColumns(colsChg -> {
for (SortedIndexColumnDefinition col : partIdx.columns()) {
colsChg.create(col.name(), colInit -> convert(col, colInit));
}
});
case SORTED_INDEX_TYPE:
SortedIndexDefinition sortIdx = (SortedIndexDefinition) idx;
return idxChg.changeUniq(sortIdx.unique()).convert(SortedIndexChange.class).changeColumns(colsInit -> {
for (SortedIndexColumnDefinition col : sortIdx.columns()) {
colsInit.create(col.name(), colInit -> convert(col, colInit));
}
});
default:
throw new IllegalArgumentException("Unknown index type " + idx.type());
}
}
Aggregations