org.apache.ignite.internal.processors.query

## Interface GridQueryIndexing

    public interface GridQueryIndexing

Abstraction for internal indexing implementation.

### Method Summary

Methods
`IndexingQueryFilter` `backupFilter(AffinityTopologyVersion topVer, int[] parts)` Returns backup filter.
`void` `cancelAllQueries()` Cancels all executing queries.
`void` `onDisconnected(IgniteFuture<?> reconnectFut)` Client disconnected callback.
`void` `onSwap(String spaceName, CacheObject key)` Will be called when entry with given key is swapped.
`void` `onUnswap(String spaceName, CacheObject key, CacheObject val)` Will be called when entry with given key is unswapped.
`PreparedStatement` `prepareNativeStatement(String schema, String sql)` Prepare native statement to retrieve JDBC metadata from.
`<K,V> GridCloseableIterator<IgniteBiTuple<K,V>>` `queryLocalSql(String spaceName, String qry, Collection<Object> params, GridQueryTypeDescriptor type, IndexingQueryFilter filter)` Executes regular query.
`GridQueryFieldsResult` `queryLocalSqlFields(String spaceName, String qry, Collection<Object> params, IndexingQueryFilter filter, boolean enforceJoinOrder, int timeout, GridQueryCancel cancel)` Queries individual fields (generally used by JDBC drivers).
`<K,V> GridCloseableIterator<IgniteBiTuple<K,V>>` `queryLocalText(String spaceName, String qry, GridQueryTypeDescriptor type, IndexingQueryFilter filter)` Executes text query.
`QueryCursor<List<?>>` `queryTwoStep(GridCacheContext<?,?> cctx, SqlFieldsQuery qry, GridQueryCancel cancel)` Parses SQL query into two step query and executes it.
`<K,V> QueryCursor<javax.cache.Cache.Entry<K,V>>` `queryTwoStep(GridCacheContext<?,?> cctx, SqlQuery qry)` Parses SQL query into two step query and executes it.
`void` `rebuildIndexes(String spaceName, GridQueryTypeDescriptor type)` Rebuilds all indexes of given type.
`void` `registerCache(GridCacheContext<?,?> cctx, CacheConfiguration<?,?> ccfg)` Registers cache.
`boolean` `registerType(String spaceName, GridQueryTypeDescriptor desc)` Registers type if it was not known before or updates it otherwise.
`void` `remove(String spaceName, CacheObject key, CacheObject val)` Removes index entry by key.
`void` `start(GridKernalContext ctx, GridSpinBusyLock busyLock)` Starts indexing.
`void` `stop()` Stops indexing.
`void` `store(String spaceName, GridQueryTypeDescriptor type, CacheObject key, CacheObject val, byte[] ver, long expirationTime)` Updates index.
`void` `unregisterCache(CacheConfiguration<?,?> ccfg)` Unregisters cache.
`void` `unregisterType(String spaceName, GridQueryTypeDescriptor type)` Unregisters type and removes all corresponding data.

### Method Detail

#### start

    void start(GridKernalContext ctx,
             GridSpinBusyLock busyLock)
               throws IgniteCheckedException

Starts indexing.

Parameters:
  `ctx` - Context.
  `busyLock` - Busy lock.
Throws:
  `IgniteCheckedException` - If failed.

#### stop

    void stop()
              throws IgniteCheckedException

Stops indexing.

Throws:
  `IgniteCheckedException` - If failed.

#### queryTwoStep

    QueryCursor<List<?>> queryTwoStep(GridCacheContext<?,?> cctx,
                                    SqlFieldsQuery qry,
                                    GridQueryCancel cancel)
                                      throws IgniteCheckedException

Parses SQL query into two step query and executes it.

Parameters:
  `cctx` - Cache context.
  `qry` - Query.
  `cancel` - Query cancel.
Returns:
  Cursor.
Throws:
  `IgniteCheckedException` - If failed.

#### queryTwoStep

    <K,V> QueryCursor<javax.cache.Cache.Entry<K,V>> queryTwoStep(GridCacheContext<?,?> cctx,
                                                               SqlQuery qry)
                                                           throws IgniteCheckedException

Parses SQL query into two step query and executes it.

Parameters:
  `cctx` - Cache context.
  `qry` - Query.
Returns:
  Cursor.
Throws:
  `IgniteCheckedException` - If failed.

#### queryLocalSqlFields

    GridQueryFieldsResult queryLocalSqlFields(@Nullable
                                            String spaceName,
                                            String qry,
                                            Collection<Object> params,
                                            IndexingQueryFilter filter,
                                            boolean enforceJoinOrder,
                                            int timeout,
                                            GridQueryCancel cancel)
                                              throws IgniteCheckedException

Queries individual fields (generally used by JDBC drivers).

Parameters:
  `spaceName` - Space name.
  `qry` - Query.
  `params` - Query parameters.
  `filter` - Space name and key filter.
  `enforceJoinOrder` - Enforce join order of tables in the query.
  `timeout` - Query timeout in milliseconds.
  `cancel` - Query cancel.
Returns:
  Query result.
Throws:
  `IgniteCheckedException` - If failed.

#### queryLocalSql

    <K,V> GridCloseableIterator<IgniteBiTuple<K,V>> queryLocalSql(@Nullable
                                                                String spaceName,
                                                                String qry,
                                                                Collection<Object> params,
                                                                GridQueryTypeDescriptor type,
                                                                IndexingQueryFilter filter)
                                                            throws IgniteCheckedException

Executes regular query.

Parameters:
  `spaceName` - Space name.
  `qry` - Query.
  `params` - Query parameters.
  `type` - Query return type.
  `filter` - Space name and key filter.
Returns:
  Queried rows.
Throws:
  `IgniteCheckedException` - If failed.

#### queryLocalText

    <K,V> GridCloseableIterator<IgniteBiTuple<K,V>> queryLocalText(@Nullable
                                                                 String spaceName,
                                                                 String qry,
                                                                 GridQueryTypeDescriptor type,
                                                                 IndexingQueryFilter filter)
                                                             throws IgniteCheckedException

Executes text query.

Parameters:
  `spaceName` - Space name.
  `qry` - Text query.
  `type` - Query return type.
  `filter` - Space name and key filter.
Returns:
  Queried rows.
Throws:
  `IgniteCheckedException` - If failed.

#### registerCache

    void registerCache(GridCacheContext<?,?> cctx,
                     CacheConfiguration<?,?> ccfg)
                       throws IgniteCheckedException

Registers cache.

Parameters:
  `cctx` - Cache context.
  `ccfg` - Cache configuration.
Throws:
  `IgniteCheckedException` - If failed.

#### unregisterCache

    void unregisterCache(CacheConfiguration<?,?> ccfg)
                         throws IgniteCheckedException

Unregisters cache.

Parameters:
  `ccfg` - Cache configuration.
Throws:
  `IgniteCheckedException` - If failed to drop cache schema.

#### registerType

    boolean registerType(@Nullable
                       String spaceName,
                       GridQueryTypeDescriptor desc)
                         throws IgniteCheckedException

Registers type if it was not known before or updates it otherwise.

Parameters:
  `spaceName` - Space name.
  `desc` - Type descriptor.
Returns:
  `True` if type was registered, `false` if for some reason it was rejected.
Throws:
  `IgniteCheckedException` - If failed.

#### unregisterType

    void unregisterType(@Nullable
                      String spaceName,
                      GridQueryTypeDescriptor type)
                        throws IgniteCheckedException

Unregisters type and removes all corresponding data.

Parameters:
  `spaceName` - Space name.
  `type` - Type descriptor.
Throws:
  `IgniteCheckedException` - If failed.

#### store

    void store(@Nullable
             String spaceName,
             GridQueryTypeDescriptor type,
             CacheObject key,
             CacheObject val,
             byte[] ver,
             long expirationTime)
               throws IgniteCheckedException

Updates index. Note that key is unique for space, so if space contains multiple indexes the key should be removed from indexes other than one being updated.

Parameters:
  `spaceName` - Space name.
  `type` - Value type.
  `key` - Key.
  `val` - Value.
  `ver` - Version.
  `expirationTime` - Expiration time or 0 if never expires.
Throws:
  `IgniteCheckedException` - If failed.

#### remove

    void remove(@Nullable
              String spaceName,
              CacheObject key,
              CacheObject val)
                throws IgniteCheckedException

Removes index entry by key.

Parameters:
  `spaceName` - Space name.
  `key` - Key.
  `val` - Value.
Throws:
  `IgniteCheckedException` - If failed.

#### onSwap

    void onSwap(@Nullable
              String spaceName,
              CacheObject key)
                throws IgniteCheckedException

Will be called when entry with given key is swapped.

Parameters:
  `spaceName` - Space name.
  `key` - Key.
Throws:
  `IgniteCheckedException` - If failed.

#### onUnswap

    void onUnswap(@Nullable
                String spaceName,
                CacheObject key,
                CacheObject val)
                  throws IgniteCheckedException

Will be called when entry with given key is unswapped.

Parameters:
  `spaceName` - Space name.
  `key` - Key.
  `val` - Value.
Throws:
  `IgniteCheckedException` - If failed.

#### rebuildIndexes

    void rebuildIndexes(@Nullable
                      String spaceName,
                      GridQueryTypeDescriptor type)

Rebuilds all indexes of given type.

Parameters:
  `spaceName` - Space name.
  `type` - Type descriptor.

#### backupFilter

    IndexingQueryFilter backupFilter(AffinityTopologyVersion topVer,
                                   int[] parts)

Returns backup filter.

Parameters:
  `topVer` - Topology version.
  `parts` - Partitions.
Returns:
  Backup filter.

#### onDisconnected

    void onDisconnected(IgniteFuture<?> reconnectFut)

Client disconnected callback.

Parameters:
  `reconnectFut` - Reconnect future.

#### prepareNativeStatement

    PreparedStatement prepareNativeStatement(String schema,
                                           String sql)
                                             throws SQLException

Prepare native statement to retrieve JDBC metadata from.

Parameters:
  `schema` - Schema.
  `sql` - Query.
Returns:
  `PreparedStatement` from underlying engine to supply metadata to Prepared - most likely H2.
Throws:
  `SQLException`

#### cancelAllQueries

    void cancelAllQueries()

Cancels all executing queries.

2015 Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Fabric | : ver. 1.8.0
Release Date | : December 5 2016