org.apache.ignite.springdata22.repository.query

## Class IgniteRepositoryQuery.QueryCursorWrapper<T,V>

- java.lang.Object
- - java.util.AbstractCollection<V>
  - - org.apache.ignite.springdata22.repository.query.IgniteRepositoryQuery.QueryCursorWrapper<T,V>

- Type Parameters:
    `T` - input type
    `V` - transformed output type
  All Implemented Interfaces:
    AutoCloseable, Iterable<V>, Collection<V>, QueryCursor<V>
  Enclosing class:
    IgniteRepositoryQuery

      public static class IgniteRepositoryQuery.QueryCursorWrapper<T,V>
      extends AbstractCollection<V>
      implements QueryCursor<V>

  Ignite QueryCursor wrapper.

  Ensures closing underline cursor when there is no data.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `QueryCursorWrapper(QueryCursor<T> delegate, Function<T,V> transformer)` Instantiates a new Query cursor wrapper.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `close()` Closes all resources related to this cursor.
    `List<V>` | `getAll()` Gets all query results and stores them in the collection.
    `Iterator<V>` | `iterator()`
    `int` | `size()`

    - ### Methods inherited from class java.util.AbstractCollection

      `add, addAll, clear, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray, toString`

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

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

    - ### Methods inherited from interface java.lang.Iterable

      `forEach, spliterator`

    - ### Methods inherited from interface java.util.Collection

      `equals, hashCode, parallelStream, removeIf, spliterator, stream`

- - ### Constructor Detail

    - #### QueryCursorWrapper

          public QueryCursorWrapper(QueryCursor<T> delegate,
                                    Function<T,V> transformer)

      Instantiates a new Query cursor wrapper.
      Parameters:
        `delegate` - delegate QueryCursor with T input elements
        `transformer` - Function to transform T to V elements

  - ### Method Detail

    - #### iterator

          public Iterator<V> iterator()

      Specified by:
        `iterator` in interface `Iterable<V>`
      Specified by:
        `iterator` in interface `Collection<V>`
      Specified by:
        `iterator` in class `AbstractCollection<V>`

    - #### 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<V>`

    - #### getAll

          public List<V> 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<V>`
      Returns:
        List containing all query results.

    - #### size

          public int size()

      Specified by:
        `size` in interface `Collection<V>`
      Specified by:
        `size` in class `AbstractCollection<V>`

2020 Copyright © Apache Software Foundation
| Follow @ApacheIgnite
Ignite Database and Caching Platform | : ver. 2.9.0
Release Date | : October 15 2020