jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r1004568 - in /jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core: NamespaceRegistryImpl.java persistence/util/HashMapIndex.java persistence/util/HashMapIndex.java.orig
Date Tue, 05 Oct 2010 08:25:28 GMT
Author: jukka
Date: Tue Oct  5 08:25:28 2010
New Revision: 1004568

URL: http://svn.apache.org/viewvc?rev=1004568&view=rev
Log:
JCR-2760: Use hash codes instead of sequence numbers for string indexes

Added:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/util/HashMapIndex.java.orig
      - copied, changed from r1004263, jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/util/HashMapIndex.java
Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NamespaceRegistryImpl.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/util/HashMapIndex.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NamespaceRegistryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NamespaceRegistryImpl.java?rev=1004568&r1=1004567&r2=1004568&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NamespaceRegistryImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NamespaceRegistryImpl.java
Tue Oct  5 08:25:28 2010
@@ -91,8 +91,6 @@ public class NamespaceRegistryImpl imple
     private HashMap<Integer, String> indexToURI = new HashMap<Integer, String>();
     private HashMap<String, Integer> uriToIndex = new HashMap<String, Integer>();
 
-    private int lastIndex;
-
     private final FileSystem nsRegStore;
 
     /**
@@ -143,10 +141,11 @@ public class NamespaceRegistryImpl imple
         uriToPrefix.put(uri, prefix);
         if (!uriToIndex.containsKey(uri)) {
             if (idx == null) {
-                idx = ++lastIndex;
-            } else {
-                if (idx.intValue() > lastIndex) {
-                    lastIndex = idx.intValue();
+                // Need to use only 24 bits, since that's what
+                // the BundleBinding class stores in bundles
+                idx = uri.hashCode() & 0x00ffffff;
+                while (indexToURI.containsKey(idx)) {
+                    idx = (idx + 1) & 0x00ffffff;
                 }
             }
             indexToURI.put(idx, uri);
@@ -339,7 +338,7 @@ public class NamespaceRegistryImpl imple
         if (idx == null) {
             throw new IllegalArgumentException("Namespace not registered: " + uri);
         }
-        return idx.intValue();
+        return idx;
     }
 
     /**

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/util/HashMapIndex.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/util/HashMapIndex.java?rev=1004568&r1=1004567&r2=1004568&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/util/HashMapIndex.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/util/HashMapIndex.java
Tue Oct  5 08:25:28 2010
@@ -66,12 +66,17 @@ public class HashMapIndex implements Str
             idx = stringToIndex.get(nsUri);
         }
         if (idx == null) {
-            idx = Integer.valueOf(indexToString.size());
+            // Need to use only 24 bits, since that's what
+            // the BundleBinding class stores in bundles
+            idx = nsUri.hashCode() & 0x00ffffff;
+            while (indexToString.containsKey(idx)) {
+                idx = (idx + 1) & 0x00ffffff;
+            }
             stringToIndex.put(nsUri, idx);
             indexToString.put(idx, nsUri);
             save();
         }
-        return idx.intValue();
+        return idx;
     }
 
     /**

Copied: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/util/HashMapIndex.java.orig
(from r1004263, jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/util/HashMapIndex.java)
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/util/HashMapIndex.java.orig?p2=jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/util/HashMapIndex.java.orig&p1=jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/util/HashMapIndex.java&r1=1004263&r2=1004568&rev=1004568&view=diff
==============================================================================
    (empty)



Mime
View raw message