Example #1
0
 @Override
 public TitanEdge addEdge(TitanVertex outVertex, TitanVertex inVertex, TitanLabel label) {
   verifyWriteAccess(outVertex, inVertex);
   outVertex = ((InternalVertex) outVertex).it();
   inVertex = ((InternalVertex) inVertex).it();
   Preconditions.checkNotNull(label);
   Lock uniqueLock = FakeLock.INSTANCE;
   if (config.hasVerifyUniqueness()
       && (label.isUnique(Direction.OUT) || label.isUnique(Direction.IN)))
     uniqueLock = getUniquenessLock(outVertex, label, inVertex);
   uniqueLock.lock();
   try {
     // Check uniqueness
     if (config.hasVerifyUniqueness()) {
       if (label.isUnique(Direction.OUT)) {
         Preconditions.checkArgument(
             Iterables.isEmpty(
                 query(outVertex)
                     .includeHidden()
                     .type(label)
                     .direction(Direction.OUT)
                     .titanEdges()),
             "An edge with the given type already exists on the out-vertex");
       }
       if (label.isUnique(Direction.IN)) {
         Preconditions.checkArgument(
             Iterables.isEmpty(
                 query(inVertex).includeHidden().type(label).direction(Direction.IN).titanEdges()),
             "An edge with the given type already exists on the in-vertex");
       }
     }
     StandardEdge edge =
         new StandardEdge(
             temporaryID.decrementAndGet(),
             label,
             (InternalVertex) outVertex,
             (InternalVertex) inVertex,
             ElementLifeCycle.New);
     if (config.hasAssignIDsImmediately()) graph.assignID(edge);
     connectRelation(edge);
     return edge;
   } finally {
     uniqueLock.unlock();
   }
 }
Example #2
0
 public InlineTitanEdge(TitanLabel type, InternalTitanVertex start, InternalTitanVertex end) {
   super(type, start, end);
   Preconditions.checkArgument(type.isUnidirected(), "Inline Relationships must be unidirected!");
 }