@Override public AtlasCardinality getCardinality() { return GraphDbObjectFactory.createCardinality(wrappedPropertyKey.getCardinality()); }
@Override public TitanProperty addProperty(TitanVertex vertex, PropertyKey key, Object value) { if (key.getCardinality()== Cardinality.SINGLE) return setProperty(vertex, key, value); else return addPropertyInternal(vertex, key, value, true); }
@Override public GraphCentricQueryBuilder orderBy(PropertyKey key, Order order) { Preconditions.checkArgument(key!=null && order!=null,"Need to specify and key and an order"); Preconditions.checkArgument(Comparable.class.isAssignableFrom(key.getDataType()), "Can only order on keys with comparable data type. [%s] has datatype [%s]", key.getName(), key.getDataType()); Preconditions.checkArgument(key.getCardinality()== Cardinality.SINGLE, "Ordering is undefined on multi-valued key [%s]", key.getName()); Preconditions.checkArgument(!orders.containsKey(key)); orders.add(key, order); return this; }
@Override public GraphCentricQueryBuilder orderBy(PropertyKey key, Order order) { Preconditions.checkArgument(key!=null && order!=null, "Need to specify and key and an order"); Preconditions.checkArgument(Comparable.class.isAssignableFrom(key.getDataType()), "Can only order on keys with comparable data type. [%s] has datatype [%s]", key.getName(), key.getDataType()); Preconditions.checkArgument(key.getCardinality()== Cardinality.SINGLE, "Ordering is undefined on multi-valued key [%s]", key.getName()); Preconditions.checkArgument(!orders.containsKey(key)); orders.add(key, order); return this; }
@Override public Q orderBy(PropertyKey key, Order order) { Preconditions.checkArgument(key!=null && order!=null,"Need to specify and key and an order"); Preconditions.checkArgument(Comparable.class.isAssignableFrom(key.getDataType()), "Can only order on keys with comparable data type. [%s] has datatype [%s]", key.getName(), key.getDataType()); Preconditions.checkArgument(key.getCardinality()== Cardinality.SINGLE, "Ordering is undefined on multi-valued key [%s]", key.getName()); Preconditions.checkArgument(!(key instanceof SystemRelationType),"Cannot use system types in ordering: %s",key); Preconditions.checkArgument(!orders.containsKey(key)); Preconditions.checkArgument(orders.isEmpty(),"Only a single sort order is supported on vertex queries"); orders.add(key, order); return getThis(); }
@Override public GraphCentricQueryBuilder orderBy(PropertyKey key, Order order) { Preconditions.checkArgument(key!=null && order!=null,"Need to specify and key and an order"); Preconditions.checkArgument(Comparable.class.isAssignableFrom(key.getDataType()), "Can only order on keys with comparable data type. [%s] has datatype [%s]", key.getName(), key.getDataType()); Preconditions.checkArgument(key.getCardinality()== Cardinality.SINGLE, "Ordering is undefined on multi-valued key [%s]", key.getName()); Preconditions.checkArgument(!orders.containsKey(key)); orders.add(key, order); return this; }
public PropertyKeyDefinition(PropertyKey key) { this(key.getName(),key.getLongId(),key.getCardinality(),key.getDataType()); }
@Override public <O> O getProperty(PropertyKey key) { if (!((InternalRelationType)key).isHiddenType() && tx().getConfiguration().hasPropertyPrefetching()) { getProperties().iterator().hasNext(); } Iterator<TitanProperty> iter = query().type(key).properties().iterator(); if (key.getCardinality()== Cardinality.SINGLE) { if (iter.hasNext()) return (O)iter.next().getValue(); else return null; } else { List<Object> result = new ArrayList<Object>(); while (iter.hasNext()) { result.add(iter.next().getValue()); } return (O)result; } }
public Titan0Graph() { //determine multi-properties once at startup TitanManagement mgmt = null; try { mgmt = Titan0GraphDatabase.getGraphInstance().getManagementSystem(); Iterable<PropertyKey> keys = mgmt.getRelationTypes(PropertyKey.class); multiProperties = Collections.synchronizedSet(new HashSet<String>()); for(PropertyKey key : keys) { if (key.getCardinality() != Cardinality.SINGLE) { multiProperties.add(key.getName()); } } } finally { if (mgmt != null) { mgmt.rollback(); } } }
Preconditions.checkArgument(indexType instanceof IndexTypeWrapper && key instanceof TitanSchemaVertex && ((IndexTypeWrapper)indexType).getSchemaBase() instanceof TitanSchemaVertex); Preconditions.checkArgument(key.getCardinality()==Cardinality.SINGLE || indexType.getElement()!=ElementCategory.VERTEX, "Can only index single-valued property keys on vertices [%s]",key); TitanSchemaVertex indexVertex = (TitanSchemaVertex)((IndexTypeWrapper)indexType).getSchemaBase();
public TitanProperty setProperty(TitanVertex vertex, final PropertyKey key, Object value) { verifyWriteAccess(vertex); Preconditions.checkNotNull(key); if (key.getCardinality()!=Cardinality.SINGLE) throw new UnsupportedOperationException("Not a single key: "+key+". Use addProperty instead"); TransactionLock uniqueLock = FakeLock.INSTANCE; try { if (config.hasVerifyUniqueness()) { //Acquire uniqueness lock, remove and add uniqueLock = getLock(vertex, key, Direction.OUT); } uniqueLock.lock(LOCK_TIMEOUT); if (config.hasVerifyUniqueness() && ((InternalRelationType)key).getConsistencyModifier()==ConsistencyModifier.LOCK) { vertex.removeProperty(key); } else { //Only delete in-memory InternalVertex v = (InternalVertex) vertex; for (InternalRelation r : v.it().getAddedRelations(new Predicate<InternalRelation>() { @Override public boolean apply(@Nullable InternalRelation p) { return p.getType().equals(key); } })) { r.remove(); } } return addPropertyInternal(vertex, key, value, false); } finally { uniqueLock.unlock(); } }
for (PropertyKey key : keys) { Preconditions.checkArgument(key!=null && key instanceof PropertyKeyVertex,"Need to provide valid keys: %s",key); if (key.getCardinality()!=Cardinality.SINGLE) allSingleKeys=false; if (key.isNew()) oneNewKey = true; else updatedTypes.add((PropertyKeyVertex)key);
Preconditions.checkNotNull(key); final Object normalizedValue = verifyAttribute(key, value); Cardinality cardinality = key.getCardinality();
assertEquals("name", name.getName()); id = tx.getPropertyKey("uid"); assertTrue(id.getCardinality()==Cardinality.SINGLE); for (int i = 0; i < noNodes; i++) { TitanVertex n = getVertex(id, ids[i]);
assertEquals("uid",uid.getName()); assertEquals(Cardinality.SINGLE,name.getCardinality()); assertEquals(Multiplicity.MULTI,knows.getMultiplicity()); assertFalse(person.isPartitioned());
assertTrue(weight.isPropertyKey()); assertFalse(weight.isEdgeLabel()); assertEquals(Cardinality.SINGLE,weight.getCardinality()); assertEquals(Cardinality.SINGLE,someid.getCardinality()); assertEquals(Cardinality.SET,name.getCardinality()); assertEquals(Cardinality.LIST,value.getCardinality()); assertEquals(Object.class,someid.getDataType()); assertEquals(Decimal.class,weight.getDataType()); assertTrue(weight.isPropertyKey()); assertFalse(weight.isEdgeLabel()); assertEquals(Cardinality.SINGLE,weight.getCardinality()); assertEquals(Cardinality.SINGLE,someid.getCardinality()); assertEquals(Cardinality.SET,name.getCardinality()); assertEquals(Cardinality.LIST,value.getCardinality()); assertEquals(Object.class,someid.getDataType()); assertEquals(Decimal.class,weight.getDataType());
} else { assert (relation.isProperty() && ((TitanProperty)relation).getPropertyKey().getCardinality()!=Cardinality.SINGLE) || (relation.isEdge() && idManager.isPartitionedVertex(relation.getVertex(0).getLongId()) && idManager.isPartitionedVertex(relation.getVertex(1).getLongId())); newPartition = idManager.getPartitionHashForId(relation.getLongId());