jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r1514206 - in /jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins: memory/MemoryNodeBuilder.java segment/SegmentNodeBuilder.java segment/SegmentNodeState.java segment/SegmentRootBuilder.java
Date Thu, 15 Aug 2013 08:52:24 GMT
Author: jukka
Date: Thu Aug 15 08:52:23 2013
New Revision: 1514206

URL: http://svn.apache.org/r1514206
Log:
OAK-659: Move purge logic for transient changes below the NodeBuilder interface

Make SegmentRootBuilder.getNodeState() flush all changes

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MemoryNodeBuilder.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeBuilder.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeState.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentRootBuilder.java

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=1514206&r1=1514205&r2=1514206&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
Thu Aug 15 08:52:23 2013
@@ -79,18 +79,18 @@ public class MemoryNodeBuilder implement
     /**
      * Parent builder, or {@code null} for a root builder.
      */
-    private final MemoryNodeBuilder parent;
+    protected final MemoryNodeBuilder parent;
 
     /**
      * Name of this child node within the parent builder,
      * or {@code null} for a root builder.
      */
-    private final String name;
+    protected final String name;
 
     /**
      * Root builder, or {@code this} for the root builder itself.
      */
-    private final MemoryNodeBuilder rootBuilder;
+    protected final MemoryNodeBuilder rootBuilder;
 
     /**
      * Internal revision counter for the base state of this builder. The counter

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeBuilder.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeBuilder.java?rev=1514206&r1=1514205&r2=1514206&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeBuilder.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeBuilder.java
Thu Aug 15 08:52:23 2013
@@ -17,15 +17,24 @@
 package org.apache.jackrabbit.oak.plugins.segment;
 
 import org.apache.jackrabbit.oak.plugins.memory.MemoryNodeBuilder;
+import org.apache.jackrabbit.oak.spi.state.NodeState;
 
 class SegmentNodeBuilder extends MemoryNodeBuilder {
 
+    protected NodeState base;
+
+    protected long baseRevision;
+
     protected SegmentNodeBuilder(SegmentNodeState base) {
         super(base);
+        this.base = base;
+        this.baseRevision = 0;
     }
 
     private SegmentNodeBuilder(SegmentNodeBuilder parent, String name) {
         super(parent, name);
+        this.base = parent.base.getChildNode(name);
+        this.baseRevision = parent.baseRevision;
     }
 
     @Override
@@ -33,4 +42,15 @@ class SegmentNodeBuilder extends MemoryN
         return new SegmentNodeBuilder(this, name);
     }
 
+    @Override
+    public NodeState getBaseState() {
+        // TODO: Use the head mechanism in MemoryNodeBuilder instead of
+        // overriding base state tracking
+        if (baseRevision != ((SegmentNodeBuilder) rootBuilder).baseRevision) {
+            base = parent.getBaseState().getChildNode(name);
+            baseRevision = ((SegmentNodeBuilder) rootBuilder).baseRevision;
+        }
+        return base;
+    }
+
 }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeState.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeState.java?rev=1514206&r1=1514205&r2=1514206&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeState.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeState.java
Thu Aug 15 08:52:23 2013
@@ -131,7 +131,7 @@ public class SegmentNodeState extends Ab
 
     @Override @Nonnull
     public NodeBuilder builder() {
-        return new SegmentRootBuilder(this);
+        return new SegmentRootBuilder(this, new SegmentWriter(store));
     }
 
     @Override

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentRootBuilder.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentRootBuilder.java?rev=1514206&r1=1514205&r2=1514206&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentRootBuilder.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentRootBuilder.java
Thu Aug 15 08:52:23 2013
@@ -16,6 +16,8 @@
  */
 package org.apache.jackrabbit.oak.plugins.segment;
 
+import org.apache.jackrabbit.oak.spi.state.NodeState;
+
 class SegmentRootBuilder extends SegmentNodeBuilder {
 
     /**
@@ -25,19 +27,38 @@ class SegmentRootBuilder extends Segment
     private static final int UPDATE_LIMIT =
             Integer.getInteger("update.limit", 1000);
 
+    private final SegmentWriter writer;
+
     private long updateCount = 0;
 
-    SegmentRootBuilder(SegmentNodeState base) {
+    SegmentRootBuilder(SegmentNodeState base, SegmentWriter writer) {
         super(base);
+        this.writer = writer;
     }
 
     @Override
     protected void updated() {
         updateCount++;
         if (updateCount > UPDATE_LIMIT) {
-            // TODO: flush
+            getNodeState(); // flush changes
             updateCount = 0;
         }
     }
 
+    // TODO: Allow flushing of also non-root builders
+    @Override
+    public SegmentNodeState getNodeState() {
+        SegmentNodeState state = writer.writeNode(super.getNodeState());
+        writer.flush();
+        super.reset(state);
+        return state;
+    }
+
+    @Override
+    public void reset(NodeState newBase) {
+        base = newBase;
+        baseRevision++;
+        super.reset(newBase);
+    }
+
 }



Mime
View raw message