jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r1538047 - in /jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak: core/SecureNodeBuilder.java kernel/KernelNodeBuilder.java plugins/memory/MemoryNodeBuilder.java
Date Fri, 01 Nov 2013 20:09:40 GMT
Author: jukka
Date: Fri Nov  1 20:09:40 2013
New Revision: 1538047

URL: http://svn.apache.org/r1538047
Log:
OAK-1142: Optimize node builders for the common case where there are no transient changes

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/SecureNodeBuilder.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeBuilder.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MemoryNodeBuilder.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/SecureNodeBuilder.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/SecureNodeBuilder.java?rev=1538047&r1=1538046&r2=1538047&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/SecureNodeBuilder.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/SecureNodeBuilder.java
Fri Nov  1 20:09:40 2013
@@ -131,7 +131,7 @@ class SecureNodeBuilder implements NodeB
 
     @Override
     public boolean exists() {
-        return builder.exists() && getSecurityContext().canReadThisNode(); // TODO:
isNew()?
+        return getSecurityContext().canReadThisNode() && builder.exists(); // TODO:
isNew()?
     }
 
     @Override

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeBuilder.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeBuilder.java?rev=1538047&r1=1538046&r2=1538047&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeBuilder.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeBuilder.java
Fri Nov  1 20:09:40 2013
@@ -32,6 +32,10 @@ public class KernelNodeBuilder extends M
 
     private final KernelRootBuilder root;
 
+    private NodeState base = null;
+
+    protected NodeState rootBase = null;
+
     KernelNodeBuilder(MemoryNodeBuilder parent, String name, KernelRootBuilder root) {
         super(parent, name);
         this.root = checkNotNull(root);
@@ -44,10 +48,13 @@ public class KernelNodeBuilder extends M
         return new KernelNodeBuilder(this, name, root);
     }
 
-    // TODO optimise this by caching similar to what we do in MemoryNodeBuilder
     @Override
     public NodeState getBaseState() {
-        return getParent().getBaseState().getChildNode(getName());
+        if (base == null || rootBase != root.getBaseState()) {
+            base = getParent().getBaseState().getChildNode(getName());
+            rootBase = root.getBaseState();
+        }
+        return base;
     }
 
     @Override

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MemoryNodeBuilder.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MemoryNodeBuilder.java?rev=1538047&r1=1538046&r2=1538047&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MemoryNodeBuilder.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MemoryNodeBuilder.java
Fri Nov  1 20:09:40 2013
@@ -124,6 +124,8 @@ public class MemoryNodeBuilder implement
         this.parent = parent;
         this.name = name;
         this.rootBuilder = parent.rootBuilder;
+        this.baseRevision = parent.baseRevision;
+        this.base = parent.base.getChildNode(name);
         this.head = new UnconnectedHead();
     }
 
@@ -137,8 +139,7 @@ public class MemoryNodeBuilder implement
         this.name = null;
         this.rootBuilder = this;
 
-        // ensure child builder's base is updated on first access
-        this.baseRevision = 1;
+        this.baseRevision = 0;
         this.base = checkNotNull(base);
 
         this.head = new RootHead();
@@ -524,8 +525,8 @@ public class MemoryNodeBuilder implement
     }
 
     private class UnconnectedHead extends Head {
-        private long revision;
-        private NodeState state;
+        private long revision = 0;
+        private NodeState state = base;
 
         @Override
         public Head update() {
@@ -628,8 +629,6 @@ public class MemoryNodeBuilder implement
     private class RootHead extends ConnectedHead {
         public RootHead() {
             super(new MutableNodeState(base));
-            // ensure updating of child builders on first access
-            revision = 1;
         }
 
         @Override



Mime
View raw message