Package org.apache.ignite.catalog
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 Summary
Modifier and TypeMethodDescriptiondefault CacheDefinition
cacheDefinition
(String name) Returns definition of the cache with provided name ornull
if cache doesn't exist.cacheDefinition
(QualifiedName name) Returns definition of the cache with provided name ornull
if cache doesn't exist.default CompletableFuture<CacheDefinition>
cacheDefinitionAsync
(String name) Returns definition of the cache with the provided name ornull
if cache doesn't exist.Returns definition of the cache with providedQualifiedName
ornull
if cache doesn't exist.createCache
(CacheDefinition definition) Creates aCache
from the cache definition.createCacheAsync
(CacheDefinition definition) Creates aCache
from the cache definition.createTable
(Class<?> recordClass) Creates a query object from the annotated record class.createTable
(Class<?> keyClass, Class<?> valueClass) Creates a query object from the annotated key and value classes.createTable
(TableDefinition definition) Creates a query object from the table definition.createTableAsync
(Class<?> recordClass) Creates a query object from the annotated record class.createTableAsync
(Class<?> keyClass, Class<?> valueClass) Creates a query object from the annotated key and value classes.createTableAsync
(TableDefinition definition) Creates a query object from the table definition.void
createZone
(ZoneDefinition definition) Creates aCREATE ZONE
query object from the zone definition.createZoneAsync
(ZoneDefinition definition) Creates a query object from the zone definition.default void
Drops cache with the provided name.void
dropCache
(CacheDefinition definition) Drops cache with the provided cache definition.void
dropCache
(QualifiedName name) Drops cache with the provided name.default CompletableFuture<Void>
dropCacheAsync
(String name) Drops cache with the provided name.dropCacheAsync
(CacheDefinition definition) Drops cache with the provided name.dropCacheAsync
(QualifiedName name) Drops cache with the provided name.default void
Creates aDROP TABLE
query object from the table name.void
dropTable
(TableDefinition definition) Creates aDROP TABLE
query object from the table definition.void
dropTable
(QualifiedName name) Creates aDROP TABLE
query object from theQualifiedName
.default CompletableFuture<Void>
dropTableAsync
(String name) Creates aDROP TABLE
query object from the table name.dropTableAsync
(TableDefinition definition) Creates aDROP TABLE
query object from the table definition.dropTableAsync
(QualifiedName name) Creates aDROP TABLE
query object from theQualifiedName
.void
Creates aDROP ZONE
query object from the zone name.void
dropZone
(ZoneDefinition definition) Creates aDROP ZONE
query object from the zone definition.dropZoneAsync
(String name) Creates aDROP ZONE
query object from the zone name.dropZoneAsync
(ZoneDefinition definition) Creates aDROP ZONE
query object from the zone definition.default TableDefinition
tableDefinition
(String tableName) Returns definition of the table with provided name ornull
if table doesn't exist.tableDefinition
(QualifiedName name) Returns definition of the table with providedQualifiedName
ornull
if table doesn't exist.default CompletableFuture<TableDefinition>
tableDefinitionAsync
(String tableName) Returns definition of the table with provided name ornull
if table doesn't exist.Returns definition of the table with providedQualifiedName
ornull
if table doesn't exist.zoneDefinition
(String zoneName) Returns definition of the zone with provided name ornull
if zone doesn't exist.zoneDefinitionAsync
(String zoneName) Returns definition of the zone with provided name ornull
if zone doesn't exist.
-
Method Details
-
createTableAsync
Creates a query object from the annotated record class.- Parameters:
recordClass
- Annotated record class.- Returns:
- Query object.
-
createTableAsync
Creates a query object from the annotated key and value classes.- Parameters:
keyClass
- Annotated key class.valueClass
- Annotated value class.- Returns:
- Query object.
-
createTableAsync
Creates a query object from the table definition.- Parameters:
definition
- Table definition.- Returns:
- Query object.
-
createTable
Creates a query object from the annotated record class.- Parameters:
recordClass
- Annotated record class.- Returns:
- Query object.
-
createTable
Creates a query object from the annotated key and value classes.- Parameters:
keyClass
- Annotated key class.valueClass
- Annotated value class.- Returns:
- Query object.
-
createTable
Creates a query object from the table definition.- Parameters:
definition
- Table definition.- Returns:
- Query object.
-
tableDefinitionAsync
Returns definition of the table with provided name ornull
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
Returns definition of the table with providedQualifiedName
ornull
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
Returns definition of the table with provided name ornull
if table doesn't exist.- Parameters:
tableName
- Table name.- Returns:
- Table definition with provided name.
-
tableDefinition
Returns definition of the table with providedQualifiedName
ornull
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
Creates a query object from the zone definition.- Parameters:
definition
- Zone definition.
-
createZone
Creates aCREATE ZONE
query object from the zone definition.- Parameters:
definition
- Zone definition.
-
zoneDefinitionAsync
Returns definition of the zone with provided name ornull
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
Returns definition of the zone with provided name ornull
if zone doesn't exist.- Parameters:
zoneName
- Zone name.- Returns:
- Zone definition with provided name.
-
dropTableAsync
Creates aDROP TABLE
query object from the table definition.- Parameters:
definition
- Table definition.
-
dropTableAsync
Creates aDROP TABLE
query object from the table name.- Parameters:
name
- Table name.
-
dropTableAsync
Creates aDROP TABLE
query object from theQualifiedName
.- Parameters:
name
- Qualified name.
-
dropTable
Creates aDROP TABLE
query object from the table definition.- Parameters:
definition
- Table definition.
-
dropTable
Creates aDROP TABLE
query object from the table name.- Parameters:
tableName
- Table name.
-
dropTable
Creates aDROP TABLE
query object from theQualifiedName
.- Parameters:
name
- Qualified name.
-
dropZoneAsync
Creates aDROP ZONE
query object from the zone definition.- Parameters:
definition
- Zone definition.
-
dropZoneAsync
Creates aDROP ZONE
query object from the zone name.- Parameters:
name
- Zone name.
-
dropZone
Creates aDROP ZONE
query object from the zone definition.- Parameters:
definition
- Zone definition.
-
dropZone
Creates aDROP ZONE
query object from the zone name.- Parameters:
name
- Zone name.
-
createCache
Creates aCache
from the cache definition.- Parameters:
definition
- Cache definition.- Returns:
- Cache.
-
createCacheAsync
Creates aCache
from the cache definition.- Parameters:
definition
- Cache definition.- Returns:
- Future that returns a Cache.
-
cacheDefinition
Returns definition of the cache with provided name ornull
if cache doesn't exist.- Parameters:
name
- Qualified name.- Returns:
- Cache definition with the provided name.
-
cacheDefinition
Returns definition of the cache with provided name ornull
if cache doesn't exist.- Parameters:
name
- Cache name.- Returns:
- Cache definition with the provided name.
-
cacheDefinitionAsync
Returns definition of the cache with providedQualifiedName
ornull
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
Returns definition of the cache with the provided name ornull
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
Drops cache with the provided cache definition.- Parameters:
definition
- Cache definition.
-
dropCache
Drops cache with the provided name.- Parameters:
name
- Qualified name.
-
dropCache
Drops cache with the provided name.- Parameters:
name
- Cache name.
-
dropCacheAsync
Drops cache with the provided name.- Parameters:
definition
- cache definition.- Returns:
- Future that competes when a cache is dropped or operation failed.
-
dropCacheAsync
Drops cache with the provided name.- Parameters:
name
- Qualified name.- Returns:
- Future that competes when a cache is dropped or operation failed.
-
dropCacheAsync
Drops cache with the provided name.- Parameters:
name
- Cache name.- Returns:
- Future that competes when a cache is dropped or operation failed.
-