jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thom...@apache.org
Subject svn commit: r1163617 - in /jackrabbit/sandbox/microkernel/src: main/java/org/apache/jackrabbit/mk/index/ main/java/org/apache/jackrabbit/mk/mem/ main/java/org/apache/jackrabbit/mk/util/ test/java/org/apache/jackrabbit/mk/ test/java/org/apache/jackrabbi...
Date Wed, 31 Aug 2011 13:29:08 GMT
Author: thomasm
Date: Wed Aug 31 13:29:07 2011
New Revision: 1163617

URL: http://svn.apache.org/viewvc?rev=1163617&view=rev
Log:
Index mechanism (WIP)

Added:
    jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/util/ExceptionFactory.java
      - copied, changed from r1161472, jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/mem/ExceptionFactory.java
Modified:
    jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/index/Indexer.java
    jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/mem/ExceptionFactory.java
    jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/mem/MemoryKernelImpl.java
    jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/mem/NodeImpl.java
    jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/mem/NodeList.java
    jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/mem/NodeListLarge.java
    jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/mem/NodeListOld.java
    jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/mem/NodeListSmall.java
    jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/mem/NodeMap.java
    jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/mem/Revision.java
    jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/ConcurrentWriteTest.java
    jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/HelloWorld.java
    jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/LargeObjectTest.java
    jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/MoveNodeTest.java
    jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/index/IndexTest.java
    jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/index/PrefixIndexTest.java
    jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/index/PropertyIndexTest.java
    jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/large/LargeNodeTest.java

Modified: jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/index/Indexer.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/index/Indexer.java?rev=1163617&r1=1163616&r2=1163617&view=diff
==============================================================================
--- jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/index/Indexer.java (original)
+++ jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/index/Indexer.java Wed Aug 31 13:29:07 2011
@@ -46,15 +46,29 @@ public class Indexer {
             indexRootNode = "/" + indexRootNode;
         }
         this.indexRootNode = indexRootNode;
-
         revision = mk.getHeadRevision();
+        readRevision = revision;
         if (!mk.nodeExists(indexRootNode, revision)) {
             JsopBuilder jsop = new JsopBuilder();
             jsop.append("+ ").key(PathUtils.relativize("/", indexRootNode)).append("{}");
             revision = mk.commit("/", jsop.toString(), revision, null);
+        } else {
+            String node = mk.getNodes(indexRootNode, revision, 0, 0, 0);
+            JsopTokenizer t = new JsopTokenizer(node);
+            t.read('{');
+            HashMap<String, String> map = new HashMap<String, String>();
+            do {
+                String key = t.readString();
+                t.read(':');
+                t.read();
+                String value = t.getToken();
+                map.put(key, value);
+            } while (t.matches(','));
+            String rev = map.get("rev");
+            if (rev != null) {
+                readRevision = rev;
+            }
         }
-        int todoReadIfAlreadyExists;
-        readRevision = mk.getHeadRevision();
     }
 
     public Indexer(MicroKernel mk) {
@@ -148,6 +162,7 @@ public class Indexer {
     void updateUntil(String toRevision) {
         String journal = mk.getJournal(readRevision, toRevision);
         JsopTokenizer t = new JsopTokenizer(journal);
+        String lastRevision = readRevision;
         t.read('[');
         HashMap<String, String> map = new HashMap<String, String>();
         do {
@@ -160,14 +175,21 @@ public class Indexer {
                 String value = t.getToken();
                 map.put(key, value);
             } while (t.matches(','));
-            updateWith(map.get("changes"));
+            String rev = map.get("id");
+            if (!rev.equals(readRevision)) {
+                updateWith(map.get("changes"), lastRevision);
+            }
+            lastRevision = rev;
             t.read('}');
         } while (t.matches(','));
-        int todoPersistReadRevision;
         readRevision = toRevision;
+        JsopBuilder jsop = new JsopBuilder();
+        jsop.append("^ ").key("rev").value(readRevision);
+        buffer(jsop.toString());
+        commit();
     }
 
-    private void updateWith(String jsop) {
+    private void updateWith(String jsop, String lastRevision) {
         JsopTokenizer t = new JsopTokenizer(jsop);
         while (true) {
             int r = t.read();
@@ -182,7 +204,7 @@ public class Indexer {
                 NodeMap map = new NodeMap();
                 if (t.matches('{')) {
                     NodeImpl n = NodeImpl.parse(map, t, 0, path);
-                    addNodeRecursive(n);
+                    addOrRemoveRecursive(n, true, true);
                 } else {
                     String value = t.readRawValue().trim();
                     String nodePath = PathUtils.getParentPath(path);
@@ -190,16 +212,17 @@ public class Indexer {
                     node.setPath(nodePath);
                     String propertyName = PathUtils.getName(path);
                     node.cloneAndSetProperty(propertyName, value, 0);
-                    addNodeRecursive(node);
+                    addOrRemoveRecursive(node, true, true);
                 }
                 break;
             }
             case '-':
                 path = t.readString();
-                removeNode(path);
+                removeNode(path, lastRevision);
                 break;
             case '^': {
                 path = t.readString();
+                removeProperty(path, lastRevision);
                 t.read(':');
                 String value;
                 NodeMap map = new NodeMap();
@@ -213,7 +236,7 @@ public class Indexer {
                 node.setPath(nodePath);
                 String propertyName = PathUtils.getName(path);
                 node.cloneAndSetProperty(propertyName, value, 0);
-                addNodeRecursive(node);
+                addOrRemoveRecursive(node, true, true);
                 break;
             }
             case '>':
@@ -283,17 +306,21 @@ public class Indexer {
         }
     }
 
-    private void addNodeRecursive(NodeImpl n) {
+    private void addOrRemoveRecursive(NodeImpl n, boolean remove, boolean add) {
         if (isInIndex(n.getPath())) {
             // don't index the index
             return;
         }
         for (Index index : indexes) {
-            index.remove(n);
-            index.add(n);
+            if (remove) {
+                index.remove(n);
+            }
+            if (add) {
+                index.add(n);
+            }
         }
         for (Iterator<String> it = n.getChildNodeNames(); it.hasNext();) {
-            addNodeRecursive(n.getNode(it.next()));
+            addOrRemoveRecursive(n.getNode(it.next()), remove, add);
         }
     }
 
@@ -301,14 +328,37 @@ public class Indexer {
         return path.startsWith(indexRootNode);
     }
 
-    private void removeNode(String path) {
+    private void removeProperty(String path, String lastRevision) {
+        if (isInIndex(path)) {
+            // don't index the index
+            return;
+        }
+        String nodeName = PathUtils.getParentPath(path);
+        String property = PathUtils.getName(path);
+        String node = mk.getNodes(nodeName, lastRevision, 0, 0, 0);
+        JsopTokenizer t = new JsopTokenizer(node);
+        NodeMap map = new NodeMap();
+        t.read('{');
+        NodeImpl n = NodeImpl.parse(map, t, 0, path);
+        if (n.hasProperty(property)) {
+            for (Index index : indexes) {
+                index.remove(n);
+            }
+        }
+    }
+
+    private void removeNode(String path, String lastRevision) {
         if (isInIndex(path)) {
             // don't index the index
             return;
         }
-        int todo;
-        // ignore currently, because we don't know the property value
-        // (we need to read it separately)
+        String node = mk.getNodes(path, lastRevision, Integer.MAX_VALUE, 0, Integer.MAX_VALUE);
+        JsopTokenizer t = new JsopTokenizer(node);
+        NodeMap map = new NodeMap();
+        t.read('{');
+        NodeImpl n = NodeImpl.parse(map, t, 0, path);
+        n.setPath(path);
+        addOrRemoveRecursive(n, true, false);
     }
 
 }

Modified: jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/mem/MemoryKernelImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/mem/MemoryKernelImpl.java?rev=1163617&r1=1163616&r2=1163617&view=diff
==============================================================================
--- jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/mem/MemoryKernelImpl.java (original)
+++ jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/mem/MemoryKernelImpl.java Wed Aug 31 13:29:07 2011
@@ -30,10 +30,26 @@ import org.apache.jackrabbit.mk.util.Pat
 import java.io.InputStream;
 import java.util.ArrayList;
 import java.util.Collections;
-import java.util.Comparator;
 import java.util.HashMap;
-import java.util.SortedMap;
-import java.util.TreeMap;
+import java.util.Iterator;
+
+/*
+
+Node structure:
+
+/head/rev = 100
+/head/time = now()
+/head/commit/diff = "+ "/test ..."
+/head/commit/msg = "hello ..."
+/head/data/<user root>
+/old/90/rev = 90
+/old/90/data/<user root of revision 90>
+/old/91/rev = 91
+/old/99/rev = 99
+/old/old/80/rev = 80
+/old/old/89/rev = 89
+
+*/
 
 /**
  * An in-memory implementation.
@@ -41,15 +57,13 @@ import java.util.TreeMap;
  */
 public class MemoryKernelImpl implements MicroKernel {
 
+    private static final int MAX_REVISIONS_PER_NODE = 100;
     private static final HashMap<String, MemoryKernelImpl> INSTANCES = new HashMap<String, MemoryKernelImpl>();
 
     private AbstractBlobStore ds;
     private long headRevId;
-    private TreeMap<Long, Revision> revisions;
-    private ArrayList<Revision> revisionList;
+    private long rootId;
     private NodeMap nodeMap;
-    private long headRoot;
-    private long revisionRoot;
     private NonDescendingClock clock = new NonDescendingClock(System.currentTimeMillis());
     private final CommitGate gate = new CommitGate();
 
@@ -61,7 +75,10 @@ public class MemoryKernelImpl implements
         } else {
             ds = new MemoryBlobStore();
         }
-        init();
+        rootId = nodeMap.getRootId();
+        if (rootId == 0) {
+            clear();
+        }
     }
 
     public static synchronized MemoryKernelImpl get(String name) {
@@ -75,44 +92,18 @@ public class MemoryKernelImpl implements
 
     public void clear() {
         headRevId = 0;
-        headRoot = 0;
-        revisionRoot = 0;
+        rootId = 0;
         ds.clear();
         nodeMap.clear();
-        init();
-    }
-
-    private void init() {
-        revisions = new TreeMap<Long, Revision>();
-        revisionList = new ArrayList<Revision>();
-        setRoot(new NodeImpl(nodeMap, headRevId));
-//        setRevisionRoot(new NodeImpl(nodeMap, headRevId));
-        commit("+\"/\" {}", "create root node");
-    }
-
-    private NodeImpl getRoot() {
-        return nodeMap.getNode(headRoot);
-    }
-
-    private void setRoot(NodeImpl root) {
-        headRoot = nodeMap.addNode(root);
+        NodeImpl head = new NodeImpl(nodeMap, 0);
+        head.addChildNode("data", new NodeImpl(nodeMap, 0));
+        NodeImpl root = new NodeImpl(nodeMap, 0);
+        root.addChildNode("head", head);
+        root.addChildNode("old", new NodeImpl(nodeMap, 0));
+        rootId = nodeMap.addNode(root);
     }
 
-    private NodeImpl getRevisionRoot() {
-        return nodeMap.getNode(revisionRoot);
-    }
-
-    private void setRevisionRoot(NodeImpl r) {
-        revisionRoot = nodeMap.addNode(r);
-    }
-
-    private void commit(String jsonDiff, String msg) {
-        Revision r = new Revision(headRevId, clock.time(), headRoot, jsonDiff, msg);
-        revisions.put(headRevId, r);
-        revisionList.add(r);
-    }
-
-    public synchronized String commit(String path, String jsonDiff, String revisionId, String message) {
+    public synchronized String commit(String rootPath, String jsonDiff, String revisionId, String message) {
         // TODO do we really need 'path'? store the path is in the diff instead
         // TODO what is the exact meaning of 'revisionId'? is it allowed to commit
         // using an old revision, if yes when is it allowed, or how is it different from using head?
@@ -121,16 +112,11 @@ public class MemoryKernelImpl implements
         // TODO property type as comment versus as special property
         // TODO metadata in storage (version)
         // TODO optional read / write version in json 'api' (as comments?)
-
-        headRevId++;
-        jsonDiff = apply(path, jsonDiff);
-        commit(jsonDiff, message);
-        String head = getHeadRevision();
-        gate.commit(head);
-        return head;
-    }
-
-    private String apply(String rootPath, String jsonDiff) {
+        long oldRevision = headRevId++;
+        NodeImpl root = nodeMap.getNode(rootId);
+        NodeImpl head = root.getNode("head");
+        NodeImpl oldHead = head;
+        NodeImpl data = head.getNode("data");
         JsopBuilder w = new JsopBuilder();
         JsopTokenizer t = new JsopTokenizer(jsonDiff);
         String fromRoot = PathUtils.relativize("/", rootPath);
@@ -148,14 +134,14 @@ public class MemoryKernelImpl implements
                 int todoSupportAddProperty;
                 t.read('{');
                 NodeImpl n = NodeImpl.parse(nodeMap, t, headRevId);
-                setRoot(getRoot().cloneAndAddChildNode(PathUtils.concat(fromRoot, path), false, null, n, headRevId));
+                data = data.cloneAndAddChildNode(PathUtils.concat(fromRoot, path), false, null, n, headRevId);
                 n.append(w, -1, 0, -1, false);
                 w.appendWhitespace("\n");
                 break;
             case '-':
                 path = t.readString();
                 w.append("- ").value(PathUtils.concat(rootPath, path));
-                setRoot(getRoot().cloneAndRemoveChildNode(PathUtils.concat(fromRoot, path), headRevId));
+                data = data.cloneAndRemoveChildNode(PathUtils.concat(fromRoot, path), headRevId);
                 w.appendWhitespace("\n");
                 break;
             case '^':
@@ -170,14 +156,14 @@ public class MemoryKernelImpl implements
                     value = t.readRawValue().trim();
                     String nodeName = PathUtils.concat(fromRoot, PathUtils.getParentPath(path));
                     String propertyName = PathUtils.getName(path);
-                    if (getRoot().getNode(nodeName).hasProperty(propertyName)) {
+                    if (data.getNode(nodeName).hasProperty(propertyName)) {
                         w.append("^ ").key(PathUtils.concat(rootPath, path));
                     } else {
                         w.append("+ ").key(PathUtils.concat(rootPath, path));
                     }
                     w.append(value);
                 }
-                setRoot(getRoot().cloneAndSetProperty(PathUtils.concat(fromRoot, path), value, headRevId));
+                data = data.cloneAndSetProperty(PathUtils.concat(fromRoot, path), value, headRevId);
                 w.appendWhitespace("\n");
                 break;
             case '>':
@@ -247,20 +233,41 @@ public class MemoryKernelImpl implements
                         position = PathUtils.getName(from);
                     }
                 }
-                NodeImpl node = getRoot().getNode(from);
+                NodeImpl node = data.getNode(from);
                 if (!inPlaceRename) {
-                    setRoot(getRoot().cloneAndRemoveChildNode(from, headRevId));
+                    data = data.cloneAndRemoveChildNode(from, headRevId);
                 }
-                setRoot(getRoot().cloneAndAddChildNode(to, before, position, node, headRevId));
+                data = data.cloneAndAddChildNode(to, before, position, node, headRevId);
                 if (inPlaceRename) {
-                    setRoot(getRoot().cloneAndRemoveChildNode(from, headRevId));
+                    data = data.cloneAndRemoveChildNode(from, headRevId);
                 }
                 break;
             default:
                 throw new AssertionError("token: " + (char) t.getTokenType());
             }
         }
-        return w.toString();
+        head = head.setChild("data", data, headRevId);
+        head = head.cloneAndSetProperty("rev", "" + headRevId, headRevId);
+        head = head.cloneAndSetProperty("time", "" + clock.time(), headRevId);
+        String diff = w.toString();
+        NodeImpl commit = new NodeImpl(nodeMap, headRevId);
+        commit.setProperty("diff", diff);
+        commit.setProperty("msg", message);
+        head = head.setChild("commit", commit, headRevId);
+        root = root.setChild("head", head, headRevId);
+        NodeImpl old = root.getNode("old");
+        if (old.getChildNodeCount() > MAX_REVISIONS_PER_NODE) {
+            NodeImpl newOld = new NodeImpl(nodeMap, headRevId);
+            old = newOld.setChild("old", old, headRevId);
+        }
+        old = old.setChild("" + oldRevision, oldHead, headRevId);
+        root = root.setChild("old", old, headRevId);
+        nodeMap.addNode(root);
+        nodeMap.commit();
+        rootId = root.getId();
+        String headRev = getHeadRevision();
+        gate.commit(headRev);
+        return headRev;
     }
 
     public String getHeadRevision() {
@@ -268,23 +275,28 @@ public class MemoryKernelImpl implements
     }
 
     public String getRevisions(long since, int maxEntries) {
-        Revision find = new Revision(0, since, 0, null, null);
-        int index = Collections.binarySearch(revisionList, find, new Comparator<Revision>() {
-            public int compare(Revision o1, Revision o2) {
-                long t1 = o1.getTime(), t2 = o2.getTime();
-                return t1 < t2 ? -1 : t2 > t1 ? 1 : 0;
+        NodeImpl node = nodeMap.getNode(rootId);
+        ArrayList<Revision> revisions = new ArrayList<Revision>();
+        Revision r = new Revision(node.getNode("head"));
+        if (since < r.getTime()) {
+            revisions.add(r);
+            while (node.exists("old")) {
+                node = node.getNode("old");
+                for (Iterator<String> it = node.getChildNodeNames(); it.hasNext();) {
+                    r = new Revision(node.getNode(it.next()));
+                    revisions.add(r);
+                }
+                if (since >= r.getTime()) {
+                    break;
+                }
             }
-        });
-        if (index < 0) {
-            index = -index + 1;
         }
         JsopBuilder buff = new JsopBuilder().array();
-        for (int i = index; i < revisionList.size(); i++) {
-            Revision rev = revisionList.get(i);
-            buff.object().
-                    key("id").value(Long.toString(rev.getId())).
-                    key("ts").value(rev.getTime()).
-                    endObject();
+        Collections.sort(revisions);
+        for (Revision rev : revisions) {
+            if (rev.getTime() > since) {
+                buff.encodedValue(rev.toString());
+            }
         }
         return buff.endArray().toString();
     }
@@ -296,15 +308,32 @@ public class MemoryKernelImpl implements
     public String getJournal(String fromRevisionId, String toRevisionId) {
         long fromRevId = parseRevisionId(fromRevisionId);
         long toRevId = parseRevisionId(toRevisionId);
+        NodeImpl node = nodeMap.getNode(rootId);
+        ArrayList<Revision> revisions = new ArrayList<Revision>();
+        Revision r = new Revision(node.getNode("head"));
+        if (r.getId() >= fromRevId) {
+            revisions.add(r);
+        }
+        while (r.getId() > fromRevId && node.exists("old")) {
+            node = node.getNode("old");
+            for (Iterator<String> it = node.getChildNodeNames(); it.hasNext();) {
+                r = new Revision(node.getNode(it.next()));
+                if (r.getId() >= fromRevId && r.getId() <= toRevId) {
+                    revisions.add(r);
+                }
+            }
+        }
+        Collections.sort(revisions);
         JsopBuilder buff = new JsopBuilder().array().appendWhitespace("\n");
-        SortedMap<Long, Revision> map = revisions.subMap(fromRevId, true, toRevId, true);
-        for (Revision rev : map.values()) {
-            buff.object().
+        for (Revision rev : revisions) {
+            if (rev.getId() >= fromRevId && rev.getId() <= toRevId) {
+                buff.object().
                     key("id").value(Long.toString(rev.getId())).
                     key("ts").value(rev.getTime()).
                     key("msg").value(rev.getMsg()).
                     key("changes").value(rev.getDiff()).
-                    endObject().appendWhitespace("\n");
+                endObject().appendWhitespace("\n");
+            }
         }
         return buff.endArray().toString();
     }
@@ -315,32 +344,43 @@ public class MemoryKernelImpl implements
 
     public String getNodes(String path, String revisionId, int depth, long offset, int count) {
         if (!PathUtils.isAbsolute(path)) {
-            throw new IllegalArgumentException("not an absolute path: " + path);
+            throw new IllegalArgumentException("Not an absolute path: " + path);
         }
-        path = path.substring(1);
-        long revId = parseRevisionId(revisionId);
-        NodeImpl root = nodeMap.getNode(revisions.get(revId).getRoot());
-        NodeImpl n = root.getNode(path);
+        NodeImpl n = getRevision(revisionId).getNode(path.substring(1));
         if (n == null) {
-            throw new RuntimeException("path not found: " + path);
+            throw new RuntimeException("Path not found: " + path);
         }
         JsopBuilder json = new JsopBuilder();
         n.append(json, depth, offset, count, true);
         return json.toString();
     }
 
+    private NodeImpl getRevision(String revisionId) {
+        long revId = parseRevisionId(revisionId);
+        NodeImpl node = nodeMap.getNode(rootId);
+        if (revId == headRevId) {
+            node = node.getNode("head");
+        } else {
+            while (true) {
+                if (!node.exists("old")) {
+                    throw new RuntimeException("Revision not found: " + revisionId);
+                }
+                node = node.getNode("old");
+                if (node.exists(revisionId)) {
+                    node = node.getNode(revisionId);
+                    break;
+                }
+            }
+        }
+        return node.getNode("data");
+    }
+
     public boolean nodeExists(String path, String revisionId) {
-        // TODO use a bloom filter
+        // TODO possibly use a bloom filter
         if (!PathUtils.isAbsolute(path)) {
-            throw new IllegalArgumentException("not an absolute path: " + path);
-        }
-        path = path.substring(1);
-        long revId = parseRevisionId(revisionId);
-        NodeImpl n = nodeMap.getNode(revisions.get(revId).getRoot());
-        if (n == null) {
-            return false;
+            throw new IllegalArgumentException("Not an absolute path: " + path);
         }
-        return n.exists(path);
+        return getRevision(revisionId).exists(path.substring(1));
     }
 
     private static String getRevisionId(long revId) {
@@ -377,6 +417,7 @@ public class MemoryKernelImpl implements
 
     public void dispose() {
         gate.commit("end");
+        nodeMap.close();
     }
 
 }

Modified: jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/mem/NodeImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/mem/NodeImpl.java?rev=1163617&r1=1163616&r2=1163617&view=diff
==============================================================================
--- jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/mem/NodeImpl.java (original)
+++ jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/mem/NodeImpl.java Wed Aug 31 13:29:07 2011
@@ -19,8 +19,12 @@ package org.apache.jackrabbit.mk.mem;
 import org.apache.jackrabbit.mk.Constants;
 import org.apache.jackrabbit.mk.json.JsopBuilder;
 import org.apache.jackrabbit.mk.json.JsopTokenizer;
+import org.apache.jackrabbit.mk.util.IOUtils;
 import org.apache.jackrabbit.mk.util.PathUtils;
 
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashMap;
@@ -36,7 +40,7 @@ public class NodeImpl {
     private final long revId;
     private final NodeMap map;
     private HashMap<String, String> properties;
-    private NodeListSmall childNodes;
+    private NodeList childNodes;
     private String path;
     private long id;
 
@@ -53,7 +57,7 @@ public class NodeImpl {
         this.id = id;
     }
 
-    public NodeImpl clone(long revId) {
+    public NodeImpl createClone(long revId) {
         if (revId == this.revId) {
             return this;
         }
@@ -62,7 +66,7 @@ public class NodeImpl {
             clone.properties = new HashMap<String, String>(properties);
         }
         if (childNodes != null) {
-            clone.childNodes = new NodeListSmall(childNodes);
+            clone.childNodes = childNodes.createClone(map);
         }
         return clone;
     }
@@ -110,14 +114,14 @@ public class NodeImpl {
         return map.getNode(childNodes.get(name));
     }
 
-    private void addChildNode(String name, NodeImpl node) {
+    private void addNode(String name, NodeImpl node) {
         childNodes.put(name, map.addNode(node));
     }
 
     public NodeImpl cloneAndAddChildNode(String path, boolean before, String position, NodeImpl newNode, long revId) {
         int index = PathUtils.getNextSlash(path, 0);
         if (index < 0) {
-            NodeImpl clone = clone(revId);
+            NodeImpl clone = createClone(revId);
             clone.addChildNode(path, before, position, newNode);
             return clone;
         }
@@ -127,15 +131,15 @@ public class NodeImpl {
             throw new RuntimeException("Node not found: " + path);
         }
         NodeImpl n2 = n.cloneAndAddChildNode(path.substring(index + 1), before, position, newNode, revId);
-        NodeImpl c = clone(revId);
-        c.addChildNode(child, n2);
+        NodeImpl c = createClone(revId);
+        c.addNode(child, n2);
         return c;
     }
 
     public NodeImpl cloneAndRemoveChildNode(String path, long revId) {
         int index = PathUtils.getNextSlash(path, 0);
         if (index < 0) {
-            NodeImpl clone = clone(revId);
+            NodeImpl clone = createClone(revId);
             clone.removeChildNode(path);
             return clone;
         }
@@ -145,15 +149,15 @@ public class NodeImpl {
             throw new RuntimeException("Node not found: " + path);
         }
         NodeImpl n2 = n.cloneAndRemoveChildNode(path.substring(index + 1), revId);
-        NodeImpl c = clone(revId);
-        c.addChildNode(child, n2);
+        NodeImpl c = createClone(revId);
+        c.addNode(child, n2);
         return c;
     }
 
     public NodeImpl cloneAndSetProperty(String path, String value, long revId) {
         int index = PathUtils.getNextSlash(path, 0);
         if (index < 0) {
-            NodeImpl clone = clone(revId);
+            NodeImpl clone = createClone(revId);
             clone.setProperty(path, value);
             return clone;
         }
@@ -163,8 +167,8 @@ public class NodeImpl {
             throw new RuntimeException("Node not found: " + path);
         }
         NodeImpl n2 = n.cloneAndSetProperty(path.substring(index + 1), value, revId);
-        NodeImpl c = clone(revId);
-        c.addChildNode(child, n2);
+        NodeImpl c = createClone(revId);
+        c.addNode(child, n2);
         return c;
     }
 
@@ -219,6 +223,10 @@ public class NodeImpl {
         json.endObject();
     }
 
+    void addChildNode(String name, NodeImpl node) {
+        addChildNode(name, false, null, node);
+    }
+
     void addChildNode(String name, boolean before, String position, NodeImpl node) {
         if (childNodes == null) {
             childNodes = new NodeListSmall();
@@ -228,7 +236,7 @@ public class NodeImpl {
         if (Constants.NODE_NAME_AS_PROPERTY) {
             node.setProperty(":name", JsopBuilder.encode(name));
         }
-        addChildNode(name, node);
+        addNode(name, node);
         if (before || position != null) {
             boolean moveNext = false;
             ArrayList<String> move = new ArrayList<String>();
@@ -331,4 +339,70 @@ public class NodeImpl {
         return properties.entrySet();
     }
 
+    public static NodeImpl read(NodeMap map, InputStream in) throws IOException {
+        long revId = IOUtils.readVarLong(in);
+        NodeImpl node = new NodeImpl(map, revId);
+        node.id = map.readId(in);
+        int count = IOUtils.readVarInt(in);
+        for (int i = 0; i < count; i++) {
+            node.setProperty(IOUtils.readString(in), IOUtils.readString(in));
+        }
+        int childCount = IOUtils.readVarInt(in);
+        if (childCount < 0) {
+            childCount = -childCount;
+            int todoLargeChildNodeList;
+        } else if (childCount > 0) {
+            node.childNodes = new NodeListSmall();
+            for (int i = 0; i < childCount; i++) {
+                node.childNodes.put(IOUtils.readString(in), map.readId(in));
+            }
+        }
+        return node;
+    }
+
+    public void write(OutputStream out) throws IOException {
+        IOUtils.writeVarLong(out, revId);
+        map.writeId(out, map.getId(id));
+        if (properties == null) {
+            IOUtils.writeVarInt(out, 0);
+        } else {
+            IOUtils.writeVarInt(out, properties.size());
+            for (Entry<String, String> e : properties.entrySet()) {
+                IOUtils.writeString(out, e.getKey());
+                IOUtils.writeString(out, e.getValue());
+            }
+        }
+        if (childNodes == null) {
+            IOUtils.writeVarInt(out, 0);
+        } else {
+            IOUtils.writeVarLong(out, childNodes.size());
+            for (Iterator<String> it = childNodes.getNames(0); it.hasNext();) {
+                String n = it.next();
+                IOUtils.writeString(out, n);
+                long x = childNodes.get(n);
+                long y = map.getId(x);
+                if (x != y) {
+                    childNodes.put(n, y);
+                }
+                map.writeId(out, y);
+            }
+        }
+    }
+
+    NodeList getNodeList() {
+        return childNodes;
+    }
+
+    NodeImpl setChild(String name, NodeImpl child, long revId) {
+        NodeImpl result = this;
+        if (exists(name)) {
+            NodeImpl n = getChildNode(name);
+            if (n == child) {
+                return result;
+            }
+            result = cloneAndRemoveChildNode(name, revId);
+        }
+        return result.cloneAndAddChildNode(name, false, null, child, revId);
+    }
+
 }

Modified: jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/mem/NodeList.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/mem/NodeList.java?rev=1163617&r1=1163616&r2=1163617&view=diff
==============================================================================
--- jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/mem/NodeList.java (original)
+++ jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/mem/NodeList.java Wed Aug 31 13:29:07 2011
@@ -16,4 +16,6 @@ interface NodeList {
 
     Long remove(String name);
 
+    NodeList createClone(NodeMap map);
+
 }

Modified: jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/mem/NodeListLarge.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/mem/NodeListLarge.java?rev=1163617&r1=1163616&r2=1163617&view=diff
==============================================================================
--- jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/mem/NodeListLarge.java (original)
+++ jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/mem/NodeListLarge.java Wed Aug 31 13:29:07 2011
@@ -22,10 +22,11 @@ import java.util.Iterator;
 
 public class NodeListLarge implements NodeList {
 
+    ArrayList<Child> children;
     private final NodeMap map;
-    private ArrayList<Child> children;
+    private long size;
 
-    NodeListLarge(NodeMap map) {
+    NodeListLarge(NodeMap map, ArrayList<Child> children) {
         this.map = map;
         children = new ArrayList<Child>();
     }
@@ -33,39 +34,116 @@ public class NodeListLarge implements No
     public boolean containsKey(String name) {
         for (Child c : children) {
             if (c.possiblyContains(name)) {
-                return load(c).containsKey(name);
+                return getList(c).containsKey(name);
             }
         }
         return false;
     }
 
-    private NodeList load(Child c) {
-        return new NodeListSmall();
+    NodeList getList(Child c) {
+        NodeImpl n = map.getNode(c.id);
+        return n.getNodeList();
     }
 
     public Long get(String name) {
-        // TODO Auto-generated method stub
+        for (Child c : children) {
+            if (c.possiblyContains(name)) {
+                NodeList child = getList(c);
+                if (child.containsKey(name)) {
+                    return child.get(name);
+                }
+            }
+        }
         return null;
     }
 
     public Iterator<String> getNames(long offset) {
-        // TODO Auto-generated method stub
-        return null;
+        int i = 0;
+        for (; i < children.size(); i++) {
+            Child c = children.get(i);
+            if (c.size < offset) {
+                offset -= c.size;
+                continue;
+            }
+        }
+        final int start = i;
+        final long off = offset;
+        Iterator<String> it = new Iterator<String>() {
+            int pos = start;
+            long offset = off;
+            Iterator<String> it;
+            public boolean hasNext() {
+                if (it == null) {
+                    return false;
+                }
+                if (it.hasNext()) {
+                    return true;
+                }
+                it = null;
+                while (pos < children.size()) {
+                    it = getList(children.get(pos++)).getNames(offset);
+                    offset = 0;
+                    if (it.hasNext()) {
+                        return true;
+                    }
+                }
+                return false;
+            }
+
+            public String next() {
+                if (hasNext()) {
+                    return it.next();
+                } else {
+                    return null;
+                }
+            }
+
+            public void remove() {
+                throw new UnsupportedOperationException();
+            }
+        };
+        return it;
     }
 
     public void put(String name, Long x) {
-        // TODO Auto-generated method stub
-
+        for (Child c : children) {
+            if (c.possiblyContains(name)) {
+                NodeList child = getList(c);
+                if (child.containsKey(name)) {
+                    Long y = child.remove(name);
+                    if (y == null) {
+                        throw new RuntimeException("Could not remove " + name);
+                    }
+                    size--;
+                    break;
+                }
+            }
+        }
+        Child c = children.get(children.size() - 1);
+        NodeList child = getList(c);
+        child.put(name, x);
+        size++;
     }
 
     public Long remove(String name) {
-        // TODO Auto-generated method stub
+        for (Child c : children) {
+            if (c.possiblyContains(name)) {
+                NodeList child = getList(c);
+                if (child.containsKey(name)) {
+                    Long x = child.remove(name);
+                    if (x == null) {
+                        throw new RuntimeException("Could not remove " + name);
+                    }
+                    size--;
+                    return x;
+                }
+            }
+        }
         return null;
     }
 
     public long size() {
-        // TODO Auto-generated method stub
-        return 0;
+        return size;
     }
 
     static class Child {
@@ -81,4 +159,17 @@ public class NodeListLarge implements No
         }
     }
 
+    public NodeList createClone(NodeMap map) {
+        if (size < map.getMaxMemoryChildren() / 2) {
+            NodeListSmall s = new NodeListSmall();
+            for (Iterator<String> it = getNames(0); it.hasNext();) {
+                String n = it.next();
+                s.put(n, get(n));
+            }
+            return s;
+        }
+        int todo;
+        return new NodeListLarge(map, children);
+    }
+
 }

Modified: jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/mem/NodeListOld.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/mem/NodeListOld.java?rev=1163617&r1=1163616&r2=1163617&view=diff
==============================================================================
--- jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/mem/NodeListOld.java (original)
+++ jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/mem/NodeListOld.java Wed Aug 31 13:29:07 2011
@@ -16,7 +16,6 @@
  */
 package org.apache.jackrabbit.mk.mem;
 
-import java.util.Iterator;
 import java.util.LinkedHashMap;
 import java.util.Map.Entry;
 import org.apache.jackrabbit.mk.json.JsopBuilder;

Modified: jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/mem/NodeListSmall.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/mem/NodeListSmall.java?rev=1163617&r1=1163616&r2=1163617&view=diff
==============================================================================
--- jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/mem/NodeListSmall.java (original)
+++ jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/mem/NodeListSmall.java Wed Aug 31 13:29:07 2011
@@ -26,12 +26,12 @@ public class NodeListSmall implements No
 
     private LinkedHashMap<String, Long> list;
 
-    public NodeListSmall(NodeListSmall clone) {
-        this.list = new LinkedHashMap<String, Long>(clone.list);
+    private NodeListSmall(LinkedHashMap<String, Long> list) {
+        this.list = list;
     }
 
     public NodeListSmall() {
-        list = new LinkedHashMap<String, Long>();
+        this(new LinkedHashMap<String, Long>());
     }
 
     public long size() {
@@ -95,4 +95,11 @@ public class NodeListSmall implements No
         return json.toString();
     }
 
+    public NodeList createClone(NodeMap map) {
+        if (list.size() > map.getMaxMemoryChildren()) {
+
+        }
+        return new NodeListSmall(new LinkedHashMap<String, Long>(list));
+    }
+
 }

Modified: jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/mem/NodeMap.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/mem/NodeMap.java?rev=1163617&r1=1163616&r2=1163617&view=diff
==============================================================================
--- jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/mem/NodeMap.java (original)
+++ jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/mem/NodeMap.java Wed Aug 31 13:29:07 2011
@@ -16,7 +16,11 @@
  */
 package org.apache.jackrabbit.mk.mem;
 
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
 import java.util.HashMap;
+import org.apache.jackrabbit.mk.util.IOUtils;
 
 public class NodeMap {
 
@@ -25,7 +29,7 @@ public class NodeMap {
 
     public long addNode(NodeImpl node) {
         long x = node.getId();
-        if (!nodes.containsKey(x)) {
+        if (x == 0) {
             x = nextId++;
             node.setId(x);
             nodes.put(x, node);
@@ -47,4 +51,29 @@ public class NodeMap {
         return 20;
     }
 
+    public void commit() {
+        // ignore
+    }
+
+    public void close() {
+        // ignore
+    }
+
+    public long getId(long id) {
+        return id;
+    }
+
+    public void writeId(OutputStream out, long x) throws IOException {
+        IOUtils.writeVarInt(out, (int) (x >>> 32));
+        IOUtils.writeInt(out, (int) x);
+    }
+
+    public long readId(InputStream in) throws IOException {
+        return (IOUtils.readVarInt(in) << 32) | IOUtils.readInt(in);
+    }
+
+    public long getRootId() {
+        return 0;
+    }
+
 }

Modified: jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/mem/Revision.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/mem/Revision.java?rev=1163617&r1=1163616&r2=1163617&view=diff
==============================================================================
--- jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/mem/Revision.java (original)
+++ jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/mem/Revision.java Wed Aug 31 13:29:07 2011
@@ -16,29 +16,36 @@
  */
 package org.apache.jackrabbit.mk.mem;
 
+import org.apache.jackrabbit.mk.json.JsopBuilder;
+
 /**
  * A revision, including pointer to the root node of that revision.
  */
-public class Revision {
+public class Revision implements Comparable<Revision> {
 
+    private NodeImpl node;
     private final long id;
     private final long time;
-    private final long root;
-    private final String diff;
-    private final String msg;
+    private String diff;
+    private String msg;
+
+    Revision(NodeImpl node) {
+        this.node = node;
+        if (node.hasProperty("rev")) {
+            id = Long.parseLong(node.getProperty("rev"));
+            time = Long.parseLong(node.getProperty("time"));
+        } else {
+            id = time = 0;
+        }
+    }
 
-    public Revision(long id, long time, long root, String diff, String msg) {
+    public Revision(long id, long time, String diff, String msg) {
         this.id = id;
         this.time = time;
-        this.root = root;
         this.diff = diff;
         this.msg = msg;
     }
 
-    public long getRoot() {
-        return root;
-    }
-
     public long getId() {
         return id;
     }
@@ -48,11 +55,36 @@ public class Revision {
     }
 
     public String getDiff() {
+        if (diff == null) {
+            diff = getCommitValue("diff");
+        }
         return diff;
     }
 
     public String getMsg() {
+        if (msg == null) {
+            msg = getCommitValue("msg");
+        }
         return msg;
     }
 
+    private String getCommitValue(String s) {
+        if (node.exists("commit")) {
+            return node.getNode("commit").getProperty(s);
+        } else {
+            return "";
+        }
+    }
+
+    public int compareTo(Revision o) {
+        return id < o.id ? -1 : id > o.id ? 1 : 0;
+    }
+
+    public String toString() {
+        return new JsopBuilder().object().
+            key("id").value(Long.toString(id)).
+            key("ts").value(time).
+        endObject().toString();
+    }
+
 }

Copied: jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/util/ExceptionFactory.java (from r1161472, jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/mem/ExceptionFactory.java)
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/util/ExceptionFactory.java?p2=jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/util/ExceptionFactory.java&p1=jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/mem/ExceptionFactory.java&r1=1161472&r2=1163617&rev=1163617&view=diff
==============================================================================
--- jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/mem/ExceptionFactory.java (original)
+++ jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/util/ExceptionFactory.java Wed Aug 31 13:29:07 2011
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.jackrabbit.mk.mem;
+package org.apache.jackrabbit.mk.util;
 
 import org.apache.jackrabbit.mk.Constants;
 

Modified: jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/ConcurrentWriteTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/ConcurrentWriteTest.java?rev=1163617&r1=1163616&r2=1163617&view=diff
==============================================================================
--- jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/ConcurrentWriteTest.java (original)
+++ jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/ConcurrentWriteTest.java Wed Aug 31 13:29:07 2011
@@ -25,9 +25,10 @@ public class ConcurrentWriteTest extends
 
     protected static final String TEST_PATH = "/" + ConcurrentWriteTest.class.getName();
 
-    //private static final String URL = "fs:{homeDir}/target;clean";
-    private static final String URL = "fs:{homeDir}/target";
-    //private static final String URL = "mem:";
+    // private static final String URL = "fs:{homeDir}/target;clean";
+    // private static final String URL = "fs:{homeDir}/target";
+    // private static final String URL = "mem:";
+    private static final String URL = "mem:fs:target/temp;clean";
 
     private static final int NUM_THREADS = 20;
     private static final int NUM_CHILDNODES = 1000;

Modified: jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/HelloWorld.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/HelloWorld.java?rev=1163617&r1=1163616&r2=1163617&view=diff
==============================================================================
--- jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/HelloWorld.java (original)
+++ jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/HelloWorld.java Wed Aug 31 13:29:07 2011
@@ -30,8 +30,8 @@ import java.util.ArrayList;
 public class HelloWorld {
 
     public static void main(String... args) throws ParseException {
-        // test("mem:");
-        test("fs:{homeDir};clean");
+        test("mem:");
+        // test("fs:{homeDir};clean");
     }
 
     private static void test(String url) throws ParseException {

Modified: jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/LargeObjectTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/LargeObjectTest.java?rev=1163617&r1=1163616&r2=1163617&view=diff
==============================================================================
--- jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/LargeObjectTest.java (original)
+++ jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/LargeObjectTest.java Wed Aug 31 13:29:07 2011
@@ -24,8 +24,9 @@ import org.apache.jackrabbit.mk.api.Micr
  */
 public class LargeObjectTest extends TestCase {
 
-    private static final String URL = "fs:{homeDir}/target;clean";
+    // private static final String URL = "fs:{homeDir}/target;clean";
     // private static final String URL = "mem:";
+    private static final String URL = "mem:fs:target/temp;clean";
 
     private static final String TEST_PATH = "/" + LargeObjectTest.class.getName();
 

Modified: jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/MoveNodeTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/MoveNodeTest.java?rev=1163617&r1=1163616&r2=1163617&view=diff
==============================================================================
--- jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/MoveNodeTest.java (original)
+++ jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/MoveNodeTest.java Wed Aug 31 13:29:07 2011
@@ -26,7 +26,8 @@ import org.apache.jackrabbit.mk.json.Jso
 public class MoveNodeTest extends TestCase {
 
     // private static final String URL = "fs:{homeDir};clean";
-    private static final String URL = "mem:;clean";
+    // private static final String URL = "mem:;clean";
+    private static final String URL = "mem:fs:target/temp;clean";
 
     private MicroKernel mk;
 

Modified: jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/index/IndexTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/index/IndexTest.java?rev=1163617&r1=1163616&r2=1163617&view=diff
==============================================================================
--- jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/index/IndexTest.java (original)
+++ jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/index/IndexTest.java Wed Aug 31 13:29:07 2011
@@ -30,9 +30,9 @@ import java.util.TreeMap;
  */
 public class IndexTest extends TestCase {
 
-    private static final String URL = "fs:{homeDir}/target;clean";
+    // private static final String URL = "fs:{homeDir}/target;clean";
     // private static final String URL = "mem:fs:target/temp;clean";
-    // private static final String URL = "mem:";
+    private static final String URL = "mem:;clean";
 
     public void test() {
         testNonUnique(URL);

Modified: jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/index/PrefixIndexTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/index/PrefixIndexTest.java?rev=1163617&r1=1163616&r2=1163617&view=diff
==============================================================================
--- jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/index/PrefixIndexTest.java (original)
+++ jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/index/PrefixIndexTest.java Wed Aug 31 13:29:07 2011
@@ -26,9 +26,9 @@ import org.apache.jackrabbit.mk.api.Micr
  */
 public class PrefixIndexTest extends TestCase {
 
-    private static final String URL = "fs:{homeDir}/target";
+    // private static final String URL = "fs:{homeDir}/target";
     // private static final String URL = "mem:fs:target/temp;clean";
-    // private static final String URL = "mem:";
+    private static final String URL = "mem:;clean";
 
     public void test() {
         test(URL);

Modified: jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/index/PropertyIndexTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/index/PropertyIndexTest.java?rev=1163617&r1=1163616&r2=1163617&view=diff
==============================================================================
--- jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/index/PropertyIndexTest.java (original)
+++ jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/index/PropertyIndexTest.java Wed Aug 31 13:29:07 2011
@@ -27,7 +27,7 @@ public class PropertyIndexTest extends T
 
     private static final String URL = "fs:{homeDir}/target";
     // private static final String URL = "mem:fs:target/temp";
-    // private static final String URL = "mem:";
+    // private static final String URL = "mem:test";
 
     public void test() {
         test(URL);
@@ -61,6 +61,17 @@ public class PropertyIndexTest extends T
         head = mk.getHeadRevision();
         assertEquals("/test/test", index.getPath("3", head));
         assertEquals(null, index.getPath("0", head));
+
+        assertEquals("/test", index.getPath("1", head));
+        head = mk.commit("/", "^ \"test/id\": 100", head, null);
+        assertEquals(null, index.getPath("1", head));
+        assertEquals("/test", index.getPath("100", head));
+
+        assertEquals("/test/test", index.getPath("3", head));
+        head = mk.commit("/", "- \"test\"", head, null);
+        assertEquals(null, index.getPath("100", head));
+        assertEquals(null, index.getPath("3", head));
+
         mk.dispose();
     }
 

Modified: jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/large/LargeNodeTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/large/LargeNodeTest.java?rev=1163617&r1=1163616&r2=1163617&view=diff
==============================================================================
--- jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/large/LargeNodeTest.java (original)
+++ jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/large/LargeNodeTest.java Wed Aug 31 13:29:07 2011
@@ -26,7 +26,8 @@ import org.apache.jackrabbit.mk.api.Micr
 public class LargeNodeTest extends TestCase {
 
     // private static final String URL = "fs:{homeDir};clean";
-    private static final String URL = "mem:;clean";
+    // private static final String URL = "mem:;clean";
+    private static final String URL = "mem:fs:target/temp;clean";
 
     private MicroKernel mk;
 



Mime
View raw message