public class QueryUtils extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
QueryUtils.KeyOrValProperty
Property used for keyFieldName or valueFieldName
|
| Modifier and Type | Field and Description |
|---|---|
static int |
DEFAULT_COLUMNS_COUNT |
static int |
DFLT_INDEXING_DISCOVERY_HISTORY_SIZE |
static String |
DFLT_SCHEMA
Default schema.
|
static int |
KEY_COL
Key column.
|
static String |
KEY_FIELD_NAME
Field name for key.
|
static String |
SCHEMA_INFORMATION
Schema for system view.
|
static String |
SCHEMA_SYS
Schema for system view.
|
static String |
TEMPLATE_PARTITIONED
Well-known template name for PARTITIONED cache.
|
static String |
TEMPLATE_REPLICATED
Well-known template name for REPLICATED cache.
|
static int |
VAL_COL
Value column.
|
static String |
VAL_FIELD_NAME
Field name for value.
|
| Modifier and Type | Method and Description |
|---|---|
static QueryBinaryProperty |
buildBinaryProperty(GridKernalContext ctx,
String pathStr,
Class<?> resType,
Map<String,String> aliases,
boolean isKeyField,
boolean notNull,
Object dlftVal,
int precision,
int scale)
Builds binary object property.
|
static QueryClassProperty |
buildClassProperty(boolean key,
Class<?> cls,
String pathStr,
Class<?> resType,
Map<String,String> aliases,
boolean notNull,
CacheObjectContext coCtx) |
static QueryClassProperty |
buildClassProperty(Class<?> keyCls,
Class<?> valCls,
String pathStr,
Class<?> resType,
Map<String,String> aliases,
boolean notNull,
CacheObjectContext coCtx) |
static GridQueryProperty |
buildProperty(Class<?> keyCls,
Class<?> valCls,
String keyFieldName,
String valueFieldName,
String pathStr,
Class<?> resType,
Map<String,String> aliases,
boolean notNull,
CacheObjectContext coCtx) |
static void |
checkNotNullAllowed(CacheConfiguration cfg)
Performs checks to forbid cache configurations that are not compatible with NOT NULL query fields.
|
static SchemaOperationException |
checkQueryEntityConflicts(CacheConfiguration<?,?> ccfg,
Collection<DynamicCacheDescriptor> descs)
Check given
CacheConfiguration for conflicts in table and index names from any query entities
found in collection of DynamicCacheDescriptors and belonging to the same schema. |
static QueryEntity |
copy(QueryEntity entity)
Copy query entity.
|
static QueryIndexDescriptorImpl |
createIndexDescriptor(QueryTypeDescriptorImpl typeDesc,
QueryIndex idx)
Create index descriptor.
|
static String |
createTableCacheName(String schemaName,
String tblName)
Construct cache name for table.
|
static String |
createTableKeyTypeName(String valTypeName)
Construct key type name for table.
|
static String |
createTableValueTypeName(String schemaName,
String tblName)
Construct value type name for table.
|
static int |
discoveryHistorySize()
Discovery history size.
|
static String |
fieldNameByAlias(QueryEntity entity,
String alias)
Get field name by alias.
|
static String |
globalQueryId(UUID nodeId,
long qryId)
Get global query ID.
|
static String |
indexName(QueryEntity entity,
QueryIndex idx)
Get index name.
|
static String |
indexName(String tblName,
QueryIndex idx)
Get index name.
|
static boolean |
isCustomAffinityMapper(AffinityKeyMapper affinityKeyMapper)
Checks whether affinity key mapper is custom or default.
|
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 boolean |
matches(String str,
String sqlPtrn)
Checks whether string matches SQL pattern.
|
static @Nullable String |
normalizeObjectName(@Nullable String str,
boolean replace)
Normalize object name.
|
static Collection<QueryEntity> |
normalizeQueryEntities(Collection<QueryEntity> entities,
CacheConfiguration<?,?> cfg)
Normalize cache query entities.
|
static QueryEntity |
normalizeQueryEntity(QueryEntity entity,
boolean escape)
Normalize query entity.
|
static String |
normalizeSchemaName(String cacheName,
@Nullable String schemaName)
Stores rule for constructing schemaName according to 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,
@Nullable 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 boolean |
removeField(QueryEntity entity,
String alias)
Remove field by alias.
|
static String |
tableName(QueryEntity entity)
Get table name for entity.
|
static @NotNull SQLException |
toSqlException(Exception e)
Converts exception in to IgniteSqlException.
|
static QueryTypeCandidate |
typeForQueryEntity(GridKernalContext ctx,
String cacheName,
String schemaName,
GridCacheContextInfo cacheInfo,
QueryEntity qryEntity,
List<Class<?>> mustDeserializeClss,
boolean escape)
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 SchemaOperationException |
validateDropColumn(GridQueryTypeDescriptor type,
String colName)
Checks if given column can be removed from the table using its
GridQueryTypeDescriptor. |
static SchemaOperationException |
validateDropColumn(QueryEntity entity,
String fieldName,
String colName)
Checks if given column can be removed from table using its
QueryEntity. |
static int |
validateTimeout(int timeout,
TimeUnit timeUnit) |
static boolean |
wasCancelled(Throwable e)
Returns true if the exception is triggered by query cancel.
|
static SqlFieldsQuery |
withQueryTimeout(SqlFieldsQuery qry,
int timeout,
TimeUnit timeUnit) |
static @Nullable SchemaOperationException |
wrapIfNeeded(@Nullable Throwable e)
Wrap schema exception if needed.
|
public static final int DEFAULT_COLUMNS_COUNT
public static final int KEY_COL
public static final int VAL_COL
public static final String DFLT_SCHEMA
public static final String SCHEMA_SYS
public static final String SCHEMA_INFORMATION
public static final String KEY_FIELD_NAME
public static final String VAL_FIELD_NAME
public static final String TEMPLATE_PARTITIONED
public static final String TEMPLATE_REPLICATED
public static final int DFLT_INDEXING_DISCOVERY_HISTORY_SIZE
public static String tableName(QueryEntity entity)
entity - Entity.public static String indexName(QueryEntity entity, QueryIndex idx)
entity - Query entity.idx - Index.public static String indexName(String tblName, QueryIndex idx)
tblName - Table name.idx - Index.public static Collection<QueryEntity> normalizeQueryEntities(Collection<QueryEntity> entities, CacheConfiguration<?,?> cfg)
entities - Query entities.cfg - Cache config.public static QueryEntity normalizeQueryEntity(QueryEntity entity, boolean escape)
entity - Query entity.escape - Escape flag taken form configuration.public static String normalizeSchemaName(String cacheName, @Nullable @Nullable String schemaName)
cacheName - Cache name.schemaName - Schema name.@Nullable public static @Nullable String normalizeObjectName(@Nullable @Nullable String str, boolean replace)
str - String.replace - Whether to perform replace of special characters.public static QueryTypeCandidate typeForQueryEntity(GridKernalContext ctx, String cacheName, String schemaName, GridCacheContextInfo cacheInfo, QueryEntity qryEntity, List<Class<?>> mustDeserializeClss, boolean escape) throws IgniteCheckedException
cacheName - Cache name.schemaName - Schema name.cacheInfo - Cache context info.qryEntity - Query entity.mustDeserializeClss - Classes which must be deserialized.escape - Escape flag.IgniteCheckedException - If failed.public static void processBinaryMeta(GridKernalContext ctx, QueryEntity qryEntity, QueryTypeDescriptorImpl d) throws IgniteCheckedException
ctx - Kernal context.qryEntity - Declared metadata.d - Type descriptor.IgniteCheckedException - If failed.public static void processClassMeta(QueryEntity qryEntity, QueryTypeDescriptorImpl d, CacheObjectContext coCtx) throws IgniteCheckedException
qryEntity - Declared metadata.d - Type descriptor.IgniteCheckedException - If failed.public static void processDynamicIndexChange(String idxName, @Nullable @Nullable QueryIndex idx, QueryTypeDescriptorImpl d) throws IgniteCheckedException
idx - Index.d - Type descriptor to populate.IgniteCheckedException - If failed to build index information.public static QueryIndexDescriptorImpl createIndexDescriptor(QueryTypeDescriptorImpl typeDesc, QueryIndex idx) throws IgniteCheckedException
typeDesc - Type descriptor.idx - Index.IgniteCheckedException - If failed.public static QueryBinaryProperty buildBinaryProperty(GridKernalContext ctx, String pathStr, Class<?> resType, Map<String,String> aliases, boolean isKeyField, boolean notNull, Object dlftVal, int precision, int scale)
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, true if this property is a field of the key object. Note that key
not a field of itself.notNull - true if null value is not allowed.dlftVal - Default value.precision - Precision.scale - Scale.public static QueryClassProperty buildClassProperty(Class<?> keyCls, Class<?> valCls, String pathStr, Class<?> resType, Map<String,String> aliases, boolean notNull, CacheObjectContext coCtx) throws IgniteCheckedException
keyCls - Key class.valCls - Value class.pathStr - Path string.resType - Result type.aliases - Aliases.notNull - true if null value is not allowed.coCtx - Cache object context.IgniteCheckedException - If failed.public static GridQueryProperty buildProperty(Class<?> keyCls, Class<?> valCls, String keyFieldName, String valueFieldName, String pathStr, Class<?> resType, Map<String,String> aliases, boolean notNull, CacheObjectContext coCtx) throws IgniteCheckedException
keyCls - Key class.valCls - Value class.keyFieldName - Key Field.valueFieldName - Value Field.pathStr - Path string.resType - Result type.aliases - Aliases.notNull - true if null value is not allowed.coCtx - Cache object context.IgniteCheckedException - If failed.public static String propertyInitializationExceptionMessage(Class<?> keyCls, Class<?> valCls, String pathStr, Class<?> resType)
keyCls - key classvalCls - value classpathStr - property nameresType - property typepublic static QueryClassProperty buildClassProperty(boolean key, Class<?> cls, String pathStr, Class<?> resType, Map<String,String> aliases, boolean notNull, CacheObjectContext coCtx)
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.notNull - true if null value is not allowed.coCtx - Cache object context.public static boolean isSqlType(Class<?> cls)
cls - Class.true If can.public static boolean isGeometryClass(Class<?> cls)
cls - Class.true If this is geometry.public static String typeName(String clsName)
clsName - Class name.public static String typeName(Class<?> cls)
cls - Class.public static int validateTimeout(int timeout,
TimeUnit timeUnit)
timeout - Timeout.timeUnit - Time unit.public static boolean isEnabled(CacheConfiguration<?,?> ccfg)
ccfg - Cache configuration.true If query index must be enabled for this cache.public static int discoveryHistorySize()
@Nullable public static @Nullable SchemaOperationException wrapIfNeeded(@Nullable @Nullable Throwable e)
e - Original exception.public static SchemaOperationException checkQueryEntityConflicts(CacheConfiguration<?,?> ccfg, Collection<DynamicCacheDescriptor> descs)
CacheConfiguration for conflicts in table and index names from any query entities
found in collection of DynamicCacheDescriptors and belonging to the same schema.ccfg - New cache configuration.descs - Cache descriptors.null if none found.public static String createTableCacheName(String schemaName, String tblName)
schemaName - Schema name.tblName - Table name.public static String createTableValueTypeName(String schemaName, String tblName)
schemaName - Schema name.tblName - Table name.public static String createTableKeyTypeName(String valTypeName)
valTypeName - Value type name.public static QueryEntity copy(QueryEntity entity)
entity - Query entity.public static void checkNotNullAllowed(CacheConfiguration cfg)
QueryEntity.setNotNullFields(Set).cfg - Cache configuration.public static boolean isCustomAffinityMapper(AffinityKeyMapper affinityKeyMapper)
affinityKeyMapper - Affinity key mapper.true if affinity key mapper is custom.public static SchemaOperationException validateDropColumn(QueryEntity entity, String fieldName, String colName)
QueryEntity.entity - Query entity.fieldName - Name of the field of the key or value object.colName - Name of the column.null if it's OK to remove the column and exception otherwise.public static SchemaOperationException validateDropColumn(GridQueryTypeDescriptor type, String colName)
GridQueryTypeDescriptor.type - Type descriptor.colName - Name of the column.null if it's OK to remove the column and exception otherwise.public static boolean wasCancelled(Throwable e)
e - Exception.true if exception is caused by cancel.@NotNull public static @NotNull SQLException toSqlException(Exception e)
e - Exception.public static String globalQueryId(UUID nodeId, long qryId)
nodeId - Node ID.qryId - Query ID.public static boolean matches(String str, String sqlPtrn)
str - String.sqlPtrn - Pattern.public static String fieldNameByAlias(QueryEntity entity, String alias)
entity - Query entity.alias - Filed's alias.public static boolean removeField(QueryEntity entity, String alias)
entity - Query entity.alias - Filed's alias.true if the field is removed. Otherwise returns false.public static SqlFieldsQuery withQueryTimeout(SqlFieldsQuery qry, int timeout, TimeUnit timeUnit)
qry - Query.timeout - Timeout.timeUnit - Time units.
Follow @ApacheIgnite
Ignite Database and Caching Platform : ver. 2.10.0 Release Date : March 10 2021