private static Iterable<MixedIndexType> getMixedIndexes(RelationType type) { if (!type.isPropertyKey()) { return Collections.emptyList(); } return Iterables.filter(Iterables.filter(((InternalRelationType)type).getKeyIndexes(), MIXED_INDEX_FILTER), MixedIndexType.class); }
@Override public boolean containsPropertyKey(String name) { RelationType type = getRelationType(name); return type!=null && type.isPropertyKey(); }
@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 PropertyKey getOrCreatePropertyKey(String name, Object value) { RelationType et = getRelationType(name); if (et == null) { return config.getAutoSchemaMaker().makePropertyKey(makePropertyKey(name), value); } 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 JanusGraphElement> void addConstraint(RelationType type, JanusGraphPredicate predicate, Object value, MultiCondition<E> conditions, StandardJanusGraphTx tx) { if (type.isPropertyKey()) { if (value != null) value = tx.verifyAttribute((PropertyKey) type, value); } else { //t.isEdgeLabel() Preconditions.checkArgument(value instanceof JanusGraphVertex); } final PredicateCondition<RelationType, E> pc = new PredicateCondition<>(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); }
private static boolean coversAll(final MixedIndexType index, Condition<JanusGraphElement> condition, IndexSerializer indexInfo) { if (condition.getType()!=Condition.Type.LITERAL) { return StreamSupport.stream(condition.getChildren().spliterator(), false) .allMatch(child -> coversAll(index, child, indexInfo)); } if (!(condition instanceof PredicateCondition)) { return false; } final PredicateCondition<RelationType, JanusGraphElement> atom = (PredicateCondition) condition; if (atom.getValue() == null) { return false; } Preconditions.checkArgument(atom.getKey().isPropertyKey()); final PropertyKey key = (PropertyKey) atom.getKey(); final ParameterIndexField[] fields = index.getFieldKeys(); final ParameterIndexField match = Arrays.stream(fields) .filter(field -> field.getStatus() == SchemaStatus.ENABLED) .filter(field -> field.getFieldKey().equals(key)) .findAny().orElse(null); return match != null && indexInfo.supports(index, match, atom.getPredicate()); }
@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> iterator = ElementHelper.getValues(element,(PropertyKey)type).iterator(); if (iterator.hasNext()) { while (iterator.hasNext()) { if (satisfiesCondition(iterator.next())) return true; } return false; } return satisfiesCondition(null); } else { assert ((InternalRelationType)type).multiplicity().isUnique(Direction.OUT); return satisfiesCondition(element.value(type.name())); } }
maker = lm; } else { assert type.isPropertyKey(); assert direction == Direction.OUT; StandardPropertyKeyMaker lm = (StandardPropertyKeyMaker) transaction.makePropertyKey(composedName);
if (type.isPropertyKey()) { final PropertyKey key = (PropertyKey) type; assert predicate.isValidCondition(value);
for (int i = 0; i < numTypes; i++) { RelationType type = tx.getRelationType("test" + i); if (i < numTypes / 2) assertTrue(type.isPropertyKey()); else assertTrue(type.isEdgeLabel());
if (condition instanceof PredicateCondition) { final RelationType type = ((PredicateCondition<RelationType,JanusGraphElement>) condition).getKey(); Preconditions.checkArgument(type != null && type.isPropertyKey()); Iterables.addAll(indexCandidates, Iterables.filter(((InternalRelationType) type).getKeyIndexes(), indexType -> indexType.getElement() == resultType && !(conditions instanceof Or && (indexType.isCompositeIndex() || !serializer.features((MixedIndexType) indexType).supportNotQueryNormalForm()))));
assert relationType.isPropertyKey(); PropertyKey key = (PropertyKey) relationType;
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()); } }
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()); } }
if (type.isPropertyKey()) { assert next.value != null; RelationType rt = typeManager.getExistingRelationType(next.key); if (rt.isPropertyKey()) { te.property(rt.name(), next.value); } else {
if (type.isPropertyKey()) { assert next.value != null; RelationType rt = typeManager.getExistingRelationType(next.key); if (rt.isPropertyKey()) { te.property(rt.name(), next.value); } else {