org.apache.ignite.internal.processors.query

## Class QueryUtils

- java.lang.Object
- - org.apache.ignite.internal.processors.query.QueryUtils

    public class QueryUtils
    extends Object

Utility methods for queries.

### Nested Class Summary

Nested Classes
`static class` `QueryUtils.KeyOrValProperty` Property used for keyFieldName or valueFieldName

### Field Summary

Fields
`static String` `KEY_FIELD_NAME` Field name for key.
`static String` `VAL_FIELD_NAME` Field name for value.
`static String` `VER_FIELD_NAME` Version field name.

### Method Summary

Methods
`static QueryBinaryProperty` `buildBinaryProperty(GridKernalContext ctx, String pathStr, Class<?> resType, Map<String,String> aliases, Boolean isKeyField)` Builds binary object property.
`static QueryClassProperty` `buildClassProperty(boolean key, Class<?> cls, String pathStr, Class<?> resType, Map<String,String> aliases, CacheObjectContext coCtx)`
`static QueryClassProperty` `buildClassProperty(Class<?> keyCls, Class<?> valCls, String pathStr, Class<?> resType, Map<String,String> aliases, CacheObjectContext coCtx)`
`static GridQueryProperty` `buildProperty(Class<?> keyCls, Class<?> valCls, String keyFieldName, String valueFieldName, String pathStr, Class<?> resType, Map<String,String> aliases, CacheObjectContext coCtx)`
`static QueryIndexDescriptorImpl` `createIndexDescriptor(QueryTypeDescriptorImpl typeDesc, QueryIndex idx)` Create index descriptor.
`static int` `discoveryHistorySize()` Discovery history size.
`static String` `indexName(QueryEntity entity, QueryIndex idx)` Get index name.
`static String` `indexName(String tblName, QueryIndex idx)` Get index name.
`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.
`static void` `prepareCacheConfiguration(CacheConfiguration ccfg)` Prepare cache configuration.
`static void` `processBinaryMeta(GridKernalContext ctx, QueryEntity qryEntity, QueryTypeDescriptorImpl d)` Processes declarative metadata for binary object.
`static void` `processClassMeta(QueryEntity qryEntity, QueryTypeDescriptorImpl d, CacheObjectContext coCtx)` Processes declarative metadata for binary object.
`static void` `processDynamicIndexChange(String idxName, QueryIndex idx, QueryTypeDescriptorImpl d)` Process dynamic index change.
`static String` `propertyInitializationExceptionMessage(Class<?> keyCls, Class<?> valCls, String pathStr, Class<?> resType)` Exception message to compare in tests.
`static String` `tableName(QueryEntity entity)` Get table name for entity.
`static QueryTypeCandidate` `typeForQueryEntity(String space, GridCacheContext cctx, QueryEntity qryEntity, List<Class<?>> mustDeserializeClss)` Create type candidate for query entity.
`static String` `typeName(Class<?> cls)` Gets type name by class.
`static String` `typeName(String clsName)` Gets type name by class.
`static void` `validateCacheConfiguration(CacheConfiguration ccfg)` Prepare cache configuration.
`static int` `validateTimeout(int timeout, TimeUnit timeUnit)`
`static SchemaOperationException` `wrapIfNeeded(Exception e)` Wrap schema exception if needed.

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

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

### Field Detail

#### KEY_FIELD_NAME

    public static final String KEY_FIELD_NAME

Field name for key.

See Also:
  Constant Field Values

#### VAL_FIELD_NAME

    public static final String VAL_FIELD_NAME

Field name for value.

See Also:
  Constant Field Values

#### VER_FIELD_NAME

    public static final String VER_FIELD_NAME

Version field name.

See Also:
  Constant Field Values

### Method Detail

#### tableName

    public static String tableName(QueryEntity entity)

Get table name for entity.

Parameters:
  `entity` - Entity.
Returns:
  Table name.

#### indexName

    public static String indexName(QueryEntity entity,
                   QueryIndex idx)

Get index name.

Parameters:
  `entity` - Query entity.
  `idx` - Index.
Returns:
  Index name.

#### indexName

    public static String indexName(String tblName,
                   QueryIndex idx)

Get index name.

Parameters:
  `tblName` - Table name.
  `idx` - Index.
Returns:
  Index name.

#### typeForQueryEntity

    public static QueryTypeCandidate typeForQueryEntity(String space,
                                        GridCacheContext cctx,
                                        QueryEntity qryEntity,
                                        List<Class<?>> mustDeserializeClss)
                                                 throws IgniteCheckedException

Create type candidate for query entity.

Parameters:
  `space` - Space.
  `cctx` - Cache context.
  `qryEntity` - Query entity.
  `mustDeserializeClss` - Classes which must be deserialized.
Returns:
  Type candidate.
Throws:
  `IgniteCheckedException` - If failed.

#### processBinaryMeta

    public static void processBinaryMeta(GridKernalContext ctx,
                         QueryEntity qryEntity,
                         QueryTypeDescriptorImpl d)
                                  throws IgniteCheckedException

Processes declarative metadata for binary object.

Parameters:
  `ctx` - Kernal context.
  `qryEntity` - Declared metadata.
  `d` - Type descriptor.
Throws:
  `IgniteCheckedException` - If failed.

#### processClassMeta

    public static void processClassMeta(QueryEntity qryEntity,
                        QueryTypeDescriptorImpl d,
                        CacheObjectContext coCtx)
                                 throws IgniteCheckedException

Processes declarative metadata for binary object.

Parameters:
  `qryEntity` - Declared metadata.
  `d` - Type descriptor.
Throws:
  `IgniteCheckedException` - If failed.

#### processDynamicIndexChange

    public static void processDynamicIndexChange(String idxName,
                                 @Nullable
                                 QueryIndex idx,
                                 QueryTypeDescriptorImpl d)
                                          throws IgniteCheckedException

Process dynamic index change.

Parameters:
  `idx` - Index.
  `d` - Type descriptor to populate.
Throws:
  `IgniteCheckedException` - If failed to build index information.

#### createIndexDescriptor

    public static QueryIndexDescriptorImpl createIndexDescriptor(QueryTypeDescriptorImpl typeDesc,
                                                 QueryIndex idx)
                                                          throws IgniteCheckedException

Create index descriptor.

Parameters:
  `typeDesc` - Type descriptor.
  `idx` - Index.
Returns:
  Index descriptor.
Throws:
  `IgniteCheckedException` - If failed.

#### buildBinaryProperty

    public static QueryBinaryProperty buildBinaryProperty(GridKernalContext ctx,
                                          String pathStr,
                                          Class<?> resType,
                                          Map<String,String> aliases,
                                          @Nullable
                                          Boolean isKeyField)
                                                   throws IgniteCheckedException

Builds binary object property.

Parameters:
  `ctx` - Kernal context.
  `pathStr` - String representing path to the property. May contains dots '.' to identify nested fields.
  `resType` - Result type.
  `aliases` - Aliases.
  `isKeyField` - Key ownership flag, as defined in `QueryEntity.keyFields`: `true` if field belongs to key, `false` if it belongs to value, `null` if QueryEntity#keyFields is null.
Returns:
  Binary property.
Throws:
  `IgniteCheckedException`

#### buildClassProperty

    public static QueryClassProperty buildClassProperty(Class<?> keyCls,
                                        Class<?> valCls,
                                        String pathStr,
                                        Class<?> resType,
                                        Map<String,String> aliases,
                                        CacheObjectContext coCtx)
                                                 throws IgniteCheckedException

Parameters:
  `keyCls` - Key class.
  `valCls` - Value class.
  `pathStr` - Path string.
  `resType` - Result type.
  `aliases` - Aliases.
Returns:
  Class property.
Throws:
  `IgniteCheckedException` - If failed.

#### buildProperty

    public static GridQueryProperty buildProperty(Class<?> keyCls,
                                  Class<?> valCls,
                                  String keyFieldName,
                                  String valueFieldName,
                                  String pathStr,
                                  Class<?> resType,
                                  Map<String,String> aliases,
                                  CacheObjectContext coCtx)
                                           throws IgniteCheckedException

Parameters:
  `keyCls` - Key class.
  `valCls` - Value class.
  `keyFieldName` - Key Field.
  `valueFieldName` - Value Field.
  `pathStr` - Path string.
  `resType` - Result type.
  `aliases` - Aliases.
Returns:
  Class property.
Throws:
  `IgniteCheckedException` - If failed.

#### propertyInitializationExceptionMessage

    public static String propertyInitializationExceptionMessage(Class<?> keyCls,
                                                Class<?> valCls,
                                                String pathStr,
                                                Class<?> resType)

Exception message to compare in tests.

Parameters:
  `keyCls` - key class
  `valCls` - value class
  `pathStr` - property name
  `resType` - property type
Returns:
  Exception message.

#### buildClassProperty

    public static QueryClassProperty buildClassProperty(boolean key,
                                        Class<?> cls,
                                        String pathStr,
                                        Class<?> resType,
                                        Map<String,String> aliases,
                                        CacheObjectContext coCtx)

Parameters:
  `key` - If this is a key property.
  `cls` - Source type class.
  `pathStr` - String representing path to the property. May contains dots '.' to identify nested fields.
  `resType` - Expected result type.
  `aliases` - Aliases.
Returns:
  Property instance corresponding to the given path.

#### 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(String clsName)

Gets type name by class.

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

#### typeName

    public static String typeName(Class<?> cls)

Gets type name by class.

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

#### validateTimeout

    public static int validateTimeout(int timeout,
                      TimeUnit timeUnit)

Parameters:
  `timeout` - Timeout.
  `timeUnit` - Time unit.
Returns:
  Converted time.

#### isEnabled

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

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

#### discoveryHistorySize

    public static int discoveryHistorySize()

Discovery history size.

Returns:
  Discovery history size.

#### wrapIfNeeded

    @Nullable
    public static SchemaOperationException wrapIfNeeded(@Nullable
                                                 Exception e)

Wrap schema exception if needed.

Parameters:
  `e` - Original exception.
Returns:
  Schema exception.

#### prepareCacheConfiguration

    public static void prepareCacheConfiguration(CacheConfiguration ccfg)

Prepare cache configuration.

Parameters:
  `ccfg` - Cache configuration.

#### validateCacheConfiguration

    public static void validateCacheConfiguration(CacheConfiguration ccfg)
                                           throws IgniteCheckedException

Prepare cache configuration.

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

2017 Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Fabric | : ver. 2.0.0
Release Date | : April 30 2017