lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject [Lucene.Net] svn commit: r1096677 - in /incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core: Index/BufferedDeletes.cs Index/DocFieldConsumers.cs Index/DocumentsWriter.cs Index/SegmentReader.cs Index/TermsHash.cs SupportClass.cs
Date Tue, 26 Apr 2011 07:05:56 GMT
Author: digy
Date: Tue Apr 26 07:05:56 2011
New Revision: 1096677

URL: http://svn.apache.org/viewvc?rev=1096677&view=rev
Log:
[LUCENENET-412] 
"public class Dictionary<K, V> : System.Collections.Generic.IDictionary<K, V>"
added to SupportClass
Since it doesn't support non-generic GetEnumerator, it is easier to debug.

Modified:
    incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Index/BufferedDeletes.cs
    incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Index/DocFieldConsumers.cs
    incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Index/DocumentsWriter.cs
    incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Index/SegmentReader.cs
    incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Index/TermsHash.cs
    incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/SupportClass.cs

Modified: incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Index/BufferedDeletes.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Index/BufferedDeletes.cs?rev=1096677&r1=1096676&r2=1096677&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Index/BufferedDeletes.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Index/BufferedDeletes.cs Tue
Apr 26 07:05:56 2011
@@ -18,6 +18,8 @@
 using System;
 using System.Collections.Generic;
 
+using Lucene.Net.Search;
+
 namespace Lucene.Net.Index
 {
 	
@@ -32,9 +34,9 @@ namespace Lucene.Net.Index
 	class BufferedDeletes
 	{
 		internal int numTerms;
-        internal System.Collections.IDictionary terms = null;
-		internal System.Collections.Hashtable queries = new System.Collections.Hashtable();
-		internal System.Collections.ArrayList docIDs = new System.Collections.ArrayList();
+        internal IDictionary<Term, Num> terms = null;
+        internal SupportClass.Dictionary<Query, int> queries = new SupportClass.Dictionary<Query,
int>();
+        internal List<int> docIDs = new List<int>();
 		internal long bytesUsed;
         internal  bool doTermSort;
 
@@ -43,15 +45,14 @@ namespace Lucene.Net.Index
             this.doTermSort = doTermSort;
             if (doTermSort)
             {
-                terms = new SortedDictionary<object, object>();
+                terms = new SupportClass.Dictionary<Term, Num>(true);
             }
             else
             {
-                terms = new System.Collections.Hashtable();
+                terms = new SupportClass.Dictionary<Term, Num>();
             }
         }
-                
-		
+
 		// Number of documents a delete term applies to.
 		internal sealed class Num
 		{
@@ -93,17 +94,17 @@ namespace Lucene.Net.Index
 		{
 			numTerms += in_Renamed.numTerms;
 			bytesUsed += in_Renamed.bytesUsed;
-
-			System.Collections.ArrayList keys = new System.Collections.ArrayList(in_Renamed.terms.Keys);
-			System.Collections.ArrayList values = new System.Collections.ArrayList(in_Renamed.terms.Values);
-			for (int i=0; i < keys.Count; i++)
-				terms[keys[i]] = values[i];
-
-			keys = new System.Collections.ArrayList(in_Renamed.queries.Keys);
-			values = new System.Collections.ArrayList(in_Renamed.queries.Values);
-			for (int i=0; i < keys.Count; i++)
-				queries[keys[i]] = values[i];
-
+                        
+            foreach(KeyValuePair<Term,Num> kv in in_Renamed.terms)
+            {
+                terms[kv.Key] = in_Renamed.terms[kv.Key];
+            }
+			
+			foreach (KeyValuePair<Query, int> kv in in_Renamed.queries)
+            {
+                queries[kv.Key] = in_Renamed.queries[kv.Key];
+            }
+			
 			docIDs.AddRange(in_Renamed.docIDs);
 			in_Renamed.Clear();
 		}
@@ -133,60 +134,56 @@ namespace Lucene.Net.Index
 		{
 			lock (this)
 			{
-				
-				System.Collections.IDictionary newDeleteTerms;
+
+                System.Collections.Generic.IDictionary<Term, Num> newDeleteTerms;
 				
 				// Remap delete-by-term
 				if (terms.Count > 0)
 				{
                     if (doTermSort)
                     {
-                        newDeleteTerms = new SortedDictionary<object, object>();
+                        newDeleteTerms = new SupportClass.Dictionary<Term, Num>(true);
                     }
                     else
                     {
-                        newDeleteTerms = new System.Collections.Hashtable();
+                        newDeleteTerms = new SupportClass.Dictionary<Term, Num>();
+                    }
+                    foreach (KeyValuePair<Term, Num> entry in terms)
+                    {
+                        Num num = entry.Value;
+                        newDeleteTerms[entry.Key] = new Num(mapper.Remap(num.GetNum()));
                     }
-					System.Collections.IEnumerator iter = new System.Collections.Hashtable(terms).GetEnumerator();
-					while (iter.MoveNext())
-					{
-						System.Collections.DictionaryEntry entry = (System.Collections.DictionaryEntry) iter.Current;
-						Num num = (Num) entry.Value;
-						newDeleteTerms[entry.Key] = new Num(mapper.Remap(num.GetNum()));
-					}
 				}
 				else
 					newDeleteTerms = null;
 				
 				// Remap delete-by-docID
-				System.Collections.ArrayList newDeleteDocIDs;
+				List<int> newDeleteDocIDs;
 				
 				if (docIDs.Count > 0)
 				{
-					newDeleteDocIDs = new System.Collections.ArrayList(docIDs.Count);
-					System.Collections.IEnumerator iter = docIDs.GetEnumerator();
+					newDeleteDocIDs = new List<int>(docIDs.Count);
+					System.Collections.Generic.IEnumerator<int> iter = docIDs.GetEnumerator();
 					while (iter.MoveNext())
 					{
-						System.Int32 num = (System.Int32) iter.Current;
-						newDeleteDocIDs.Add((System.Int32) mapper.Remap(num));
+						int num = iter.Current;
+						newDeleteDocIDs.Add(mapper.Remap(num));
 					}
 				}
 				else
 					newDeleteDocIDs = null;
 				
 				// Remap delete-by-query
-				System.Collections.Hashtable newDeleteQueries;
+                SupportClass.Dictionary<Query, int> newDeleteQueries;
 				
 				if (queries.Count > 0)
 				{
-					newDeleteQueries = new System.Collections.Hashtable(queries.Count);
-					System.Collections.IEnumerator iter = new System.Collections.Hashtable(queries).GetEnumerator();
-					while (iter.MoveNext())
-					{
-						System.Collections.DictionaryEntry entry = (System.Collections.DictionaryEntry) iter.Current;
-						System.Int32 num = (System.Int32) entry.Value;
-						newDeleteQueries[entry.Key] = (System.Int32) mapper.Remap(num);
-					}
+                    newDeleteQueries = new SupportClass.Dictionary<Query, int>(queries.Count);
+                    foreach(KeyValuePair<Query,int> entry in queries)
+                    {
+                        int num = entry.Value;
+                        newDeleteQueries[entry.Key] = mapper.Remap(num);
+                    }
 				}
 				else
 					newDeleteQueries = null;

Modified: incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Index/DocFieldConsumers.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Index/DocFieldConsumers.cs?rev=1096677&r1=1096676&r2=1096677&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Index/DocFieldConsumers.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Index/DocFieldConsumers.cs Tue
Apr 26 07:05:56 2011
@@ -55,16 +55,12 @@ namespace Lucene.Net.Index
 
             SupportClass.Dictionary<DocFieldConsumerPerThread, IList<DocFieldConsumerPerField>>
oneThreadsAndFields = new SupportClass.Dictionary<DocFieldConsumerPerThread, IList<DocFieldConsumerPerField>>();
             SupportClass.Dictionary<DocFieldConsumerPerThread, IList<DocFieldConsumerPerField>>
twoThreadsAndFields = new SupportClass.Dictionary<DocFieldConsumerPerThread, IList<DocFieldConsumerPerField>>();
-			
-			System.Collections.IEnumerator it = new System.Collections.Hashtable(threadsAndFields).GetEnumerator();
-			while (it.MoveNext())
-			{
-				
-				System.Collections.DictionaryEntry entry = (System.Collections.DictionaryEntry) it.Current;
-				
-				DocFieldConsumersPerThread perThread = (DocFieldConsumersPerThread) entry.Key;
+
+            foreach (KeyValuePair<DocFieldConsumerPerThread, IList<DocFieldConsumerPerField>>
entry in new SupportClass.Dictionary<DocFieldConsumerPerThread, IList<DocFieldConsumerPerField>>(threadsAndFields))
+            {
+            	DocFieldConsumersPerThread perThread = (DocFieldConsumersPerThread) entry.Key;
 				
-				System.Collections.ICollection fields = (System.Collections.ICollection) entry.Value;
+				IList<DocFieldConsumerPerField> fields = entry.Value;
 				
 				System.Collections.IEnumerator fieldsIt = fields.GetEnumerator();
                 IList<DocFieldConsumerPerField> oneFields = new List<DocFieldConsumerPerField>();

Modified: incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Index/DocumentsWriter.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Index/DocumentsWriter.cs?rev=1096677&r1=1096676&r2=1096677&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Index/DocumentsWriter.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Index/DocumentsWriter.cs Tue
Apr 26 07:05:56 2011
@@ -1136,7 +1136,7 @@ namespace Lucene.Net.Index
 		}
 		
 		// for testing
-		internal System.Collections.IDictionary GetBufferedDeleteTerms()
+		internal System.Collections.Generic.IDictionary<Term,BufferedDeletes.Num> GetBufferedDeleteTerms()
 		{
 			lock (this)
 			{
@@ -1342,20 +1342,17 @@ namespace Lucene.Net.Index
                 System.Diagnostics.Debug.Assert(CheckDeleteTerm(null));
 
 				// Delete by term
-                //System.Collections.IEnumerator iter = new System.Collections.Hashtable(deletesFlushed.terms).GetEnumerator();
-				System.Collections.IEnumerator iter = deletesFlushed.terms.GetEnumerator();
 				TermDocs docs = reader.TermDocs();
 				try
 				{
-					while (iter.MoveNext())
+                    foreach(KeyValuePair<Term,BufferedDeletes.Num> entry in deletesFlushed.terms)
 					{
-						System.Collections.DictionaryEntry entry = (System.Collections.DictionaryEntry) iter.Current;
-						Term term = (Term) entry.Key;
+						Term term = entry.Key;
 						// LUCENE-2086: we should be iterating a TreeMap,
                         // here, so terms better be in order:
                         System.Diagnostics.Debug.Assert(CheckDeleteTerm(term));
 						docs.Seek(term);
-						int limit = ((BufferedDeletes.Num) entry.Value).GetNum();
+						int limit = entry.Value.GetNum();
 						while (docs.Next())
 						{
 							int docID = docs.Doc();
@@ -1372,10 +1369,8 @@ namespace Lucene.Net.Index
 				}
 				
 				// Delete by docID
-				iter = deletesFlushed.docIDs.GetEnumerator();
-				while (iter.MoveNext())
+                foreach(int docID in deletesFlushed.docIDs)
 				{
-					int docID = ((System.Int32) iter.Current);
 					if (docID >= docIDStart && docID < docEnd)
 					{
 						reader.DeleteDocument(docID - docIDStart);
@@ -1385,12 +1380,10 @@ namespace Lucene.Net.Index
 				
 				// Delete by query
 				IndexSearcher searcher = new IndexSearcher(reader);
-				iter = new System.Collections.Hashtable(deletesFlushed.queries).GetEnumerator();
-				while (iter.MoveNext())
+                foreach(KeyValuePair<Query,int> entry in new SupportClass.Dictionary<Query,int>(deletesFlushed.queries))
 				{
-					System.Collections.DictionaryEntry entry = (System.Collections.DictionaryEntry) iter.Current;
-					Query query = (Query) entry.Key;
-					int limit = ((System.Int32) entry.Value);
+					Query query = entry.Key;
+					int limit = entry.Value;
 					Weight weight = query.Weight(searcher);
 					Scorer scorer = weight.Scorer(reader, true, false);
 					if (scorer != null)
@@ -1418,7 +1411,9 @@ namespace Lucene.Net.Index
 		{
 			lock (this)
 			{
-				BufferedDeletes.Num num = (BufferedDeletes.Num) deletesInRAM.terms[term];
+				//BufferedDeletes.Num num = deletesInRAM.terms[term];
+                //BufferedDeletes.Num num =  ((SupportClass.Dictionary<Term,BufferedDeletes.Num>)
deletesInRAM.terms)[term];
+                BufferedDeletes.Num num = deletesInRAM.terms[term];
 				int docIDUpto = flushedDocCount + docCount;
 				if (num == null)
 					deletesInRAM.terms[term] = new BufferedDeletes.Num(docIDUpto);

Modified: incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Index/SegmentReader.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Index/SegmentReader.cs?rev=1096677&r1=1096676&r2=1096677&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Index/SegmentReader.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Index/SegmentReader.cs Tue Apr
26 07:05:56 2011
@@ -1817,7 +1817,7 @@ namespace Lucene.Net.Index
 			}
 		}
 
-        public System.Collections.IDictionary norms_ForNUnit
+        public IDictionary<string, Norm> norms_ForNUnit
         {
             get { return norms; }
         }

Modified: incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Index/TermsHash.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Index/TermsHash.cs?rev=1096677&r1=1096676&r2=1096677&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Index/TermsHash.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Index/TermsHash.cs Tue Apr 26
07:05:56 2011
@@ -87,8 +87,8 @@ namespace Lucene.Net.Index
 			if (nextTermsHash != null)
 				nextTermsHash.Abort();
 		}
-		
-		internal void  ShrinkFreePostings(System.Collections.IDictionary threadsAndFields, SegmentWriteState
state)
+
+        internal void ShrinkFreePostings(IDictionary<InvertedDocConsumerPerThread, IList<InvertedDocConsumerPerField>>
threadsAndFields, SegmentWriteState state)
 		{
 			
 			System.Diagnostics.Debug.Assert(postingsFreeCount == postingsAllocCount, "Thread.currentThread().getName()"
+ ": postingsFreeCount=" + postingsFreeCount + " postingsAllocCount=" + postingsAllocCount
+ " consumer=" + consumer);

Modified: incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/SupportClass.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/SupportClass.cs?rev=1096677&r1=1096676&r2=1096677&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/SupportClass.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/SupportClass.cs Tue Apr 26 07:05:56
2011
@@ -1406,35 +1406,127 @@ public class SupportClass
     }
     #endregion
 
-    public class Dictionary<K, V> : System.Collections.Generic.Dictionary<K, V>
+    public class Dictionary<K, V> : System.Collections.Generic.IDictionary<K, V>
     {
-        public Dictionary() : base()
+        System.Collections.Generic.IDictionary<K, V> _Dict = null;
+
+        public Dictionary()
         {
+            _Dict = new System.Collections.Generic.Dictionary<K, V>();
         }
 
-        public Dictionary(System.Collections.Generic.Dictionary<K, V> dict) : base(dict)
+        public Dictionary(bool sortedDictionary)
         {
+            _Dict = new System.Collections.Generic.SortedDictionary<K, V>();
         }
 
-        public Dictionary(int capacity) : base(capacity)
+        public Dictionary(int capacity)
         {
+            _Dict = new System.Collections.Generic.Dictionary<K, V>(capacity);
         }
 
-        public new V this[K key]
+        public Dictionary(System.Collections.Generic.IDictionary<K,V> dict)
+        {
+            _Dict = new System.Collections.Generic.Dictionary<K, V>(dict);
+        }
+
+        public Dictionary(Dictionary<K, V> dict)
+        {
+            _Dict = new System.Collections.Generic.Dictionary<K, V>(dict);
+        }
+
+
+
+        public void Add(K key, V value)
+        {
+            _Dict.Add(key, value);
+        }
+
+        public bool ContainsKey(K key)
+        {
+            return _Dict.ContainsKey(key);
+        }
+
+        public System.Collections.Generic.ICollection<K> Keys
+        {
+            get { return _Dict.Keys; }
+        }
+
+        public bool Remove(K key)
+        {
+            return _Dict.Remove(key);
+        }
+
+        public bool TryGetValue(K key, out V value)
+        {
+            return _Dict.TryGetValue(key, out value);
+        }
+
+        public System.Collections.Generic.ICollection<V> Values
+        {
+            get { return _Dict.Values; }
+        }
+
+        public V this[K key]
         {
-            set
-            {
-                base[key] = value;
-            }
             get
             {
                 V val = default(V);
-                base.TryGetValue(key, out val);
+                _Dict.TryGetValue(key, out val);
                 return val;
             }
+            set
+            {
+                _Dict[key] = value;
+            }
+        }
+
+        public void Add(System.Collections.Generic.KeyValuePair<K, V> item)
+        {
+            throw new NotImplementedException();
+        }
+
+        public void Clear()
+        {
+            _Dict.Clear();
+        }
+
+        public bool Contains(System.Collections.Generic.KeyValuePair<K, V> item)
+        {
+            throw new NotImplementedException();
+        }
+
+        public void CopyTo(System.Collections.Generic.KeyValuePair<K, V>[] array, int
arrayIndex)
+        {
+            throw new NotImplementedException();
         }
-    }
 
+        public int Count
+        {
+            get { return _Dict.Count; }
+        }
+
+        public bool IsReadOnly
+        {
+            get { return false; }
+        }
+
+        public bool Remove(System.Collections.Generic.KeyValuePair<K, V> item)
+        {
+            throw new NotImplementedException();
+        }
+
+        public System.Collections.Generic.IEnumerator<System.Collections.Generic.KeyValuePair<K,
V>> GetEnumerator()
+        {
+            return _Dict.GetEnumerator();
+        }
+
+        IEnumerator IEnumerable.GetEnumerator()
+        {
+            throw new NotImplementedException();
+        }
+    }
+    
     [Serializable]
     public class Set<T> : System.Collections.Generic.List<T>
     {



Mime
View raw message