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; }
@Nullable @Override public Condition<TitanElement> apply(@Nullable Condition<TitanElement> condition) { Preconditions.checkArgument(condition instanceof PredicateCondition); PredicateCondition pc = (PredicateCondition) condition; PropertyKey key = (PropertyKey) pc.getKey(); return new PredicateCondition<String, TitanElement>(key2Field(index,key), pc.getPredicate(), pc.getValue()); } });
public static Map.Entry<RelationType,Collection> extractOrCondition(Or<TitanRelation> condition) { RelationType masterType = null; List<Object> values = new ArrayList<Object>(); for (Condition c : condition.getChildren()) { if (!(c instanceof PredicateCondition)) return null; PredicateCondition<RelationType, TitanRelation> atom = (PredicateCondition)c; if (atom.getPredicate()!=Cmp.EQUAL) return null; Object value = atom.getValue(); if (value==null) return null; RelationType type = atom.getKey(); if (masterType==null) masterType=type; else if (!masterType.equals(type)) return null; values.add(value); } if (masterType==null) return null; assert !values.isEmpty(); return new AbstractMap.SimpleImmutableEntry(masterType,values); }
@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; } });
type = atom.getKey(); Interval interval = constraintMap.get(type); newInterval = intersectConstraints(interval, type, atom.getPredicate(), atom.getValue());
public String buildQueryFilter(Condition<TitanElement> condition, KeyInformation.StoreRetriever informations) { if (condition instanceof PredicateCondition) { PredicateCondition<String, TitanElement> atom = (PredicateCondition<String, TitanElement>) condition; Object value = atom.getValue(); String key = atom.getKey(); TitanPredicate titanPredicate = atom.getPredicate();
vertices = com.google.common.collect.Iterators.transform(newVertexIndexEntries.get(standardIndexKey.getValue(), standardIndexKey.getKey()).iterator(), new Function<TitanVertexProperty, TitanVertex>() { @Nullable @Override
private static final boolean coversAll(final MixedIndexType index, Condition<TitanElement> condition, IndexSerializer indexInfo) { if (condition.getType()==Condition.Type.LITERAL) { if (!(condition instanceof PredicateCondition)) return false; PredicateCondition<RelationType, TitanElement> atom = (PredicateCondition) condition; if (atom.getValue()==null) return false; Preconditions.checkArgument(atom.getKey().isPropertyKey()); PropertyKey key = (PropertyKey) atom.getKey(); ParameterIndexField[] fields = index.getFieldKeys(); ParameterIndexField match = null; for (int i = 0; i < fields.length; i++) { if (fields[i].getStatus()!= SchemaStatus.ENABLED) continue; if (fields[i].getFieldKey().equals(key)) match = fields[i]; } if (match==null) return false; return indexInfo.supports(index,match,atom.getPredicate()); } else { for (Condition<TitanElement> child : condition.getChildren()) { if (!coversAll(index,child,indexInfo)) return false; } return true; } }
public FilterBuilder getFilter(Condition<?> condition, KeyInformation.StoreRetriever informations) { if (condition instanceof PredicateCondition) { PredicateCondition<String, ?> atom = (PredicateCondition) condition; Object value = atom.getValue(); String key = atom.getKey(); TitanPredicate titanPredicate = atom.getPredicate();
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; }
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; }
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; }
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; }
@Nullable @Override public Condition<TitanElement> apply(@Nullable Condition<TitanElement> condition) { Preconditions.checkArgument(condition instanceof PredicateCondition); PredicateCondition pc = (PredicateCondition) condition; PropertyKey key = (PropertyKey) pc.getKey(); return new PredicateCondition<String, TitanElement>(key2Field(index,key), pc.getPredicate(), pc.getValue()); } });
@Nullable @Override public Condition<TitanElement> apply(@Nullable Condition<TitanElement> condition) { Preconditions.checkArgument(condition instanceof PredicateCondition); PredicateCondition pc = (PredicateCondition) condition; PropertyKey key = (PropertyKey) pc.getKey(); return new PredicateCondition<String, TitanElement>(key2Field(index,key), pc.getPredicate(), pc.getValue()); } });
public static Map.Entry<RelationType,Collection> extractOrCondition(Or<TitanRelation> condition) { RelationType masterType = null; List<Object> values = new ArrayList<Object>(); for (Condition c : condition.getChildren()) { if (!(c instanceof PredicateCondition)) return null; PredicateCondition<RelationType, TitanRelation> atom = (PredicateCondition)c; if (atom.getPredicate()!=Cmp.EQUAL) return null; Object value = atom.getValue(); if (value==null) return null; RelationType type = atom.getKey(); if (masterType==null) masterType=type; else if (!masterType.equals(type)) return null; values.add(value); } if (masterType==null) return null; assert !values.isEmpty(); return new AbstractMap.SimpleImmutableEntry(masterType,values); }
public static Map.Entry<RelationType,Collection> extractOrCondition(Or<TitanRelation> condition) { RelationType masterType = null; List<Object> values = new ArrayList<Object>(); for (Condition c : condition.getChildren()) { if (!(c instanceof PredicateCondition)) return null; PredicateCondition<RelationType, TitanRelation> atom = (PredicateCondition)c; if (atom.getPredicate()!=Cmp.EQUAL) return null; Object value = atom.getValue(); if (value==null) return null; RelationType type = atom.getKey(); if (masterType==null) masterType=type; else if (!masterType.equals(type)) return null; values.add(value); } if (masterType==null) return null; assert !values.isEmpty(); return new AbstractMap.SimpleImmutableEntry(masterType,values); }
@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; } });
@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; } });