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

## Class GridCacheQueriesImpl<K,V>

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

All Implemented Interfaces:
  Externalizable, Serializable, CacheQueries<K,V>, GridCacheQueriesEx<K,V>

    public class GridCacheQueriesImpl<K,V>
    extends Object
    implements GridCacheQueriesEx<K,V>, Externalizable

`CacheQueries` implementation.

See Also:
  Serialized Form

### Constructor Summary

Constructors
Constructor and Description
`GridCacheQueriesImpl()` Required by `Externalizable`.
`GridCacheQueriesImpl(GridCacheContext<K,V> ctx, GridCacheProjectionImpl<K,V> prj)`

### Method Summary

Methods
`CacheQuery<Map.Entry<K,V>>` `createFullTextQuery(Class<?> cls, String search)` Creates user's full text query, queried class, and query clause.
`CacheQuery<Map.Entry<K,V>>` `createFullTextQuery(String clsName, String search)` Creates user's full text query, queried class, and query clause.
`CacheQuery<Map.Entry<K,V>>` `createScanQuery(IgniteBiPredicate<K,V> filter)` Creates user's predicate based scan query.
`<R> CacheQuery<R>` `createSpiQuery()` Query for `IndexingSpi`.
`CacheQuery<List<?>>` `createSqlFieldsQuery(String qry)` Creates user's SQL fields query for given clause.
`CacheQuery<List<?>>` `createSqlFieldsQuery(String qry, boolean incMeta)` Creates SQL fields query which will include results metadata if needed.
`CacheQuery<Map.Entry<K,V>>` `createSqlQuery(Class<?> cls, String clause)` Creates user's SQL query, queried class, and query clause which is generally a where clause.
`CacheQuery<Map.Entry<K,V>>` `createSqlQuery(String clsName, String clause)` Creates user's SQL query, queried class, and query clause which is generally a where clause.
`QueryCursor<List<?>>` `execute(String space, GridCacheTwoStepQuery qry)`
`QueryCursor<List<?>>` `executeTwoStepQuery(String space, String sqlQry, Object[] params)`
`QueryMetrics` `metrics()` Accumulated metrics for all queries executed for this cache.
`void` `readExternal(ObjectInput in)`
`IgniteInternalFuture<?>` `rebuildAllIndexes()` Forces this cache to rebuild search indexes of all types.
`IgniteInternalFuture<?>` `rebuildIndexes(Class<?> cls)` Forces this cache to rebuild all search indexes of given value type.
`IgniteInternalFuture<?>` `rebuildIndexes(String typeName)` Forces this cache to rebuild all search indexes of given value type.
`void` `resetMetrics()` Resets accumulated metrics.
`Collection<GridCacheSqlMetadata>` `sqlMetadata()` Gets SQL metadata.
`void` `writeExternal(ObjectOutput out)`

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

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

### Constructor Detail

#### GridCacheQueriesImpl

    public GridCacheQueriesImpl()

Required by `Externalizable`.

#### GridCacheQueriesImpl

    public GridCacheQueriesImpl(GridCacheContext<K,V> ctx,
                        @Nullable
                        GridCacheProjectionImpl<K,V> prj)

Parameters:
  `ctx` - Context.
  `prj` - Projection.

### Method Detail

#### createSqlQuery

    public CacheQuery<Map.Entry<K,V>> createSqlQuery(Class<?> cls,
                                            String clause)

Creates user's SQL query, queried class, and query clause which is generally a where clause. For more information refer to `CacheQuery` documentation.

Specified by:
  `createSqlQuery` in interface `CacheQueries<K,V>`
Parameters:
  `cls` - Query class.
  `clause` - Query clause.
Returns:
  Created query.

#### createSqlQuery

    public CacheQuery<Map.Entry<K,V>> createSqlQuery(String clsName,
                                            String clause)

Creates user's SQL query, queried class, and query clause which is generally a where clause. For more information refer to `CacheQuery` documentation.

Specified by:
  `createSqlQuery` in interface `CacheQueries<K,V>`
Parameters:
  `clsName` - Query class name.
  `clause` - Query clause.
Returns:
  Created query.

#### createSqlFieldsQuery

    public CacheQuery<List<?>> createSqlFieldsQuery(String qry)

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

Specified by:
  `createSqlFieldsQuery` in interface `CacheQueries<K,V>`
Parameters:
  `qry` - Query.
Returns:
  Created query.

#### createFullTextQuery

    public CacheQuery<Map.Entry<K,V>> createFullTextQuery(Class<?> cls,
                                                 String search)

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

Specified by:
  `createFullTextQuery` in interface `CacheQueries<K,V>`
Parameters:
  `cls` - Query class.
  `search` - Search clause.
Returns:
  Created query.

#### createFullTextQuery

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

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

Specified by:
  `createFullTextQuery` in interface `CacheQueries<K,V>`
Parameters:
  `clsName` - Query class name.
  `search` - Search clause.
Returns:
  Created query.

#### createScanQuery

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

Creates user's predicate based scan query.

Specified by:
  `createScanQuery` in interface `CacheQueries<K,V>`
Parameters:
  `filter` - Scan filter.
Returns:
  Created query.

#### createSpiQuery

    public <R> CacheQuery<R> createSpiQuery()

Query for `IndexingSpi`.

Specified by:
  `createSpiQuery` in interface `GridCacheQueriesEx<K,V>`
Returns:
  Query.

#### execute

    public QueryCursor<List<?>> execute(String space,
                               GridCacheTwoStepQuery qry)

Specified by:
  `execute` in interface `GridCacheQueriesEx<K,V>`
Parameters:
  `space` - Space name.
  `qry` - Query.
Returns:
  Cursor.

#### executeTwoStepQuery

    public QueryCursor<List<?>> executeTwoStepQuery(String space,
                                           String sqlQry,
                                           Object[] params)

Specified by:
  `executeTwoStepQuery` in interface `GridCacheQueriesEx<K,V>`
Parameters:
  `space` - Space.
  `sqlQry` - Query.
  `params` - Parameters.
Returns:
  Cursor.

#### rebuildIndexes

    public IgniteInternalFuture<?> rebuildIndexes(Class<?> cls)

Forces this cache to rebuild all search indexes of given value type. Sometimes indexes may hold references to objects that have already been removed from cache. Although not affecting query results, these objects may consume extra memory. Rebuilding indexes will remove any redundant references that may have temporarily got stuck inside in-memory index.

Specified by:
  `rebuildIndexes` in interface `CacheQueries<K,V>`
Parameters:
  `cls` - Value type to rebuild indexes for.
Returns:
  Future that will be completed when rebuilding of all indexes is finished.

#### rebuildIndexes

    public IgniteInternalFuture<?> rebuildIndexes(String typeName)

Forces this cache to rebuild all search indexes of given value type. Sometimes indexes may hold references to objects that have already been removed from cache. Although not affecting query results, these objects may consume extra memory. Rebuilding indexes will remove any redundant references that may have temporarily got stuck inside in-memory index.

Specified by:
  `rebuildIndexes` in interface `CacheQueries<K,V>`
Parameters:
  `typeName` - Value type name to rebuild indexes for.
Returns:
  Future that will be completed when rebuilding of all indexes is finished.

#### rebuildAllIndexes

    public IgniteInternalFuture<?> rebuildAllIndexes()

Forces this cache to rebuild search indexes of all types. Sometimes indexes may hold references to objects that have already been removed from cache. Although not affecting query results, these objects may consume extra memory. Rebuilding indexes will remove any redundant references that may have temporarily got stuck inside in-memory index.

Specified by:
  `rebuildAllIndexes` in interface `CacheQueries<K,V>`
Returns:
  Future that will be completed when rebuilding of all indexes is finished.

#### metrics

    public QueryMetrics metrics()

Accumulated metrics for all queries executed for this cache.

Specified by:
  `metrics` in interface `CacheQueries<K,V>`
Returns:
  Cache query metrics.

#### resetMetrics

    public void resetMetrics()

Resets accumulated metrics.

Specified by:
  `resetMetrics` in interface `CacheQueries<K,V>`

#### sqlMetadata

    public Collection<GridCacheSqlMetadata> sqlMetadata()
                                                 throws IgniteCheckedException

Gets SQL metadata.

Specified by:
  `sqlMetadata` in interface `GridCacheQueriesEx<K,V>`
Returns:
  SQL metadata.
Throws:
  `IgniteCheckedException` - In case of error.

#### createSqlFieldsQuery

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

Creates SQL fields query which will include results metadata if needed.

Specified by:
  `createSqlFieldsQuery` in interface `GridCacheQueriesEx<K,V>`
Parameters:
  `qry` - SQL query.
  `incMeta` - Whether to include results metadata.
Returns:
  Created query.

#### writeExternal

    public void writeExternal(ObjectOutput out)
                       throws IOException

Specified by:
  `writeExternal` in interface `Externalizable`
Throws:
  `IOException`

#### readExternal

    public void readExternal(ObjectInput in)
                      throws IOException,
                             ClassNotFoundException

Specified by:
  `readExternal` in interface `Externalizable`
Throws:
  `IOException`
  `ClassNotFoundException`

2015 Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Fabric | : ver. 1.0.0
Release Date | : March 31 2015