org.apache.ignite.cache.query

## Class SqlFieldsQuery

- java.lang.Object
- - org.apache.ignite.cache.query.Query<List<?>>
  - - org.apache.ignite.cache.query.SqlFieldsQuery

All Implemented Interfaces:
  Serializable

    public final class SqlFieldsQuery
    extends Query<List<?>>

SQL Fields query. This query can return specific fields of data based on SQL `'select'` clause, as opposed to `SqlQuery`, which always returns the whole key and value objects back.

# Collocated Flag

Collocation flag is used for optimization purposes. Whenever Ignite executes a distributed query, it sends sub-queries to individual cluster members. If you know in advance that the elements of your query selection are collocated together on the same node, usually based on some affinity-key, Ignite can make significant performance and network optimizations.

For example, in case of Word-Count example, we know that all identical words are processed on the same cluster member, because we use the `word` itself as affinity key. This allows Ignite to execute the `'limit'` clause on the remote nodes and bring back only the small data set specified within the 'limit' clause, instead of the whole query result as would happen in a non-collocated execution.

See Also:
  `IgniteCache.query(Query)`, Serialized Form

### Field Summary

### Fields inherited from class org.apache.ignite.cache.query.Query

`DFLT_PAGE_SIZE`

### Constructor Summary

Constructors
Constructor and Description
`SqlFieldsQuery(String sql)` Constructs SQL fields query.
`SqlFieldsQuery(String sql, boolean collocated)` Constructs SQL fields query.

### Method Summary

Methods
`Object[]` `getArgs()` Gets SQL arguments.
`String` `getSql()` Gets SQL clause.
`boolean` `isCollocated()` Checks if this query is collocated.
`SqlFieldsQuery` `setArgs(Object... args)` Sets SQL arguments.
`SqlFieldsQuery` `setCollocated(boolean collocated)` Sets flag defining if this query is collocated.
`SqlFieldsQuery` `setLocal(boolean loc)` Sets whether this query should be executed on local node only.
`SqlFieldsQuery` `setPageSize(int pageSize)` Sets optional page size, if `0`, then default is used.
`SqlFieldsQuery` `setSql(String sql)` Sets SQL clause.
`String` `toString()`

### Methods inherited from class org.apache.ignite.cache.query.Query

`getPageSize, isLocal`

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

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

### Constructor Detail

#### SqlFieldsQuery

    public SqlFieldsQuery(String sql)

Constructs SQL fields query.

Parameters:
  `sql` - SQL query.

#### SqlFieldsQuery

    public SqlFieldsQuery(String sql,
                  boolean collocated)

Constructs SQL fields query.

Parameters:
  `sql` - SQL query.
  `collocated` - Collocated flag.

### Method Detail

#### getSql

    public String getSql()

Gets SQL clause.

Returns:
  SQL clause.

#### setSql

    public SqlFieldsQuery setSql(String sql)

Sets SQL clause.

Parameters:
  `sql` - SQL clause.
Returns:
  `this` For chaining.

#### getArgs

    public Object[] getArgs()

Gets SQL arguments.

Returns:
  SQL arguments.

#### setArgs

    public SqlFieldsQuery setArgs(Object... args)

Sets SQL arguments.

Parameters:
  `args` - SQL arguments.
Returns:
  `this` For chaining.

#### isCollocated

    public boolean isCollocated()

Checks if this query is collocated.

Returns:
  `true` If the query is collocated.

#### setCollocated

    public SqlFieldsQuery setCollocated(boolean collocated)

Sets flag defining if this query is collocated.

Parameters:
  `collocated` - Flag value.
Returns:
  `this` For chaining.

#### setPageSize

    public SqlFieldsQuery setPageSize(int pageSize)

Sets optional page size, if `0`, then default is used.

Overrides:
  `setPageSize` in class `Query<List<?>>`
Parameters:
  `pageSize` - Optional page size.
Returns:
  `this` for chaining.

#### setLocal

    public SqlFieldsQuery setLocal(boolean loc)

Sets whether this query should be executed on local node only.

Overrides:
  `setLocal` in class `Query<List<?>>`
Parameters:
  `loc` - Local flag.
Returns:
  `this` for chaining.

#### toString

    public String toString()

Overrides:
  `toString` in class `Query<List<?>>`

2015 Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Fabric | : ver. 1.5.0.final
Release Date | : December 29 2015