org.apache.ignite.internal.processors.cache

## 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
`protected static class` `QueryCursorImpl.State` Query cursor state

### Nested classes/interfaces inherited from interface org.apache.ignite.internal.processors.cache.query.QueryCursorEx

`QueryCursorEx.Consumer<T>`

### Constructor Summary

Constructors
Constructor and Description
`QueryCursorImpl(Iterable<T> iterExec)`
`QueryCursorImpl(Iterable<T> iterExec, GridQueryCancel cancel)`
`QueryCursorImpl(Iterable<T> iterExec, GridQueryCancel cancel, boolean isQry)`

### Method Summary

All Methods Instance Methods Concrete Methods
`void` `close()` Closes all resources related to this cursor.
`List<GridQueryFieldMetadata>` `fieldsMeta()`
`void` `fieldsMeta(List<GridQueryFieldMetadata> fieldsMeta)`
`List<T>` `getAll()` Gets all query results and stores them in the collection.
`void` `getAll(QueryCursorEx.Consumer<T> clo)` Get all values passing them through passed consumer.
`int` `getColumnsCount()` Gets number of columns in a row.
`String` `getFieldName(int idx)` Gets field name.
`boolean` `isQuery()`
`Iterator<T>` `iterator()`

### 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,
                           GridQueryCancel cancel)

Parameters:
  `iterExec` - Query executor.
  `cancel` - Cancellation closure.

#### QueryCursorImpl

    public QueryCursorImpl(Iterable<T> iterExec)

Parameters:
  `iterExec` - Query executor.

#### QueryCursorImpl

    public QueryCursorImpl(Iterable<T> iterExec,
                           GridQueryCancel cancel,
                           boolean isQry)

Parameters:
  `iterExec` - Query executor.
  `isQry` - Result type flag - `true` for query, `false` for update operation.

### Method Detail

#### iterator

    public Iterator<T> iterator()

Specified by:
  `iterator` in interface `Iterable<T>`

#### 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:
  `getAll` in interface `QueryCursor<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:
  `getAll` in interface `QueryCursorEx<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:
  `close` in interface `AutoCloseable`
Specified by:
  `close` in interface `QueryCursor<T>`

#### isQuery

    public boolean isQuery()

Returns:
  `true` if this cursor corresponds to a `ResultSet` as a result of query, `false` if 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:
  `fieldsMeta` in interface `QueryCursorEx<T>`
Returns:
  SQL Fields query result metadata.

#### getFieldName

    public String getFieldName(int idx)

Gets field name.

Specified by:
  `getFieldName` in interface `FieldsQueryCursor<T>`
Parameters:
  `idx` - field index.
Returns:
  Field name.

#### getColumnsCount

    public int getColumnsCount()

Gets number of columns in a row.

Specified by:
  `getColumnsCount` in interface `FieldsQueryCursor<T>`
Returns:
  row size.

2018 Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Fabric | : ver. 2.5.0
Release Date | : May 23 2018