Class SchemaManager


  • public class SchemaManager
    extends Object
    Local schema manager. Responsible for all manipulations on schema objects.
    • 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.
      • 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.
      • 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.
      • schemaNames

        public Set<String> schemaNames()
        Get schemas names.
        Returns:
        Schemas names.
      • generateProxyIdxName

        public static String generateProxyIdxName​(String idxName)
      • 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:
        true If 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:
        true If 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, true if index rebuild started, false if 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 null if 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 null if none found.
      • 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 be null to don't use the filter.
        tblNamePtrn - Filter by table name. Can be null to don't use the filter.
        tblTypes - Filter by table type. As Of now supported only 'TABLES' and 'VIEWS'. Can be null or 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 be null to don't use the filter.
        tblNamePtrn - Filter by table name. Can be null to don't use the filter.
        colNamePtrn - Filter by column name. Can be null to don't use the filter.
        Returns:
        Column information filtered by given patterns.