@Override public And<E> clone() { return new And<E>(this); }
public static <E extends TitanElement> And<E> of(Condition<E>... elements) { return new And<E>(elements); }
public static final Condition<TitanElement> indexCover(final MixedIndexType index, Condition<TitanElement> condition, final IndexSerializer indexInfo, final Set<Condition> covered) { assert QueryUtil.isQueryNormalForm(condition); assert condition instanceof And; And<TitanElement> subcondition = new And<TitanElement>(condition.numChildren()); for (Condition<TitanElement> subclause : condition.getChildren()) { if (coversAll(index,subclause,indexInfo)) { subcondition.add(subclause); covered.add(subclause); } } return subcondition.isEmpty()?null:subcondition; }
return (key + ":(" + escapeValue(terms.get(0)) + ")"); } else { And<TitanElement> andTerms = new And<TitanElement>(); for (String term : terms) { andTerms.add(new PredicateCondition<String, TitanElement>(key, titanPredicate, term));
And<E> conditions = new And<E>(constraints.size() + 4); for (PredicateCondition<String, E> atom : constraints) { RelationType type = getType(tx, atom.getKey());
public static final<E extends TitanElement> Condition<E> transformation(Condition<E> condition, Function<Condition<E>,Condition<E>> transformation) { Condition<E> transformed = transformation.apply(condition); if (transformed!=null) return transformed; //if transformed==null we go a level deeper if (condition.getType()== Condition.Type.LITERAL) { return condition; } else if (condition instanceof Not) { return Not.of(transformation(((Not) condition).getChild(), transformation)); } else if (condition instanceof And) { And<E> newand = new And<E>(condition.numChildren()); for (Condition<E> child : condition.getChildren()) newand.add(transformation(child, transformation)); return newand; } else if (condition instanceof Or) { Or<E> newor = new Or<E>(condition.numChildren()); for (Condition<E> child : condition.getChildren()) newor.add(transformation(child, transformation)); return newor; } else throw new IllegalArgumentException("Unexpected condition type: " + condition); }
/** * Constructs a {@link VertexCentricQuery} for this query builder. The query construction and optimization * logic is taken from {@link #constructQuery(com.thinkaurelius.titan.graphdb.internal.RelationCategory)} * This method only adds the additional conditions that are based on the base vertex. * * @param vertex for which to construct this query * @param baseQuery as constructed by {@link #constructQuery(com.thinkaurelius.titan.graphdb.internal.RelationCategory)} * @return */ protected VertexCentricQuery constructQuery(InternalVertex vertex, BaseVertexCentricQuery baseQuery) { Condition<TitanRelation> condition = baseQuery.getCondition(); if (!baseQuery.isEmpty()) { //Add adjacent-vertex and direction related conditions; copy conditions to so that baseQuery does not change And<TitanRelation> newcond = new And<TitanRelation>(); if (condition instanceof And) newcond.addAll((And) condition); else newcond.add(condition); newcond.add(new DirectionCondition<TitanRelation>(vertex,dir)); if (adjacentVertex != null) newcond.add(new IncidenceCondition<TitanRelation>(vertex,adjacentVertex)); condition = newcond; } VertexCentricQuery query = new VertexCentricQuery(vertex, condition, baseQuery.getDirection(), baseQuery.getQueries(),baseQuery.getOrders(), baseQuery.getLimit()); Preconditions.checkArgument(!queryOnlyLoaded || query.isSimple(),"Query-only-loaded only works on simple queries"); return query; }
@Override public And<E> clone() { return new And<E>(this); }
@Override public And<E> clone() { return new And<E>(this); }
public static <E extends TitanElement> And<E> of(Condition<E>... elements) { return new And<E>(elements); }
public static <E extends TitanElement> And<E> of(Condition<E>... elements) { return new And<E>(elements); }
public static final Condition<TitanElement> indexCover(final MixedIndexType index, Condition<TitanElement> condition, final IndexSerializer indexInfo, final Set<Condition> covered) { assert QueryUtil.isQueryNormalForm(condition); assert condition instanceof And; And<TitanElement> subcondition = new And<TitanElement>(condition.numChildren()); for (Condition<TitanElement> subclause : condition.getChildren()) { if (coversAll(index,subclause,indexInfo)) { subcondition.add(subclause); covered.add(subclause); } } return subcondition.isEmpty()?null:subcondition; }
public static final Condition<TitanElement> indexCover(final MixedIndexType index, Condition<TitanElement> condition, final IndexSerializer indexInfo, final Set<Condition> covered) { assert QueryUtil.isQueryNormalForm(condition); assert condition instanceof And; And<TitanElement> subcondition = new And<TitanElement>(condition.numChildren()); for (Condition<TitanElement> subclause : condition.getChildren()) { if (coversAll(index,subclause,indexInfo)) { subcondition.add(subclause); covered.add(subclause); } } return subcondition.isEmpty()?null:subcondition; }
public static final Condition<TitanElement> indexCover(final MixedIndexType index, Condition<TitanElement> condition, final IndexSerializer indexInfo, final Set<Condition> covered) { assert QueryUtil.isQueryNormalForm(condition); assert condition instanceof And; And<TitanElement> subcondition = new And<TitanElement>(condition.numChildren()); for (Condition<TitanElement> subclause : condition.getChildren()) { if (coversAll(index,subclause,indexInfo)) { subcondition.add(subclause); covered.add(subclause); } } return subcondition.isEmpty()?null:subcondition; }
public static final Condition<TitanElement> indexCover(final MixedIndexType index, Condition<TitanElement> condition, final IndexSerializer indexInfo, final Set<Condition> covered) { assert QueryUtil.isQueryNormalForm(condition); assert condition instanceof And; And<TitanElement> subcondition = new And<>(condition.numChildren()); for (Condition<TitanElement> subclause : condition.getChildren()) { if (coversAll(index, subclause, indexInfo)) { subcondition.add(subclause); covered.add(subclause); } } return subcondition.isEmpty()?null:subcondition; }
public static final<E extends TitanElement> Condition<E> transformation(Condition<E> condition, Function<Condition<E>,Condition<E>> transformation) { Condition<E> transformed = transformation.apply(condition); if (transformed!=null) return transformed; //if transformed==null we go a level deeper if (condition.getType()== Condition.Type.LITERAL) { return condition; } else if (condition instanceof Not) { return Not.of(transformation(((Not) condition).getChild(), transformation)); } else if (condition instanceof And) { And<E> newand = new And<E>(condition.numChildren()); for (Condition<E> child : condition.getChildren()) newand.add(transformation(child, transformation)); return newand; } else if (condition instanceof Or) { Or<E> newor = new Or<E>(condition.numChildren()); for (Condition<E> child : condition.getChildren()) newor.add(transformation(child, transformation)); return newor; } else throw new IllegalArgumentException("Unexpected condition type: " + condition); }
And<E> conditions = new And<E>(constraints.size() + 4); for (PredicateCondition<String, E> atom : constraints) { RelationType type = getType(tx, atom.getKey());
public static final<E extends TitanElement> Condition<E> transformation(Condition<E> condition, Function<Condition<E>,Condition<E>> transformation) { Condition<E> transformed = transformation.apply(condition); if (transformed!=null) return transformed; //if transformed==null we go a level deeper if (condition.getType()== Condition.Type.LITERAL) { return condition; } else if (condition instanceof Not) { return Not.of(transformation(((Not) condition).getChild(), transformation)); } else if (condition instanceof And) { And<E> newand = new And<E>(condition.numChildren()); for (Condition<E> child : condition.getChildren()) newand.add(transformation(child, transformation)); return newand; } else if (condition instanceof Or) { Or<E> newor = new Or<E>(condition.numChildren()); for (Condition<E> child : condition.getChildren()) newor.add(transformation(child, transformation)); return newor; } else throw new IllegalArgumentException("Unexpected condition type: " + condition); }
/** * Constructs a {@link VertexCentricQuery} for this query builder. The query construction and optimization * logic is taken from {@link #constructQuery(com.thinkaurelius.titan.graphdb.internal.RelationCategory)} * This method only adds the additional conditions that are based on the base vertex. * * @param vertex for which to construct this query * @param baseQuery as constructed by {@link #constructQuery(com.thinkaurelius.titan.graphdb.internal.RelationCategory)} * @return */ protected VertexCentricQuery constructQuery(InternalVertex vertex, BaseVertexCentricQuery baseQuery) { Condition<TitanRelation> condition = baseQuery.getCondition(); if (!baseQuery.isEmpty()) { //Add adjacent-vertex and direction related conditions; copy conditions to so that baseQuery does not change And<TitanRelation> newcond = new And<TitanRelation>(); if (condition instanceof And) newcond.addAll((And) condition); else newcond.add(condition); newcond.add(new DirectionCondition<TitanRelation>(vertex,dir)); if (adjacentVertex != null) newcond.add(new IncidenceCondition<TitanRelation>(vertex,adjacentVertex)); condition = newcond; } VertexCentricQuery query = new VertexCentricQuery(vertex, condition, baseQuery.getDirection(), baseQuery.getQueries(),baseQuery.getOrders(), baseQuery.getLimit()); Preconditions.checkArgument(!queryOnlyLoaded || query.isSimple(),"Query-only-loaded only works on simple queries"); return query; }
/** * Constructs a {@link VertexCentricQuery} for this query builder. The query construction and optimization * logic is taken from {@link #constructQuery(com.thinkaurelius.titan.graphdb.internal.RelationCategory)} * This method only adds the additional conditions that are based on the base vertex. * * @param vertex for which to construct this query * @param baseQuery as constructed by {@link #constructQuery(com.thinkaurelius.titan.graphdb.internal.RelationCategory)} * @return */ protected VertexCentricQuery constructQuery(InternalVertex vertex, BaseVertexCentricQuery baseQuery) { Condition<TitanRelation> condition = baseQuery.getCondition(); if (!baseQuery.isEmpty()) { //Add adjacent-vertex and direction related conditions; copy conditions to so that baseQuery does not change And<TitanRelation> newcond = new And<TitanRelation>(); if (condition instanceof And) newcond.addAll((And) condition); else newcond.add(condition); newcond.add(new DirectionCondition<TitanRelation>(vertex,dir)); if (adjacentVertex != null) newcond.add(new IncidenceCondition<TitanRelation>(vertex,adjacentVertex)); condition = newcond; } VertexCentricQuery query = new VertexCentricQuery(vertex, condition, baseQuery.getDirection(), baseQuery.getQueries(),baseQuery.getOrders(), baseQuery.getLimit()); Preconditions.checkArgument(!queryOnlyLoaded || query.isSimple(),"Query-only-loaded only works on simple queries"); return query; }