Class SqlFieldsQuery
- java.lang.Object
- 
- org.apache.ignite.cache.query.Query<List<?>>
- 
- org.apache.ignite.cache.query.SqlFieldsQuery
 
 
- 
- All Implemented Interfaces:
- Serializable
 
 public class SqlFieldsQuery extends Query<List<?>> SQL Fields query. This query can return specific fields of data based on SQL'select'clause.Collocated FlagCollocation 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 worditself 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 SummaryFields Modifier and Type Field Description static booleanDFLT_LAZYDo not remove.- 
Fields inherited from class org.apache.ignite.cache.query.QueryDFLT_PAGE_SIZE
 
- 
 - 
Constructor SummaryConstructors Constructor Description SqlFieldsQuery(String sql)Constructs SQL fields query.SqlFieldsQuery(String sql, boolean collocated)Constructs SQL fields query.SqlFieldsQuery(SqlFieldsQuery qry)Copy constructs SQL fields query.
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description SqlFieldsQuerycopy()Object[]getArgs()Gets SQL arguments.@org.jetbrains.annotations.Nullable int[]getPartitions()StringgetQueryInitiatorId()@Nullable StringgetSchema()Get schema for the query.StringgetSql()Gets SQL clause.intgetTimeout()Gets the query execution timeout in milliseconds.intgetUpdateBatchSize()Gets update internal bach size.booleanisCollocated()Checks if this query is collocated.booleanisDistributedJoins()Check if distributed joins are enabled for this query.booleanisEnforceJoinOrder()Checks if join order of tables if enforced.booleanisLazy()Deprecated.UseQuery.getPageSize()instead.booleanisReplicatedOnly()Deprecated.No longer used as of Apache Ignite 2.8.static voidresetThreadedQueryInitiatorId()Used at the job worker to clear originator for current thread.SqlFieldsQuerysetArgs(Object... args)Sets SQL arguments.SqlFieldsQuerysetCollocated(boolean collocated)Sets flag defining if this query is collocated.SqlFieldsQuerysetDistributedJoins(boolean distributedJoins)Specify if distributed joins are enabled for this query.SqlFieldsQuerysetEnforceJoinOrder(boolean enforceJoinOrder)Sets flag to enforce join order of tables in the query.SqlFieldsQuerysetLazy(boolean lazy)Deprecated.UsesetPageSize(int)instead.SqlFieldsQuerysetLocal(boolean loc)Sets whether this query should be executed on local node only.SqlFieldsQuerysetPageSize(int pageSize)Sets optional page size, if0, then default is used.SqlFieldsQuerysetPartitions(@org.jetbrains.annotations.Nullable int... parts)Sets partitions for a query.SqlFieldsQuerysetQueryInitiatorId(String qryInitiatorId)SqlFieldsQuerysetReplicatedOnly(boolean replicatedOnly)Deprecated.No longer used as of Apache Ignite 2.8.SqlFieldsQuerysetSchema(@Nullable String schema)Set schema for the query.SqlFieldsQuerysetSql(String sql)Sets SQL clause.static voidsetThreadedQueryInitiatorId(String originator)Used at the Job worker to setup originator by default for current thread.SqlFieldsQuerysetTimeout(int timeout, TimeUnit timeUnit)Sets the query execution timeout.SqlFieldsQuerysetUpdateBatchSize(int updateBatchSize)Sets update internal bach size.static StringthreadedQueryInitiatorId()StringtoString()- 
Methods inherited from class org.apache.ignite.cache.query.QuerygetPageSize, isLocal, prepare
 
- 
 
- 
- 
- 
Constructor Detail- 
SqlFieldsQuerypublic SqlFieldsQuery(SqlFieldsQuery qry) Copy constructs SQL fields query.- Parameters:
- qry- SQL query.
 
 - 
SqlFieldsQuerypublic SqlFieldsQuery(String sql) Constructs SQL fields query.- Parameters:
- sql- SQL query.
 
 - 
SqlFieldsQuerypublic SqlFieldsQuery(String sql, boolean collocated) Constructs SQL fields query.- Parameters:
- sql- SQL query.
- collocated- Collocated flag.
 
 
- 
 - 
Method Detail- 
getSqlpublic String getSql() Gets SQL clause.- Returns:
- SQL clause.
 
 - 
setSqlpublic SqlFieldsQuery setSql(String sql) Sets SQL clause.- Parameters:
- sql- SQL clause.
- Returns:
- thisFor chaining.
 
 - 
getArgspublic Object[] getArgs() Gets SQL arguments.- Returns:
- SQL arguments.
 
 - 
setArgspublic SqlFieldsQuery setArgs(Object... args) Sets SQL arguments.- Parameters:
- args- SQL arguments.
- Returns:
- thisFor chaining.
 
 - 
getTimeoutpublic int getTimeout() Gets the query execution timeout in milliseconds.- Returns:
- Timeout value.
 
 - 
setTimeoutpublic SqlFieldsQuery setTimeout(int timeout, TimeUnit timeUnit) Sets the query execution timeout. Query will be automatically cancelled if the execution timeout is exceeded.- Parameters:
- timeout- Timeout value. Zero value disables timeout.
- timeUnit- Time unit.
- Returns:
- thisFor chaining.
 
 - 
isCollocatedpublic boolean isCollocated() Checks if this query is collocated.- Returns:
- trueIf the query is collocated.
 
 - 
setCollocatedpublic SqlFieldsQuery setCollocated(boolean collocated) Sets flag defining if this query is collocated. Collocation flag is used for optimization purposes of queries with GROUP BY statements. 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 and you group by collocated key (primary or affinity key), then Ignite can make significant performance and network optimizations by grouping data on remote nodes.- Parameters:
- collocated- Flag value.
- Returns:
- thisFor chaining.
 
 - 
isEnforceJoinOrderpublic boolean isEnforceJoinOrder() Checks if join order of tables if enforced.- Returns:
- Flag value.
 
 - 
setEnforceJoinOrderpublic SqlFieldsQuery setEnforceJoinOrder(boolean enforceJoinOrder) Sets flag to enforce join order of tables in the query. If set totruequery optimizer will not reorder tables in join. By default isfalse.It is not recommended to enable this property until you are sure that your indexes and the query itself are correct and tuned as much as possible but query optimizer still produces wrong join order. - Parameters:
- enforceJoinOrder- Flag value.
- Returns:
- thisFor chaining.
 
 - 
setDistributedJoinspublic SqlFieldsQuery setDistributedJoins(boolean distributedJoins) Specify if distributed joins are enabled for this query.- Parameters:
- distributedJoins- Distributed joins enabled.
- Returns:
- thisFor chaining.
 
 - 
isDistributedJoinspublic boolean isDistributedJoins() Check if distributed joins are enabled for this query.- Returns:
- trueIf distributed joins enabled.
 
 - 
setPageSizepublic SqlFieldsQuery setPageSize(int pageSize) Sets optional page size, if0, then default is used.- Overrides:
- setPageSizein class- Query<List<?>>
- Parameters:
- pageSize- Optional page size.
- Returns:
- thisfor chaining.
 
 - 
setLocalpublic SqlFieldsQuery setLocal(boolean loc) Sets whether this query should be executed on local node only.
 - 
setReplicatedOnly@Deprecated public SqlFieldsQuery setReplicatedOnly(boolean replicatedOnly) Deprecated.No longer used as of Apache Ignite 2.8.Specify if the query contains only replicated tables. This is a hint for potentially more effective execution.- Parameters:
- replicatedOnly- The query contains only replicated tables.
- Returns:
- thisFor chaining.
 
 - 
isReplicatedOnly@Deprecated public boolean isReplicatedOnly() Deprecated.No longer used as of Apache Ignite 2.8.Check is the query contains only replicated tables.- Returns:
- trueIf the query contains only replicated tables.
 
 - 
setLazypublic SqlFieldsQuery setLazy(boolean lazy) Deprecated.UsesetPageSize(int)instead.Sets lazy query execution flag.If lazy=falseIgnite will attempt to fetch the whole query result set to memory and send it to the client. For small and medium result sets this provides optimal performance and minimize duration of internal database locks, thus increasing concurrency.If result set is too big to fit in available memory this could lead to excessive GC pauses and even OutOfMemoryError. Use this flag as a hint for Ignite to fetch result set lazily, thus minimizing memory consumption at the cost of moderate performance hit.Defaults to true, meaning that the only first page of result set is fetched to memory.- Parameters:
- lazy- Lazy query execution flag.
- Returns:
- thisFor chaining.
 
 - 
isLazypublic boolean isLazy() Deprecated.UseQuery.getPageSize()instead.Gets lazy query execution flag.See setLazy(boolean)for more information.- Returns:
- Lazy flag.
 
 - 
getPartitions@Nullable public @org.jetbrains.annotations.Nullable int[] getPartitions() - Returns:
- Partitions for query, in ascending order.
 
 - 
setPartitionspublic SqlFieldsQuery setPartitions(@Nullable @org.jetbrains.annotations.Nullable int... parts) Sets partitions for a query. The query will be executed only on nodes which are primary for specified partitions.Note what passed array'll be sorted in place for performance reasons, if it wasn't sorted yet. - Parameters:
- parts- Partitions.
- Returns:
- thisfor chaining.
 
 - 
getSchema@Nullable public @Nullable String getSchema() Get schema for the query. If not set, current cache name is used, which means you can omit schema name for tables within the current cache.- Returns:
- Schema. Null if schema is not set.
 
 - 
setSchemapublic SqlFieldsQuery setSchema(@Nullable @Nullable String schema) Set schema for the query. If not set, current cache name is used, which means you can omit schema name for tables within the current cache.- Parameters:
- schema- Schema. Null to unset schema.
- Returns:
- thisfor chaining.
 
 - 
getUpdateBatchSizepublic int getUpdateBatchSize() Gets update internal bach size. Default is 1 to prevent deadlock on update where keys sequence are different in several concurrent updates.- Returns:
- Update internal batch size
 
 - 
setUpdateBatchSizepublic SqlFieldsQuery setUpdateBatchSize(int updateBatchSize) Sets update internal bach size. Default is 1 to prevent deadlock on update where keys sequence are different in several concurrent updates.- Parameters:
- updateBatchSize- Update internal batch size.
- Returns:
- thisfor chaining.
 
 - 
getQueryInitiatorIdpublic String getQueryInitiatorId() - Returns:
- Query's initiator identifier string (client host+port, user name, job name or any user's information about query initiator).
 
 - 
setQueryInitiatorIdpublic SqlFieldsQuery setQueryInitiatorId(String qryInitiatorId) - Parameters:
- qryInitiatorId- Query's initiator identifier string (client host+port, user name, job name or any user's information about query initiator).
- Returns:
- thisfor chaining.
 
 - 
copypublic SqlFieldsQuery copy() - Returns:
- Copy of this query.
 
 - 
setThreadedQueryInitiatorIdpublic static void setThreadedQueryInitiatorId(String originator) Used at the Job worker to setup originator by default for current thread.- Parameters:
- originator- Query's originator string.
 
 - 
resetThreadedQueryInitiatorIdpublic static void resetThreadedQueryInitiatorId() Used at the job worker to clear originator for current thread.
 - 
threadedQueryInitiatorIdpublic static String threadedQueryInitiatorId() - Returns:
- originator set up by the job worker.
 
 
- 
 
-