/** obsolete every file in the original transaction */
  public void obsoleteOriginals() {
    logger.debug("Staging for obsolescence {}", originals);
    // if we're obsoleting, we should have no staged updates for the original files
    assert Iterables.isEmpty(filterIn(staged.update, originals)) : staged.update;

    // stage obsoletes for any currently visible versions of any original readers
    Iterables.addAll(staged.obsolete, filterIn(current(), originals));
  }
Esempio n. 2
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();
   }
 }
Esempio n. 3
0
 public TitanProperty addPropertyInternal(TitanVertex vertex, TitanKey key, Object value) {
   verifyWriteAccess(vertex);
   vertex = ((InternalVertex) vertex).it();
   Preconditions.checkNotNull(key);
   value = AttributeUtil.verifyAttribute(key, value);
   Lock uniqueLock = FakeLock.INSTANCE;
   if (config.hasVerifyUniqueness() && (key.isUnique(Direction.OUT) || key.isUnique(Direction.IN)))
     uniqueLock = getUniquenessLock(vertex, key, value);
   uniqueLock.lock();
   try {
     // Check uniqueness
     if (config.hasVerifyUniqueness()) {
       if (key.isUnique(Direction.OUT)) {
         Preconditions.checkArgument(
             Iterables.isEmpty(
                 query(vertex).includeHidden().type(key).direction(Direction.OUT).properties()),
             "An property with the given key already exists on the vertex and the property key is defined as out-unique");
       }
       if (key.isUnique(Direction.IN)) {
         Preconditions.checkArgument(
             Iterables.isEmpty(getVertices(key, value)),
             "The given value is already used as a property and the property key is defined as in-unique");
       }
     }
     StandardProperty prop =
         new StandardProperty(
             temporaryID.decrementAndGet(),
             key,
             (InternalVertex) vertex,
             value,
             ElementLifeCycle.New);
     if (config.hasAssignIDsImmediately()) graph.assignID(prop);
     connectRelation(prop);
     return prop;
   } finally {
     uniqueLock.unlock();
   }
 }
Esempio n. 4
0
 @Override
 public boolean containsType(String name) {
   verifyOpen();
   return (typeCache.containsKey(name)
       || !Iterables.isEmpty(getVertices(SystemKey.TypeName, name)));
 }