lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From synhers...@apache.org
Subject svn commit: r1388982 - in /lucene.net/trunk: src/contrib/Spatial/Util/CompatibilityExtensions.cs test/contrib/Spatial/SpatialTestCase.cs
Date Sun, 23 Sep 2012 09:03:51 GMT
Author: synhershko
Date: Sun Sep 23 09:03:51 2012
New Revision: 1388982

URL: http://svn.apache.org/viewvc?rev=1388982&view=rev
Log:
Make sure to purge all caches in the spatial module between tests

Modified:
    lucene.net/trunk/src/contrib/Spatial/Util/CompatibilityExtensions.cs
    lucene.net/trunk/test/contrib/Spatial/SpatialTestCase.cs

Modified: lucene.net/trunk/src/contrib/Spatial/Util/CompatibilityExtensions.cs
URL: http://svn.apache.org/viewvc/lucene.net/trunk/src/contrib/Spatial/Util/CompatibilityExtensions.cs?rev=1388982&r1=1388981&r2=1388982&view=diff
==============================================================================
--- lucene.net/trunk/src/contrib/Spatial/Util/CompatibilityExtensions.cs (original)
+++ lucene.net/trunk/src/contrib/Spatial/Util/CompatibilityExtensions.cs Sun Sep 23 09:03:51
2012
@@ -47,6 +47,26 @@ namespace Lucene.Net.Spatial.Util
 			return _docsWithFieldCache.GetOrAdd(field, f => DocsWithFieldCacheEntry_CreateValue(reader,
new Entry(field, null), false));
 		}
 
+        /// <summary> <p/>
+        /// EXPERT: Instructs the FieldCache to forcibly expunge all entries 
+        /// from the underlying caches.  This is intended only to be used for 
+        /// test methods as a way to ensure a known base state of the Cache 
+        /// (with out needing to rely on GC to free WeakReferences).  
+        /// It should not be relied on for "Cache maintenance" in general 
+        /// application code.
+        /// <p/>
+        /// <p/>
+        /// <b>EXPERIMENTAL API:</b> This API is considered extremely advanced

+        /// and experimental.  It may be removed or altered w/o warning in future 
+        /// releases 
+        /// of Lucene.
+        /// <p/>
+        /// </summary>
+        public static void PurgeSpatialCaches(this FieldCache fc)
+        {
+            _docsWithFieldCache.Clear();
+        }
+
 		private static IBits DocsWithFieldCacheEntry_CreateValue(IndexReader reader, Entry entryKey,
bool setDocsWithField /* ignored */)
 		{
 			var field = entryKey.field;

Modified: lucene.net/trunk/test/contrib/Spatial/SpatialTestCase.cs
URL: http://svn.apache.org/viewvc/lucene.net/trunk/test/contrib/Spatial/SpatialTestCase.cs?rev=1388982&r1=1388981&r2=1388982&view=diff
==============================================================================
--- lucene.net/trunk/test/contrib/Spatial/SpatialTestCase.cs (original)
+++ lucene.net/trunk/test/contrib/Spatial/SpatialTestCase.cs Sun Sep 23 09:03:51 2012
@@ -23,6 +23,7 @@ using Lucene.Net.Analysis;
 using Lucene.Net.Documents;
 using Lucene.Net.Index;
 using Lucene.Net.Search;
+using Lucene.Net.Spatial.Util;
 using Lucene.Net.Store;
 using Lucene.Net.Util;
 using NUnit.Framework;
@@ -65,6 +66,7 @@ namespace Lucene.Net.Contrib.Spatial.Tes
 				directory.Dispose();
 				directory = null;
 			}
+            CompatibilityExtensions.PurgeSpatialCaches(null);
 			base.TearDown();
 		}
 		// ================================================= Helper Methods ================================================



Mime
View raw message