Search in sources :

Example 1 with HashIndexDefinitionBuilder

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

the class SchemaConfigurationConverterTest method testConvertHashIndex.

/**
 * Add/remove HashIndex into configuration and read it back.
 */
@Test
public void testConvertHashIndex() throws Exception {
    HashIndexDefinitionBuilder builder = SchemaBuilders.hashIndex("testHI").withColumns("A", "B", "C").withHints(Collections.singletonMap("param", "value"));
    HashIndexDefinition idx = builder.build();
    getTbl().change(ch -> SchemaConfigurationConverter.addIndex(idx, ch)).get();
    TableDefinition tbl = SchemaConfigurationConverter.convert(getTbl().value());
    HashIndexDefinition idx2 = (HashIndexDefinition) getIdx(idx.name(), tbl.indices());
    assertNotNull(idx2);
    assertEquals("HASH", idx2.type());
    assertEquals(3, 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) HashIndexDefinitionBuilder(org.apache.ignite.schema.definition.builder.HashIndexDefinitionBuilder) HashIndexDefinition(org.apache.ignite.schema.definition.index.HashIndexDefinition) TableDefinition(org.apache.ignite.schema.definition.TableDefinition) Test(org.junit.jupiter.api.Test)

Example 2 with HashIndexDefinitionBuilder

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

the class HashIndexDefinitionBuilderTest method testBuild.

/**
 * Build index and check its parameters.
 */
@Test
public void testBuild() {
    HashIndexDefinitionBuilder builder = SchemaBuilders.hashIndex("testHI").withColumns("A", "B", "C").withHints(Collections.singletonMap("param", "value"));
    HashIndexDefinition idx = builder.build();
    assertEquals("TESTHI", idx.name());
    assertEquals(3, idx.columns().size());
}
Also used : HashIndexDefinitionBuilder(org.apache.ignite.schema.definition.builder.HashIndexDefinitionBuilder) HashIndexDefinition(org.apache.ignite.schema.definition.index.HashIndexDefinition) Test(org.junit.jupiter.api.Test)

Example 3 with HashIndexDefinitionBuilder

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

the class HashIndexDefinitionBuilderTest method testBuildNoColumns.

/**
 * Try to create index without columns and check error.
 */
@Test
public void testBuildNoColumns() {
    HashIndexDefinitionBuilder builder = SchemaBuilders.hashIndex("testHI");
    assertThrows(AssertionError.class, builder::build);
}
Also used : HashIndexDefinitionBuilder(org.apache.ignite.schema.definition.builder.HashIndexDefinitionBuilder) Test(org.junit.jupiter.api.Test)

Aggregations

HashIndexDefinitionBuilder (org.apache.ignite.schema.definition.builder.HashIndexDefinitionBuilder)3 Test (org.junit.jupiter.api.Test)3 HashIndexDefinition (org.apache.ignite.schema.definition.index.HashIndexDefinition)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