protected void cleanSnapshots() throws InterruptedException {
  HashSet<MemValue> processedSubjects=new HashSet<MemValue>();
  HashSet<MemValue> processedPredicates=new HashSet<MemValue>();
  HashSet<MemValue> processedObjects=new HashSet<MemValue>();
  HashSet<MemValue> processedContexts=new HashSet<MemValue>();
  int lastStmtPos;
  Lock stReadLock=statementListLockManager.getReadLock();
  try {
    lastStmtPos=statements.size() - 1;
  }
  finally {
    stReadLock.release();
  }
  int nextSnapshot=currentSnapshot;
  for (int i=lastStmtPos; i >= 0; i--) {
    Lock stWriteLock=statementListLockManager.getWriteLock();
    try {
      lastStmtPos=statements.size() - 1;
      i=Math.min(i,lastStmtPos);
      if (i >= 0) {
        MemStatement st=statements.get(i);
        if (st.getTillSnapshot() <= nextSnapshot) {
          MemResource subj=st.getSubject();
          if (processedSubjects.add(subj)) {
            subj.cleanSnapshotsFromSubjectStatements(nextSnapshot);
          }
          MemIRI pred=st.getPredicate();
          if (processedPredicates.add(pred)) {
            pred.cleanSnapshotsFromPredicateStatements(nextSnapshot);
          }
          MemValue obj=st.getObject();
          if (processedObjects.add(obj)) {
            obj.cleanSnapshotsFromObjectStatements(nextSnapshot);
          }
          MemResource context=st.getContext();
          if (context != null && processedContexts.add(context)) {
            context.cleanSnapshotsFromContextStatements(nextSnapshot);
          }
          statements.remove(i);
        }
      }
    }
  finally {
      stWriteLock.release();
    }
  }
}

protected void cleanSnapshots ( ) throws InterruptedException { HashSet < MemValue > processedSubjects = new HashSet < MemValue > ( ) ; HashSet < MemValue > processedPredicates = new HashSet < MemValue > ( ) ; HashSet < MemValue > processedObjects = new HashSet < MemValue > ( ) ; HashSet < MemValue > processedContexts = new HashSet < MemValue > ( ) ; int lastStmtPos ; Lock stReadLock = statementListLockManager . getReadLock ( ) ; try { lastStmtPos = statements . size ( ) - 1 ; } finally { stReadLock . release ( ) ; } int nextSnapshot = currentSnapshot ; for ( int i = lastStmtPos ; i >= 0 ; i -- ) { Lock stWriteLock = statementListLockManager . getWriteLock ( ) ; try { lastStmtPos = statements . size ( ) - 1 ; i = Math . min ( i , lastStmtPos ) ; if ( i >= 0 ) { MemStatement st = statements . get ( i ) ; if ( st . getTillSnapshot ( ) <= nextSnapshot ) { MemResource subj = st . getSubject ( ) ; if ( processedSubjects . add ( subj ) ) { subj . cleanSnapshotsFromSubjectStatements ( nextSnapshot ) ; } MemIRI pred = st . getPredicate ( ) ; if ( processedPredicates . add ( pred ) ) { pred . cleanSnapshotsFromPredicateStatements ( nextSnapshot ) ; } MemValue obj = st . getObject ( ) ; if ( processedObjects . add ( obj ) ) { obj . cleanSnapshotsFromObjectStatements ( nextSnapshot ) ; } MemResource context = st . getContext ( ) ; if ( context != null && processedContexts . add ( context ) ) { context . cleanSnapshotsFromContextStatements ( nextSnapshot ) ; } statements . remove ( i ) ; } } } finally { stWriteLock . release ( ) ; } } }
removes statements from old snapshots from the main statement list and resets the snapshot to 1 for the rest of the statements .
