Class GridQueryProcessor

    • Field Detail

      • INLINE_SIZES_DIFFER_WARN_MSG_FORMAT

        public static final String INLINE_SIZES_DIFFER_WARN_MSG_FORMAT
        Warn message if some indexes have different inline sizes on the nodes.
        See Also:
        Constant Field Values
      • QRY_HINT_PATTERN

        public static final Pattern QRY_HINT_PATTERN
        Pattern of query hint.
      • QRY_ENGINE_PATTERN

        public static final Pattern QRY_ENGINE_PATTERN
        Pattern of hint to choose query engine.
    • Method Detail

      • onKernalStop

        public void onKernalStop​(boolean cancel)
        Callback to notify that kernal is about to stop.
        Specified by:
        onKernalStop in interface GridComponent
        Overrides:
        onKernalStop in class GridProcessorAdapter
        Parameters:
        cancel - Flag indicating whether jobs should be canceled.
      • onCacheKernalStart

        public void onCacheKernalStart()
                                throws IgniteCheckedException
        Handle cache kernal start. At this point discovery and IO managers are operational, caches are not started yet.
        Throws:
        IgniteCheckedException - If failed.
      • beforeExchange

        public void beforeExchange​(GridDhtPartitionsExchangeFuture fut)
        Prepare index rebuild futures if needed before exchange.
        Parameters:
        fut - Exchange future.
      • onSchemaPropose

        public void onSchemaPropose​(SchemaProposeDiscoveryMessage msg)
        Handle schema propose from exchange thread.
        Parameters:
        msg - Discovery message.
      • indexingEnabled

        public boolean indexingEnabled()
        Returns:
        true If indexing module is in classpath and successfully initialized.
      • moduleEnabled

        public boolean moduleEnabled()
        Returns:
        true If indexing module is enabled or any query engine is enabled.
      • onCacheStart0

        public void onCacheStart0​(GridCacheContextInfo<?,​?> cacheInfo,
                                  QuerySchema schema,
                                  boolean isSql)
                           throws IgniteCheckedException
        Create type descriptors from schema and initialize indexing for given cache.

        Use with busyLock where appropriate.

        Parameters:
        cacheInfo - Cache context info.
        schema - Initial schema.
        isSql - true in case create cache initialized from SQL.
        Throws:
        IgniteCheckedException - If failed.
      • onCacheStart

        public void onCacheStart​(GridCacheContextInfo cacheInfo,
                                 QuerySchema schema,
                                 boolean isSql)
                          throws IgniteCheckedException
        Handle cache start. Invoked either from GridCacheProcessor.onKernalStart() method or from exchange worker. When called for the first time, we initialize topology thus understanding whether current node is coordinator or not.
        Parameters:
        cacheInfo - Cache context info.
        schema - Index states.
        isSql - true in case create cache initialized from SQL.
        Throws:
        IgniteCheckedException - If failed.
      • onCacheStop

        public void onCacheStop​(String cacheName)
        Destroy H2 structures for not started caches.
        Parameters:
        cacheName - Cache name.
      • onCacheStop

        public void onCacheStop​(GridCacheContextInfo cacheInfo,
                                boolean removeIdx,
                                boolean clearIdx)
        Parameters:
        cacheInfo - Cache context info.
        removeIdx - If true, will remove index.
        clearIdx - If true, will clear the index.
      • onClientCacheStop

        public void onClientCacheStop​(GridCacheContextInfo cacheInfo)
        Parameters:
        cacheInfo - Cache context info.
      • skipFieldLookup

        public boolean skipFieldLookup()
        Returns:
        Skip field lookup flag.
      • skipFieldLookup

        public void skipFieldLookup​(boolean skipFieldLookup)
        Parameters:
        skipFieldLookup - Skip field lookup flag.
      • registerMetadataForRegisteredCaches

        public void registerMetadataForRegisteredCaches​(boolean platformOnly)
        Register metadata locally for already registered caches.
        Parameters:
        platformOnly - Whether to register non-Java platformOnly types only.
      • onCacheChangeRequested

        public void onCacheChangeRequested​(DynamicCacheChangeBatch batch)
        Handle of cache change request.
        Parameters:
        batch - Dynamic cache change batch request.
      • onCoordinatorFinished

        public void onCoordinatorFinished​(SchemaAbstractOperation op,
                                          @Nullable
                                          @Nullable SchemaOperationException err,
                                          boolean nop)
        Invoked when coordinator finished ensuring that all participants are ready.
        Parameters:
        op - Operation.
        err - Error (if any).
      • onLocalOperationFinished

        public void onLocalOperationFinished​(SchemaAbstractOperation op,
                                             @Nullable
                                             @Nullable QueryTypeDescriptorImpl type)
        Apply positive index operation result.
        Parameters:
        op - Operation.
        type - Type descriptor (if available),
      • onNodeLeave

        public void onNodeLeave​(ClusterNode node)
        Handle node leave.
        Parameters:
        node - Node.
      • dynamicTableCreate

        public void dynamicTableCreate​(String schemaName,
                                       QueryEntity entity,
                                       String templateName,
                                       String cacheName,
                                       String cacheGroup,
                                       @Nullable
                                       @Nullable String dataRegion,
                                       String affinityKey,
                                       @Nullable
                                       @Nullable CacheAtomicityMode atomicityMode,
                                       @Nullable
                                       @Nullable CacheWriteSynchronizationMode writeSyncMode,
                                       @Nullable
                                       @Nullable Integer backups,
                                       boolean ifNotExists,
                                       @Nullable
                                       @Nullable Boolean encrypted,
                                       @Nullable
                                       @Nullable Integer qryParallelism)
                                throws IgniteCheckedException
        Create cache and table from given query entity.
        Parameters:
        schemaName - Schema name to create table in. Case sensitive, must not be \"quoted\".
        entity - Entity to create table from.
        templateName - Template name.
        cacheName - Cache name.
        cacheGroup - Cache group name.
        dataRegion - Data region name.
        affinityKey - Affinity key column name.
        atomicityMode - Atomicity mode.
        writeSyncMode - Write synchronization mode.
        backups - Backups.
        ifNotExists - Quietly ignore this command if table already exists.
        encrypted - Encrypted flag.
        qryParallelism - query parallelism value for configuration of underlying cache.
        Throws:
        IgniteCheckedException - If failed.
      • dynamicTableDrop

        public void dynamicTableDrop​(String cacheName,
                                     String tblName,
                                     boolean ifExists)
                              throws SchemaOperationException
        Drop table by destroying its cache if it's an 1:1 per cache table.
        Parameters:
        cacheName - Cache name.
        tblName - Table name.
        ifExists - Quietly ignore this command if table does not exist.
        Throws:
        SchemaOperationException - if ifExists is false and cache was not found.
      • onCacheStop0

        public void onCacheStop0​(GridCacheContextInfo cacheInfo,
                                 boolean destroy,
                                 boolean clearIdx)
        Unregister cache.

        Use with busyLock where appropriate.

        Parameters:
        cacheInfo - Cache context info.
        destroy - Destroy flag.
        clearIdx - Clear flag.
      • belongsToTable

        public boolean belongsToTable​(GridCacheContext cctx,
                                      String expCacheName,
                                      String expTblName,
                                      KeyCacheObject key,
                                      CacheObject val)
                               throws IgniteCheckedException
        Check whether provided key and value belongs to expected cache and table.
        Parameters:
        cctx - Target cache context.
        expCacheName - Expected cache name.
        expTblName - Expected table name.
        key - Key.
        val - Value.
        Returns:
        True if this key-value pair belongs to expected cache/table, false otherwise or if cache or table doesn't exist.
        Throws:
        IgniteCheckedException - If failed.
      • tableName

        @Nullable
        public @Nullable String tableName​(String cacheName,
                                          String valType)
        Get table name by specified cache and cache value class.
        Parameters:
        cacheName - Cache name.
        valType - Value type.
        Returns:
        Table name or null if there is no match.
      • markAsRebuildNeeded

        public void markAsRebuildNeeded​(GridCacheContext cctx,
                                        boolean val)
        Mark that for given cache index should/would be rebuilt.
        Parameters:
        cctx - Cache context.
      • rebuildIndexesFromHash

        public IgniteInternalFuture<?> rebuildIndexesFromHash​(GridCacheContext cctx,
                                                              boolean force)
        Rebuilds indexes for provided caches from corresponding hash indexes.
        Parameters:
        cctx - Cache context.
        force - Force rebuild indexes.
        Returns:
        Future that will be completed when rebuilding is finished.
      • indexRebuildFuture

        @Nullable
        public @Nullable IgniteInternalFuture<?> indexRebuildFuture​(int cacheId)
        Returns:
        Future that will be completed when indexes for given cache are restored.
      • querySqlFields

        public List<FieldsQueryCursor<List<?>>> querySqlFields​(SqlFieldsQuery qry,
                                                               boolean keepBinary,
                                                               boolean failOnMultipleStmts)
        Query SQL fields.
        Parameters:
        qry - Query.
        keepBinary - Keep binary flag.
        Returns:
        Cursor.
      • querySqlFields

        public FieldsQueryCursor<List<?>> querySqlFields​(SqlFieldsQuery qry,
                                                         boolean keepBinary)
        Query SQL fields.
        Parameters:
        qry - Query.
        keepBinary - Keep binary flag.
        Returns:
        Cursor.
      • querySqlFields

        public List<FieldsQueryCursor<List<?>>> querySqlFields​(@Nullable
                                                               @Nullable GridCacheContext<?,​?> cctx,
                                                               SqlFieldsQuery qry,
                                                               SqlClientContext cliCtx,
                                                               boolean keepBinary,
                                                               boolean failOnMultipleStmts)
        Query SQL fields.
        Parameters:
        cctx - Cache context.
        qry - Query.
        cliCtx - Client context.
        keepBinary - Keep binary flag.
        failOnMultipleStmts - If true the method must throws exception when query contains more then one SQL statement.
        Returns:
        Cursor.
      • querySqlFields

        public List<FieldsQueryCursor<List<?>>> querySqlFields​(@Nullable
                                                               @Nullable GridCacheContext<?,​?> cctx,
                                                               SqlFieldsQuery qry,
                                                               SqlClientContext cliCtx,
                                                               boolean keepBinary,
                                                               boolean failOnMultipleStmts,
                                                               @Nullable
                                                               @Nullable GridQueryCancel cancel)
        Query SQL fields.
        Parameters:
        cctx - Cache context.
        qry - Query.
        cliCtx - Client context.
        keepBinary - Keep binary flag.
        failOnMultipleStmts - If true the method must throws exception when query contains more then one SQL statement.
        cancel - Hook for query cancellation.
        Returns:
        Cursor.
      • querySqlFields

        public List<FieldsQueryCursor<List<?>>> querySqlFields​(@Nullable
                                                               @Nullable GridCacheContext<?,​?> cctx,
                                                               SqlFieldsQuery qry,
                                                               SqlClientContext cliCtx,
                                                               boolean keepBinary,
                                                               boolean failOnMultipleStmts,
                                                               GridCacheQueryType qryType,
                                                               @Nullable
                                                               @Nullable GridQueryCancel cancel)
        Query SQL fields.
        Parameters:
        cctx - Cache context.
        qry - Query.
        cliCtx - Client context.
        keepBinary - Keep binary flag.
        failOnMultipleStmts - If true the method must throws exception when query contains more then one SQL statement.
        qryType - Real query type.
        cancel - Hook for query cancellation.
        Returns:
        Cursor.
      • schemaName

        public String schemaName​(GridCacheContext<?,​?> cctx)
        Parameters:
        cctx - Cache context.
        Returns:
        Schema name.
      • streamUpdateQuery

        public long streamUpdateQuery​(@Nullable
                                      @Nullable String cacheName,
                                      String schemaName,
                                      IgniteDataStreamer<?,​?> streamer,
                                      String qry,
                                      Object[] args,
                                      String qryInitiatorId)
        Parameters:
        cacheName - Cache name.
        schemaName - Schema name.
        streamer - Data streamer.
        qry - Query.
        Returns:
        Update counter.
      • streamBatchedUpdateQuery

        public List<Long> streamBatchedUpdateQuery​(String schemaName,
                                                   SqlClientContext cliCtx,
                                                   String qry,
                                                   List<Object[]> args,
                                                   String qryInitiatorId)
        Parameters:
        schemaName - Schema name.
        cliCtx - Client context.
        qry - Query.
        args - Query arguments.
        Returns:
        Update counters.
      • querySql

        public <K,​V> QueryCursor<javax.cache.Cache.Entry<K,​V>> querySql​(GridCacheContext<?,​?> cctx,
                                                                                    SqlQuery qry,
                                                                                    boolean keepBinary)
        Execute distributed SQL query.
        Parameters:
        cctx - Cache context.
        qry - Query.
        keepBinary - Keep binary flag.
        Returns:
        Cursor.
      • runningQueries

        public Collection<GridRunningQueryInfo> runningQueries​(long duration)
        Collect local queries that already running more than specified duration.
        Parameters:
        duration - Duration to check.
        Returns:
        Collection of long running queries.
      • cancelQuery

        public void cancelQuery​(long queryId,
                                @Nullable
                                @Nullable UUID nodeId,
                                boolean async)
        Cancel query running on remote or local Node.
        Parameters:
        queryId - Query id.
        nodeId - Node id, if null, cancel local query.
        async - If true, execute asynchronously.
      • cancelLocalQueries

        public void cancelLocalQueries​(Collection<Long> queries)
        Cancel specified queries.
        Parameters:
        queries - Queries ID's to cancel.
      • dynamicIndexCreate

        public IgniteInternalFuture<?> dynamicIndexCreate​(String cacheName,
                                                          String schemaName,
                                                          String tblName,
                                                          QueryIndex idx,
                                                          boolean ifNotExists,
                                                          int parallel)
        Entry point for index procedure.
        Parameters:
        cacheName - Cache name.
        schemaName - Schema name.
        tblName - Table name.
        idx - Index.
        ifNotExists - When set to true operation will fail if index already exists.
        parallel - Index creation parallelism level.
        Returns:
        Future completed when index is created.
      • dynamicIndexDrop

        public IgniteInternalFuture<?> dynamicIndexDrop​(String cacheName,
                                                        String schemaName,
                                                        String idxName,
                                                        boolean ifExists)
        Entry point for index drop procedure
        Parameters:
        cacheName - Cache name.
        schemaName - Schema name.
        idxName - Index name.
        ifExists - When set to true operation fill fail if index doesn't exists.
        Returns:
        Future completed when index is created.
      • dynamicColumnAdd

        public IgniteInternalFuture<?> dynamicColumnAdd​(String cacheName,
                                                        String schemaName,
                                                        String tblName,
                                                        List<QueryField> cols,
                                                        boolean ifTblExists,
                                                        boolean ifNotExists)
        Entry point for add column procedure.
        Parameters:
        schemaName - Schema name.
        tblName - Target table name.
        cols - Columns to add.
        ifTblExists - Ignore operation if target table doesn't exist.
        ifNotExists - Ignore operation if column exists.
      • dynamicColumnRemove

        public IgniteInternalFuture<?> dynamicColumnRemove​(String cacheName,
                                                           String schemaName,
                                                           String tblName,
                                                           List<String> cols,
                                                           boolean ifTblExists,
                                                           boolean ifExists)
        Entry point for drop column procedure.
        Parameters:
        schemaName - Schema name.
        tblName - Target table name.
        cols - Columns to drop.
        ifTblExists - Ignore operation if target table doesn't exist.
        ifExists - Ignore operation if column does not exist.
      • queryIndex

        public <K,​V> IndexQueryResult<K,​V> queryIndex​(String cacheName,
                                                                  String valCls,
                                                                  IndexQueryDesc idxQryDesc,
                                                                  @Nullable
                                                                  @Nullable IgniteBiPredicate<K,​V> entryFilter,
                                                                  IndexingQueryFilter cacheFilter,
                                                                  boolean keepBinary,
                                                                  int taskHash)
                                                           throws IgniteCheckedException
        Type Parameters:
        K - Key type.
        V - Value type.
        Parameters:
        cacheName - Cache name.
        valCls - Cache value class.
        idxQryDesc - Index query description.
        entryFilter - Optional user defined cache entries filter.
        cacheFilter - Ignite specific cache entries filters.
        keepBinary - Keep binary flag.
        taskHash - Hashcode of the task.
        Returns:
        Key/value rows.
        Throws:
        IgniteCheckedException - If failed.
      • typeDescriptor

        @Nullable
        public @Nullable GridQueryTypeDescriptor typeDescriptor​(@Nullable
                                                                @Nullable String cacheName,
                                                                String typeName)
        Gets type descriptor for provided cache name and type name if type is still valid.
        Parameters:
        cacheName - Cache name.
        typeName - Type name.
        Returns:
        Query type descriptor or null if descriptor was not found.
      • sendStatusMessage

        public void sendStatusMessage​(UUID destNodeId,
                                      UUID opId,
                                      SchemaOperationException err,
                                      boolean nop)
        Send status message to coordinator node.
        Parameters:
        destNodeId - Destination node ID.
        opId - Operation ID.
        err - Error.
        nop - No-op flag.
      • onClientDisconnect

        public void onClientDisconnect()
                                throws IgniteCheckedException
        Performs necessary actions on disconnect of a stateful client (say, one associated with a transaction).
        Throws:
        IgniteCheckedException - If failed.
      • setRequestAffinityTopologyVersion

        public static void setRequestAffinityTopologyVersion​(AffinityTopologyVersion ver)
        Parameters:
        ver - Version.
      • getRequestAffinityTopologyVersion

        public static AffinityTopologyVersion getRequestAffinityTopologyVersion()
        Returns:
        Affinity topology version of the current request.
      • removeIndexRebuildFuturesOnExchange

        public void removeIndexRebuildFuturesOnExchange​(GridDhtPartitionsExchangeFuture fut,
                                                        @Nullable
                                                        @Nullable Set<Integer> cacheIds)
        Removing futures of rebuilding indexes that should have been rebuilt on the exchange.
        Parameters:
        fut - Exchange future.
        cacheIds - Cache ids for which futures will be deleted, if null then ids will be taken from the fut.
      • rebuildIndexOnExchange

        public boolean rebuildIndexOnExchange​(int cacheId,
                                              GridDhtPartitionsExchangeFuture fut)
        Checks that the indexes need to be rebuilt on the exchange.
        Parameters:
        cacheId - Cache id.
        fut - Exchange future.
        Returns:
        True if need to rebuild.
      • prepareRebuildIndexes

        public Set<Integer> prepareRebuildIndexes​(Set<Integer> cacheIds)
        Preparing futures of rebuilding indexes for caches. The future for the cache will be added only if the previous one is missing or completed.
        Parameters:
        cacheIds - Cache ids.
        Returns:
        Cache ids for which features have not been added.
      • markIndexRecreate

        public void markIndexRecreate​(GridCacheContext cacheCtx)
        Mark that index.bin recreating in progress.
        Parameters:
        cacheCtx - Cache context.
      • onFinishRebuildIndexes

        public void onFinishRebuildIndexes​(GridCacheContext cacheCtx)
        Callback on finish of rebuild cache indexes.

        If the cache is persistent, then we mark that the rebuilding of the indexes is completed and the entry will be deleted from the MetaStorage at the end of the checkpoint. Otherwise, delete the index rebuild entry.

        Parameters:
        cacheCtx - Cache context.
      • rebuildIndexesCompleted

        public boolean rebuildIndexesCompleted​(GridCacheContext cacheCtx)
        Check if rebuilding of indexes for the cache has been completed.
        Parameters:
        cacheCtx - Cache context.
        Returns:
        True if completed.
      • recreateCompleted

        public boolean recreateCompleted​(String cacheName)
        Parameters:
        cacheName - Cache name.
        Returns:
        True if index.bin recreating completed.
      • completeRebuildIndexes

        public void completeRebuildIndexes​(String cacheName)
        Force a mark that the index rebuild for the cache has completed.

        If the cache is persistent, then we mark that the rebuilding of the indexes is completed and the entry will be deleted from the MetaStorage at the end of the checkpoint. Otherwise, delete the index rebuild entry.

        Parameters:
        cacheName - Cache name.
      • getIdxBuildStatusStorage

        public IndexBuildStatusStorage getIdxBuildStatusStorage()
        Returns:
        Index build status storage.
      • schemaManager

        public SchemaManager schemaManager()
        Returns:
        Schema manager.