@Override public GraphCentricQueryBuilder has(String key, TitanPredicate predicate, Object condition) { Preconditions.checkNotNull(key); Preconditions.checkNotNull(predicate); Preconditions.checkArgument(predicate.isValidCondition(condition), "Invalid condition: %s", condition); constraints.add(new PredicateCondition<String, TitanElement>(key, predicate, condition)); return this; }
@Nullable @Override public Condition<E> apply(@Nullable Condition<E> cond) { if (cond instanceof Not) { Condition<E> child = ((Not) cond).getChild(); Preconditions.checkArgument(child.getType() == Condition.Type.LITERAL); //verify QNF if (child instanceof PredicateCondition) { PredicateCondition<?, E> pc = (PredicateCondition) child; if (pc.getPredicate().hasNegation()) { return new PredicateCondition(pc.getKey(), pc.getPredicate().negate(), pc.getValue()); } } } return null; } });
private static final boolean isQNFLiteral(Condition<?> condition) { if (condition.getType() != Condition.Type.LITERAL) return false; if (condition instanceof PredicateCondition) { return ((PredicateCondition) condition).getPredicate().isQNF(); } else return true; }
assert predicate.isValidCondition(value); Preconditions.checkArgument(key.dataType()==Object.class || predicate.isValidValueType(key.dataType()), "Data type of key is not compatible with condition"); } else { //its a label Preconditions.checkArgument(((EdgeLabel) type).isUnidirected()); Preconditions.checkArgument(predicate.isValidValueType(TitanVertex.class), "Data type of key is not compatible with condition");
private static final boolean isQNFLiteralOrNot(Condition<?> condition) { if (condition instanceof Not) { Condition child = ((Not) condition).getChild(); if (!isQNFLiteral(child)) return false; else if (child instanceof PredicateCondition) { return !((PredicateCondition) child).getPredicate().hasNegation(); } else return true; } else return isQNFLiteral(condition); }
private boolean satisfiesCondition(Object value) { return predicate.test(value, this.value); }
private boolean satisfiesCondition(Object value) { return predicate.evaluate(value, this.value); }
assert predicate.isValidCondition(value); Preconditions.checkArgument(key.getDataType()==Object.class || predicate.isValidValueType(key.getDataType()), "Data type of key is not compatible with condition"); } else { //its a label Preconditions.checkArgument(((EdgeLabel) type).isUnidirected()); Preconditions.checkArgument(predicate.isValidValueType(TitanVertex.class), "Data type of key is not compatible with condition");
private static final boolean isQNFLiteralOrNot(Condition<?> condition) { if (condition instanceof Not) { Condition child = ((Not) condition).getChild(); if (!isQNFLiteral(child)) return false; else if (child instanceof PredicateCondition) { return !((PredicateCondition) child).getPredicate().hasNegation(); } else return true; } else return isQNFLiteral(condition); }
private boolean satisfiesCondition(Object value) { return predicate.test(value, this.value); }
private Q addConstraint(String type, TitanPredicate rel, Object value) { Preconditions.checkArgument(type != null && StringUtils.isNotBlank(type) && rel != null); //Treat special cases if (type.equals(ImplicitKey.ADJACENT_ID.name())) { Preconditions.checkArgument(rel == Cmp.EQUAL, "Only equality constraints are supported for %s", type); long vertexId = ElementUtils.getVertexId(value); Preconditions.checkArgument(vertexId > 0, "Expected valid vertex id: %s", value); return adjacent(getVertex(vertexId)); } else if (type.equals(ImplicitKey.ID.name())) { RelationIdentifier rid = ElementUtils.getEdgeId(value); Preconditions.checkArgument(rid != null, "Expected valid relation id: %s", value); return addConstraint(ImplicitKey.TITANID.name(), rel, rid.getRelationId()); } else { Preconditions.checkArgument(rel.isValidCondition(value), "Invalid condition provided: " + value); } if (constraints == NO_CONSTRAINTS) constraints = new ArrayList<PredicateCondition<String, TitanRelation>>(5); constraints.add(new PredicateCondition<String, TitanRelation>(type, rel, value)); return getThis(); }
assert predicate.isValidCondition(value); Preconditions.checkArgument(key.dataType()==Object.class || predicate.isValidValueType(key.dataType()), "Data type of key is not compatible with condition"); } else { //its a label Preconditions.checkArgument(((EdgeLabel) type).isUnidirected()); Preconditions.checkArgument(predicate.isValidValueType(TitanVertex.class), "Data type of key is not compatible with condition");
@Nullable @Override public Condition<E> apply(@Nullable Condition<E> cond) { if (cond instanceof Not) { Condition<E> child = ((Not) cond).getChild(); Preconditions.checkArgument(child.getType() == Condition.Type.LITERAL); //verify QNF if (child instanceof PredicateCondition) { PredicateCondition<?, E> pc = (PredicateCondition) child; if (pc.getPredicate().hasNegation()) { return new PredicateCondition(pc.getKey(), pc.getPredicate().negate(), pc.getValue()); } } } return null; } });
private static final boolean isQNFLiteralOrNot(Condition<?> condition) { if (condition instanceof Not) { Condition child = ((Not) condition).getChild(); if (!isQNFLiteral(child)) return false; else if (child instanceof PredicateCondition) { return !((PredicateCondition) child).getPredicate().hasNegation(); } else return true; } else return isQNFLiteral(condition); }
private static final boolean isQNFLiteral(Condition<?> condition) { if (condition.getType() != Condition.Type.LITERAL) return false; if (condition instanceof PredicateCondition) { return ((PredicateCondition) condition).getPredicate().isQNF(); } else return true; }
@Override public GraphCentricQueryBuilder has(String key, TitanPredicate predicate, Object condition) { Preconditions.checkNotNull(key); Preconditions.checkNotNull(predicate); Preconditions.checkArgument(predicate.isValidCondition(condition), "Invalid condition: %s", condition); constraints.add(new PredicateCondition<String, TitanElement>(key, predicate, condition)); return this; }
@Nullable @Override public Condition<E> apply(@Nullable Condition<E> cond) { if (cond instanceof Not) { Condition<E> child = ((Not) cond).getChild(); Preconditions.checkArgument(child.getType() == Condition.Type.LITERAL); //verify QNF if (child instanceof PredicateCondition) { PredicateCondition<?, E> pc = (PredicateCondition) child; if (pc.getPredicate().hasNegation()) { return new PredicateCondition(pc.getKey(), pc.getPredicate().negate(), pc.getValue()); } } } return null; } });
private static final boolean isQNFLiteral(Condition<?> condition) { if (condition.getType() != Condition.Type.LITERAL) return false; if (condition instanceof PredicateCondition) { return ((PredicateCondition) condition).getPredicate().isQNF(); } else return true; }
private GraphCentricQueryBuilder has(String key, TitanPredicate predicate, Object condition) { Preconditions.checkNotNull(key); Preconditions.checkNotNull(predicate); Preconditions.checkArgument(predicate.isValidCondition(condition), "Invalid condition: %s", condition); constraints.add(new PredicateCondition<String, TitanElement>(key, predicate, condition)); return this; }
private GraphCentricQueryBuilder has(String key, TitanPredicate predicate, Object condition) { Preconditions.checkNotNull(key); Preconditions.checkNotNull(predicate); Preconditions.checkArgument(predicate.isValidCondition(condition), "Invalid condition: %s", condition); constraints.add(new PredicateCondition<String, TitanElement>(key, predicate, condition)); return this; }