jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thom...@apache.org
Subject svn commit: r1186706 - /jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/index/Indexer.java
Date Thu, 20 Oct 2011 10:04:15 GMT
Author: thomasm
Date: Thu Oct 20 10:04:15 2011
New Revision: 1186706

URL: http://svn.apache.org/viewvc?rev=1186706&view=rev
Log:
Index: simple read cache

Modified:
    jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/index/Indexer.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=1186706&r1=1186705&r2=1186706&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
Thu Oct 20 10:04:15 2011
@@ -24,6 +24,7 @@ import org.apache.jackrabbit.mk.mem.Node
 import org.apache.jackrabbit.mk.mem.NodeMap;
 import org.apache.jackrabbit.mk.util.ExceptionFactory;
 import org.apache.jackrabbit.mk.util.PathUtils;
+import org.apache.jackrabbit.mk.util.SimpleLRUCache;
 
 import java.util.ArrayList;
 import java.util.HashMap;
@@ -44,6 +45,7 @@ public class Indexer {
     private StringBuilder buffer;
     private HashMap<String, Index> indexes = new HashMap<String, Index>();
     private HashMap<String, BTreePage> modified = new HashMap<String, BTreePage>();
+    private SimpleLRUCache<String, BTreePage> cache = SimpleLRUCache.newInstance(100);
     private String readRevision;
 
     public Indexer(MicroKernel mk, String indexRootNode) {
@@ -137,6 +139,11 @@ public class Indexer {
         if (page != null) {
             return page;
         }
+        String cacheId = p + "@" + revision;
+        page = cache.get(cacheId);
+        if (page != null) {
+            return page;
+        }
         String json = mk.getNodes(p, revision, 0, 0, 0);
         if (json == null) {
             page = new BTreeLeaf(tree, parent, name,
@@ -159,6 +166,7 @@ public class Indexer {
                 page = leaf;
             }
         }
+        cache.put(cacheId, page);
         return page;
     }
 



Mime
View raw message