lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From synhers...@apache.org
Subject [37/46] lucenenet git commit: In Facet.Taxonomy.WriterCache.NameIntCacheLRU, renamed Size and MaxSize to Count and Capacity (.NETified)
Date Tue, 04 Oct 2016 20:02:07 GMT
In Facet.Taxonomy.WriterCache.NameIntCacheLRU, renamed Size and MaxSize to Count and Capacity
(.NETified)


Project: http://git-wip-us.apache.org/repos/asf/lucenenet/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucenenet/commit/007b217c
Tree: http://git-wip-us.apache.org/repos/asf/lucenenet/tree/007b217c
Diff: http://git-wip-us.apache.org/repos/asf/lucenenet/diff/007b217c

Branch: refs/heads/master
Commit: 007b217c72ae728b8a55ee76e3d747cf9dfc88ce
Parents: 6475006
Author: Shad Storhaug <shad@shadstorhaug.com>
Authored: Sun Sep 25 17:35:07 2016 +0700
Committer: Shad Storhaug <shad@shadstorhaug.com>
Committed: Mon Oct 3 23:32:04 2016 +0700

----------------------------------------------------------------------
 .../WriterCache/LruTaxonomyWriterCache.cs       |  2 +-
 .../Taxonomy/WriterCache/NameIntCacheLRU.cs     | 20 +++++++++++---------
 2 files changed, 12 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/007b217c/src/Lucene.Net.Facet/Taxonomy/WriterCache/LruTaxonomyWriterCache.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Facet/Taxonomy/WriterCache/LruTaxonomyWriterCache.cs b/src/Lucene.Net.Facet/Taxonomy/WriterCache/LruTaxonomyWriterCache.cs
index ad76ccd..7152094 100644
--- a/src/Lucene.Net.Facet/Taxonomy/WriterCache/LruTaxonomyWriterCache.cs
+++ b/src/Lucene.Net.Facet/Taxonomy/WriterCache/LruTaxonomyWriterCache.cs
@@ -85,7 +85,7 @@
             {
                 lock (this)
                 {
-                    return cache.Size == cache.MaxSize;
+                    return cache.Count == cache.Capacity;
                 }
             }
         }

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/007b217c/src/Lucene.Net.Facet/Taxonomy/WriterCache/NameIntCacheLRU.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Facet/Taxonomy/WriterCache/NameIntCacheLRU.cs b/src/Lucene.Net.Facet/Taxonomy/WriterCache/NameIntCacheLRU.cs
index e5c81e5..ca0011a 100644
--- a/src/Lucene.Net.Facet/Taxonomy/WriterCache/NameIntCacheLRU.cs
+++ b/src/Lucene.Net.Facet/Taxonomy/WriterCache/NameIntCacheLRU.cs
@@ -33,27 +33,27 @@ namespace Lucene.Net.Facet.Taxonomy.WriterCache
         private Dictionary<object, int?> cache;
         internal long nMisses = 0; // for debug
         internal long nHits = 0; // for debug
-        private int maxCacheSize;
+        private int capacity;
 
-        internal NameIntCacheLRU(int maxCacheSize)
+        internal NameIntCacheLRU(int capacity)
         {
-            this.maxCacheSize = maxCacheSize;
-            CreateCache(maxCacheSize);
+            this.capacity = capacity;
+            CreateCache(capacity);
         }
 
         /// <summary>
         /// Maximum number of cache entries before eviction. </summary>
-        public virtual int MaxSize
+        public virtual int Capacity
         {
             get
             {
-                return maxCacheSize;
+                return capacity;
             }
         }
 
         /// <summary>
         /// Number of entries currently in the cache. </summary>
-        public virtual int Size
+        public virtual int Count
         {
             get
             {
@@ -63,6 +63,8 @@ namespace Lucene.Net.Facet.Taxonomy.WriterCache
 
         private void CreateCache(int maxSize)
         {
+            // LUCENENET TODO: Create an adapter so we can plug in either a generic
+            // dictionary or LRUHashMap or alternatively make LRUHashMap implement IDictionary<TKey,
TValue>
             //if (maxSize < int.MaxValue)
             //{
             //    cache = new LRUHashMap<object,int?>(1000,true); //for LRU
@@ -120,7 +122,7 @@ namespace Lucene.Net.Facet.Taxonomy.WriterCache
         {
             get
             {
-                return cache.Count > maxCacheSize;
+                return cache.Count > capacity;
             }
         }
 
@@ -147,7 +149,7 @@ namespace Lucene.Net.Facet.Taxonomy.WriterCache
             {
                 return false;
             }
-            int n = cache.Count - (2 * maxCacheSize) / 3;
+            int n = cache.Count - (2 * capacity) / 3;
             if (n <= 0)
             {
                 return false;


Mime
View raw message