Class QueryTypeDescriptorImpl
- java.lang.Object
-
- org.apache.ignite.internal.processors.query.QueryTypeDescriptorImpl
-
- All Implemented Interfaces:
GridQueryTypeDescriptor
public class QueryTypeDescriptorImpl extends Object implements GridQueryTypeDescriptor
Descriptor of type.
-
-
Constructor Summary
Constructors Constructor Description QueryTypeDescriptorImpl(String cacheName, CacheObjectContext coCtx)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddFieldToTextIndex(String field)Adds field to text index.voidaddIndex(QueryIndexDescriptorImpl idx)Add index.voidaddProperty(GridQueryProperty prop, boolean failOnDuplicate)Adds property to the type descriptor.voidaddProperty(GridQueryProperty prop, boolean failOnDuplicate, boolean isField)Adds property to the type descriptor.intaffinityFieldInlineSize()Gets affinity fields index INLINE_SIZE.voidaffinityFieldInlineSize(int affFieldInlineSize)Sets affinity fields index INLINE_SIZE.StringaffinityKey()Returns affinity key field name ornullfor default.voidaffinityKey(String affKey)Map<String,String>aliases()voidaliases(Map<String,String> aliases)StringcacheName()Gets cache name of this type.booleancustomAffinityKeyMapper()voidcustomAffinityKeyMapper(boolean customAffKeyMapper)voiddropIndex(String idxName)Drop index.LinkedHashMap<String,Class<?>>fields()Gets mapping from field name to its type.booleanfillAbsentPKsWithDefaults()booleanhasField(String field)Chedk if particular field exists.booleanimplicitPk()Gets whether a primary key should be autogenerated.voidimplicitPk(boolean implicitPk)Sets whether a primary key should be autogenerated.@Nullable QueryIndexDescriptorImplindex(String name)Get index by name.Map<String,GridQueryIndexDescriptor>indexes()Gets indexes for this type.Collection<QueryIndexDescriptorImpl>indexes0()Class<?>keyClass()Gets key class.voidkeyClass(Class<?> keyCls)Set key class.@Nullable StringkeyFieldAlias()Gets key field alias.StringkeyFieldName()Gets key field name.StringkeyTypeName()Gets key type name.voidkeyTypeName(String keyTypeName)Set key type name.voidmarkObsolete()Mark index as obsolete.booleanmatchType(CacheObject val)Stringname()Gets type name which uniquely identifies this type.voidname(String name)Sets type name.booleanobsolete()Set<String>primaryKeyFields()Gets primary key fields if defined, or empty collection otherwise.voidprimaryKeyFields(Set<String> keys)Sets primary key fields.intprimaryKeyInlineSize()Gets primary key index INLINE_SIZE.voidprimaryKeyInlineSize(int pkInlineSize)Sets primary key index INLINE_SIZE.Map<String,GridQueryProperty>properties()GridQueryPropertyproperty(String name)voidremoveProperty(String name)Removes a property with specified name.StringschemaName()Gets schema name for type (database schema means here).voidschemaName(String schemaName)voidsetDefaults(Object key, Object val)Sets defaults value for given key and value.voidsetFillAbsentPKsWithDefaults(boolean fillAbsentPKsWithDefaults)Sets up fillAbsentPKsWithDefaults flag.voidsetValue(String field, Object key, Object val, Object propVal)Sets field value for given key and value.StringtableName()Gets table name for type.voidtableName(String tblName)Sets table name for type.GridQueryIndexDescriptortextIndex()Get text index for this type (if any).StringtoString()inttypeId()voidtypeId(int typeId)voidvalidateKeyAndValue(Object key, Object val)Performs validation of given key and value against configured constraints.<T> Tvalue(String field, Object key, Object val)Gets field value for given key and value.Class<?>valueClass()Gets value class.voidvalueClass(Class<?> valCls)Sets value class.@Nullable StringvalueFieldAlias()Gets value field alias.StringvalueFieldName()Gets value field name.booleanvalueTextIndex()Returnstrueif string representation of value should be indexed as text.voidvalueTextIndex(boolean valTextIdx)Sets if this value should be text indexed.StringvalueTypeName()Gets value type name.voidvalueTypeName(String valTypeName)Set value type name.
-
-
-
Constructor Detail
-
QueryTypeDescriptorImpl
public QueryTypeDescriptorImpl(String cacheName, CacheObjectContext coCtx)
Constructor.- Parameters:
cacheName- Cache name.coCtx- Cache object context.
-
-
Method Detail
-
cacheName
public String cacheName()
Gets cache name of this type.- Specified by:
cacheNamein interfaceGridQueryTypeDescriptor- Returns:
- Cache name.
-
name
public String name()
Gets type name which uniquely identifies this type.- Specified by:
namein interfaceGridQueryTypeDescriptor- Returns:
- Type name which uniquely identifies this type.
-
schemaName
public String schemaName()
Gets schema name for type (database schema means here).- Specified by:
schemaNamein interfaceGridQueryTypeDescriptor- Returns:
- Schema name.
-
name
public void name(String name)
Sets type name.- Parameters:
name- Name.
-
tableName
public String tableName()
Gets table name for type.- Specified by:
tableNamein interfaceGridQueryTypeDescriptor- Returns:
- Table name.
-
tableName
public void tableName(String tblName)
Sets table name for type.- Parameters:
tblName- Table name.
-
fields
public LinkedHashMap<String,Class<?>> fields()
Gets mapping from field name to its type.- Specified by:
fieldsin interfaceGridQueryTypeDescriptor- Returns:
- Fields that can be indexed, participate in queries and can be queried using method.
-
property
public GridQueryProperty property(String name)
- Specified by:
propertyin interfaceGridQueryTypeDescriptor- Parameters:
name- Property name.- Returns:
- Property.
-
properties
public Map<String,GridQueryProperty> properties()
- Specified by:
propertiesin interfaceGridQueryTypeDescriptor- Returns:
- All properties.
-
value
public <T> T value(String field, Object key, Object val) throws IgniteCheckedException
Gets field value for given key and value.- Specified by:
valuein interfaceGridQueryTypeDescriptor- Parameters:
field- Field name.key- Key.val- Value.- Returns:
- Value for given field.
- Throws:
IgniteCheckedException- If failed.
-
setValue
public void setValue(String field, Object key, Object val, Object propVal) throws IgniteCheckedException
Sets field value for given key and value.- Specified by:
setValuein interfaceGridQueryTypeDescriptor- Parameters:
field- Field name.key- Key.val- Value.propVal- Value for given field.- Throws:
IgniteCheckedException- If failed.
-
indexes
public Map<String,GridQueryIndexDescriptor> indexes()
Gets indexes for this type.- Specified by:
indexesin interfaceGridQueryTypeDescriptor- Returns:
- Indexes for this type.
-
typeId
public int typeId()
- Specified by:
typeIdin interfaceGridQueryTypeDescriptor- Returns:
- BinaryObject's type ID if indexed value is BinaryObject, otherwise value class' hash code.
-
matchType
public boolean matchType(CacheObject val)
- Specified by:
matchTypein interfaceGridQueryTypeDescriptor- Parameters:
val- Value cache object.- Returns:
trueIf the type of the given value cache object matches this descriptor.
-
typeId
public void typeId(int typeId)
- Parameters:
typeId- Type ID.
-
index
@Nullable public @Nullable QueryIndexDescriptorImpl index(String name)
Get index by name.- Parameters:
name- Name.- Returns:
- Index.
-
indexes0
public Collection<QueryIndexDescriptorImpl> indexes0()
- Returns:
- Raw index descriptors.
-
textIndex
public GridQueryIndexDescriptor textIndex()
Get text index for this type (if any).- Specified by:
textIndexin interfaceGridQueryTypeDescriptor- Returns:
- Text index or
null.
-
addIndex
public void addIndex(QueryIndexDescriptorImpl idx) throws IgniteCheckedException
Add index.- Parameters:
idx- Index.- Throws:
IgniteCheckedException- If failed.
-
dropIndex
public void dropIndex(String idxName)
Drop index.- Parameters:
idxName- Index name.
-
hasField
public boolean hasField(String field)
Chedk if particular field exists.- Parameters:
field- Field.- Returns:
Trueif exists.
-
addFieldToTextIndex
public void addFieldToTextIndex(String field) throws IgniteCheckedException
Adds field to text index.- Parameters:
field- Field name.- Throws:
IgniteCheckedException- If failed.
-
valueClass
public Class<?> valueClass()
Gets value class.- Specified by:
valueClassin interfaceGridQueryTypeDescriptor- Returns:
- Value class.
-
valueClass
public void valueClass(Class<?> valCls)
Sets value class.- Parameters:
valCls- Value class.
-
keyClass
public Class<?> keyClass()
Gets key class.- Specified by:
keyClassin interfaceGridQueryTypeDescriptor- Returns:
- Key class.
-
keyClass
public void keyClass(Class<?> keyCls)
Set key class.- Parameters:
keyCls- Key class.
-
keyTypeName
public String keyTypeName()
Gets key type name.- Specified by:
keyTypeNamein interfaceGridQueryTypeDescriptor- Returns:
- Key type name.
-
keyTypeName
public void keyTypeName(String keyTypeName)
Set key type name.- Parameters:
keyTypeName- Key type name.
-
valueTypeName
public String valueTypeName()
Gets value type name.- Specified by:
valueTypeNamein interfaceGridQueryTypeDescriptor- Returns:
- Value type name.
-
valueTypeName
public void valueTypeName(String valTypeName)
Set value type name.- Parameters:
valTypeName- Value type name.
-
addProperty
public void addProperty(GridQueryProperty prop, boolean failOnDuplicate) throws IgniteCheckedException
Adds property to the type descriptor.- Parameters:
prop- Property.failOnDuplicate- Fail on duplicate flag.- Throws:
IgniteCheckedException- In case of error.
-
addProperty
public void addProperty(GridQueryProperty prop, boolean failOnDuplicate, boolean isField) throws IgniteCheckedException
Adds property to the type descriptor.- Parameters:
prop- Property.failOnDuplicate- Fail on duplicate flag.isField-Trueifpropif field,Falseif prop is "_KEY" or "_VAL".- Throws:
IgniteCheckedException- In case of error.
-
removeProperty
public void removeProperty(String name) throws IgniteCheckedException
Removes a property with specified name.- Parameters:
name- Name of a property to remove.- Throws:
IgniteCheckedException
-
schemaName
public void schemaName(String schemaName)
- Parameters:
schemaName- Schema name.
-
valueTextIndex
public boolean valueTextIndex()
Returnstrueif string representation of value should be indexed as text.- Specified by:
valueTextIndexin interfaceGridQueryTypeDescriptor- Returns:
- If string representation of value should be full-text indexed.
-
valueTextIndex
public void valueTextIndex(boolean valTextIdx)
Sets if this value should be text indexed.- Parameters:
valTextIdx- Flag value.
-
affinityKey
public String affinityKey()
Returns affinity key field name ornullfor default.- Specified by:
affinityKeyin interfaceGridQueryTypeDescriptor- Returns:
- Affinity key.
-
affinityKey
public void affinityKey(String affKey)
- Parameters:
affKey- Affinity key field.
-
customAffinityKeyMapper
public boolean customAffinityKeyMapper()
- Specified by:
customAffinityKeyMapperin interfaceGridQueryTypeDescriptor- Returns:
- Whether custom affinity key mapper exists.
-
customAffinityKeyMapper
public void customAffinityKeyMapper(boolean customAffKeyMapper)
- Parameters:
customAffKeyMapper- Whether custom affinity key mapper is set.
-
obsolete
public boolean obsolete()
- Returns:
Trueif obsolete.
-
markObsolete
public void markObsolete()
Mark index as obsolete.
-
keyFieldName
public String keyFieldName()
Gets key field name.- Specified by:
keyFieldNamein interfaceGridQueryTypeDescriptor- Returns:
- Key field name.
-
valueFieldName
public String valueFieldName()
Gets value field name.- Specified by:
valueFieldNamein interfaceGridQueryTypeDescriptor- Returns:
- value field name.
-
keyFieldAlias
@Nullable public @Nullable String keyFieldAlias()
Gets key field alias.- Specified by:
keyFieldAliasin interfaceGridQueryTypeDescriptor- Returns:
- Key field alias.
-
valueFieldAlias
@Nullable public @Nullable String valueFieldAlias()
Gets value field alias.- Specified by:
valueFieldAliasin interfaceGridQueryTypeDescriptor- Returns:
- value field alias.
-
validateKeyAndValue
public void validateKeyAndValue(Object key, Object val) throws IgniteCheckedException
Performs validation of given key and value against configured constraints. Throws runtime exception if validation fails.- Specified by:
validateKeyAndValuein interfaceGridQueryTypeDescriptor- Parameters:
key- Key.val- Value.- Throws:
IgniteCheckedException
-
setDefaults
public void setDefaults(Object key, Object val) throws IgniteCheckedException
Sets defaults value for given key and value.- Specified by:
setDefaultsin interfaceGridQueryTypeDescriptor- Parameters:
key- Key.val- Value.- Throws:
IgniteCheckedException- If failed.
-
primaryKeyFields
public Set<String> primaryKeyFields()
Gets primary key fields if defined, or empty collection otherwise.- Specified by:
primaryKeyFieldsin interfaceGridQueryTypeDescriptor
-
primaryKeyFields
public void primaryKeyFields(Set<String> keys)
Sets primary key fields.- Specified by:
primaryKeyFieldsin interfaceGridQueryTypeDescriptor- Parameters:
keys- Primary keys.
-
implicitPk
public boolean implicitPk()
Gets whether a primary key should be autogenerated.- Specified by:
implicitPkin interfaceGridQueryTypeDescriptor
-
implicitPk
public void implicitPk(boolean implicitPk)
Sets whether a primary key should be autogenerated.- Specified by:
implicitPkin interfaceGridQueryTypeDescriptor- Parameters:
implicitPk- Whether a PK should be autogenerated.
-
fillAbsentPKsWithDefaults
public boolean fillAbsentPKsWithDefaults()
- Specified by:
fillAbsentPKsWithDefaultsin interfaceGridQueryTypeDescriptor- Returns:
trueif absent PK parts should be filled with defaults,falseotherwise.
-
setFillAbsentPKsWithDefaults
public void setFillAbsentPKsWithDefaults(boolean fillAbsentPKsWithDefaults)
Sets up fillAbsentPKsWithDefaults flag.- Specified by:
setFillAbsentPKsWithDefaultsin interfaceGridQueryTypeDescriptor- Parameters:
fillAbsentPKsWithDefaults- Flag.
-
primaryKeyInlineSize
public int primaryKeyInlineSize()
Gets primary key index INLINE_SIZE.- Specified by:
primaryKeyInlineSizein interfaceGridQueryTypeDescriptor
-
primaryKeyInlineSize
public void primaryKeyInlineSize(int pkInlineSize)
Sets primary key index INLINE_SIZE.- Specified by:
primaryKeyInlineSizein interfaceGridQueryTypeDescriptor
-
affinityFieldInlineSize
public int affinityFieldInlineSize()
Gets affinity fields index INLINE_SIZE.- Specified by:
affinityFieldInlineSizein interfaceGridQueryTypeDescriptor
-
affinityFieldInlineSize
public void affinityFieldInlineSize(int affFieldInlineSize)
Sets affinity fields index INLINE_SIZE.- Specified by:
affinityFieldInlineSizein interfaceGridQueryTypeDescriptor
-
-