@Override public boolean containsEdgeLabel(String name) { RelationType type = getRelationType(name); return type!=null && type.isEdgeLabel(); }
@Override public EdgeLabel getEdgeLabel(String name) { RelationType el = getRelationType(name); Preconditions.checkArgument(el==null || el.isEdgeLabel(), "The relation type with name [%s] is not an edge label",name); return (EdgeLabel)el; }
@Override public EdgeLabel getOrCreateEdgeLabel(String name) { RelationType et = getRelationType(name); if (et == null) { return config.getAutoSchemaMaker().makeEdgeLabel(makeEdgeLabel(name)); } else if (et.isEdgeLabel()) { return (EdgeLabel) et; } else throw new IllegalArgumentException("The type of given name is not a label: " + name); }
@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(); } });
if (type.isEdgeLabel()) { StandardEdgeLabelMaker lm = (StandardEdgeLabelMaker) transaction.makeEdgeLabel(composedName); lm.unidirected(direction);
tv.property(card, type.name(), value, T.id, relation.relationId); } else { assert type.isEdgeLabel();
TitanRelation findRelation(TitanTransaction tx) { TitanVertex v = ((StandardTitanTx)tx).getInternalVertex(outVertexId); if (v == null || v.isRemoved()) return null; TitanVertex typeVertex = tx.getVertex(typeId); if (typeVertex == null) return null; if (!(typeVertex instanceof RelationType)) throw new IllegalArgumentException("Invalid RelationIdentifier: typeID does not reference a type"); RelationType type = (RelationType) typeVertex; Iterable<? extends TitanRelation> rels; if (((RelationType) typeVertex).isEdgeLabel()) { Direction dir = Direction.OUT; TitanVertex other = ((StandardTitanTx)tx).getInternalVertex(inVertexId); if (other==null || other.isRemoved()) return null; if (((StandardTitanTx) tx).isPartitionedVertex(v) && !((StandardTitanTx) tx).isPartitionedVertex(other)) { //Swap for likely better performance TitanVertex tmp = other; other = v; v = tmp; dir = Direction.IN; } rels = ((VertexCentricQueryBuilder) v.query()).noPartitionRestriction().types((EdgeLabel) type).direction(dir).adjacent(other).edges(); } else { rels = ((VertexCentricQueryBuilder) v.query()).noPartitionRestriction().types((PropertyKey) type).properties(); } for (TitanRelation r : rels) { //Find current or previous relation if (r.longId() == relationId || ((r instanceof StandardRelation) && ((StandardRelation) r).getPreviousID() == relationId)) return r; } return null; }
int startKeyPos = in.getPosition(); int endKeyPos = 0; if (relationType.isEdgeLabel()) { long otherVertexId; if (multiplicity.isConstrained()) {
@Override public EdgeLabel getEdgeLabel(String name) { RelationType el = getRelationType(name); Preconditions.checkArgument(el==null || el.isEdgeLabel(), "The relation type with name [%s] is not an edge label",name); return (EdgeLabel)el; }
@Override public boolean containsEdgeLabel(String name) { RelationType type = getRelationType(name); return type!=null && type.isEdgeLabel(); }
@Override public EdgeLabel getEdgeLabel(String name) { RelationType el = getRelationType(name); Preconditions.checkArgument(el==null || el.isEdgeLabel(), "The relation type with name [%s] is not an edge label",name); return (EdgeLabel)el; }
@Override public boolean containsEdgeLabel(String name) { RelationType type = getRelationType(name); return type!=null && type.isEdgeLabel(); }
private static long[] checkSignature(List<RelationType> sig) { Preconditions.checkArgument(sig.size() == (Sets.newHashSet(sig)).size(), "Signature and sort key cannot contain duplicate types"); long[] signature = new long[sig.size()]; for (int i = 0; i < sig.size(); i++) { RelationType et = sig.get(i); Preconditions.checkNotNull(et); Preconditions.checkArgument(!et.isEdgeLabel() || ((EdgeLabel) et).isUnidirected(), "Label must be unidirectional: %s", et.getName()); Preconditions.checkArgument(!et.isPropertyKey() || !((PropertyKey) et).getDataType().equals(Object.class), "Signature and sort keys must have a proper declared datatype: %s", et.getName()); signature[i] = et.getLongId(); } return signature; }
@Override public <O> O getProperty(RelationType type) { if (type.isEdgeLabel()) return (O)getProperty((EdgeLabel)type); else return getProperty((PropertyKey)type); }
private long[] checkSortKey(List<RelationType> sig) { for (RelationType t : sig) { Preconditions.checkArgument(t.isEdgeLabel() || attributeHandler.isOrderPreservingDatatype(((PropertyKey) t).getDataType()), "Key must have an order-preserving data type to be used as sort key: " + t); } return checkSignature(sig); }
@Override public EdgeLabel getOrCreateEdgeLabel(String name) { RelationType et = getRelationType(name); if (et == null) { return config.getAutoSchemaMaker().makeEdgeLabel(makeEdgeLabel(name)); } else if (et.isEdgeLabel()) { return (EdgeLabel) et; } else throw new IllegalArgumentException("The type of given name is not a label: " + name); }
@Override public EdgeLabel getOrCreateEdgeLabel(String name) { RelationType et = getRelationType(name); if (et == null) { return config.getAutoSchemaMaker().makeEdgeLabel(makeEdgeLabel(name)); } else if (et.isEdgeLabel()) { return (EdgeLabel) et; } else throw new IllegalArgumentException("The type of given name is not a label: " + name); }
private Object readInline(ReadBuffer read, RelationType type, InlineType inlineType) { if (type.isPropertyKey()) { PropertyKey key = ((PropertyKey) type); return readPropertyValue(read,key, inlineType); } else { assert type.isEdgeLabel(); long id; if (inlineType.writeByteOrdered()) id = LongSerializer.INSTANCE.readByteOrder(read); else id = VariableLong.readPositive(read); return id == 0 ? null : id; } }
@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(); } });
private void writeInline(DataOutput out, RelationType type, Object value, InlineType inlineType) { assert !(type.isPropertyKey() && !inlineType.writeEdgeType()) || !AttributeUtil.hasGenericDataType((PropertyKey) type); if (inlineType.writeEdgeType()) { IDHandler.writeInlineEdgeType(out, type.getLongId()); } if (type.isPropertyKey()) { writePropertyValue(out,(PropertyKey)type,value, inlineType); } else { assert type.isEdgeLabel() && ((EdgeLabel) type).isUnidirected(); long id = (value==null?0:((InternalVertex) value).getLongId()); if (inlineType.writeByteOrdered()) LongSerializer.INSTANCE.writeByteOrder(out,id); else VariableLong.writePositive(out,id); } }