Java Code Examples for com.thinkaurelius.titan.core.attribute.Cmp#EQUAL

The following examples show how to use com.thinkaurelius.titan.core.attribute.Cmp#EQUAL . 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: TitanPredicate.java    From titan1withtp3.1 with Apache License 2.0 6 votes vote down vote up
/**
 * Convert Tinkerpop's comparison operators to Titan's
 *
 * @param p Any predicate
 * @return A TitanPredicate equivalent to the given predicate
 * @throws IllegalArgumentException if the given Predicate is unknown
 */
public static final TitanPredicate convertInternal(BiPredicate p) {
    if (p instanceof TitanPredicate) {
        return (TitanPredicate)p;
    } else if (p instanceof Compare) {
        Compare comp = (Compare)p;
        switch(comp) {
            case eq: return Cmp.EQUAL;
            case neq: return Cmp.NOT_EQUAL;
            case gt: return Cmp.GREATER_THAN;
            case gte: return Cmp.GREATER_THAN_EQUAL;
            case lt: return Cmp.LESS_THAN;
            case lte: return Cmp.LESS_THAN_EQUAL;
            default: throw new IllegalArgumentException("Unexpected comparator: " + comp);
        }
    } else if (p instanceof Contains) {
        Contains con = (Contains)p;
        switch (con) {
            case within: return Contain.IN;
            case without: return Contain.NOT_IN;
            default: throw new IllegalArgumentException("Unexpected container: " + con);

        }
    } else return null;
}
 
Example 2
Source File: GraphCentricQueryBuilder.java    From titan1withtp3.1 with Apache License 2.0 6 votes vote down vote up
private static final Map.Entry<Condition,Collection<Object>> getEqualityConditionValues(Condition<TitanElement> condition, RelationType type) {
    for (Condition c : condition.getChildren()) {
        if (c instanceof Or) {
            Map.Entry<RelationType,Collection> orEqual = QueryUtil.extractOrCondition((Or)c);
            if (orEqual!=null && orEqual.getKey().equals(type) && !orEqual.getValue().isEmpty()) {
                return new AbstractMap.SimpleImmutableEntry(c,orEqual.getValue());
            }
        } else if (c instanceof PredicateCondition) {
            PredicateCondition<RelationType, TitanRelation> atom = (PredicateCondition)c;
            if (atom.getKey().equals(type) && atom.getPredicate()==Cmp.EQUAL && atom.getValue()!=null) {
                return new AbstractMap.SimpleImmutableEntry(c,ImmutableList.of(atom.getValue()));
            }
        }

    }
    return null;
}
 
Example 3
Source File: GraphCentricQueryBuilder.java    From incubator-atlas with Apache License 2.0 6 votes vote down vote up
private static final Map.Entry<Condition, Collection<Object>> getEqualityConditionValues(Condition<TitanElement> condition, RelationType type) {
    for (Condition c : condition.getChildren()) {
        if (c instanceof Or) {
            Map.Entry<RelationType, Collection> orEqual = QueryUtil.extractOrCondition((Or)c);
            if (orEqual!=null && orEqual.getKey().equals(type) && !orEqual.getValue().isEmpty()) {
                return new AbstractMap.SimpleImmutableEntry(c, orEqual.getValue());
            }
        } else if (c instanceof PredicateCondition) {
            PredicateCondition<RelationType, TitanRelation> atom = (PredicateCondition)c;
            if (atom.getKey().equals(type) && atom.getPredicate()==Cmp.EQUAL && atom.getValue()!=null) {
                return new AbstractMap.SimpleImmutableEntry(c, ImmutableList.of(atom.getValue()));
            }
        }

    }
    return null;
}
 
Example 4
Source File: StandardIndexInformation.java    From titan1withtp3.1 with Apache License 2.0 4 votes vote down vote up
@Override
public boolean supports(KeyInformation information, TitanPredicate titanPredicate) {
    return titanPredicate == Cmp.EQUAL || titanPredicate == Contain.IN;
}