use of org.apache.ignite.cache.query.annotations.QueryGroupIndex in project ignite by apache.
the class CacheConfiguration method processAnnotationsInClass.
/**
* Process annotations for class.
*
* @param key If given class relates to key.
* @param cls Class.
* @param type Type descriptor.
* @param parent Parent in case of embeddable.
*/
private static void processAnnotationsInClass(boolean key, Class<?> cls, TypeDescriptor type, @Nullable ClassProperty parent) {
if (U.isJdk(cls) || QueryUtils.isGeometryClass(cls)) {
if (parent == null && !key && QueryUtils.isSqlType(cls)) {
// We have to index primitive _val.
String idxName = cls.getSimpleName() + "_" + QueryUtils.VAL_FIELD_NAME + "_idx";
type.addIndex(idxName, QueryUtils.isGeometryClass(cls) ? QueryIndexType.GEOSPATIAL : QueryIndexType.SORTED);
type.addFieldToIndex(idxName, QueryUtils.VAL_FIELD_NAME, 0, false);
}
return;
}
if (parent != null && parent.knowsClass(cls))
throw new CacheException("Recursive reference found in type: " + cls.getName());
if (parent == null) {
// Check class annotation at top level only.
QueryTextField txtAnnCls = cls.getAnnotation(QueryTextField.class);
if (txtAnnCls != null)
type.valueTextIndex(true);
QueryGroupIndex grpIdx = cls.getAnnotation(QueryGroupIndex.class);
if (grpIdx != null)
type.addIndex(grpIdx.name(), QueryIndexType.SORTED);
QueryGroupIndex.List grpIdxList = cls.getAnnotation(QueryGroupIndex.List.class);
if (grpIdxList != null && !F.isEmpty(grpIdxList.value())) {
for (QueryGroupIndex idx : grpIdxList.value()) type.addIndex(idx.name(), QueryIndexType.SORTED);
}
}
for (Class<?> c = cls; c != null && !c.equals(Object.class); c = c.getSuperclass()) {
for (Field field : c.getDeclaredFields()) {
QuerySqlField sqlAnn = field.getAnnotation(QuerySqlField.class);
QueryTextField txtAnn = field.getAnnotation(QueryTextField.class);
if (sqlAnn != null || txtAnn != null) {
ClassProperty prop = new ClassProperty(field);
prop.parent(parent);
// Add parent property before its possible nested properties so that
// resulting parent column comes before columns corresponding to those
// nested properties in the resulting table - that way nested
// properties override will happen properly (first parent, then children).
type.addProperty(prop, key, true);
processAnnotation(key, sqlAnn, txtAnn, cls, c, field.getType(), prop, type);
}
}
}
}
Aggregations