jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tri...@apache.org
Subject svn commit: r164770 - in /incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core: CachingHierarchyManager.java HierarchyManagerImpl.java ItemImpl.java ItemManager.java NodeImpl.java state/ItemStateCache.java
Date Tue, 26 Apr 2005 10:04:33 GMT
Author: tripod
Date: Tue Apr 26 03:04:31 2005
New Revision: 164770

URL: http://svn.apache.org/viewcvs?rev=164770&view=rev
Log:
- minor performance improvements 

Modified:
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/CachingHierarchyManager.java
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/HierarchyManagerImpl.java
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/ItemImpl.java
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/ItemManager.java
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/NodeImpl.java
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/state/ItemStateCache.java

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/CachingHierarchyManager.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/CachingHierarchyManager.java?rev=164770&r1=164769&r2=164770&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/CachingHierarchyManager.java
(original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/CachingHierarchyManager.java
Tue Apr 26 03:04:31 2005
@@ -148,19 +148,8 @@
      */
     public boolean isAncestor(NodeId nodeId, ItemId itemId)
             throws ItemNotFoundException, RepositoryException {
-        if (pathCache.containsKey(nodeId) && pathCache.containsKey(itemId)) {
-            // use cached Path objects rather than calling delegatee
-            try {
-                return getPath(nodeId).isAncestorOf(getPath(itemId));
-            } catch (MalformedPathException mpe) {
-                // should never get here...
-                String msg = "failed to determine degree of relationship of "
-                        + nodeId + " and " + itemId;
-                throw new ItemNotFoundException(msg, mpe);
-            }
-        } else {
-            return delegatee.isAncestor(nodeId, itemId);
-        }
+        // do not used cached paths. calculating paths is more expesive
+        return delegatee.isAncestor(nodeId, itemId);
     }
 
     /**

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/HierarchyManagerImpl.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/HierarchyManagerImpl.java?rev=164770&r1=164769&r2=164770&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/HierarchyManagerImpl.java
(original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/HierarchyManagerImpl.java
Tue Apr 26 03:04:31 2005
@@ -389,10 +389,10 @@
             throws ItemNotFoundException, RepositoryException {
         try {
             int depth = 0;
-            ItemState state = getItemState(id);
+            ItemState state = getItemState(id, true);
             String parentUUID = state.getParentUUID();
             while (parentUUID != null) {
-                state = (NodeState) getItemState(new NodeId(parentUUID));
+                state = getItemState(new NodeId(parentUUID), true);
                 parentUUID = state.getParentUUID();
                 depth++;
             }
@@ -517,18 +517,12 @@
      */
     private ItemState getItemState(ItemId id, boolean includeZombies)
             throws NoSuchItemStateException, ItemStateException {
-        if (!includeZombies || attic == null) {
-            // get transient/persistent state
-            return provider.getItemState(id);
-        }
-
-        try {
+        if (includeZombies && attic != null && attic.hasItemState(id)) {
             // try attic first
             return attic.getItemState(id);
-        } catch (NoSuchItemStateException e) {
-            // fallback: get transient/persistent state
-            return provider.getItemState(id);
         }
+        // fallback: get transient/persistent state
+        return provider.getItemState(id);
     }
 
     /**

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/ItemImpl.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/ItemImpl.java?rev=164770&r1=164769&r2=164770&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/ItemImpl.java (original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/ItemImpl.java Tue Apr 26
03:04:31 2005
@@ -365,7 +365,7 @@
 
         if (isNode()) {
             // build list of 'new' or 'modified' descendents
-            Iterator iter = stateMgr.getDescendantTransientItemStates(id);
+            Iterator iter = stateMgr.getDescendantTransientItemStates((NodeId) id);
             while (iter.hasNext()) {
                 transientState = (ItemState) iter.next();
                 switch (transientState.getStatus()) {
@@ -416,7 +416,7 @@
         ItemState transientState;
 
         if (isNode()) {
-            Iterator iter = stateMgr.getDescendantTransientItemStatesInAttic(id);
+            Iterator iter = stateMgr.getDescendantTransientItemStatesInAttic((NodeId) id);
             while (iter.hasNext()) {
                 transientState = (ItemState) iter.next();
                 // check if stale
@@ -1375,7 +1375,7 @@
 
         if (isNode()) {
             // build list of 'new', 'modified' or 'stale' descendents
-            Iterator iter = stateMgr.getDescendantTransientItemStates(id);
+            Iterator iter = stateMgr.getDescendantTransientItemStates((NodeId) id);
             while (iter.hasNext()) {
                 transientState = (ItemState) iter.next();
                 switch (transientState.getStatus()) {
@@ -1405,14 +1405,16 @@
             stateMgr.disposeTransientItemState(transientState);
         }
 
-        // discard all transient descendents in the attic (i.e. those marked
-        // as 'removed'); this will resurrect the removed items
-        iter = stateMgr.getDescendantTransientItemStatesInAttic(id);
-        while (iter.hasNext()) {
-            transientState = (ItemState) iter.next();
-            // dispose the transient state; this will indirectly (through
-            // stateDiscarded listener method) resurrect the wrapping Item instances
-            stateMgr.disposeTransientItemStateInAttic(transientState);
+        if (isNode()) {
+            // discard all transient descendents in the attic (i.e. those marked
+            // as 'removed'); this will resurrect the removed items
+            iter = stateMgr.getDescendantTransientItemStatesInAttic((NodeId) id);
+            while (iter.hasNext()) {
+                transientState = (ItemState) iter.next();
+                // dispose the transient state; this will indirectly (through
+                // stateDiscarded listener method) resurrect the wrapping Item instances
+                stateMgr.disposeTransientItemStateInAttic(transientState);
+            }
         }
     }
 

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/ItemManager.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/ItemManager.java?rev=164770&r1=164769&r2=164770&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/ItemManager.java (original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/ItemManager.java Tue Apr
26 03:04:31 2005
@@ -613,7 +613,9 @@
         if (itemCache.containsKey(id)) {
             log.warn("overwriting cached item " + id);
         }
-        log.debug("caching item " + id);
+        if (log.isDebugEnabled()) {
+            log.debug("caching item " + id);
+        }
         itemCache.put(id, item);
     }
 
@@ -623,7 +625,9 @@
      * @param id id of the item to remove from the cache
      */
     private void evictItem(ItemId id) {
-        log.debug("removing item " + id + " from cache");
+        if (log.isDebugEnabled()) {
+            log.debug("removing item " + id + " from cache");
+        }
         itemCache.remove(id);
     }
 
@@ -667,7 +671,9 @@
      * {@inheritDoc}
      */
     public void itemCreated(ItemImpl item) {
-        log.debug("created item " + item.getId());
+        if (log.isDebugEnabled()) {
+            log.debug("created item " + item.getId());
+        }
         // add instance to cache
         cacheItem(item);
     }
@@ -676,7 +682,9 @@
      * {@inheritDoc}
      */
     public void itemInvalidated(ItemId id, ItemImpl item) {
-        log.debug("invalidated item " + id);
+        if (log.isDebugEnabled()) {
+            log.debug("invalidated item " + id);
+        }
         // remove instance from cache
         evictItem(id);
     }
@@ -685,7 +693,9 @@
      * {@inheritDoc}
      */
     public void itemDestroyed(ItemId id, ItemImpl item) {
-        log.debug("destroyed item " + id);
+        if (log.isDebugEnabled()) {
+            log.debug("destroyed item " + id);
+        }
         // we're no longer interested in this item
         item.removeLifeCycleListener(this);
         // remove instance from cache

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/NodeImpl.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/NodeImpl.java?rev=164770&r1=164769&r2=164770&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/NodeImpl.java (original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/NodeImpl.java Tue Apr 26
03:04:31 2005
@@ -255,7 +255,7 @@
         if (isTransient()) {
             return true;
         }
-        Iterator iter = stateMgr.getDescendantTransientItemStates(id);
+        Iterator iter = stateMgr.getDescendantTransientItemStates((NodeId) id);
         return iter.hasNext();
     }
 

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/state/ItemStateCache.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/state/ItemStateCache.java?rev=164770&r1=164769&r2=164770&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/state/ItemStateCache.java
(original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/state/ItemStateCache.java
Tue Apr 26 03:04:31 2005
@@ -102,7 +102,9 @@
         if (cache.containsKey(id)) {
             log.warn("overwriting cached entry " + id);
         }
-        log.debug("caching " + id);
+        if (log.isDebugEnabled()) {
+            log.debug("caching " + id);
+        }
         cache.put(id, state);
     }
 
@@ -113,7 +115,9 @@
      *           reference should be removed from the cache.
      */
     protected void evict(ItemId id) {
-        log.debug("removing entry " + id + " from cache");
+        if (log.isDebugEnabled()) {
+            log.debug("removing entry " + id + " from cache");
+        }
         cache.remove(id);
     }
 
@@ -121,7 +125,9 @@
      * Clears all entries from the cache.
      */
     protected void evictAll() {
-        log.debug("removing all entries from cache");
+        if (log.isDebugEnabled()) {
+            log.debug("removing all entries from cache");
+        }
         cache.clear();
     }
 



Mime
View raw message