jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thom...@apache.org
Subject svn commit: r1365000 - in /jackrabbit/oak/trunk/oak-core/src: main/java/org/apache/jackrabbit/mk/simple/ main/java/org/apache/jackrabbit/mk/wrapper/ main/java/org/apache/jackrabbit/oak/query/index/ test/java/org/apache/jackrabbit/mk/ test/java/org/apac...
Date Tue, 24 Jul 2012 12:16:12 GMT
Author: thomasm
Date: Tue Jul 24 12:16:11 2012
New Revision: 1365000

URL: http://svn.apache.org/viewvc?rev=1365000&view=rev
Log:
OAK-202 Simplify the code when possible

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/simple/NodeImpl.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/simple/NodeListTrie.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/simple/NodeMap.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/simple/SimpleKernelImpl.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/wrapper/LogWrapper.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/wrapper/MicroKernelWrapperBase.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/wrapper/SecurityWrapper.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/wrapper/VirtualRepositoryWrapper.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/index/TraversingCursor.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/index/TraversingIndex.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/mk/MultiMkTestBase.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/mk/simple/AscendingClockTest.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/mk/wrapper/SecurityWrapperTest.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/FullTextTest.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/index/LikePatternTest.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/simple/NodeImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/simple/NodeImpl.java?rev=1365000&r1=1364999&r2=1365000&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/simple/NodeImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/simple/NodeImpl.java
Tue Jul 24 12:16:11 2012
@@ -198,11 +198,11 @@ public class NodeImpl implements Cache.V
             throw ExceptionFactory.get("Node not found: " + path);
         }
         long diffDescendant = -n.descendantCount;
-        long diffInline = -n.descendantInlineCount;
+        // long diffInline = -n.descendantInlineCount;
         NodeImpl n2 = n.cloneAndAddChildNode(path.substring(index + 1), before, position,
newNode, revId);
         NodeImpl clone = setChild(child, n2, revId);
         diffDescendant += n2.descendantCount;
-        diffInline += n2.descendantInlineCount;
+        // diffInline += n2.descendantInlineCount;
         clone.descendantCount += diffDescendant;
         clone.descendantInlineCount += diffDescendant;
         return clone;
@@ -625,17 +625,14 @@ public class NodeImpl implements Cache.V
                 String key = t.readString();
                 t.read(':');
                 String value = t.readRawValue();
-                if (key.length() > 0 && key.charAt(0) == ':') {
-                    if (key.equals(CHILDREN)) {
-                        node.childNodes = NodeListTrie.read(t, map, value);
-                    } else if (key.equals(DESCENDANT_COUNT)) {
-                        node.descendantCount = Long.parseLong(value);
-                        descendantCountSet = true;
-                    } else if (key.equals(HASH)) {
-                        node.id.setHash(StringUtils.convertHexToBytes(JsopTokenizer.decodeQuoted(value)));
-                    } else {
-                        node.setProperty(key, value);
-                    }
+                boolean hidden = key.length() > 0 && key.charAt(0) == ':';
+                if (hidden && key.equals(CHILDREN)) {
+                    node.childNodes = NodeListTrie.read(t, map, value);
+                } else if (hidden && key.equals(DESCENDANT_COUNT)) {
+                    node.descendantCount = Long.parseLong(value);
+                    descendantCountSet = true;
+                } else if (hidden && key.equals(HASH)) {
+                    node.id.setHash(StringUtils.convertHexToBytes(JsopTokenizer.decodeQuoted(value)));
                 } else if (map.isId(value)) {
                     if (node.childNodes == null) {
                         node.childNodes = new NodeListSmall();
@@ -691,6 +688,9 @@ public class NodeImpl implements Cache.V
         }
     }
 
+    /**
+     * A visitor over the child nodes.
+     */
     interface ChildVisitor {
         void accept(NodeId childId);
     }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/simple/NodeListTrie.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/simple/NodeListTrie.java?rev=1365000&r1=1364999&r2=1365000&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/simple/NodeListTrie.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/simple/NodeListTrie.java
Tue Jul 24 12:16:11 2012
@@ -81,7 +81,7 @@ public class NodeListTrie implements Nod
         this.size = size;
     }
 
-    private String getPrefix(String name, int len) {
+    private static String getPrefix(String name, int len) {
         if (name.length() < len) {
             return name + new String(new char[len - name.length()]);
         }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/simple/NodeMap.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/simple/NodeMap.java?rev=1365000&r1=1364999&r2=1365000&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/simple/NodeMap.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/simple/NodeMap.java
Tue Jul 24 12:16:11 2012
@@ -24,6 +24,9 @@ import java.util.concurrent.atomic.Atomi
 import org.apache.jackrabbit.mk.ExceptionFactory;
 import org.apache.jackrabbit.mk.simple.NodeImpl.ChildVisitor;
 
+/**
+ * A map of nodes that are accessible by id.
+ */
 public class NodeMap {
 
     public static final String MAX_MEMORY_CHILDREN = "maxMemoryChildren";

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/simple/SimpleKernelImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/simple/SimpleKernelImpl.java?rev=1365000&r1=1364999&r2=1365000&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/simple/SimpleKernelImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/simple/SimpleKernelImpl.java
Tue Jul 24 12:16:11 2012
@@ -422,7 +422,7 @@ public class SimpleKernelImpl extends Mi
         return buff.endArray();
    }
 
-    private NodeImpl getRevisionNode(NodeImpl node, long fromRev, long toRev) {
+    private static NodeImpl getRevisionNode(NodeImpl node, long fromRev, long toRev) {
         while (true) {
             long next = -1;
             String nextRev = null;

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/wrapper/LogWrapper.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/wrapper/LogWrapper.java?rev=1365000&r1=1364999&r2=1365000&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/wrapper/LogWrapper.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/wrapper/LogWrapper.java
Tue Jul 24 12:16:11 2012
@@ -249,7 +249,7 @@ public class LogWrapper implements Micro
         return o.toString();
     }
 
-    private RuntimeException convert(Exception e) {
+    private static RuntimeException convert(Exception e) {
         if (e instanceof RuntimeException) {
             return (RuntimeException) e;
         }
@@ -257,15 +257,15 @@ public class LogWrapper implements Micro
         return ExceptionFactory.convert(e);
     }
 
-    private void logException(Exception e) {
+    private static void logException(Exception e) {
         log("// exception: " + e.toString());
     }
 
-    private void logResult(Object result) {
+    private static void logResult(Object result) {
         log("// " + quote(result));
     }
 
-    private void log(String message) {
+    private static void log(String message) {
         if (DEBUG) {
             System.out.println(message);
         }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/wrapper/MicroKernelWrapperBase.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/wrapper/MicroKernelWrapperBase.java?rev=1365000&r1=1364999&r2=1365000&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/wrapper/MicroKernelWrapperBase.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/wrapper/MicroKernelWrapperBase.java
Tue Jul 24 12:16:11 2012
@@ -89,15 +89,18 @@ public abstract class MicroKernelWrapper
         throw new IllegalArgumentException("wrapper instance was not created by this factory");
     }
 
+    /**
+     * A wrapper for MicroKernel implementations that don't support JSOP methods.
+     */
     private static class MicroKernelWrapperImpl implements MicroKernelWrapper {
 
         final MicroKernel wrapped;
 
-        private MicroKernelWrapperImpl(MicroKernel mk) {
+        MicroKernelWrapperImpl(MicroKernel mk) {
             wrapped = mk;
         }
 
-        private MicroKernel getWrapped() {
+        MicroKernel getWrapped() {
             return wrapped;
         }
 

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/wrapper/SecurityWrapper.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/wrapper/SecurityWrapper.java?rev=1365000&r1=1364999&r2=1365000&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/wrapper/SecurityWrapper.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/wrapper/SecurityWrapper.java
Tue Jul 24 12:16:11 2012
@@ -390,7 +390,7 @@ public class SecurityWrapper extends Mic
         return n;
     }
 
-    private boolean checkPropertyRights(String path) {
+    private static boolean checkPropertyRights(String path) {
         return !PathUtils.getName(path).equals(":rights");
     }
 

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/wrapper/VirtualRepositoryWrapper.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/wrapper/VirtualRepositoryWrapper.java?rev=1365000&r1=1364999&r2=1365000&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/wrapper/VirtualRepositoryWrapper.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/wrapper/VirtualRepositoryWrapper.java
Tue Jul 24 12:16:11 2012
@@ -287,7 +287,7 @@ public class VirtualRepositoryWrapper ex
         return mk.getNodesStream(path, rev, depth, offset, count, filter);
     }
 
-    private String getRevision(String mount, String revisionId) {
+    private static String getRevision(String mount, String revisionId) {
         for (String rev : revisionId.split(",")) {
             if (rev.startsWith(mount + ":")) {
                 return rev.substring(mount.length() + 1);

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/index/TraversingCursor.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/index/TraversingCursor.java?rev=1365000&r1=1364999&r2=1365000&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/index/TraversingCursor.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/index/TraversingCursor.java
Tue Jul 24 12:16:11 2012
@@ -100,6 +100,9 @@ public class TraversingCursor implements
         return false;
     }
 
+    /**
+     * A pointer to a child node within a node.
+     */
     static class NodeCursor {
         NodeImpl node;
         long pos;

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/index/TraversingIndex.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/index/TraversingIndex.java?rev=1365000&r1=1364999&r2=1365000&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/index/TraversingIndex.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/index/TraversingIndex.java
Tue Jul 24 12:16:11 2012
@@ -24,6 +24,9 @@ import org.apache.jackrabbit.oak.spi.Cur
 import org.apache.jackrabbit.oak.spi.Filter;
 import org.apache.jackrabbit.oak.spi.QueryIndex;
 
+/**
+ * An index that traverses over a given subtree.
+ */
 public class TraversingIndex implements QueryIndex {
 
     private final MicroKernel mk;

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/mk/MultiMkTestBase.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/mk/MultiMkTestBase.java?rev=1365000&r1=1364999&r2=1365000&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/mk/MultiMkTestBase.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/mk/MultiMkTestBase.java
Tue Jul 24 12:16:11 2012
@@ -31,6 +31,10 @@ import org.junit.After;
 import org.junit.Before;
 import org.junit.runners.Parameterized.Parameters;
 
+/**
+ * The base class for tests that are run using multiple MicroKernel
+ * implementations.
+ */
 public class MultiMkTestBase {
 
     private static final boolean PROFILE = false;
@@ -95,6 +99,7 @@ public class MultiMkTestBase {
     /**
      * Whether this is (directly or indirectly) the MemoryKernelImpl.
      *
+     * @param mk the MicroKernel implementation
      * @return true if it is
      */
     public static boolean isSimpleKernel(MicroKernel mk) {

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/mk/simple/AscendingClockTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/mk/simple/AscendingClockTest.java?rev=1365000&r1=1364999&r2=1365000&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/mk/simple/AscendingClockTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/mk/simple/AscendingClockTest.java
Tue Jul 24 12:16:11 2012
@@ -16,10 +16,11 @@
  */
 package org.apache.jackrabbit.mk.simple;
 
-import org.apache.jackrabbit.mk.simple.AscendingClock;
-
 import junit.framework.TestCase;
 
+/**
+ * A test for the class {@code AscendingClock}.
+ */
 public class AscendingClockTest extends TestCase {
 
     public void testMillis() throws InterruptedException {

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/mk/wrapper/SecurityWrapperTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/mk/wrapper/SecurityWrapperTest.java?rev=1365000&r1=1364999&r2=1365000&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/mk/wrapper/SecurityWrapperTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/mk/wrapper/SecurityWrapperTest.java
Tue Jul 24 12:16:11 2012
@@ -116,7 +116,7 @@ public class SecurityWrapperTest {
         assertEquals("{\":childNodeCount\":1,\"test\":{\"data\":\"Hello\",\":childNodeCount\":0}}",
mkGuest.getNodes("/", head, 1, 0, -1, null));
     }
 
-    private String filterJournal(String journal) {
+    private static String filterJournal(String journal) {
         JsopTokenizer t = new JsopTokenizer(journal);
         StringBuilder buff = new StringBuilder();
         t.read('[');

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/FullTextTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/FullTextTest.java?rev=1365000&r1=1364999&r2=1365000&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/FullTextTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/FullTextTest.java
Tue Jul 24 12:16:11 2012
@@ -16,8 +16,13 @@
  */
 package org.apache.jackrabbit.oak.query;
 
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
 import java.text.ParseException;
+
 import org.apache.jackrabbit.oak.query.ast.FullTextSearchImpl;
 import org.junit.Test;
 

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/index/LikePatternTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/index/LikePatternTest.java?rev=1365000&r1=1364999&r2=1365000&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/index/LikePatternTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/index/LikePatternTest.java
Tue Jul 24 12:16:11 2012
@@ -24,6 +24,9 @@ import static org.junit.Assert.assertFal
 import org.apache.jackrabbit.oak.query.ast.ComparisonImpl;
 import org.junit.Test;
 
+/**
+ * Tests "like" pattern matching.
+ */
 public class LikePatternTest {
 
     @Test



Mime
View raw message