Search in sources :

Example 1 with PartialIndexDefinitionBuilder

use of org.apache.ignite.schema.definition.builder.PartialIndexDefinitionBuilder in project ignite-3 by apache.

the class SchemaConfigurationConverterTest method testPartialIndex.

/**
 * Add/remove PartialIndex into configuration and read it back.
 */
@Test
public void testPartialIndex() throws Exception {
    PartialIndexDefinitionBuilder builder = SchemaBuilders.partialIndex("TEST");
    builder.addIndexColumn("A").done();
    builder.withExpression("WHERE A > 0");
    PartialIndexDefinition idx = builder.build();
    getTbl().change(ch -> SchemaConfigurationConverter.addIndex(idx, ch)).get();
    TableDefinition tbl = SchemaConfigurationConverter.convert(getTbl().value());
    PartialIndexDefinition idx2 = (PartialIndexDefinition) getIdx(idx.name(), tbl.indices());
    assertNotNull(idx2);
    assertEquals("PARTIAL", idx2.type());
    assertEquals(idx.columns().size(), idx2.columns().size());
}
Also used : Assertions.assertNotNull(org.junit.jupiter.api.Assertions.assertNotNull) HashIndexConfigurationSchema(org.apache.ignite.configuration.schemas.table.HashIndexConfigurationSchema) SortedIndexDefinitionBuilder(org.apache.ignite.schema.definition.builder.SortedIndexDefinitionBuilder) BeforeEach(org.junit.jupiter.api.BeforeEach) IndexColumnDefinition(org.apache.ignite.schema.definition.index.IndexColumnDefinition) SortOrder(org.apache.ignite.schema.definition.index.SortOrder) HashIndexDefinition(org.apache.ignite.schema.definition.index.HashIndexDefinition) DISTRIBUTED(org.apache.ignite.configuration.annotation.ConfigurationType.DISTRIBUTED) TableConfiguration(org.apache.ignite.configuration.schemas.table.TableConfiguration) PartialIndexConfigurationSchema(org.apache.ignite.configuration.schemas.table.PartialIndexConfigurationSchema) SortedIndexConfigurationSchema(org.apache.ignite.configuration.schemas.table.SortedIndexConfigurationSchema) HashIndexDefinitionBuilder(org.apache.ignite.schema.definition.builder.HashIndexDefinitionBuilder) Disabled(org.junit.jupiter.api.Disabled) Map(java.util.Map) RocksDbDataRegionConfigurationSchema(org.apache.ignite.configuration.schemas.store.RocksDbDataRegionConfigurationSchema) SortedIndexDefinition(org.apache.ignite.schema.definition.index.SortedIndexDefinition) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) IndexDefinition(org.apache.ignite.schema.definition.index.IndexDefinition) TableDefinition(org.apache.ignite.schema.definition.TableDefinition) Collection(java.util.Collection) DataStorageConfiguration(org.apache.ignite.configuration.schemas.store.DataStorageConfiguration) TablesConfiguration(org.apache.ignite.configuration.schemas.table.TablesConfiguration) PartialIndexDefinition(org.apache.ignite.schema.definition.index.PartialIndexDefinition) Set(java.util.Set) PartialIndexDefinitionBuilder(org.apache.ignite.schema.definition.builder.PartialIndexDefinitionBuilder) TableValidator(org.apache.ignite.configuration.schemas.table.TableValidator) ColumnType(org.apache.ignite.schema.definition.ColumnType) Collectors(java.util.stream.Collectors) ExecutionException(java.util.concurrent.ExecutionException) Test(org.junit.jupiter.api.Test) TableDefinitionBuilder(org.apache.ignite.schema.definition.builder.TableDefinitionBuilder) List(java.util.List) AfterEach(org.junit.jupiter.api.AfterEach) ConfigurationRegistry(org.apache.ignite.internal.configuration.ConfigurationRegistry) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) TestConfigurationStorage(org.apache.ignite.internal.configuration.storage.TestConfigurationStorage) SchemaBuilders(org.apache.ignite.schema.SchemaBuilders) Collections(java.util.Collections) PartialIndexDefinitionBuilder(org.apache.ignite.schema.definition.builder.PartialIndexDefinitionBuilder) PartialIndexDefinition(org.apache.ignite.schema.definition.index.PartialIndexDefinition) TableDefinition(org.apache.ignite.schema.definition.TableDefinition) Test(org.junit.jupiter.api.Test)

Example 2 with PartialIndexDefinitionBuilder

use of org.apache.ignite.schema.definition.builder.PartialIndexDefinitionBuilder in project ignite-3 by apache.

the class PartialIndexDefinitionBuilderTest method testPartialIndexCreate.

/**
 * Test partial index parameters.
 */
@Test
public void testPartialIndexCreate() {
    PartialIndexDefinitionBuilder builder = SchemaBuilders.partialIndex("TEST");
    builder.addIndexColumn("A").done();
    builder.withExpression("WHERE A > 0");
    PartialIndexDefinition idx = builder.build();
    assertEquals(1, idx.columns().size());
    assertEquals("WHERE A > 0", idx.expr());
}
Also used : PartialIndexDefinitionBuilder(org.apache.ignite.schema.definition.builder.PartialIndexDefinitionBuilder) PartialIndexDefinition(org.apache.ignite.schema.definition.index.PartialIndexDefinition) Test(org.junit.jupiter.api.Test)

Aggregations

PartialIndexDefinitionBuilder (org.apache.ignite.schema.definition.builder.PartialIndexDefinitionBuilder)2 PartialIndexDefinition (org.apache.ignite.schema.definition.index.PartialIndexDefinition)2 Test (org.junit.jupiter.api.Test)2 Collection (java.util.Collection)1 Collections (java.util.Collections)1 List (java.util.List)1 Map (java.util.Map)1 Set (java.util.Set)1 ExecutionException (java.util.concurrent.ExecutionException)1 Collectors (java.util.stream.Collectors)1 DISTRIBUTED (org.apache.ignite.configuration.annotation.ConfigurationType.DISTRIBUTED)1 DataStorageConfiguration (org.apache.ignite.configuration.schemas.store.DataStorageConfiguration)1 RocksDbDataRegionConfigurationSchema (org.apache.ignite.configuration.schemas.store.RocksDbDataRegionConfigurationSchema)1 HashIndexConfigurationSchema (org.apache.ignite.configuration.schemas.table.HashIndexConfigurationSchema)1 PartialIndexConfigurationSchema (org.apache.ignite.configuration.schemas.table.PartialIndexConfigurationSchema)1 SortedIndexConfigurationSchema (org.apache.ignite.configuration.schemas.table.SortedIndexConfigurationSchema)1 TableConfiguration (org.apache.ignite.configuration.schemas.table.TableConfiguration)1 TableValidator (org.apache.ignite.configuration.schemas.table.TableValidator)1 TablesConfiguration (org.apache.ignite.configuration.schemas.table.TablesConfiguration)1 ConfigurationRegistry (org.apache.ignite.internal.configuration.ConfigurationRegistry)1