Interface IgniteCatalog


public interface IgniteCatalog
Provides the ability to create and execute SQL DDL queries from annotated classes or fluent builders. This is an example of the simple table created from the annotated class:
    @Table
    private static class Value {
        String val;
    }
    ignite.catalog().createTable(Integer.class, Value.class);
 
This is equivalent to executing the following statement:
     CREATE TABLE IF NOT EXISTS Value (id int, val varchar, PRIMARY KEY (id));
 
The same statement can be produced using builders:
    TableDefinition table = TableDefinition.builder("Value")
            .ifNotExists()
            .columns(
                    column("id", INTEGER),
                    column("val", VARCHAR)
            )
            .primaryKey("id")
            .build();
    ignite.catalog().createTable(table);
 
This is an example of the table created from simple annotated record class.
    @Table
    private static class Pojo {
        @Id
        Integer id;
    }
 
When this class is passed to the createTableAsync(Class) method it will produce the following statement:
    CREATE TABLE IF NOT EXISTS Pojo (id int, PRIMARY KEY (id));
 
Again, using builders this can be written as:
    TableDefinition table = TableDefinition.builder("Pojo")
            .ifNotExists()
            .columns(column("id", INTEGER))
            .primaryKey("id")
            .build();
    ignite.catalog().createTable(table);
 
Here's an example of more complex annotations including zones, colocation and indexes:
    @@Zone(
            value = "zone_test",
            replicas = 3,
            partitions = 1,
            storageProfiles = "default"
    )
    private static class ZoneTest {}

    @Table(
            value = "table_test",
            zone = ZoneTest.class,
            colocateBy = @ColumnRef("id"),
            indexes = @Index(value = "ix_pojo", columns = {
                    @ColumnRef("f_name"),
                    @ColumnRef(value = "l_name", sort = SortOrder.DESC)
            })
    )
    private static class Pojo {
        @Id
        Integer id;

        @Id
        @Column(value = "id_str", length = 20)
        String idStr;

        @Column(value = "f_name", columnDefinition = "varchar(20) not null default 'a'")
        String firstName;

        @Column("l_name")
        String lastName;

        String str;
    }
 
These classes when passed to the createTableAsync(Class) method will produce the following statements:
    CREATE ZONE IF NOT EXISTS zone_test WITH PARTITIONS=1, REPLICAS=3, STORAGE_PROFILES='default';
    CREATE TABLE IF NOT EXISTS table_test (id int, id_str varchar(20), f_name varchar(20) not null default 'a', \
    l_name varchar, str varchar, PRIMARY KEY (id, id_str)) COLOCATE BY (id, id_str) ZONE ZONE_TEST;
    CREATE INDEX IF NOT EXISTS ix_pojo ON table_test (f_name, l_name desc);
 
And here's the equivalent definition using builders:
    ZoneDefinition zone = ZoneDefinition.builder("zone_test")
             .ifNotExists()
             .partitions(1)
             .replicas(3)
             .storageProfiles("default")
             .build();
    TableDefinition table = TableDefinition.builder("table_test")
            .ifNotExists()
            .columns(
                    column("id", ColumnType.INTEGER),
                    column("id_str", ColumnType.varchar(20)),
                    column("f_name", ColumnType.varchar(20).notNull().defaultValue("a")),
                    column("l_name", ColumnType.VARCHAR),
                    column("str", ColumnType.VARCHAR)
            )
            .primaryKey("id", "id_str")
            .colocateBy("id", "id_str")
            .zone("zone_test")
            .index("ix_pojo", IndexType.DEFAULT, ColumnSorted.column("f_name"), ColumnSorted.column("l_name", SortOrder.DESC))
            .build();
    ignite.catalog().createZone(zone);
    ignite.catalog().createTable(table);
 
  • Method Details

    • createTableAsync

      CompletableFuture<Table> createTableAsync(Class<?> recordClass)
      Creates a query object from the annotated record class.
      Parameters:
      recordClass - Annotated record class.
      Returns:
      Query object.
    • createTableAsync

      CompletableFuture<Table> createTableAsync(Class<?> keyClass, Class<?> valueClass)
      Creates a query object from the annotated key and value classes.
      Parameters:
      keyClass - Annotated key class.
      valueClass - Annotated value class.
      Returns:
      Query object.
    • createTableAsync

      CompletableFuture<Table> createTableAsync(TableDefinition definition)
      Creates a query object from the table definition.
      Parameters:
      definition - Table definition.
      Returns:
      Query object.
    • createTable

      Table createTable(Class<?> recordClass)
      Creates a query object from the annotated record class.
      Parameters:
      recordClass - Annotated record class.
      Returns:
      Query object.
    • createTable

      Table createTable(Class<?> keyClass, Class<?> valueClass)
      Creates a query object from the annotated key and value classes.
      Parameters:
      keyClass - Annotated key class.
      valueClass - Annotated value class.
      Returns:
      Query object.
    • createTable

      Table createTable(TableDefinition definition)
      Creates a query object from the table definition.
      Parameters:
      definition - Table definition.
      Returns:
      Query object.
    • tableDefinitionAsync

      default CompletableFuture<TableDefinition> tableDefinitionAsync(String tableName)
      Returns definition of the table with provided name or null if table doesn't exist.
      Parameters:
      tableName - Table name.
      Returns:
      Future with table definition with provided name or null if table doesn't exist.
    • tableDefinitionAsync

      CompletableFuture<TableDefinition> tableDefinitionAsync(QualifiedName name)
      Returns definition of the table with provided QualifiedName or null if table doesn't exist.
      Parameters:
      name - Qualified name.
      Returns:
      Future with table definition with provided name or null if table doesn't exist.
    • tableDefinition

      default TableDefinition tableDefinition(String tableName)
      Returns definition of the table with provided name or null if table doesn't exist.
      Parameters:
      tableName - Table name.
      Returns:
      Table definition with provided name.
    • tableDefinition

      TableDefinition tableDefinition(QualifiedName name)
      Returns definition of the table with provided QualifiedName or null if table doesn't exist.
      Parameters:
      name - Qualified name.
      Returns:
      Future with table definition with provided name or null if table doesn't exist.
    • createZoneAsync

      CompletableFuture<Void> createZoneAsync(ZoneDefinition definition)
      Creates a query object from the zone definition.
      Parameters:
      definition - Zone definition.
    • createZone

      void createZone(ZoneDefinition definition)
      Creates a CREATE ZONE query object from the zone definition.
      Parameters:
      definition - Zone definition.
    • zoneDefinitionAsync

      CompletableFuture<ZoneDefinition> zoneDefinitionAsync(String zoneName)
      Returns definition of the zone with provided name or null if zone doesn't exist.
      Parameters:
      zoneName - Zone name.
      Returns:
      Future with zone definition with provided name or null if zone doesn't exist.
    • zoneDefinition

      ZoneDefinition zoneDefinition(String zoneName)
      Returns definition of the zone with provided name or null if zone doesn't exist.
      Parameters:
      zoneName - Zone name.
      Returns:
      Zone definition with provided name.
    • dropTableAsync

      CompletableFuture<Void> dropTableAsync(TableDefinition definition)
      Creates a DROP TABLE query object from the table definition.
      Parameters:
      definition - Table definition.
    • dropTableAsync

      default CompletableFuture<Void> dropTableAsync(String name)
      Creates a DROP TABLE query object from the table name.
      Parameters:
      name - Table name.
    • dropTableAsync

      CompletableFuture<Void> dropTableAsync(QualifiedName name)
      Creates a DROP TABLE query object from the QualifiedName.
      Parameters:
      name - Qualified name.
    • dropTable

      void dropTable(TableDefinition definition)
      Creates a DROP TABLE query object from the table definition.
      Parameters:
      definition - Table definition.
    • dropTable

      default void dropTable(String tableName)
      Creates a DROP TABLE query object from the table name.
      Parameters:
      tableName - Table name.
    • dropTable

      void dropTable(QualifiedName name)
      Creates a DROP TABLE query object from the QualifiedName.
      Parameters:
      name - Qualified name.
    • dropZoneAsync

      CompletableFuture<Void> dropZoneAsync(ZoneDefinition definition)
      Creates a DROP ZONE query object from the zone definition.
      Parameters:
      definition - Zone definition.
    • dropZoneAsync

      CompletableFuture<Void> dropZoneAsync(String name)
      Creates a DROP ZONE query object from the zone name.
      Parameters:
      name - Zone name.
    • dropZone

      void dropZone(ZoneDefinition definition)
      Creates a DROP ZONE query object from the zone definition.
      Parameters:
      definition - Zone definition.
    • dropZone

      void dropZone(String name)
      Creates a DROP ZONE query object from the zone name.
      Parameters:
      name - Zone name.
    • createCache

      Cache createCache(CacheDefinition definition)
      Creates a Cache from the cache definition.
      Parameters:
      definition - Cache definition.
      Returns:
      Cache.
    • createCacheAsync

      CompletableFuture<Cache> createCacheAsync(CacheDefinition definition)
      Creates a Cache from the cache definition.
      Parameters:
      definition - Cache definition.
      Returns:
      Future that returns a Cache.
    • cacheDefinition

      CacheDefinition cacheDefinition(QualifiedName name)
      Returns definition of the cache with provided name or null if cache doesn't exist.
      Parameters:
      name - Qualified name.
      Returns:
      Cache definition with the provided name.
    • cacheDefinition

      default CacheDefinition cacheDefinition(String name)
      Returns definition of the cache with provided name or null if cache doesn't exist.
      Parameters:
      name - Cache name.
      Returns:
      Cache definition with the provided name.
    • cacheDefinitionAsync

      CompletableFuture<CacheDefinition> cacheDefinitionAsync(QualifiedName name)
      Returns definition of the cache with provided QualifiedName or null if cache doesn't exist.
      Parameters:
      name - Qualified name.
      Returns:
      Future with cache definition with the provided name or null if cache doesn't exist.
    • cacheDefinitionAsync

      default CompletableFuture<CacheDefinition> cacheDefinitionAsync(String name)
      Returns definition of the cache with the provided name or null if cache doesn't exist.
      Parameters:
      name - Cache name.
      Returns:
      Future with cache definition with the provided name or null if cache doesn't exist.
    • dropCache

      void dropCache(CacheDefinition definition)
      Drops cache with the provided cache definition.
      Parameters:
      definition - Cache definition.
    • dropCache

      void dropCache(QualifiedName name)
      Drops cache with the provided name.
      Parameters:
      name - Qualified name.
    • dropCache

      default void dropCache(String name)
      Drops cache with the provided name.
      Parameters:
      name - Cache name.
    • dropCacheAsync

      CompletableFuture<Void> dropCacheAsync(CacheDefinition definition)
      Drops cache with the provided name.
      Parameters:
      definition - cache definition.
      Returns:
      Future that competes when a cache is dropped or operation failed.
    • dropCacheAsync

      CompletableFuture<Void> dropCacheAsync(QualifiedName name)
      Drops cache with the provided name.
      Parameters:
      name - Qualified name.
      Returns:
      Future that competes when a cache is dropped or operation failed.
    • dropCacheAsync

      default CompletableFuture<Void> dropCacheAsync(String name)
      Drops cache with the provided name.
      Parameters:
      name - Cache name.
      Returns:
      Future that competes when a cache is dropped or operation failed.