Class QueryCursorImpl<T>
- java.lang.Object
-
- org.apache.ignite.internal.processors.cache.QueryCursorImpl<T>
-
- All Implemented Interfaces:
AutoCloseable,Iterable<T>,FieldsQueryCursor<T>,QueryCursor<T>,QueryCursorEx<T>
public class QueryCursorImpl<T> extends Object implements QueryCursorEx<T>, FieldsQueryCursor<T>
Query cursor implementation.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classQueryCursorImpl.LazyIterator<Type>Iterator wrapper for lazy results.protected static classQueryCursorImpl.StateQuery cursor state-
Nested classes/interfaces inherited from interface org.apache.ignite.internal.processors.cache.query.QueryCursorEx
QueryCursorEx.Consumer<T>
-
-
Constructor Summary
Constructors Constructor Description QueryCursorImpl(Iterable<T> iterExec)QueryCursorImpl(Iterable<T> iterExec, GridQueryCancel cancel, boolean isQry, boolean lazy)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Closes all resources related to this cursor.List<GridQueryFieldMetadata>fieldsMeta()voidfieldsMeta(List<GridQueryFieldMetadata> fieldsMeta)List<T>getAll()Gets all query results and stores them in the collection.voidgetAll(QueryCursorEx.Consumer<T> clo)Get all values passing them through passed consumer.intgetColumnsCount()Gets number of columns in a row.StringgetFieldName(int idx)Gets field name.booleanisQuery()protected Iterator<T>iter()Iterator<T>iterator()protected booleanlazy()PartitionResultpartitionResult()voidpartitionResult(PartitionResult partRes)-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Constructor Detail
-
QueryCursorImpl
public QueryCursorImpl(Iterable<T> iterExec)
- Parameters:
iterExec- Query executor.
-
QueryCursorImpl
public QueryCursorImpl(Iterable<T> iterExec, GridQueryCancel cancel, boolean isQry, boolean lazy)
- Parameters:
iterExec- Query executor.isQry- Result type flag -truefor query,falsefor update operation.
-
-
Method Detail
-
getAll
public List<T> getAll()
Gets all query results and stores them in the collection. Use this method when you know in advance that query result is relatively small and will not cause memory utilization issues.Since all the results will be fetched, all the resources will be closed automatically after this call, e.g. there is no need to call
QueryCursor.close()method in this case.- Specified by:
getAllin interfaceQueryCursor<T>- Returns:
- List containing all query results.
-
getAll
public void getAll(QueryCursorEx.Consumer<T> clo) throws IgniteCheckedException
Get all values passing them through passed consumer.- Specified by:
getAllin interfaceQueryCursorEx<T>- Parameters:
clo- Consumer.- Throws:
IgniteCheckedException
-
close
public void close()
Closes all resources related to this cursor. If the query execution is in progress (which is possible in case of invoking from another thread), a cancel will be attempted. Sequential calls to this method have no effect.Note: don't forget to close query cursors. Not doing so may lead to various resource leaks.
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceQueryCursor<T>
-
isQuery
public boolean isQuery()
- Specified by:
isQueryin interfaceQueryCursorEx<T>- Returns:
trueif this cursor corresponds to aResultSetas a result of query,falseif query was modifying operation like INSERT, UPDATE, or DELETE.
-
fieldsMeta
public void fieldsMeta(List<GridQueryFieldMetadata> fieldsMeta)
- Parameters:
fieldsMeta- SQL Fields query result metadata.
-
fieldsMeta
public List<GridQueryFieldMetadata> fieldsMeta()
- Specified by:
fieldsMetain interfaceQueryCursorEx<T>- Returns:
- SQL Fields query result metadata.
-
getFieldName
public String getFieldName(int idx)
Gets field name.- Specified by:
getFieldNamein interfaceFieldsQueryCursor<T>- Parameters:
idx- field index.- Returns:
- Field name.
-
getColumnsCount
public int getColumnsCount()
Gets number of columns in a row.- Specified by:
getColumnsCountin interfaceFieldsQueryCursor<T>- Returns:
- row size.
-
partitionResult
public PartitionResult partitionResult()
- Returns:
- Partition result.
-
lazy
protected boolean lazy()
- Returns:
- Lazy mode flag.
-
partitionResult
public void partitionResult(PartitionResult partRes)
- Parameters:
partRes- New partition result.
-
-