You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by sh...@apache.org on 2011/10/05 15:21:22 UTC

svn commit: r1179213 - /lucene/dev/branches/branch_3x/lucene/contrib/facet/src/java/org/apache/lucene/facet/taxonomy/lucene/LuceneTaxonomyReader.java

Author: shaie
Date: Wed Oct  5 13:21:22 2011
New Revision: 1179213

URL: http://svn.apache.org/viewvc?rev=1179213&view=rev
Log:
rename two private members in LuceneTaxonomyReader

Modified:
    lucene/dev/branches/branch_3x/lucene/contrib/facet/src/java/org/apache/lucene/facet/taxonomy/lucene/LuceneTaxonomyReader.java

Modified: lucene/dev/branches/branch_3x/lucene/contrib/facet/src/java/org/apache/lucene/facet/taxonomy/lucene/LuceneTaxonomyReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/lucene/contrib/facet/src/java/org/apache/lucene/facet/taxonomy/lucene/LuceneTaxonomyReader.java?rev=1179213&r1=1179212&r2=1179213&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/lucene/contrib/facet/src/java/org/apache/lucene/facet/taxonomy/lucene/LuceneTaxonomyReader.java (original)
+++ lucene/dev/branches/branch_3x/lucene/contrib/facet/src/java/org/apache/lucene/facet/taxonomy/lucene/LuceneTaxonomyReader.java Wed Oct  5 13:21:22 2011
@@ -65,7 +65,7 @@ public class LuceneTaxonomyReader implem
   private ReadWriteLock indexReaderLock = new ReentrantReadWriteLock();
 
   // The following are the limited-size LRU caches used to cache the latest
-  // results from getOrdinal() and getCategoryCache().
+  // results from getOrdinal() and getLabel().
   // Because LRUHashMap is not thread-safe, we need to synchronize on this
   // object when using it. Unfortunately, this is not optimal under heavy
   // contention because it means that while one thread is using the cache
@@ -78,8 +78,8 @@ public class LuceneTaxonomyReader implem
   // the mistake of locking out readers while waiting for disk in a cache
   // miss - below, we do not hold cache lock while reading missing data from
   // disk.
-  private final LRUHashMap<String, Integer> getOrdinalCache;
-  private final LRUHashMap<Integer, String> getCategoryCache;
+  private final LRUHashMap<String, Integer> ordinalCache;
+  private final LRUHashMap<Integer, String> categoryCache;
 
   // getParent() needs to be extremely efficient, to the point that we need
   // to fetch all the data in advance into memory, and answer these calls
@@ -113,10 +113,10 @@ public class LuceneTaxonomyReader implem
 
     // These are the default cache sizes; they can be configured after
     // construction with the cache's setMaxSize() method
-    getOrdinalCache = new LRUHashMap<String, Integer>(4000);
-    getCategoryCache = new LRUHashMap<Integer, String>(4000);
+    ordinalCache = new LRUHashMap<String, Integer>(4000);
+    categoryCache = new LRUHashMap<Integer, String>(4000);
 
-    // TODO (Facet): consider lazily create parent array it when asked, not in the constructor
+    // TODO (Facet): consider lazily create parent array when asked, not in the constructor
     parentArray = new ParentArray();
     parentArray.refresh(indexReader);
   }
@@ -145,11 +145,11 @@ public class LuceneTaxonomyReader implem
    */
   public void setCacheSize(int size) {
     ensureOpen();
-    synchronized(getCategoryCache) {
-      getCategoryCache.setMaxSize(size);
+    synchronized(categoryCache) {
+      categoryCache.setMaxSize(size);
     }
-    synchronized(getOrdinalCache) {
-      getOrdinalCache.setMaxSize(size);
+    synchronized(ordinalCache) {
+      ordinalCache.setMaxSize(size);
     }
   }
 
@@ -176,8 +176,8 @@ public class LuceneTaxonomyReader implem
     String path = categoryPath.toString(delimiter);
 
     // First try to find the answer in the LRU cache:
-    synchronized(getOrdinalCache) {
-      Integer res = getOrdinalCache.get(path);
+    synchronized(ordinalCache) {
+      Integer res = ordinalCache.get(path);
       if (res!=null) {
         return res.intValue();
       }
@@ -201,10 +201,10 @@ public class LuceneTaxonomyReader implem
     // other thread already added the same category to the cache. We do
     // not care about this possibilty, as LRUCache replaces previous values
     // of the same keys (it doesn't store duplicates).
-    synchronized(getOrdinalCache) {
+    synchronized(ordinalCache) {
       // GB: new Integer(int); creates a new object each and every time.
       // Integer.valueOf(int) might not (See JavaDoc). 
-      getOrdinalCache.put(path, Integer.valueOf(ret));
+      ordinalCache.put(path, Integer.valueOf(ret));
     }
 
     return ret;
@@ -212,7 +212,7 @@ public class LuceneTaxonomyReader implem
 
   public CategoryPath getPath(int ordinal) throws CorruptIndexException, IOException {
     ensureOpen();
-    // TODO (Facet): Currently, the LRU cache we use (getCategoryCache) holds
+    // TODO (Facet): Currently, the LRU cache we use (categoryCache) holds
     // strings with delimiters, not CategoryPath objects, so even if
     // we have a cache hit, we need to process the string and build a new
     // CategoryPath object every time. What is preventing us from putting
@@ -248,8 +248,8 @@ public class LuceneTaxonomyReader implem
     // Integer.valueOf(int) might not (See JavaDoc). 
     Integer catIDInteger = Integer.valueOf(catID);
 
-    synchronized(getCategoryCache) {
-      String res = getCategoryCache.get(catIDInteger);
+    synchronized(categoryCache) {
+      String res = categoryCache.get(catIDInteger);
       if (res!=null) {
         return res;
       }
@@ -280,8 +280,8 @@ public class LuceneTaxonomyReader implem
     // other thread already added the same category to the cache. We do
     // not care about this possibility, as LRUCache replaces previous
     // values of the same keys (it doesn't store duplicates).
-    synchronized (getCategoryCache) {
-      getCategoryCache.put(catIDInteger, ret);
+    synchronized (categoryCache) {
+      categoryCache.put(catIDInteger, ret);
     }
 
     return ret;
@@ -382,7 +382,7 @@ public class LuceneTaxonomyReader implem
 
       // Remove any INVALID_ORDINAL values from the ordinal cache,
       // because it is possible those are now answered by the new data!
-      Iterator<Entry<String, Integer>> i = getOrdinalCache.entrySet().iterator();
+      Iterator<Entry<String, Integer>> i = ordinalCache.entrySet().iterator();
       while (i.hasNext()) {
         Entry<String, Integer> e = i.next();
         if (e.getValue().intValue() == INVALID_ORDINAL) {
@@ -406,8 +406,8 @@ public class LuceneTaxonomyReader implem
 
     parentArray = null;
     childrenArrays = null;
-    getCategoryCache.clear();
-    getOrdinalCache.clear();
+    categoryCache.clear();
+    ordinalCache.clear();
   }
 
   public int getSize() {