jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r1448728 - in /jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment: JcrImporter.java MemoryStore.java MongoStore.java SegmentNodeState.java SegmentNodeStoreBranch.java SegmentWriter.java
Date Thu, 21 Feb 2013 17:24:27 GMT
Author: jukka
Date: Thu Feb 21 17:24:27 2013
New Revision: 1448728

URL: http://svn.apache.org/r1448728
Log:
OAK-593: Segment-based MK

Return SegmentNodeState instead of plain RecordId from writeNode()

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/JcrImporter.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/MemoryStore.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/MongoStore.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/SegmentNodeStoreBranch.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentWriter.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/JcrImporter.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/JcrImporter.java?rev=1448728&r1=1448727&r2=1448728&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/JcrImporter.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/JcrImporter.java
Thu Feb 21 17:24:27 2013
@@ -28,6 +28,7 @@ import org.apache.jackrabbit.oak.plugins
 import org.apache.jackrabbit.oak.plugins.memory.MemoryNodeState;
 import org.apache.jackrabbit.oak.plugins.memory.PropertyStates;
 import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
+import org.apache.jackrabbit.oak.spi.state.NodeState;
 
 public class JcrImporter {
 
@@ -37,7 +38,7 @@ public class JcrImporter {
         this.writer = writer;
     }
 
-    public RecordId writeNode(Node node) throws RepositoryException {
+    public NodeState writeNode(Node node) throws RepositoryException {
         NodeBuilder builder =
                 new MemoryNodeBuilder(MemoryNodeState.EMPTY_NODE);
         buildNode(builder, node);

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/MemoryStore.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/MemoryStore.java?rev=1448728&r1=1448727&r2=1448728&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/MemoryStore.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/MemoryStore.java
Thu Feb 21 17:24:27 2013
@@ -34,7 +34,7 @@ public class MemoryStore implements Segm
 
     public MemoryStore(NodeState root) {
         SegmentWriter writer = new SegmentWriter(this, new SegmentReader(this));
-        journals.put("root", writer.writeNode(root));
+        journals.put("root", writer.writeNode(root).getRecordId());
         writer.flush();
     }
 

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/MongoStore.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/MongoStore.java?rev=1448728&r1=1448727&r2=1448728&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/MongoStore.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/MongoStore.java
Thu Feb 21 17:24:27 2013
@@ -46,7 +46,7 @@ public class MongoStore implements Segme
 
         if (journals.findOne(new BasicDBObject("_id", "root")) == null) {
             SegmentWriter writer = new SegmentWriter(this, new SegmentReader(this));
-            RecordId id = writer.writeNode(MemoryNodeState.EMPTY_NODE);
+            RecordId id = writer.writeNode(MemoryNodeState.EMPTY_NODE).getRecordId();
             writer.flush();
             journals.insert(new BasicDBObject(ImmutableMap.of(
                     "_id", "root", "head", id.toString())));

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=1448728&r1=1448727&r2=1448728&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 Feb 21 17:24:27 2013
@@ -31,14 +31,6 @@ import org.apache.jackrabbit.oak.spi.sta
 
 class SegmentNodeState extends AbstractNodeState {
 
-    public static RecordId getRecordIdIfAvailable(NodeState state) {
-        if (state instanceof SegmentNodeState) {
-            SegmentNodeState sstate = (SegmentNodeState) state;
-            return sstate.recordId;
-        }
-        return null;
-    }
-
     private final SegmentReader reader;
 
     private final RecordId recordId;
@@ -50,6 +42,10 @@ class SegmentNodeState extends AbstractN
         this.recordId = checkNotNull(id);
     }
 
+    RecordId getRecordId() {
+        return recordId;
+    }
+
     private synchronized Template getTemplate() {
         if (template == null) {
             template = reader.readTemplate(reader.readRecordId(recordId, 0));

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStoreBranch.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStoreBranch.java?rev=1448728&r1=1448727&r2=1448728&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStoreBranch.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStoreBranch.java
Thu Feb 21 17:24:27 2013
@@ -76,7 +76,7 @@ class SegmentNodeStoreBranch implements 
 
     @Override
     public synchronized void setRoot(NodeState newRoot) {
-        this.rootId = writer.writeNode(newRoot);
+        this.rootId = writer.writeNode(newRoot).getRecordId();
         writer.flush();
     }
 
@@ -168,7 +168,7 @@ class SegmentNodeStoreBranch implements 
                     new MemoryNodeBuilder(new SegmentNodeState(reader, newBaseId));
             getRoot().compareAgainstBaseState(getBase(), new RebaseDiff(builder));
             this.baseId = newBaseId;
-            this.rootId = writer.writeNode(builder.getNodeState());
+            this.rootId = writer.writeNode(builder.getNodeState()).getRecordId();
             writer.flush();
         }
     }
@@ -183,7 +183,7 @@ class SegmentNodeStoreBranch implements 
             // rebase to latest head and apply commit hooks
             rebase();
             RecordId headId = writer.writeNode(
-                    hook.processCommit(getBase(), getRoot()));
+                    hook.processCommit(getBase(), getRoot())).getRecordId();
             writer.flush();
 
             // use optimistic locking to update the journal

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentWriter.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentWriter.java?rev=1448728&r1=1448727&r2=1448728&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentWriter.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentWriter.java
Thu Feb 21 17:24:27 2013
@@ -630,10 +630,9 @@ public class SegmentWriter {
         return id;
     }
 
-    public RecordId writeNode(NodeState state) {
-        RecordId nodeId = SegmentNodeState.getRecordIdIfAvailable(state);
-        if (nodeId != null) {
-            return nodeId;
+    public SegmentNodeState writeNode(NodeState state) {
+        if (state instanceof SegmentNodeState) {
+            return (SegmentNodeState) state;
         }
 
         SegmentNodeState before = null;
@@ -661,12 +660,12 @@ public class SegmentWriter {
                 after.compareAgainstBaseState(before, new DefaultNodeStateDiff() {
                     @Override
                     public void childNodeAdded(String name, NodeState after) {
-                        childNodes.put(name, writeNode(after));
+                        childNodes.put(name, writeNode(after).getRecordId());
                     }
                     @Override
                     public void childNodeChanged(
                             String name, NodeState before, NodeState after) {
-                        childNodes.put(name, writeNode(after));
+                        childNodes.put(name, writeNode(after).getRecordId());
                     }
                     @Override
                     public void childNodeDeleted(String name, NodeState before) {
@@ -676,12 +675,14 @@ public class SegmentWriter {
             } else {
                 base = null;
                 for (ChildNodeEntry entry : state.getChildNodeEntries()) {
-                    childNodes.put(entry.getName(), writeNode(entry.getNodeState()));
+                    childNodes.put(
+                            entry.getName(),
+                            writeNode(entry.getNodeState()).getRecordId());
                 }
             }
             ids.add(writeMap(base, childNodes).getRecordId());
         } else if (!template.hasNoChildNodes()) {
-            ids.add(writeNode(state.getChildNode(template.getChildName())));
+            ids.add(writeNode(state.getChildNode(template.getChildName())).getRecordId());
         }
 
         for (PropertyTemplate property : template.getPropertyTemplates()) {
@@ -692,7 +693,7 @@ public class SegmentWriter {
         for (RecordId id : ids) {
             writeRecordId(id);
         }
-        return recordId;
+        return new SegmentNodeState(reader, recordId);
     }
 
 }



Mime
View raw message