Package org.apache.ignite.cache
Class QueryEntity
- java.lang.Object
-
- org.apache.ignite.cache.QueryEntity
-
- All Implemented Interfaces:
Serializable
public class QueryEntity extends Object implements Serializable
Query entity is a description ofcacheentry (composed of key and value) in a way of how it must be indexed and can be queried.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description QueryEntity()Creates an empty query entity.QueryEntity(Class<?> keyCls, Class<?> valCls)Creates a query entity with the given key and value types.QueryEntity(String keyType, String valType)Creates a query entity with the given key and value types.QueryEntity(QueryEntity other)Copy constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description QueryEntityaddQueryField(String fullName, String type, String alias)Utility method for building query entities programmatically.booleanequals(Object o)StringfindKeyType()Attempts to get key type from fields in case it was not set directly.StringfindValueType()Attempts to get value type from fields in case it was not set directly.Map<String,String>getAliases()Gets aliases map.Map<String,Object>getDefaultFieldValues()Gets fields default values.LinkedHashMap<String,String>getFields()Gets query fields for this query pair.Map<String,Integer>getFieldsPrecision()Map<String,Integer>getFieldsScale()@NotNull Collection<QueryIndex>getIndexes()Gets a collection of index entities.StringgetKeyFieldName()Gets key field name.Set<String>getKeyFields()Gets query fields for this query pair that belongs to the key.StringgetKeyType()Gets key type for this query pair.@Nullable Set<String>getNotNullFields()Gets names of fields that must be checked for null.StringgetTableName()Gets table name for this query entity.StringgetValueFieldName()Get value field name.StringgetValueType()Gets value type for this query pair.inthashCode()@NotNull QueryEntityPatchmakePatch(QueryEntity target)Make query entity patch.QueryEntitysetAliases(Map<String,String> aliases)Sets mapping from full property name in dot notation to an alias that will be used as SQL column name.QueryEntitysetDefaultFieldValues(Map<String,Object> defaultFieldValues)Sets fields default values.QueryEntitysetFields(LinkedHashMap<String,String> fields)Sets query fields for this query pair.QueryEntitysetFieldsPrecision(Map<String,Integer> fieldsPrecision)Sets fieldsPrecision map for a fields.QueryEntitysetFieldsScale(Map<String,Integer> fieldsScale)Sets fieldsScale map for a fields.QueryEntitysetIndexes(Collection<QueryIndex> idxs)Sets a collection of index entities.QueryEntitysetKeyFieldName(String keyFieldName)Sets key field name.QueryEntitysetKeyFields(Set<String> keyFields)Gets query fields for this query pair that belongs to the key.QueryEntitysetKeyType(String keyType)Sets key type for this query pair.QueryEntitysetNotNullFields(@Nullable Set<String> notNullFields)Sets names of fields that must checked for null.QueryEntitysetTableName(String tableName)Sets table name for this query entity.QueryEntitysetValueFieldName(String valueFieldName)Sets value field name.QueryEntitysetValueType(String valType)Sets value type for this query pair.StringtoString()
-
-
-
Constructor Detail
-
QueryEntity
public QueryEntity()
Creates an empty query entity.
-
QueryEntity
public QueryEntity(QueryEntity other)
Copy constructor.- Parameters:
other- Other entity.
-
QueryEntity
public QueryEntity(String keyType, String valType)
Creates a query entity with the given key and value types.- Parameters:
keyType- Key type.valType- Value type.
-
-
Method Detail
-
makePatch
@NotNull public @NotNull QueryEntityPatch makePatch(QueryEntity target)
Make query entity patch. This patch can only add properties to entity and can't remove them. Other words, the patch will contain only add operations(e.g. add column, create index) and not remove ones.- Parameters:
target- Query entity to which this entity should be expanded.- Returns:
- Patch which contains operations for expanding this entity.
-
getKeyType
public String getKeyType()
Gets key type for this query pair.- Returns:
- Key type.
-
findKeyType
public String findKeyType()
Attempts to get key type from fields in case it was not set directly.- Returns:
- Key type.
-
setKeyType
public QueryEntity setKeyType(String keyType)
Sets key type for this query pair.- Parameters:
keyType- Key type.- Returns:
thisfor chaining.
-
getValueType
public String getValueType()
Gets value type for this query pair.- Returns:
- Value type.
-
findValueType
public String findValueType()
Attempts to get value type from fields in case it was not set directly.- Returns:
- Value type.
-
setValueType
public QueryEntity setValueType(String valType)
Sets value type for this query pair.- Parameters:
valType- Value type.- Returns:
thisfor chaining.
-
getFields
public LinkedHashMap<String,String> getFields()
Gets query fields for this query pair. The order of fields is important as it defines the order of columns returned by the 'select *' queries.- Returns:
- Field-to-type map.
-
setFields
public QueryEntity setFields(LinkedHashMap<String,String> fields)
Sets query fields for this query pair. The order if fields is important as it defines the order of columns returned by the 'select *' queries.- Parameters:
fields- Field-to-type map.- Returns:
thisfor chaining.
-
getKeyFields
public Set<String> getKeyFields()
Gets query fields for this query pair that belongs to the key. We need this for the cases when no key-value classes are present on cluster nodes, and we need to build/modify keys and values during SQL DML operations. Thus, setting this parameter in XML is not mandatory and should be based on particular use case.- Returns:
- Set of names of key fields.
-
setKeyFields
public QueryEntity setKeyFields(Set<String> keyFields)
Gets query fields for this query pair that belongs to the key. We need this for the cases when no key-value classes are present on cluster nodes, and we need to build/modify keys and values during SQL DML operations. Thus, setting this parameter in XML is not mandatory and should be based on particular use case.- Parameters:
keyFields- Set of names of key fields.- Returns:
thisfor chaining.
-
getKeyFieldName
public String getKeyFieldName()
Gets key field name.- Returns:
- Key name.
-
setKeyFieldName
public QueryEntity setKeyFieldName(String keyFieldName)
Sets key field name.- Parameters:
keyFieldName- Key name.- Returns:
thisfor chaining.
-
getValueFieldName
public String getValueFieldName()
Get value field name.- Returns:
- Value name.
-
setValueFieldName
public QueryEntity setValueFieldName(String valueFieldName)
Sets value field name.- Parameters:
valueFieldName- value name.- Returns:
thisfor chaining.
-
getIndexes
@NotNull public @NotNull Collection<QueryIndex> getIndexes()
Gets a collection of index entities.- Returns:
- Collection of index entities.
-
setAliases
public QueryEntity setAliases(Map<String,String> aliases)
Sets mapping from full property name in dot notation to an alias that will be used as SQL column name. Example: {"parent.name" -> "parentName"}.- Parameters:
aliases- Aliases map.- Returns:
thisfor chaining.
-
setIndexes
public QueryEntity setIndexes(Collection<QueryIndex> idxs)
Sets a collection of index entities.- Parameters:
idxs- Collection of index entities.- Returns:
thisfor chaining.
-
getTableName
public String getTableName()
Gets table name for this query entity.- Returns:
- table name
-
setTableName
public QueryEntity setTableName(String tableName)
Sets table name for this query entity.- Parameters:
tableName- table name- Returns:
thisfor chaining.
-
getNotNullFields
@Nullable public @Nullable Set<String> getNotNullFields()
Gets names of fields that must be checked for null.- Returns:
- Set of names of fields that must have non-null values.
-
setNotNullFields
public QueryEntity setNotNullFields(@Nullable @Nullable Set<String> notNullFields)
Sets names of fields that must checked for null.- Parameters:
notNullFields- Set of names of fields that must have non-null values.- Returns:
thisfor chaining.
-
getFieldsPrecision
public Map<String,Integer> getFieldsPrecision()
- Returns:
- Precision map for a fields.
-
setFieldsPrecision
public QueryEntity setFieldsPrecision(Map<String,Integer> fieldsPrecision)
Sets fieldsPrecision map for a fields.- Parameters:
fieldsPrecision- Precision map for a fields.- Returns:
Thisfor chaining.
-
setFieldsScale
public QueryEntity setFieldsScale(Map<String,Integer> fieldsScale)
Sets fieldsScale map for a fields.- Parameters:
fieldsScale- Scale map for a fields.- Returns:
Thisfor chaining.
-
getDefaultFieldValues
public Map<String,Object> getDefaultFieldValues()
Gets fields default values.- Returns:
- Field's name to default value map.
-
setDefaultFieldValues
public QueryEntity setDefaultFieldValues(Map<String,Object> defaultFieldValues)
Sets fields default values.- Parameters:
defaultFieldValues- Field's name to default value map.- Returns:
thisfor chaining.
-
addQueryField
public QueryEntity addQueryField(String fullName, String type, String alias)
Utility method for building query entities programmatically.- Parameters:
fullName- Full name of the field.type- Type of the field.alias- Field alias.- Returns:
thisfor chaining.
-
-