Exemple #1
0
 /**
  * Rename the map.
  *
  * @param newMapName the name name
  */
 public void renameMap(String newMapName) {
   beforeWrite();
   try {
     store.renameMap(this, newMapName);
   } finally {
     afterWrite();
   }
 }
Exemple #2
0
 /** Remove all entries. */
 public void clear() {
   beforeWrite();
   try {
     root.removeAllRecursive();
     newRoot(Page.createEmpty(this, store.getCurrentVersion()));
   } finally {
     afterWrite();
   }
 }
Exemple #3
0
 /**
  * Remove a key-value pair, if the key exists.
  *
  * @param key the key (may not be null)
  * @return the old value if the key existed, or null otherwise
  */
 public V remove(Object key) {
   beforeWrite();
   try {
     long writeVersion = store.getCurrentVersion();
     Page p = copyOnWrite(root, writeVersion);
     @SuppressWarnings("unchecked")
     V result = (V) remove(p, writeVersion, key);
     newRoot(p);
     return result;
   } finally {
     afterWrite();
   }
 }
Exemple #4
0
 /** Remove all entries, and close the map. */
 public void removeMap() {
   checkOpen();
   if (this == store.getMetaMap()) {
     return;
   }
   beforeWrite();
   try {
     root.removeAllRecursive();
     store.removeMap(id);
     close();
   } finally {
     afterWrite();
   }
 }
Exemple #5
0
 /**
  * Add or replace a key-value pair.
  *
  * @param key the key (may not be null)
  * @param value the value (may not be null)
  * @return the old value if the key existed, or null otherwise
  */
 @SuppressWarnings("unchecked")
 public V put(K key, V value) {
   DataUtils.checkArgument(value != null, "The value may not be null");
   beforeWrite();
   try {
     long writeVersion = store.getCurrentVersion();
     Page p = copyOnWrite(root, writeVersion);
     p = splitRootIfNeeded(p, writeVersion);
     Object result = put(p, writeVersion, key, value);
     newRoot(p);
     return (V) result;
   } finally {
     afterWrite();
   }
 }
Exemple #6
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();
   }
 }