Exemplo n.º 1
0
 /**
  * Use the new root page from now on.
  *
  * @param newRoot the new root page
  */
 protected void newRoot(Page newRoot) {
   if (root != newRoot) {
     removeUnusedOldVersions();
     if (root.getVersion() != newRoot.getVersion()) {
       ArrayList<Page> list = oldRoots;
       if (list.size() > 0) {
         Page last = list.get(list.size() - 1);
         if (last.getVersion() != root.getVersion()) {
           list.add(root);
         }
       } else {
         list.add(root);
       }
       store.markChanged(this);
     }
     root = newRoot;
   }
 }
Exemplo n.º 2
0
 /**
  * Rollback to the given version.
  *
  * @param version the version
  */
 void rollbackTo(long version) {
   beforeWrite();
   try {
     removeUnusedOldVersions();
     if (version <= createVersion) {
       // the map is removed later
     } else if (root.getVersion() >= version) {
       // iterating in descending order -
       // this is not terribly efficient if there are many versions
       ArrayList<Page> list = oldRoots;
       while (list.size() > 0) {
         int i = list.size() - 1;
         Page p = list.get(i);
         root = p;
         list.remove(i);
         if (p.getVersion() < version) {
           break;
         }
       }
     }
   } finally {
     afterWrite();
   }
 }