@Override public boolean containsPropertyKey(String name) { RelationType type = getRelationType(name); return type!=null && type.isPropertyKey(); }
private static Iterable<MixedIndexType> getMixedIndexes(RelationType type) { if (!type.isPropertyKey()) return Collections.EMPTY_LIST; return Iterables.filter(Iterables.filter(((InternalRelationType)type).getKeyIndexes(),MIXED_INDEX_FILTER),MixedIndexType.class); }
@Override public PropertyKey getPropertyKey(String name) { RelationType pk = getRelationType(name); Preconditions.checkArgument(pk==null || pk.isPropertyKey(), "The relation type with name [%s] is not a property key",name); return (PropertyKey)pk; }
@Override public boolean apply(@Nullable Condition<TitanElement> condition) { if (condition instanceof PredicateCondition) { RelationType type = ((PredicateCondition<RelationType,TitanElement>)condition).getKey(); Preconditions.checkArgument(type!=null && type.isPropertyKey()); Iterables.addAll(indexCandidates,Iterables.filter(((InternalRelationType) type).getKeyIndexes(), new Predicate<IndexType>() { @Override public boolean apply(@Nullable IndexType indexType) { return indexType.getElement()==resultType; } })); } return true; } });
@Override public PropertyKey getOrCreatePropertyKey(String name) { RelationType et = getRelationType(name); if (et == null) { return config.getAutoSchemaMaker().makePropertyKey(makePropertyKey(name)); } else if (et.isPropertyKey()) { return (PropertyKey) et; } else throw new IllegalArgumentException("The type of given name is not a key: " + name); }
private static <E extends TitanElement> void addConstraint(RelationType type, TitanPredicate predicate, Object value, MultiCondition<E> conditions, StandardTitanTx tx) { if (type.isPropertyKey()) { if (value != null) value = tx.verifyAttribute((PropertyKey) type, value); } else { //t.isEdgeLabel() Preconditions.checkArgument(value instanceof TitanVertex); } PredicateCondition<RelationType, E> pc = new PredicateCondition<RelationType, E>(type, predicate, value); if (!conditions.contains(pc)) conditions.add(pc); }
private VertexProperty.Cardinality getPropertyKeyCardinality(String name) { RelationType rt = typeManager.getRelationType(name); if (null == rt || !rt.isPropertyKey()) return VertexProperty.Cardinality.single; PropertyKey pk = typeManager.getExistingPropertyKey(rt.longId()); switch (pk.cardinality()) { case SINGLE: return VertexProperty.Cardinality.single; case LIST: return VertexProperty.Cardinality.list; case SET: return VertexProperty.Cardinality.set; default: throw new IllegalStateException("Unknown cardinality " + pk.cardinality()); } }
@Override public void run() { TitanTransaction tx = graph.newTransaction(); for (int i = 0; i < numTypes; i++) { RelationType type = tx.getRelationType("test" + i); if (i < numTypes / 2) assertTrue(type.isPropertyKey()); else assertTrue(type.isEdgeLabel()); } tx.commit(); } });
@Override public boolean evaluate(E element) { RelationType type; if (key instanceof String) { type = ((InternalElement) element).tx().getRelationType((String) key); if (type == null) return satisfiesCondition(null); } else { type = (RelationType) key; } Preconditions.checkNotNull(type); if (type.isPropertyKey()) { Iterator<Object> iter = ElementHelper.getValues(element,(PropertyKey)type).iterator(); if (iter.hasNext()) { while (iter.hasNext()) { if (satisfiesCondition(iter.next())) return true; } return false; } return satisfiesCondition(null); } else { assert ((InternalRelationType)type).multiplicity().isUnique(Direction.OUT); return satisfiesCondition((TitanVertex)element.value(type.name())); } }
maker = lm; } else { assert type.isPropertyKey(); assert direction == Direction.OUT; StandardPropertyKeyMaker lm = (StandardPropertyKeyMaker) transaction.makePropertyKey(composedName);
if (type.isPropertyKey()) { PropertyKey key = (PropertyKey) type; assert predicate.isValidCondition(value);
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; } }
if (type.isPropertyKey()) { assert next.value != null; RelationType rt = typeManager.getExistingRelationType(next.key); if (rt.isPropertyKey()) {
assert relationType.isPropertyKey(); PropertyKey key = (PropertyKey) relationType;
@Override public boolean containsPropertyKey(String name) { RelationType type = getRelationType(name); return type!=null && type.isPropertyKey(); }
@Override public boolean containsPropertyKey(String name) { RelationType type = getRelationType(name); return type!=null && type.isPropertyKey(); }
@Override public PropertyKey getOrCreatePropertyKey(String name) { RelationType et = getRelationType(name); if (et == null) { return config.getAutoSchemaMaker().makePropertyKey(makePropertyKey(name)); } else if (et.isPropertyKey()) { return (PropertyKey) et; } else throw new IllegalArgumentException("The type of given name is not a key: " + name); }
private static <E extends TitanElement> void addConstraint(RelationType type, TitanPredicate predicate, Object value, MultiCondition<E> conditions, StandardTitanTx tx) { if (type.isPropertyKey()) { if (value != null) value = tx.verifyAttribute((PropertyKey) type, value); } else { //t.isEdgeLabel() Preconditions.checkArgument(value instanceof TitanVertex); } PredicateCondition<RelationType, E> pc = new PredicateCondition<RelationType, E>(type, predicate, value); if (!conditions.contains(pc)) conditions.add(pc); }
@Override public PropertyKey getOrCreatePropertyKey(String name) { RelationType et = getRelationType(name); if (et == null) { return config.getAutoSchemaMaker().makePropertyKey(makePropertyKey(name)); } else if (et.isPropertyKey()) { return (PropertyKey) et; } else throw new IllegalArgumentException("The type of given name is not a key: " + name); }
@Override public <O> O removeProperty(RelationType key) { assert key.isPropertyKey(); Object result = null; for (TitanProperty p : query().type(key).properties()) { result = p.getValue(); p.remove(); } return (O) result; }