@Override public <O> O valueOrNull(PropertyKey key) { if (key instanceof ImplicitKey) return ((ImplicitKey)key).computeProperty(this); return null; }
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(); }
@Override public Multiplicity multiplicity() { return Multiplicity.convert(cardinality()); }
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.getName())) { Preconditions.checkArgument(rel == Cmp.EQUAL,"Only equality constraints are supported for %s",type); Preconditions.checkArgument(value instanceof Number,"Expected valid vertex id: %s",value); return adjacent(getVertex(((Number)value).longValue())); } else if (type.equals(ImplicitKey.ID.getName())) { Preconditions.checkArgument(value instanceof RelationIdentifier,"Expected valid relation id: %s",value); return addConstraint(ImplicitKey.TITANID.getName(),rel,((RelationIdentifier)value).getRelationId()); } if (constraints==NO_CONSTRAINTS) constraints = new ArrayList<PredicateCondition<String, TitanRelation>>(5); constraints.add(new PredicateCondition<String, TitanRelation>(type, rel, value)); return getThis(); }
if (key!=null) { assert metas.getValue()!=null; properties.put(key.longId(),metas.getValue());
@Override public Multiplicity getMultiplicity() { return Multiplicity.convert(getCardinality()); }
if (key!=null) { assert metas.getValue()!=null; properties.put(key.getLongId(),metas.getValue());
} else throw new AssertionError("Implicit key property is undefined: " + this.getName());
if (key!=null) { assert metas.getValue()!=null; properties.put(key.longId(),metas.getValue());
/** * If {@link #isImplicitKeyQuery(com.thinkaurelius.titan.graphdb.internal.RelationCategory)} is true, * this method provides the result set for the query based on the evaluation of the {@link ImplicitKey}. * </p> * Handling of implicit keys is completely distinct from "normal" query execution and handled extra * for completeness reasons. * * @param v * @return */ protected Iterable<TitanRelation> executeImplicitKeyQuery(InternalVertex v) { assert isImplicitKeyQuery(RelationCategory.PROPERTY); if (dir==Direction.IN || limit<1) return ImmutableList.of(); ImplicitKey key = (ImplicitKey)tx.getRelationType(types[0]); return ImmutableList.of((TitanRelation)new StandardVertexProperty(0,key,v,key.computeProperty(v), v.isNew()?ElementLifeCycle.New:ElementLifeCycle.Loaded)); }
HasContainer.makeHasContainers(ImplicitKey.ADJACENT_ID.name(), P.eq(vertex))), traversal);
assertEquals("$ttl", ImplicitKey.TTL.getName());
@Override public Multiplicity multiplicity() { return Multiplicity.convert(cardinality()); }
@Override public <O> O valueOrNull(PropertyKey key) { verifyAccess(); if (key instanceof ImplicitKey) return ((ImplicitKey)key).computeProperty(this); return it().getValueDirect(key); }
} else throw new AssertionError("Implicit key property is undefined: " + this.name());
@Override public <O> O valueOrNull(PropertyKey key) { if (key instanceof ImplicitKey) return ((ImplicitKey)key).computeProperty(this); return null; }
assertEquals("~ttl", ImplicitKey.TTL.name());
@Override public <O> O getProperty(PropertyKey key) { if (key instanceof ImplicitKey) return ((ImplicitKey)key).computeProperty(this); return null; }
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(); }
@Override public <O> O getProperty(PropertyKey key) { if (key instanceof ImplicitKey) return ((ImplicitKey)key).computeProperty(this); throw getAccessException(); }