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

## Class GridCacheQueryAdapter<T>

- java.lang.Object
- - org.apache.ignite.internal.processors.cache.query.GridCacheQueryAdapter<T>

All Implemented Interfaces:
  CacheQuery<T>

    public class GridCacheQueryAdapter<T>
    extends Object
    implements CacheQuery<T>

Query adapter.

### Constructor Summary

Constructors
Constructor and Description
`GridCacheQueryAdapter(GridCacheContext<?,?> cctx, GridCacheQueryType type, IgniteBiPredicate<Object,Object> filter, IgniteClosure<Map.Entry,Object> transform, Integer part, boolean keepBinary, boolean forceLocal)`
`GridCacheQueryAdapter(GridCacheContext<?,?> cctx, GridCacheQueryType type, IgniteLogger log, int pageSize, long timeout, boolean incBackups, boolean dedup, ClusterGroup prj, IgniteBiPredicate<Object,Object> filter, Integer part, String clsName, String clause, boolean incMeta, boolean keepBinary, UUID subjId, int taskHash, MvccSnapshot mvccSnapshot)`
`GridCacheQueryAdapter(GridCacheContext<?,?> cctx, GridCacheQueryType type, String clsName, String clause, IgniteBiPredicate<Object,Object> filter, Integer part, boolean incMeta, boolean keepBinary)`

### Method Summary

All Methods Instance Methods Concrete Methods
`String` `clause()`
`boolean` `enableDedup()`
`CacheQuery<T>` `enableDedup(boolean dedup)` Sets whether or not to deduplicate query result set.
`<R> CacheQueryFuture<R>` `execute(IgniteReducer<T,R> rmtReducer, Object... args)` Executes the query the same way as `CacheQuery.execute(Object...)` method but reduces result remotely.
`CacheQueryFuture<T>` `execute(Object... args)` Executes the query and returns the query future.
`GridCloseableIterator` `executeScanQuery()`
`boolean` `forceLocal()`
`boolean` `includeBackups()`
`CacheQuery<T>` `includeBackups(boolean incBackups)` Sets whether or not to include backup entries into query result.
`boolean` `includeMetadata()`
`boolean` `keepBinary()`
`void` `keepBinary(boolean keepBinary)` Forces query to keep binary object representation even if query was created on plain projection.
`QueryMetrics` `metrics()` Gets metrics for this query.
`int` `pageSize()`
`CacheQuery<T>` `pageSize(int pageSize)` Sets result page size.
`Integer` `partition()`
`ClusterGroup` `projection()`
`CacheQuery<T>` `projection(ClusterGroup prj)` Sets optional grid projection to execute this query on.
`String` `queryClassName()`
`void` `resetMetrics()` Resets metrics for this query.
`<K,V> IgniteBiPredicate<K,V>` `scanFilter()`
`UUID` `subjectId()`
`void` `subjectId(UUID subjId)`
`int` `taskHash()`
`long` `timeout()`
`CacheQuery<T>` `timeout(long timeout)` Sets query timeout.
`String` `toString()`
`<K,V> IgniteClosure<Map.Entry<K,V>,Object>` `transform()`
`GridCacheQueryType` `type()`
`void` `validate()`

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

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

### Constructor Detail

#### GridCacheQueryAdapter

    public GridCacheQueryAdapter(GridCacheContext<?,?> cctx,
                                 GridCacheQueryType type,
                                 @Nullable
                                 IgniteBiPredicate<Object,Object> filter,
                                 @Nullable
                                 IgniteClosure<Map.Entry,Object> transform,
                                 @Nullable
                                 Integer part,
                                 boolean keepBinary,
                                 boolean forceLocal)

Parameters:
  `cctx` - Context.
  `type` - Query type.
  `filter` - Scan filter.
  `part` - Partition.
  `keepBinary` - Keep binary flag.
  `forceLocal` - Flag to force local query.

#### GridCacheQueryAdapter

    public GridCacheQueryAdapter(GridCacheContext<?,?> cctx,
                                 GridCacheQueryType type,
                                 @Nullable
                                 String clsName,
                                 @Nullable
                                 String clause,
                                 @Nullable
                                 IgniteBiPredicate<Object,Object> filter,
                                 @Nullable
                                 Integer part,
                                 boolean incMeta,
                                 boolean keepBinary)

Parameters:
  `cctx` - Context.
  `type` - Query type.
  `clsName` - Class name.
  `clause` - Clause.
  `filter` - Scan filter.
  `part` - Partition.
  `incMeta` - Include metadata flag.
  `keepBinary` - Keep binary flag.

#### GridCacheQueryAdapter

    public GridCacheQueryAdapter(GridCacheContext<?,?> cctx,
                                 GridCacheQueryType type,
                                 IgniteLogger log,
                                 int pageSize,
                                 long timeout,
                                 boolean incBackups,
                                 boolean dedup,
                                 ClusterGroup prj,
                                 IgniteBiPredicate<Object,Object> filter,
                                 @Nullable
                                 Integer part,
                                 @Nullable
                                 String clsName,
                                 String clause,
                                 boolean incMeta,
                                 boolean keepBinary,
                                 UUID subjId,
                                 int taskHash,
                                 MvccSnapshot mvccSnapshot)

Parameters:
  `cctx` - Context.
  `type` - Query type.
  `log` - Logger.
  `pageSize` - Page size.
  `timeout` - Timeout.
  `incBackups` - Include backups flag.
  `dedup` - Enable dedup flag.
  `prj` - Grid projection.
  `filter` - Key-value filter.
  `part` - Partition.
  `clsName` - Class name.
  `clause` - Clause.
  `incMeta` - Include metadata flag.
  `keepBinary` - Keep binary flag.
  `subjId` - Security subject ID.
  `taskHash` - Task hash.
  `mvccSnapshot` - Mvcc version.

### Method Detail

#### type

    public GridCacheQueryType type()

Returns:
  Type.

#### queryClassName

    @Nullable
    public String queryClassName()

Returns:
  Class name.

#### clause

    @Nullable
    public String clause()

Returns:
  Clause.

#### includeMetadata

    public boolean includeMetadata()

Returns:
  Include metadata flag.

#### keepBinary

    public boolean keepBinary()

Returns:
  `True` if binary should not be deserialized.

#### keepBinary

    public void keepBinary(boolean keepBinary)

Forces query to keep binary object representation even if query was created on plain projection.

Parameters:
  `keepBinary` - Keep binary flag.

#### forceLocal

    public boolean forceLocal()

Returns:
  `True` if the query is forced local.

#### subjectId

    public UUID subjectId()

Returns:
  Security subject ID.

#### taskHash

    public int taskHash()

Returns:
  Task hash.

#### subjectId

    public void subjectId(UUID subjId)

Parameters:
  `subjId` - Security subject ID.

#### pageSize

    public CacheQuery<T> pageSize(int pageSize)

Sets result page size. If not provided, `Query.DFLT_PAGE_SIZE` will be used. Results are returned from queried nodes one page at a tme.

Specified by:
  `pageSize` in interface `CacheQuery<T>`
Parameters:
  `pageSize` - Page size.
Returns:
  `this` query instance for chaining.

#### pageSize

    public int pageSize()

Returns:
  Page size.

#### timeout

    public CacheQuery<T> timeout(long timeout)

Sets query timeout. `0` means there is no timeout (this is a default value).

Specified by:
  `timeout` in interface `CacheQuery<T>`
Parameters:
  `timeout` - Query timeout.
Returns:
  `this` query instance for chaining.

#### timeout

    public long timeout()

Returns:
  Timeout.

#### includeBackups

    public CacheQuery<T> includeBackups(boolean incBackups)

Sets whether or not to include backup entries into query result. This flag is `false` by default.

Specified by:
  `includeBackups` in interface `CacheQuery<T>`
Parameters:
  `incBackups` - Query `includeBackups` flag.
Returns:
  `this` query instance for chaining.

#### includeBackups

    public boolean includeBackups()

Returns:
  Include backups.

#### enableDedup

    public CacheQuery<T> enableDedup(boolean dedup)

Sets whether or not to deduplicate query result set. If this flag is `true` then query result will not contain some key more than once even if several nodes returned entries with the same keys. Default value is `false`.

Specified by:
  `enableDedup` in interface `CacheQuery<T>`
Parameters:
  `dedup` - Query `enableDedup` flag.
Returns:
  `this` query instance for chaining.

#### enableDedup

    public boolean enableDedup()

Returns:
  Enable dedup flag.

#### projection

    public CacheQuery<T> projection(ClusterGroup prj)

Sets optional grid projection to execute this query on.

Specified by:
  `projection` in interface `CacheQuery<T>`
Parameters:
  `prj` - Projection.
Returns:
  `this` query instance for chaining.

#### projection

    public ClusterGroup projection()

Returns:
  Grid projection.

#### scanFilter

    @Nullable
    public <K,V> IgniteBiPredicate<K,V> scanFilter()

Returns:
  Key-value filter.

#### transform

    @Nullable
    public <K,V> IgniteClosure<Map.Entry<K,V>,Object> transform()

Returns:
  Transformer.

#### partition

    @Nullable
    public Integer partition()

Returns:
  Partition.

#### validate

    public void validate()
                  throws IgniteCheckedException

Throws:
  `IgniteCheckedException` - If query is invalid.

#### execute

    public CacheQueryFuture<T> execute(@Nullable
                                       Object... args)

Executes the query and returns the query future. Caller may decide to iterate over the returned future directly in which case the iterator may block until the next value will become available, or wait for the whole query to finish by calling any of the `'get(..)'` methods on the returned future.

Note that if the passed in grid projection is a local node, then query will be executed locally without distribution to other nodes.

Also note that query state cannot be changed (clause, timeout etc.), except arguments, if this method was called at least once.

Specified by:
  `execute` in interface `CacheQuery<T>`
Parameters:
  `args` - Optional arguments.
Returns:
  Future for the query result.

#### execute

    public <R> CacheQueryFuture<R> execute(IgniteReducer<T,R> rmtReducer,
                                           @Nullable
                                           Object... args)

Executes the query the same way as `CacheQuery.execute(Object...)` method but reduces result remotely.

Specified by:
  `execute` in interface `CacheQuery<T>`
Parameters:
  `rmtReducer` - Remote reducer.
  `args` - Optional arguments.
Returns:
  Future for the query result.

#### metrics

    public QueryMetrics metrics()

Gets metrics for this query.

Specified by:
  `metrics` in interface `CacheQuery<T>`
Returns:
  Query metrics.

#### resetMetrics

    public void resetMetrics()

Resets metrics for this query.

Specified by:
  `resetMetrics` in interface `CacheQuery<T>`

#### executeScanQuery

    public GridCloseableIterator executeScanQuery()
                                           throws IgniteCheckedException

Specified by:
  `executeScanQuery` in interface `CacheQuery<T>`
Returns:
  Scan query iterator.
Throws:
  `IgniteCheckedException`

#### toString

    public String toString()

Overrides:
  `toString` in class `Object`

2018 Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Database and Caching Platform | : ver. 2.7.0
Release Date | : November 30 2018