jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tri...@apache.org
Subject svn commit: r111706 - in incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core: state version virtual
Date Mon, 13 Dec 2004 11:58:25 GMT
Author: tripod
Date: Mon Dec 13 03:58:24 2004
New Revision: 111706

URL: http://svn.apache.org/viewcvs?view=rev&rev=111706
Log:
- VersionItemStateProvider speedup
Modified:
   incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/state/SessionItemStateManager.java
   incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/PersistentVersionManager.java
   incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/VersionItemStateProvider.java
   incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/virtual/VirtualItemStateProvider.java

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/state/SessionItemStateManager.java
Url: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/state/SessionItemStateManager.java?view=diff&rev=111706&p1=incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/state/SessionItemStateManager.java&r1=111705&p2=incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/state/SessionItemStateManager.java&r2=111706
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/state/SessionItemStateManager.java
(original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/state/SessionItemStateManager.java
Mon Dec 13 03:58:24 2004
@@ -229,9 +229,9 @@
             return transientStateMgr.getItemState(id);
         }
 
-        // check if there is a virtual state for the specified item
+        // check the virtual root ids (needed for overlay)
         for (int i = 0; i < virtualProviders.length; i++) {
-            if (virtualProviders[i].hasItemState(id)) {
+            if (virtualProviders[i].isVirtualRoot(id)) {
                 return virtualProviders[i].getItemState(id);
             }
         }
@@ -241,6 +241,13 @@
             return persistentStateMgr.getItemState(id);
         }
 
+        // check if there is a virtual state for the specified item
+        for (int i = 0; i < virtualProviders.length; i++) {
+            if (virtualProviders[i].hasItemState(id)) {
+                return virtualProviders[i].getItemState(id);
+            }
+        }
+
         throw new NoSuchItemStateException(id.toString());
     }
 
@@ -263,34 +270,25 @@
 	    return true;
 	}
 
-	// check if there is a virtual state for the specified item
-	for (int i = 0; i < virtualProviders.length; i++) {
-	    if (virtualProviders[i].hasItemState(id)) {
-		return true;
-	    }
-	}
-
+        // check the virtual root ids (needed for overlay)
+        for (int i = 0; i < virtualProviders.length; i++) {
+            if (virtualProviders[i].isVirtualRoot(id)) {
+                return true;
+            }
+        }
 	// check if there's persistent state for the specified item
 	if (persistentStateMgr.hasItemState(id)) {
 	    return true;
 	}
 
-	return false;
-    }
-
-    /**
-     * Checks if there is a virtual item state
-     *
-     * @param id
-     * @return
-     */
-    private boolean hasVirtualItemState(ItemId id) {
+        // check if there is a virtual state for the specified item
         for (int i = 0; i < virtualProviders.length; i++) {
             if (virtualProviders[i].hasItemState(id)) {
                 return true;
             }
         }
-        return false;
+
+	return false;
     }
 
     /**

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/PersistentVersionManager.java
Url: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/PersistentVersionManager.java?view=diff&rev=111706&p1=incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/PersistentVersionManager.java&r1=111705&p2=incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/PersistentVersionManager.java&r2=111706
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/PersistentVersionManager.java
(original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/PersistentVersionManager.java
Mon Dec 13 03:58:24 2004
@@ -105,7 +105,7 @@
     /**
      * the version histories. key=uuid, value=version history
      */
-    private Map histories = new ReferenceMap(ReferenceMap.HARD, ReferenceMap.WEAK);
+    private Map histories = new ReferenceMap(ReferenceMap.HARD, ReferenceMap.SOFT);
 
     /**
      * Creates a new PersistentVersionManager.

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/VersionItemStateProvider.java
Url: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/VersionItemStateProvider.java?view=diff&rev=111706&p1=incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/VersionItemStateProvider.java&r1=111705&p2=incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/VersionItemStateProvider.java&r2=111706
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/VersionItemStateProvider.java
(original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/VersionItemStateProvider.java
Mon Dec 13 03:58:24 2004
@@ -25,8 +25,10 @@
 import org.apache.jackrabbit.core.virtual.VirtualItemStateProvider;
 import org.apache.jackrabbit.core.virtual.VirtualNodeState;
 import org.apache.log4j.Logger;
+import org.apache.commons.collections.ReferenceMap;
 
 import javax.jcr.RepositoryException;
+import java.util.Map;
 
 /**
  * This Class implements...
@@ -42,6 +44,12 @@
 
     private final VersionManager vMgr;
 
+    /**
+     * the version histories. key=ItemId, value=ItemState
+     */
+    private Map items = new ReferenceMap(ReferenceMap.HARD, ReferenceMap.SOFT);
+
+
     public VersionItemStateProvider(VersionManager vMgr, String rootId, String parentId)
{
         this.vMgr = vMgr;
         this.root = new HistoryRootNodeState(this, rootId, parentId);
@@ -51,19 +59,35 @@
         return vMgr;
     }
 
+    public boolean isVirtualRoot(ItemId id) {
+        return id.equals(root.getId());
+    }
+
+    public NodeId getVirtualRootId() {
+        return (NodeId) root.getId();
+    }
+
     public ItemState getItemState(ItemId id)
             throws NoSuchItemStateException, ItemStateException {
-        if (id instanceof NodeId) {
-            return getNodeState((NodeId) id);
-        } else {
-            return getPropertyState((PropertyId) id);
+
+        ItemState state = (ItemState) items.get(id);
+        if (state==null) {
+            if (id instanceof NodeId) {
+                state = getNodeState((NodeId) id);
+            } else {
+                state = getPropertyState((PropertyId) id);
+            }
+            // add state to cache
+            items.put(id, state);
         }
+        return state;
     }
 
     public boolean hasNodeState(NodeId id) {
         if (id.equals(root.getId())) {
             return true;
         }
+
         // check version history
         if (vMgr.hasVersionHistory(id.getUUID())) {
             return true;
@@ -140,7 +164,11 @@
     }
 
     public boolean hasItemState(ItemId id) {
-        if (id instanceof NodeId) {
+
+        // check cache
+        if (items.containsKey(id)) {
+            return true;
+        } else if (id instanceof NodeId) {
             return hasNodeState((NodeId) id);
         } else {
             return hasPropertyState((PropertyId) id);

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/virtual/VirtualItemStateProvider.java
Url: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/virtual/VirtualItemStateProvider.java?view=diff&rev=111706&p1=incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/virtual/VirtualItemStateProvider.java&r1=111705&p2=incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/virtual/VirtualItemStateProvider.java&r2=111706
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/virtual/VirtualItemStateProvider.java
(original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/virtual/VirtualItemStateProvider.java
Mon Dec 13 03:58:24 2004
@@ -19,6 +19,8 @@
 import org.apache.jackrabbit.core.nodetype.NodeDefId;
 import org.apache.jackrabbit.core.nodetype.PropDefId;
 import org.apache.jackrabbit.core.state.ItemStateProvider;
+import org.apache.jackrabbit.core.NodeId;
+import org.apache.jackrabbit.core.ItemId;
 
 /**
  * This Interface defines a virtual item state provider.
@@ -39,4 +41,8 @@
      * @return
      */
     public PropDefId getPropDefId(QName propname);
+
+    public boolean isVirtualRoot(ItemId id);
+
+    public NodeId getVirtualRootId();
 }

Mime
View raw message