use of org.apache.ignite.schema.definition.index.SortOrder in project ignite-3 by apache.
the class SchemaConfigurationConverterTest method testUniqueIndexDetection.
/**
* Detect an index containing affinity key as unique one.
*/
@Disabled("https://issues.apache.org/jira/browse/IGNITE-15483")
@Test
public void testUniqueIndexDetection() throws Exception {
SortedIndexDefinition idx = SchemaBuilders.sortedIndex("uniq_sorted").addIndexColumn("A").done().addIndexColumn("COL1").desc().done().build();
getTbl().change(ch -> SchemaConfigurationConverter.addIndex(idx, ch)).get();
TableDefinition tbl = SchemaConfigurationConverter.convert(getTbl().value());
SortedIndexDefinition idx2 = (SortedIndexDefinition) getIdx(idx.name(), tbl.indices());
assertNotNull(idx2);
assertEquals("uniq_sorted", idx2.name());
assertEquals("SORTED", idx2.type());
assertTrue(idx2.unique());
assertEquals(2, idx2.columns().size());
assertEquals("A", idx2.columns().get(0).name());
assertEquals("COL1", idx2.columns().get(1).name());
assertEquals(SortOrder.ASC, idx2.columns().get(0).sortOrder());
assertEquals(SortOrder.DESC, idx2.columns().get(1).sortOrder());
}
use of org.apache.ignite.schema.definition.index.SortOrder in project ignite-3 by apache.
the class SchemaConfigurationConverterTest method testConvertSortedIndex.
/**
* Add/remove SortedIndex into configuration and read it back.
*/
@Test
public void testConvertSortedIndex() throws Exception {
SortedIndexDefinitionBuilder builder = SchemaBuilders.sortedIndex("SIDX");
builder.addIndexColumn("A").asc().done();
builder.addIndexColumn("B").desc().done();
SortedIndexDefinition idx = builder.build();
getTbl().change(ch -> SchemaConfigurationConverter.addIndex(idx, ch)).get();
TableDefinition tbl = SchemaConfigurationConverter.convert(getTbl().value());
SortedIndexDefinition idx2 = (SortedIndexDefinition) getIdx(idx.name(), tbl.indices());
assertNotNull(idx2);
assertEquals("SORTED", idx2.type());
assertEquals(2, idx2.columns().size());
assertEquals("A", idx2.columns().get(0).name());
assertEquals("B", idx2.columns().get(1).name());
assertEquals(SortOrder.ASC, idx2.columns().get(0).sortOrder());
assertEquals(SortOrder.DESC, idx2.columns().get(1).sortOrder());
}
Aggregations