org.apache.ignite.internal.processors.cache.query

## Class GridCacheQueryManager<K,V>

- java.lang.Object
- - org.apache.ignite.internal.processors.cache.GridCacheManagerAdapter<K,V>
  - - org.apache.ignite.internal.processors.cache.query.GridCacheQueryManager<K,V>

All Implemented Interfaces:
  GridCacheManager<K,V>

Direct Known Subclasses:
  GridCacheDistributedQueryManager, GridCacheLocalQueryManager

    public abstract class GridCacheQueryManager<K,V>
    extends GridCacheManagerAdapter<K,V>

Query and index manager.

### Nested Class Summary

Nested Classes
`static class` `GridCacheQueryManager.CacheSqlIndexMetadata` Cache metadata index.
`static class` `GridCacheQueryManager.CacheSqlMetadata` Cache metadata.

### Field Summary

### Fields inherited from class org.apache.ignite.internal.processors.cache.GridCacheManagerAdapter

`cctx, log, starting`

### Constructor Summary

Constructors
Constructor and Description
`GridCacheQueryManager()`

### Method Summary

All Methods Instance Methods Abstract Methods Concrete Methods
`String` `cacheName()` FOR TESTING ONLY
`void` `collectMetrics(GridCacheQueryType qryType, String qry, long startTime, long duration, boolean failed)`
`CacheQuery<Map.Entry<K,V>>` `createFullTextQuery(String clsName, String search, boolean keepBinary)` Creates user's full text query, queried class, and query clause.
`<T,R> CacheQuery<R>` `createScanQuery(IgniteBiPredicate<K,V> filter, IgniteClosure<T,R> trans, Integer part, boolean keepBinary, boolean forceLocal)` Creates user's predicate based scan query.
`<R> CacheQuery<R>` `createScanQuery(IgniteBiPredicate<K,V> filter, Integer part, boolean keepBinary)` Creates user's predicate based scan query.
`<R> CacheQuery<R>` `createSpiQuery(boolean keepBinary)` Query for `IndexingSpi`.
`CacheQuery<List<?>>` `createSqlFieldsQuery(String qry, boolean keepBinary)` Creates user's SQL fields query for given clause.
`Collection<GridCacheQueryDetailMetricsAdapter>` `detailMetrics()` Gets cache queries detailed metrics.
`boolean` `enabled()`
`void` `evictDetailMetrics()` Evict detail metrics.
`abstract void` `loadPage(long id, GridCacheQueryAdapter<?> qry, Collection<ClusterNode> nodes, boolean all)` Loads page.
`QueryMetrics` `metrics()` Gets cache queries metrics.
`protected abstract boolean` `onFieldsPageReady(boolean loc, org.apache.ignite.internal.processors.cache.query.GridCacheQueryInfo qryInfo, List<GridQueryFieldMetadata> metaData, Collection<?> entities, Collection<?> data, boolean finished, Throwable e)`
`protected void` `onKernalStop0(boolean cancel)`
`protected abstract boolean` `onPageReady(boolean loc, org.apache.ignite.internal.processors.cache.query.GridCacheQueryInfo qryInfo, Collection<?> data, boolean finished, Throwable e)` Called when data for page is ready.
`void` `printMemoryStats()` Prints memory statistics for debugging purposes.
`abstract CacheQueryFuture<?>` `queryDistributed(GridCacheQueryBean qry, Collection<ClusterNode> nodes)` Executes distributed query.
`abstract CacheQueryFuture<?>` `queryFieldsDistributed(GridCacheQueryBean qry, Collection<ClusterNode> nodes)` Executes distributed fields query.
`abstract CacheQueryFuture<?>` `queryFieldsLocal(GridCacheQueryBean qry)` Executes distributed fields query.
`AffinityTopologyVersion` `queryTopologyVersion()`
`void` `remove(KeyCacheObject key, CacheDataRow prevRow)`
`protected void` `removeFieldsQueryResult(UUID sndId, long reqId)`
`protected void` `removeQueryResult(UUID sndId, long reqId)`
`void` `resetDetailMetrics()` Resets detail metrics.
`void` `resetMetrics()` Resets metrics.
`protected void` `runFieldsQuery(org.apache.ignite.internal.processors.cache.query.GridCacheQueryInfo qryInfo)` Processes fields query request.
`protected void` `runQuery(org.apache.ignite.internal.processors.cache.query.GridCacheQueryInfo qryInfo)` Processes cache query request.
`abstract GridCloseableIterator` `scanQueryDistributed(GridCacheQueryAdapter qry, Collection<ClusterNode> nodes)` Executes distributed SCAN query.
`protected GridCloseableIterator` `scanQueryLocal(GridCacheQueryAdapter qry, boolean updateStatistics)` Process local scan query.
`Collection<GridCacheSqlMetadata>` `sqlMetadata()` Gets SQL metadata.
`Collection<GridCacheSqlMetadata>` `sqlMetadataV2()` Gets SQL metadata with not nulls fields.
`void` `start0()`
`void` `stop0(boolean cancel, boolean destroy)` Stops query manager.
`void` `store(CacheDataRow newRow, CacheDataRow prevRow, boolean prevRowAvailable)`

### Methods inherited from class org.apache.ignite.internal.processors.cache.GridCacheManagerAdapter

`context, kernalStartInfo, kernalStopInfo, log, onDisconnected, onKernalStart, onKernalStart0, onKernalStop, start, startInfo, stop, stopInfo, toString`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

### Constructor Detail

#### GridCacheQueryManager

    public GridCacheQueryManager()

### Method Detail

#### start0

    public void start0()
                throws IgniteCheckedException

Overrides:
  `start0` in class `GridCacheManagerAdapter<K,V>`
Throws:
  `IgniteCheckedException` - If failed.

#### enabled

    public boolean enabled()

Returns:
  `True` if indexing is enabled for cache.

#### onKernalStop0

    protected void onKernalStop0(boolean cancel)

Overrides:
  `onKernalStop0` in class `GridCacheManagerAdapter<K,V>`
Parameters:
  `cancel` - Cancel flag.

#### stop0

    public final void stop0(boolean cancel,
                            boolean destroy)

Stops query manager.

Overrides:
  `stop0` in class `GridCacheManagerAdapter<K,V>`
Parameters:
  `cancel` - Cancel queries.
  `destroy` - Cache destroy flag..

#### store

    public void store(CacheDataRow newRow,
                      @Nullable
                      CacheDataRow prevRow,
                      boolean prevRowAvailable)
               throws IgniteCheckedException

Parameters:
  `newRow` - New row.
  `prevRow` - Previous row.
  `prevRowAvailable` - Whether previous row is available.
Throws:
  `IgniteCheckedException` - In case of error.

#### remove

    public void remove(KeyCacheObject key,
                       @Nullable
                       CacheDataRow prevRow)
                throws IgniteCheckedException

Parameters:
  `key` - Key.
  `prevRow` - Previous row.
Throws:
  `IgniteCheckedException` - Thrown in case of any errors.

#### queryDistributed

    public abstract CacheQueryFuture<?> queryDistributed(GridCacheQueryBean qry,
                                                         Collection<ClusterNode> nodes)

Executes distributed query.

Parameters:
  `qry` - Query.
  `nodes` - Nodes.
Returns:
  Query future.

#### scanQueryDistributed

    public abstract GridCloseableIterator scanQueryDistributed(GridCacheQueryAdapter qry,
                                                               Collection<ClusterNode> nodes)
                                                        throws IgniteCheckedException

Executes distributed SCAN query.

Parameters:
  `qry` - Query.
  `nodes` - Nodes.
Returns:
  Iterator.
Throws:
  `IgniteCheckedException` - If failed.

#### loadPage

    public abstract void loadPage(long id,
                                  GridCacheQueryAdapter<?> qry,
                                  Collection<ClusterNode> nodes,
                                  boolean all)

Loads page.

Parameters:
  `id` - Query ID.
  `qry` - Query.
  `nodes` - Nodes.
  `all` - Whether to load all pages.

#### queryFieldsLocal

    public abstract CacheQueryFuture<?> queryFieldsLocal(GridCacheQueryBean qry)

Executes distributed fields query.

Parameters:
  `qry` - Query.
Returns:
  Query future.

#### queryFieldsDistributed

    public abstract CacheQueryFuture<?> queryFieldsDistributed(GridCacheQueryBean qry,
                                                               Collection<ClusterNode> nodes)

Executes distributed fields query.

Parameters:
  `qry` - Query.
  `nodes` - Nodes.
Returns:
  Query future.

#### runFieldsQuery

    protected void runFieldsQuery(org.apache.ignite.internal.processors.cache.query.GridCacheQueryInfo qryInfo)

Processes fields query request.

Parameters:
  `qryInfo` - Query info.

#### runQuery

    protected void runQuery(org.apache.ignite.internal.processors.cache.query.GridCacheQueryInfo qryInfo)

Processes cache query request.

Parameters:
  `qryInfo` - Query info.

#### scanQueryLocal

    protected GridCloseableIterator scanQueryLocal(GridCacheQueryAdapter qry,
                                                   boolean updateStatistics)
                                            throws IgniteCheckedException

Process local scan query.

Parameters:
  `qry` - Query.
  `updateStatistics` - Update statistics flag.
Throws:
  `IgniteCheckedException`

#### removeQueryResult

    protected void removeQueryResult(@Nullable
                                     UUID sndId,
                                     long reqId)

Parameters:
  `sndId` - Sender node ID.
  `reqId` - Request ID.

#### removeFieldsQueryResult

    protected void removeFieldsQueryResult(@Nullable
                                           UUID sndId,
                                           long reqId)

Parameters:
  `sndId` - Sender node ID.
  `reqId` - Request ID.

#### onPageReady

    protected abstract boolean onPageReady(boolean loc,
                                           org.apache.ignite.internal.processors.cache.query.GridCacheQueryInfo qryInfo,
                                           @Nullable
                                           Collection<?> data,
                                           boolean finished,
                                           @Nullable
                                           Throwable e)

Called when data for page is ready.

Parameters:
  `loc` - Local query or not.
  `qryInfo` - Query info.
  `data` - Result data.
  `finished` - Last page or not.
  `e` - Exception in case of error.
Returns:
  `true` if page was processed right.

#### onFieldsPageReady

    protected abstract boolean onFieldsPageReady(boolean loc,
                                                 org.apache.ignite.internal.processors.cache.query.GridCacheQueryInfo qryInfo,
                                                 @Nullable
                                                 List<GridQueryFieldMetadata> metaData,
                                                 @Nullable
                                                 Collection<?> entities,
                                                 @Nullable
                                                 Collection<?> data,
                                                 boolean finished,
                                                 @Nullable
                                                 Throwable e)

Parameters:
  `loc` - Local query or not.
  `qryInfo` - Query info.
  `metaData` - Meta data.
  `entities` - Indexing entities.
  `data` - Data.
  `finished` - Last page or not.
  `e` - Exception in case of error.
Returns:
  `true` if page was processed right.

#### metrics

    public QueryMetrics metrics()

Gets cache queries metrics.

Returns:
  Cache queries metrics.

#### detailMetrics

    public Collection<GridCacheQueryDetailMetricsAdapter> detailMetrics()

Gets cache queries detailed metrics. Detail metrics could be enabled by setting non-zero value via `CacheConfiguration.setQueryDetailMetricsSize(int)`

Returns:
  Cache queries metrics aggregated by query type and query text.

#### evictDetailMetrics

    public void evictDetailMetrics()

Evict detail metrics.

#### resetMetrics

    public void resetMetrics()

Resets metrics.

#### resetDetailMetrics

    public void resetDetailMetrics()

Resets detail metrics.

#### collectMetrics

    public void collectMetrics(GridCacheQueryType qryType,
                               String qry,
                               long startTime,
                               long duration,
                               boolean failed)

Parameters:
  `qryType` - Query type.
  `qry` - Query description.
  `startTime` - Query start size.
  `duration` - Execution duration.
  `failed` - `True` if query execution failed.

#### sqlMetadata

    public Collection<GridCacheSqlMetadata> sqlMetadata()
                                                 throws IgniteCheckedException

Gets SQL metadata.

Returns:
  SQL metadata.
Throws:
  `IgniteCheckedException` - In case of error.

#### sqlMetadataV2

    public Collection<GridCacheSqlMetadata> sqlMetadataV2()
                                                   throws IgniteCheckedException

Gets SQL metadata with not nulls fields.

Returns:
  SQL metadata.
Throws:
  `IgniteCheckedException` - In case of error.

#### queryTopologyVersion

    public AffinityTopologyVersion queryTopologyVersion()

Returns:
  Topology version for query requests.

#### printMemoryStats

    public void printMemoryStats()

Prints memory statistics for debugging purposes.

Specified by:
  `printMemoryStats` in interface `GridCacheManager<K,V>`
Overrides:
  `printMemoryStats` in class `GridCacheManagerAdapter<K,V>`

#### cacheName

    public String cacheName()

FOR TESTING ONLY

Returns:
  Cache name for this query manager.

#### createSpiQuery

    public <R> CacheQuery<R> createSpiQuery(boolean keepBinary)

Query for `IndexingSpi`.

Parameters:
  `keepBinary` - Keep binary flag.
Returns:
  Query.

#### createScanQuery

    public <R> CacheQuery<R> createScanQuery(@Nullable
                                             IgniteBiPredicate<K,V> filter,
                                             @Nullable
                                             Integer part,
                                             boolean keepBinary)

Creates user's predicate based scan query.

Parameters:
  `filter` - Scan filter.
  `part` - Partition.
  `keepBinary` - Keep binary flag.
Returns:
  Created query.

#### createScanQuery

    public <T,R> CacheQuery<R> createScanQuery(@Nullable
                                               IgniteBiPredicate<K,V> filter,
                                               @Nullable
                                               IgniteClosure<T,R> trans,
                                               @Nullable
                                               Integer part,
                                               boolean keepBinary,
                                               boolean forceLocal)

Creates user's predicate based scan query.

Parameters:
  `filter` - Scan filter.
  `trans` - Transformer.
  `part` - Partition.
  `keepBinary` - Keep binary flag.
  `forceLocal` - Flag to force local scan.
Returns:
  Created query.

#### createFullTextQuery

    public CacheQuery<Map.Entry<K,V>> createFullTextQuery(String clsName,
                                                          String search,
                                                          boolean keepBinary)

Creates user's full text query, queried class, and query clause. For more information refer to `CacheQuery` documentation.

Parameters:
  `clsName` - Query class name.
  `search` - Search clause.
  `keepBinary` - Keep binary flag.
Returns:
  Created query.

#### createSqlFieldsQuery

    public CacheQuery<List<?>> createSqlFieldsQuery(String qry,
                                                    boolean keepBinary)

Creates user's SQL fields query for given clause. For more information refer to `CacheQuery` documentation.

Parameters:
  `qry` - Query.
  `keepBinary` - Keep binary flag.
Returns:
  Created query.

${current.year} Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Database and Caching Platform | : ver. 2.7.6
Release Date | : September 11 2019