Class SchemaManager
- java.lang.Object
-
- org.apache.ignite.internal.processors.query.schema.management.SchemaManager
-
public class SchemaManager extends Object
Local schema manager. Responsible for all manipulations on schema objects.
-
-
Field Summary
Fields Modifier and Type Field Description static StringSQL_IDXS_VIEWstatic StringSQL_IDXS_VIEW_DESCstatic StringSQL_SCHEMA_VIEWstatic StringSQL_SCHEMA_VIEW_DESCstatic StringSQL_TBL_COLS_VIEWstatic StringSQL_TBL_COLS_VIEW_DESCstatic StringSQL_TBLS_VIEWstatic StringSQL_TBLS_VIEW_DESCstatic StringSQL_VIEW_COLS_VIEWstatic StringSQL_VIEW_COLS_VIEW_DESCstatic StringSQL_VIEWS_VIEWstatic StringSQL_VIEWS_VIEW_DESC
-
Constructor Summary
Constructors Constructor Description SchemaManager(GridKernalContext ctx)Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddColumn(String schemaName, String tblName, List<QueryField> cols, boolean ifTblExists, boolean ifColNotExists)Add column.voidaddIndex(TableDescriptor tbl, IndexDescriptor idxDesc)Add index to the schema.Collection<IndexDescriptor>allIndexes()@Nullable GridCacheContextInfo<?,?>cacheInfo(String cacheName)Find registered cache info by it's name.booleanclearCacheContext(GridCacheContext<?,?> cctx)Clear cache context on call cache.close() on non-affinity node.Collection<ColumnInformation>columnsInformation(String schemaNamePtrn, String tblNamePtrn, String colNamePtrn)Return column information filtered by given patterns.voidcreateIndex(String schemaName, String tblName, QueryIndexDescriptorImpl idxDesc, boolean ifNotExists, SchemaIndexCacheVisitor cacheVisitor)Create index dynamically.voidcreateSystemView(String schema, SystemView<?> view)Registers new system view.voidcreateView(String schemaName, String viewName, String viewSql)Create view.voiddropColumn(String schemaName, String tblName, List<String> cols, boolean ifTblExists, boolean ifColExists)Drop column.voiddropIndex(String schemaName, String idxName, boolean ifExists)Drop index.voiddropView(String schemaName, String viewName)Drop view.static StringgenerateProxyIdxName(String idxName)@Nullable IndexDescriptorindex(String schemaName, String idxName)Find index by it's identifier.booleaninitCacheContext(GridCacheContext<?,?> cctx)Initialize table's cache context created for not started cache.voidmarkIndexRebuild(String cacheName, boolean mark)Mark tables for index rebuild, so that their indexes are not used.voidonCacheCreated(String cacheName, String schemaName, Class<?>[] sqlFuncs)Invoked when cache is created.voidonCacheStopped(String cacheName, boolean destroy, boolean clearIdx)Handle cache stop.voidonCacheTypeCreated(GridCacheContextInfo<?,?> cacheInfo, GridQueryTypeDescriptor type, boolean isSql)Registers new class description.static voidregisterIndexDescriptorFactory(QueryIndexType type, IndexDescriptorFactory factory)Register index descriptor factory for custom index type.StringschemaName(String cacheName)Get schema name for cache.Set<String>schemaNames()Get schemas names.voidstart(String[] schemaNames)Handle node start.voidstop()Handle node stop.@Nullable TableDescriptortable(String schemaName, String tblName)Find table by it's identifier.Collection<TableDescriptor>tablesForCache(String cacheName)Gets collection of table for given schema name.Collection<TableInformation>tablesInformation(String schemaNamePtrn, String tblNamePtrn, String... tblTypes)Return table information filtered by given patterns.@Nullable GridQueryTypeDescriptortypeDescriptorForType(String schemaName, String cacheName, String type)Get table descriptor.static voidunregisterIndexDescriptorFactory(QueryIndexType type)Unregister index descriptor factory for custom index type.
-
-
-
Field Detail
-
SQL_SCHEMA_VIEW
public static final String SQL_SCHEMA_VIEW
- See Also:
- Constant Field Values
-
SQL_SCHEMA_VIEW_DESC
public static final String SQL_SCHEMA_VIEW_DESC
- See Also:
- Constant Field Values
-
SQL_TBLS_VIEW
public static final String SQL_TBLS_VIEW
- See Also:
- Constant Field Values
-
SQL_TBLS_VIEW_DESC
public static final String SQL_TBLS_VIEW_DESC
- See Also:
- Constant Field Values
-
SQL_VIEWS_VIEW
public static final String SQL_VIEWS_VIEW
- See Also:
- Constant Field Values
-
SQL_VIEWS_VIEW_DESC
public static final String SQL_VIEWS_VIEW_DESC
- See Also:
- Constant Field Values
-
SQL_IDXS_VIEW
public static final String SQL_IDXS_VIEW
- See Also:
- Constant Field Values
-
SQL_IDXS_VIEW_DESC
public static final String SQL_IDXS_VIEW_DESC
- See Also:
- Constant Field Values
-
SQL_TBL_COLS_VIEW
public static final String SQL_TBL_COLS_VIEW
-
SQL_TBL_COLS_VIEW_DESC
public static final String SQL_TBL_COLS_VIEW_DESC
- See Also:
- Constant Field Values
-
SQL_VIEW_COLS_VIEW
public static final String SQL_VIEW_COLS_VIEW
-
SQL_VIEW_COLS_VIEW_DESC
public static final String SQL_VIEW_COLS_VIEW_DESC
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
SchemaManager
public SchemaManager(GridKernalContext ctx)
Constructor.- Parameters:
ctx- Kernal context.
-
-
Method Detail
-
registerIndexDescriptorFactory
public static void registerIndexDescriptorFactory(QueryIndexType type, IndexDescriptorFactory factory)
Register index descriptor factory for custom index type.
-
unregisterIndexDescriptorFactory
public static void unregisterIndexDescriptorFactory(QueryIndexType type)
Unregister index descriptor factory for custom index type.
-
start
public void start(String[] schemaNames) throws IgniteCheckedException
Handle node start.- Parameters:
schemaNames- Schema names.- Throws:
IgniteCheckedException
-
stop
public void stop()
Handle node stop.
-
createSystemView
public void createSystemView(String schema, SystemView<?> view)
Registers new system view.- Parameters:
schema- Schema to create view in.view- System view.
-
onCacheCreated
public void onCacheCreated(String cacheName, String schemaName, Class<?>[] sqlFuncs) throws IgniteCheckedException
Invoked when cache is created.- Parameters:
cacheName- Cache name.schemaName- Schema name.sqlFuncs- Custom SQL functions.- Throws:
IgniteCheckedException- If failed.
-
onCacheTypeCreated
public void onCacheTypeCreated(GridCacheContextInfo<?,?> cacheInfo, GridQueryTypeDescriptor type, boolean isSql) throws IgniteCheckedException
Registers new class description.- Parameters:
cacheInfo- Cache info.type- Type descriptor.isSql- Whether SQL enabled.- Throws:
IgniteCheckedException- If failed.
-
onCacheStopped
public void onCacheStopped(String cacheName, boolean destroy, boolean clearIdx)
Handle cache stop.- Parameters:
cacheName- Cache name.destroy- Destroy cache.clearIdx- Whether to clear the index.
-
schemaName
public String schemaName(String cacheName)
Get schema name for cache.- Parameters:
cacheName- Cache name.- Returns:
- Schema name.
-
createIndex
public void createIndex(String schemaName, String tblName, QueryIndexDescriptorImpl idxDesc, boolean ifNotExists, SchemaIndexCacheVisitor cacheVisitor) throws IgniteCheckedException
Create index dynamically.- Parameters:
schemaName- Schema name.tblName- Table name.idxDesc- Index descriptor.ifNotExists- If-not-exists.cacheVisitor- Cache visitor.- Throws:
IgniteCheckedException- If failed.
-
addIndex
public void addIndex(TableDescriptor tbl, IndexDescriptor idxDesc) throws IgniteCheckedException
Add index to the schema.- Parameters:
tbl- Table descriptor.idxDesc- Index descriptor.- Throws:
IgniteCheckedException
-
dropIndex
public void dropIndex(String schemaName, String idxName, boolean ifExists) throws IgniteCheckedException
Drop index.- Parameters:
schemaName- Schema name.idxName- Index name.ifExists- If exists.- Throws:
IgniteCheckedException
-
addColumn
public void addColumn(String schemaName, String tblName, List<QueryField> cols, boolean ifTblExists, boolean ifColNotExists) throws IgniteCheckedException
Add column.- Parameters:
schemaName- Schema name.tblName- Table name.cols- Columns.ifTblExists- If table exists.ifColNotExists- If column not exists.- Throws:
IgniteCheckedException- If failed.
-
dropColumn
public void dropColumn(String schemaName, String tblName, List<String> cols, boolean ifTblExists, boolean ifColExists) throws IgniteCheckedException
Drop column.- Parameters:
schemaName- Schema name.tblName- Table name.cols- Columns.ifTblExists- If table exists.ifColExists- If column exists.- Throws:
IgniteCheckedException- If failed.
-
createView
public void createView(String schemaName, String viewName, String viewSql)
Create view.- Parameters:
schemaName- Schema name.viewName- View name.viewSql- View SQL.
-
dropView
public void dropView(String schemaName, String viewName)
Drop view.- Parameters:
schemaName- Schema name.viewName- View name.
-
initCacheContext
public boolean initCacheContext(GridCacheContext<?,?> cctx)
Initialize table's cache context created for not started cache.- Parameters:
cctx- Cache context.- Returns:
trueIf context has been initialized.
-
clearCacheContext
public boolean clearCacheContext(GridCacheContext<?,?> cctx)
Clear cache context on call cache.close() on non-affinity node.- Parameters:
cctx- Cache context.- Returns:
trueIf context has been cleared.
-
markIndexRebuild
public void markIndexRebuild(String cacheName, boolean mark)
Mark tables for index rebuild, so that their indexes are not used.- Parameters:
cacheName- Cache name.mark- Mark/unmark flag,trueif index rebuild started,falseif finished.
-
typeDescriptorForType
@Nullable public @Nullable GridQueryTypeDescriptor typeDescriptorForType(String schemaName, String cacheName, String type)
Get table descriptor.- Parameters:
schemaName- Schema name.cacheName- Cache name.type- Type name.- Returns:
- Descriptor.
-
tablesForCache
public Collection<TableDescriptor> tablesForCache(String cacheName)
Gets collection of table for given schema name.- Parameters:
cacheName- Cache name.- Returns:
- Collection of table descriptors.
-
cacheInfo
@Nullable public @Nullable GridCacheContextInfo<?,?> cacheInfo(String cacheName)
Find registered cache info by it's name.
-
table
@Nullable public @Nullable TableDescriptor table(String schemaName, String tblName)
Find table by it's identifier.- Parameters:
schemaName- Schema name.tblName- Table name.- Returns:
- Table descriptor or
nullif none found.
-
index
@Nullable public @Nullable IndexDescriptor index(String schemaName, String idxName)
Find index by it's identifier.- Parameters:
schemaName- Schema name.idxName- Index name.- Returns:
- Index or
nullif none found.
-
allIndexes
public Collection<IndexDescriptor> allIndexes()
- Returns:
- Collection of all present index descriptors.
-
tablesInformation
public Collection<TableInformation> tablesInformation(String schemaNamePtrn, String tblNamePtrn, String... tblTypes)
Return table information filtered by given patterns.- Parameters:
schemaNamePtrn- Filter by schema name. Can benullto don't use the filter.tblNamePtrn- Filter by table name. Can benullto don't use the filter.tblTypes- Filter by table type. As Of now supported only 'TABLES' and 'VIEWS'. Can benullor empty to don't use the filter.- Returns:
- Table information filtered by given patterns.
-
columnsInformation
public Collection<ColumnInformation> columnsInformation(String schemaNamePtrn, String tblNamePtrn, String colNamePtrn)
Return column information filtered by given patterns.- Parameters:
schemaNamePtrn- Filter by schema name. Can benullto don't use the filter.tblNamePtrn- Filter by table name. Can benullto don't use the filter.colNamePtrn- Filter by column name. Can benullto don't use the filter.- Returns:
- Column information filtered by given patterns.
-
-