Java Code Examples for org.apache.atlas.type.AtlasStructType#getQualifiedAttributeName()

The following examples show how to use org.apache.atlas.type.AtlasStructType#getQualifiedAttributeName() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SearchProcessor.java    From incubator-atlas with Apache License 2.0 5 votes vote down vote up
protected void processSearchAttributes(AtlasStructType structType, FilterCriteria filterCriteria, Set<String> solrFiltered, Set<String> gremlinFiltered, Set<String> allAttributes) {
    if (structType == null || filterCriteria == null) {
        return;
    }

    Condition            filterCondition = filterCriteria.getCondition();
    List<FilterCriteria> criterion       = filterCriteria.getCriterion();

    if (filterCondition != null && CollectionUtils.isNotEmpty(criterion)) {
        for (SearchParameters.FilterCriteria criteria : criterion) {
            processSearchAttributes(structType, criteria, solrFiltered, gremlinFiltered, allAttributes);
        }
    } else if (StringUtils.isNotEmpty(filterCriteria.getAttributeName())) {
        try {
            String      attributeName = filterCriteria.getAttributeName();
            String      qualifiedName = structType.getQualifiedAttributeName(attributeName);
            Set<String> indexedKeys   = context.getIndexedKeys();

            if (indexedKeys != null && indexedKeys.contains(qualifiedName)) {
                solrFiltered.add(attributeName);
            } else {
                LOG.warn("search includes non-indexed attribute '{}'; might cause poor performance", qualifiedName);

                gremlinFiltered.add(attributeName);
            }

            if (structType instanceof AtlasEntityType) {
                // Capture the entity attributes
                context.getEntityAttributes().add(attributeName);
            }

            allAttributes.add(attributeName);
        } catch (AtlasBaseException e) {
            LOG.warn(e.getMessage());
        }
    }
}
 
Example 2
Source File: SearchProcessor.java    From incubator-atlas with Apache License 2.0 5 votes vote down vote up
protected boolean canApplySolrFilter(AtlasStructType structType, FilterCriteria filterCriteria, boolean insideOrCondition) {
    if (filterCriteria == null) {
        return true;
    }

    boolean              ret             = true;
    Condition            filterCondition = filterCriteria.getCondition();
    List<FilterCriteria> criterion       = filterCriteria.getCriterion();
    Set<String>          indexedKeys     = context.getIndexedKeys();


    if (filterCondition != null && CollectionUtils.isNotEmpty(criterion)) {
        insideOrCondition = insideOrCondition || filterCondition == Condition.OR;

        // If we have nested criterion let's find any nested ORs with non-indexed attr
        for (FilterCriteria criteria : criterion) {
            ret = canApplySolrFilter(structType, criteria, insideOrCondition);

            if (!ret) {
                break;
            }
        }
    } else if (StringUtils.isNotEmpty(filterCriteria.getAttributeName())) {
        try {
            String qualifiedName = structType.getQualifiedAttributeName(filterCriteria.getAttributeName());

            if (insideOrCondition && (indexedKeys == null || !indexedKeys.contains(qualifiedName))) {
                ret = false;
            }
        } catch (AtlasBaseException e) {
            LOG.warn(e.getMessage());
        }
    }

    return ret;
}
 
Example 3
Source File: SearchProcessor.java    From incubator-atlas with Apache License 2.0 5 votes vote down vote up
private String toSolrExpression(AtlasStructType type, String attrName, SearchParameters.Operator op, String attrVal) {
    String ret = EMPTY_STRING;

    try {
        if (OPERATOR_MAP.get(op) != null) {
            String qualifiedName = type.getQualifiedAttributeName(attrName);

            ret = String.format(OPERATOR_MAP.get(op), qualifiedName, AtlasStructType.AtlasAttribute.escapeIndexQueryValue(attrVal));
        }
    } catch (AtlasBaseException ex) {
        LOG.warn(ex.getMessage());
    }

    return ret;
}
 
Example 4
Source File: AtlasGraphUtilsV1.java    From incubator-atlas with Apache License 2.0 5 votes vote down vote up
public static String getQualifiedAttributePropertyKey(AtlasStructType fromType, String attributeName) throws AtlasBaseException {
    switch (fromType.getTypeCategory()) {
     case ENTITY:
     case STRUCT:
     case CLASSIFICATION:
         return fromType.getQualifiedAttributeName(attributeName);
    default:
        throw new AtlasBaseException(AtlasErrorCode.UNKNOWN_TYPE, fromType.getTypeCategory().name());
    }
}