org.apache.ignite.internal.processors.query

## Class GridQueryProcessor

- java.lang.Object
- - org.apache.ignite.internal.processors.GridProcessorAdapter
  - - org.apache.ignite.internal.processors.query.GridQueryProcessor

All Implemented Interfaces:
  GridComponent, GridProcessor

    public class GridQueryProcessor
    extends GridProcessorAdapter

Indexing processor.

### Nested Class Summary

### Nested classes/interfaces inherited from interface org.apache.ignite.internal.GridComponent

`GridComponent.DiscoveryDataExchangeType`

### Field Summary

Fields
`static String` `_VAL`
`static Class<? extends GridQueryIndexing>` `idxCls` For tests.

### Fields inherited from class org.apache.ignite.internal.processors.GridProcessorAdapter

`ctx, log`

### Constructor Summary

Constructors
Constructor and Description
`GridQueryProcessor(GridKernalContext ctx)`

### Method Summary

Methods
`<R> R` `executeQuery(GridCacheContext<?,?> cctx, IgniteOutClosureX<R> clo, boolean complete)`
`static boolean` `isEnabled(CacheConfiguration<?,?> ccfg)`
`static boolean` `isGeometryClass(Class<?> cls)` Checks if the given class is GEOMETRY.
`static boolean` `isSqlType(Class<?> cls)` Checks if the given class can be mapped to a simple SQL type.
`boolean` `moduleEnabled()`
`void` `onCacheStart(GridCacheContext cctx)`
`void` `onCacheStop(GridCacheContext cctx)`
`static void` `onCompleted(GridCacheContext<?,?> cctx, Object res, Throwable err, long startTime, long duration, IgniteLogger log)`
`void` `onDisconnected(IgniteFuture<?> reconnectFut)` Client disconnected callback.
`void` `onKernalStop(boolean cancel)` Callback to notify that kernal is about to stop.
`void` `onSwap(String spaceName, CacheObject key)` Will be called when entry for key will be swapped.
`void` `onUndeploy(String space, ClassLoader ldr)` Removes index tables for all classes belonging to given class loader.
`void` `onUnswap(String spaceName, CacheObject key, CacheObject val)` Will be called when entry for key will be unswapped.
`<K,V> Iterator<javax.cache.Cache.Entry<K,V>>` `queryLocal(GridCacheContext<?,?> cctx, SqlQuery qry, boolean keepBinary)`
`QueryCursor<List<?>>` `queryLocalFields(GridCacheContext<?,?> cctx, SqlFieldsQuery qry)`
`<K,V> GridCloseableIterator<IgniteBiTuple<K,V>>` `queryText(String space, String clause, String resType, IndexingQueryFilter filters)`
`QueryCursor<List<?>>` `queryTwoStep(GridCacheContext<?,?> cctx, SqlFieldsQuery qry)`
`<K,V> QueryCursor<javax.cache.Cache.Entry<K,V>>` `queryTwoStep(GridCacheContext<?,?> cctx, SqlQuery qry)`
`IgniteInternalFuture<?>` `rebuildAllIndexes()` Rebuilds all search indexes for given spi.
`IgniteInternalFuture<?>` `rebuildIndexes(String space, String valTypeName)` Rebuilds all search indexes of given value type for given space of spi.
`void` `remove(String space, CacheObject key, CacheObject val)`
`void` `start()` Starts grid component.
`void` `stop(boolean cancel)` Stops grid component.
`void` `store(String space, CacheObject key, CacheObject val, byte[] ver, long expirationTime)` Writes key-value pair to index.
`GridQueryTypeDescriptor` `type(String space, String typeName)` Gets type descriptor for space and type name.
`static String` `typeName(Class<?> cls)` Gets type name by class.
`static String` `typeName(String clsName)` Gets type name by class.
`Collection<GridQueryTypeDescriptor>` `types(String space)` Gets types for space.

### Methods inherited from class org.apache.ignite.internal.processors.GridProcessorAdapter

`assertParameter, collectDiscoveryData, discoveryDataType, onDiscoveryDataReceived, onKernalStart, onReconnected, printMemoryStats, toString, validateNode`

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

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

### Field Detail

#### _VAL

    public static final String _VAL

See Also:
  Constant Field Values

#### idxCls

    public static Class<? extends GridQueryIndexing> idxCls

For tests.

### Constructor Detail

#### GridQueryProcessor

    public GridQueryProcessor(GridKernalContext ctx)
                       throws IgniteCheckedException

Parameters:
  `ctx` - Kernal context.
Throws:
  `IgniteCheckedException`

### Method Detail

#### start

    public void start()
               throws IgniteCheckedException

Starts grid component.

Specified by:
  `start` in interface `GridComponent`
Overrides:
  `start` in class `GridProcessorAdapter`
Throws:
  `IgniteCheckedException` - Throws in case of any errors.

#### isEnabled

    public static boolean isEnabled(CacheConfiguration<?,?> ccfg)

Parameters:
  `ccfg` - Cache configuration.
Returns:
  `true` If query index must be enabled for this cache.

#### moduleEnabled

    public boolean moduleEnabled()

Returns:
  `true` If indexing module is in classpath and successfully initialized.

#### onKernalStop

    public void onKernalStop(boolean cancel)

Callback to notify that kernal is about to stop.

Specified by:
  `onKernalStop` in interface `GridComponent`
Overrides:
  `onKernalStop` in class `GridProcessorAdapter`
Parameters:
  `cancel` - Flag indicating whether jobs should be canceled.

#### stop

    public void stop(boolean cancel)
              throws IgniteCheckedException

Stops grid component.

Specified by:
  `stop` in interface `GridComponent`
Overrides:
  `stop` in class `GridProcessorAdapter`
Parameters:
  `cancel` - If `true`, then all ongoing tasks or jobs for relevant components need to be cancelled.
Throws:
  `IgniteCheckedException` - Thrown in case of any errors.

#### onDisconnected

    public void onDisconnected(IgniteFuture<?> reconnectFut)
                        throws IgniteCheckedException

Client disconnected callback.

Specified by:
  `onDisconnected` in interface `GridComponent`
Overrides:
  `onDisconnected` in class `GridProcessorAdapter`
Parameters:
  `reconnectFut` - Reconnect future.
Throws:
  `IgniteCheckedException` - If failed.

#### onCacheStart

    public void onCacheStart(GridCacheContext cctx)
                      throws IgniteCheckedException

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

#### onCacheStop

    public void onCacheStop(GridCacheContext cctx)

Parameters:
  `cctx` - Cache context.

#### rebuildIndexes

    public IgniteInternalFuture<?> rebuildIndexes(@Nullable
                                         String space,
                                         String valTypeName)

Rebuilds all search indexes of given value type for given space of spi.

Parameters:
  `space` - Space.
  `valTypeName` - Value type name.
Returns:
  Future that will be completed when rebuilding of all indexes is finished.

#### rebuildAllIndexes

    public IgniteInternalFuture<?> rebuildAllIndexes()

Rebuilds all search indexes for given spi.

Returns:
  Future that will be completed when rebuilding of all indexes is finished.

#### store

    public void store(String space,
             CacheObject key,
             CacheObject val,
             byte[] ver,
             long expirationTime)
               throws IgniteCheckedException

Writes key-value pair to index.

Parameters:
  `space` - Space.
  `key` - Key.
  `val` - Value.
  `ver` - Cache entry version.
  `expirationTime` - Expiration time or 0 if never expires.
Throws:
  `IgniteCheckedException` - In case of error.

#### queryTwoStep

    public QueryCursor<List<?>> queryTwoStep(GridCacheContext<?,?> cctx,
                                    SqlFieldsQuery qry)

Parameters:
  `cctx` - Cache context.
  `qry` - Query.
Returns:
  Cursor.

#### queryTwoStep

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

Parameters:
  `cctx` - Cache context.
  `qry` - Query.
Returns:
  Cursor.

#### queryLocal

    public <K,V> Iterator<javax.cache.Cache.Entry<K,V>> queryLocal(GridCacheContext<?,?> cctx,
                                                          SqlQuery qry,
                                                          boolean keepBinary)

Parameters:
  `cctx` - Cache context.
  `qry` - Query.
  `keepBinary` - Keep binary flag.
Returns:
  Cursor.

#### queryLocalFields

    public QueryCursor<List<?>> queryLocalFields(GridCacheContext<?,?> cctx,
                                        SqlFieldsQuery qry)

Parameters:
  `cctx` - Cache context.
  `qry` - Query.
Returns:
  Iterator.

#### remove

    public void remove(String space,
              CacheObject key,
              CacheObject val)
                throws IgniteCheckedException

Parameters:
  `space` - Space.
  `key` - Key.
Throws:
  `IgniteCheckedException` - Thrown in case of any errors.

#### isSqlType

    public static boolean isSqlType(Class<?> cls)

Checks if the given class can be mapped to a simple SQL type.

Parameters:
  `cls` - Class.
Returns:
  `true` If can.

#### isGeometryClass

    public static boolean isGeometryClass(Class<?> cls)

Checks if the given class is GEOMETRY.

Parameters:
  `cls` - Class.
Returns:
  `true` If this is geometry.

#### typeName

    public static String typeName(Class<?> cls)

Gets type name by class.

Parameters:
  `cls` - Class.
Returns:
  Type name.

#### typeName

    public static String typeName(String clsName)

Gets type name by class.

Parameters:
  `clsName` - Class name.
Returns:
  Type name.

#### queryText

    public <K,V> GridCloseableIterator<IgniteBiTuple<K,V>> queryText(String space,
                                                            String clause,
                                                            String resType,
                                                            IndexingQueryFilter filters)
                                                        throws IgniteCheckedException

Type Parameters:
  `K` - Key type.
  `V` - Value type.
Parameters:
  `space` - Space.
  `clause` - Clause.
  `resType` - Result type.
  `filters` - Key and value filters.
Returns:
  Key/value rows.
Throws:
  `IgniteCheckedException` - If failed.

#### onSwap

    public void onSwap(String spaceName,
              CacheObject key)
                throws IgniteCheckedException

Will be called when entry for key will be swapped.

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

#### onUnswap

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

Will be called when entry for key will be unswapped.

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

#### onUndeploy

    public void onUndeploy(@Nullable
                  String space,
                  ClassLoader ldr)
                    throws IgniteCheckedException

Removes index tables for all classes belonging to given class loader.

Parameters:
  `space` - Space name.
  `ldr` - Class loader to undeploy.
Throws:
  `IgniteCheckedException` - If undeploy failed.

#### types

    public Collection<GridQueryTypeDescriptor> types(@Nullable
                                            String space)

Gets types for space.

Parameters:
  `space` - Space name.
Returns:
  Descriptors.

#### type

    public GridQueryTypeDescriptor type(@Nullable
                               String space,
                               String typeName)
                                 throws IgniteCheckedException

Gets type descriptor for space and type name.

Parameters:
  `space` - Space name.
  `typeName` - Type name.
Returns:
  Type descriptor.
Throws:
  `IgniteCheckedException` - If failed.

#### executeQuery

    public <R> R executeQuery(GridCacheContext<?,?> cctx,
                     IgniteOutClosureX<R> clo,
                     boolean complete)
                   throws IgniteCheckedException

Parameters:
  `cctx` - Cache context.
  `clo` - Closure.
  `complete` - Complete.
Throws:
  `IgniteCheckedException`

#### onCompleted

    public static void onCompleted(GridCacheContext<?,?> cctx,
                   Object res,
                   Throwable err,
                   long startTime,
                   long duration,
                   IgniteLogger log)

Parameters:
  `cctx` - Cctx.
  `res` - Result.
  `err` - Err.
  `startTime` - Start time.
  `duration` - Duration.
  `log` - Logger.

2015 Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Fabric | : ver. 1.7.0
Release Date | : August 1 2016