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.

### Field Summary

Fields
`static int` `MAX_ITERATORS`
`protected GridQueryProcessor` `qryProc`

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

`cctx, log`

### Constructor Summary

Constructors
Constructor and Description
`GridCacheQueryManager()`

### Method Summary

Methods
`<K,V> IndexingQueryFilter` `backupsFilter(boolean includeBackups)`
`CacheQuery<Map.Entry<K,V>>` `createFullTextQuery(String clsName, String search, boolean keepPortable)` Creates user's full text query, queried class, and query clause.
`CacheQuery<Map.Entry<K,V>>` `createScanQuery(IgniteBiPredicate<K,V> filter, Integer part, boolean keepPortable)` Creates user's predicate based scan query.
`<R> CacheQuery<R>` `createSpiQuery(boolean keepPortable)` Query for `IndexingSpi`.
`CacheQuery<List<?>>` `createSqlFieldsQuery(String qry, boolean keepPortable)` Creates user's SQL fields query for given clause.
`boolean` `enabled()`
`abstract void` `loadPage(long id, GridCacheQueryAdapter<?> qry, Collection<ClusterNode> nodes, boolean all)` Loads page.
`QueryMetrics` `metrics()` Gets cache queries metrics.
`void` `onCompleted(long duration, boolean fail)`
`void` `onExecuted(boolean fail)`
`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` `onSwap(CacheObject key)` Entry for given key unswapped.
`void` `onUndeploy(ClassLoader ldr)` Undeploys given class loader.
`void` `onUnswap(CacheObject key, CacheObject val)` Entry for given key unswapped.
`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.
`abstract CacheQueryFuture<?>` `queryLocal(GridCacheQueryBean qry)` Executes local query.
`AffinityTopologyVersion` `queryTopologyVersion()`
`IgniteInternalFuture<?>` `rebuildIndexes(String typeName)` Rebuilds all search indexes of given value type.
`void` `remove(CacheObject key, CacheObject val)`
`protected void` `removeFieldsQueryResult(UUID sndId, long reqId)`
`protected void` `removeQueryResult(UUID sndId, long reqId)`
`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.
`long` `size(Class<?> valType)` Gets number of objects of given type in index.
`String` `space()` FOR TESTING ONLY
`Collection<GridCacheSqlMetadata>` `sqlMetadata()` Gets SQL metadata.
`void` `start0()`
`void` `stop0(boolean cancel)` Stops query manager.
`void` `store(CacheObject key, CacheObject val, GridCacheVersion ver, long expirationTime)` Writes key-value pair to index.

### 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`

### Field Detail

#### MAX_ITERATORS

    public static int MAX_ITERATORS

#### qryProc

    protected GridQueryProcessor qryProc

### 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)

Stops query manager.

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

#### size

    public long size(Class<?> valType)
              throws IgniteCheckedException

Gets number of objects of given type in index.

Parameters:
  `valType` - Value type.
Returns:
  Number of objects or -1 if type was not indexed at all.
Throws:
  `IgniteCheckedException` - If failed.

#### rebuildIndexes

    public IgniteInternalFuture<?> rebuildIndexes(String typeName)

Rebuilds all search indexes of given value type.

Parameters:
  `typeName` - Value type name.
Returns:
  Future that will be completed when rebuilding of all indexes is finished.

#### onSwap

    public void onSwap(CacheObject key)
                throws IgniteCheckedException

Entry for given key unswapped.

Parameters:
  `key` - Key.
Throws:
  `IgniteCheckedException` - If failed.

#### onUnswap

    public void onUnswap(CacheObject key,
                CacheObject val)
                  throws IgniteCheckedException

Entry for given key unswapped.

Parameters:
  `key` - Key.
  `val` - Value
Throws:
  `IgniteCheckedException` - If failed.

#### store

    public void store(CacheObject key,
             CacheObject val,
             GridCacheVersion ver,
             long expirationTime)
               throws IgniteCheckedException

Writes key-value pair to index.

Parameters:
  `key` - Key.
  `val` - Value.
  `ver` - Cache entry version.
  `expirationTime` - Expiration time or 0 if never expires.
Throws:
  `IgniteCheckedException` - In case of error.

#### remove

    public void remove(CacheObject key,
              CacheObject val)
                throws IgniteCheckedException

Parameters:
  `key` - Key.
  `val` - Value.
Throws:
  `IgniteCheckedException` - Thrown in case of any errors.

#### onUndeploy

    public void onUndeploy(ClassLoader ldr)

Undeploys given class loader.

Parameters:
  `ldr` - Class loader to undeploy.

#### queryLocal

    public abstract CacheQueryFuture<?> queryLocal(GridCacheQueryBean qry)

Executes local query.

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

#### queryDistributed

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

Executes distributed query.

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

#### 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.

#### 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.

#### resetMetrics

    public void resetMetrics()

Resets metrics.

#### onExecuted

    public void onExecuted(boolean fail)

Parameters:
  `fail` - `true` if execution failed.

#### onCompleted

    public void onCompleted(long duration,
                   boolean fail)

Parameters:
  `duration` - Execution duration.
  `fail` - `true` if execution failed.

#### sqlMetadata

    public Collection<GridCacheSqlMetadata> sqlMetadata()
                                                 throws IgniteCheckedException

Gets SQL metadata.

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

#### backupsFilter

    @Nullable
    public <K,V> IndexingQueryFilter backupsFilter(boolean includeBackups)

Type Parameters:
  `K` - Key type.
  `V` - Value type.
Parameters:
  `includeBackups` - Include backups.
Returns:
  Predicate.

#### 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>`

#### space

    public String space()

FOR TESTING ONLY

Returns:
  Indexing space for this query manager.

#### createSpiQuery

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

Query for `IndexingSpi`.

Parameters:
  `keepPortable` - Keep portable flag.
Returns:
  Query.

#### createScanQuery

    public CacheQuery<Map.Entry<K,V>> createScanQuery(@Nullable
                                             IgniteBiPredicate<K,V> filter,
                                             @Nullable
                                             Integer part,
                                             boolean keepPortable)

Creates user's predicate based scan query.

Parameters:
  `filter` - Scan filter.
  `part` - Partition.
  `keepPortable` - Keep portable flag.
Returns:
  Created query.

#### createFullTextQuery

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

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.
  `keepPortable` - Keep portable flag.
Returns:
  Created query.

#### createSqlFieldsQuery

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

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

Parameters:
  `qry` - Query.
  `keepPortable` - Keep portable flag.
Returns:
  Created query.

2015 Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Fabric | : ver. 1.5.0-b1
Release Date | : December 1 2015