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: r1100634 - in /incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core: Index/ Search/ Search/Payloads/ Support/
Date Sat, 07 May 2011 21:36:56 GMT
Author: digy
Date: Sat May  7 21:36:56 2011
New Revision: 1100634

URL: http://svn.apache.org/viewvc?rev=1100634&view=rev
Log:
[LUCENENET-412]

Modified:
    incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Index/CheckIndex.cs
    incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Index/ParallelReader.cs
    incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Search/DisjunctionMaxQuery.cs
    incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Search/Payloads/PayloadNearQuery.cs
    incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Search/Payloads/PayloadSpanUtil.cs
    incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Search/Similarity.cs
    incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Support/Dictionary.cs

Modified: incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Index/CheckIndex.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Index/CheckIndex.cs?rev=1100634&r1=1100633&r2=1100634&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Index/CheckIndex.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Index/CheckIndex.cs Sat May 
7 21:36:56 2011
@@ -459,12 +459,11 @@ namespace Lucene.Net.Index
 				result.partial = true;
 				if (infoStream != null)
 					infoStream.Write("\nChecking only these segments:");
-				System.Collections.IEnumerator it = onlySegments.GetEnumerator();
-				while (it.MoveNext())
+                foreach(string s in onlySegments)
 				{
 					if (infoStream != null)
 					{
-						infoStream.Write(" " + it.Current);
+						infoStream.Write(" " + s);
 					}
 				}
                 foreach (string seg in onlySegments)
@@ -663,11 +662,9 @@ namespace Lucene.Net.Index
 				{
 					infoStream.Write("    test: field norms.........");
 				}
-				System.Collections.IEnumerator it = fieldNames.GetEnumerator();
 				byte[] b = new byte[reader.MaxDoc()];
-				while (it.MoveNext())
+                foreach(string fieldName in fieldNames)
 				{
-					System.String fieldName = (System.String) it.Current;
                     if (reader.HasNorms(fieldName))
                     {
                         reader.Norms(fieldName, b, 0);

Modified: incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Index/ParallelReader.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Index/ParallelReader.cs?rev=1100634&r1=1100633&r2=1100634&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Index/ParallelReader.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Index/ParallelReader.cs Sat May
 7 21:36:56 2011
@@ -49,7 +49,7 @@ namespace Lucene.Net.Index
         private List<IndexReader> readers = new List<IndexReader>();
         private List<bool> decrefOnClose = new List<bool>(); // remember which
subreaders to decRef on close
 		internal bool incRefReaders = false;
-		private System.Collections.SortedList fieldToReader = new System.Collections.SortedList();
+        private Support.Dictionary<string, IndexReader> fieldToReader = new Support.Dictionary<string,
IndexReader>(true);
         private Support.Dictionary<IndexReader, ICollection<String>> readerToFields
= new Support.Dictionary<IndexReader, ICollection<string>>();
         private List<IndexReader> storedFieldReaders = new List<IndexReader>();
 		
@@ -340,12 +340,10 @@ namespace Lucene.Net.Index
 		{
 			EnsureOpen();
             List<TermFreqVector> results = new List<TermFreqVector>();
-            System.Collections.IEnumerator i = new System.Collections.Hashtable(fieldToReader).GetEnumerator();
-			while (i.MoveNext())
+            foreach(KeyValuePair<string,IndexReader> e in fieldToReader)
 			{
-				System.Collections.DictionaryEntry e = (System.Collections.DictionaryEntry) i.Current;
-				System.String field = (System.String) e.Key;
-				IndexReader reader = (IndexReader) e.Value;
+				System.String field = e.Key;
+				IndexReader reader = e.Value;
 				TermFreqVector vector = reader.GetTermFreqVector(n, field);
 				if (vector != null)
 					results.Add(vector);
@@ -356,7 +354,7 @@ namespace Lucene.Net.Index
 		public override TermFreqVector GetTermFreqVector(int n, System.String field)
 		{
 			EnsureOpen();
-			IndexReader reader = ((IndexReader) fieldToReader[field]);
+			IndexReader reader = fieldToReader[field];
 			return reader == null?null:reader.GetTermFreqVector(n, field);
 		}
 		
@@ -364,7 +362,7 @@ namespace Lucene.Net.Index
 		public override void  GetTermFreqVector(int docNumber, System.String field, TermVectorMapper
mapper)
 		{
 			EnsureOpen();
-			IndexReader reader = ((IndexReader) fieldToReader[field]);
+			IndexReader reader = fieldToReader[field];
 			if (reader != null)
 			{
 				reader.GetTermFreqVector(docNumber, field, mapper);
@@ -375,12 +373,10 @@ namespace Lucene.Net.Index
 		{
 			EnsureOpen();
 
-            System.Collections.IEnumerator i = new System.Collections.Hashtable(fieldToReader).GetEnumerator();
-			while (i.MoveNext())
+            foreach(KeyValuePair<string,IndexReader> e in fieldToReader)
 			{
-				System.Collections.DictionaryEntry e = (System.Collections.DictionaryEntry) i.Current;
-				System.String field = (System.String) e.Key;
-				IndexReader reader = (IndexReader) e.Value;
+				System.String field = e.Key;
+				IndexReader reader = e.Value;
 				reader.GetTermFreqVector(docNumber, field, mapper);
 			}
 		}
@@ -388,28 +384,28 @@ namespace Lucene.Net.Index
 		public override bool HasNorms(System.String field)
 		{
 			EnsureOpen();
-			IndexReader reader = ((IndexReader) fieldToReader[field]);
+			IndexReader reader = fieldToReader[field];
 			return reader == null?false:reader.HasNorms(field);
 		}
 		
 		public override byte[] Norms(System.String field)
 		{
 			EnsureOpen();
-			IndexReader reader = ((IndexReader) fieldToReader[field]);
+			IndexReader reader = fieldToReader[field];
 			return reader == null?null:reader.Norms(field);
 		}
 		
 		public override void  Norms(System.String field, byte[] result, int offset)
 		{
 			EnsureOpen();
-			IndexReader reader = ((IndexReader) fieldToReader[field]);
+			IndexReader reader = fieldToReader[field];
 			if (reader != null)
 				reader.Norms(field, result, offset);
 		}
 		
 		protected internal override void  DoSetNorm(int n, System.String field, byte value_Renamed)
 		{
-			IndexReader reader = ((IndexReader) fieldToReader[field]);
+			IndexReader reader = fieldToReader[field];
 			if (reader != null)
 				reader.DoSetNorm(n, field, value_Renamed);
 		}
@@ -564,7 +560,7 @@ namespace Lucene.Net.Index
 				
 			}
 			private System.String field;
-			private System.Collections.IEnumerator fieldIterator;
+			private IEnumerator<string> fieldIterator;
 			private TermEnum termEnum;
 			
 			public ParallelTermEnum(ParallelReader enclosingInstance)
@@ -572,7 +568,7 @@ namespace Lucene.Net.Index
 				InitBlock(enclosingInstance);
 				try
 				{
-					field = ((System.String) Enclosing_Instance.fieldToReader.GetKey(0));
+					field = Enclosing_Instance.fieldToReader.FirstKey;
 				}
 				catch (ArgumentOutOfRangeException e)
 				{
@@ -580,14 +576,14 @@ namespace Lucene.Net.Index
 					return;
 				}
 				if (field != null)
-					termEnum = ((IndexReader) Enclosing_Instance.fieldToReader[field]).Terms();
+					termEnum = Enclosing_Instance.fieldToReader[field].Terms();
 			}
 			
 			public ParallelTermEnum(ParallelReader enclosingInstance, Term term)
 			{
 				InitBlock(enclosingInstance);
 				field = term.Field();
-				IndexReader reader = ((IndexReader) Enclosing_Instance.fieldToReader[field]);
+				IndexReader reader = Enclosing_Instance.fieldToReader[field];
 				if (reader != null)
 					termEnum = reader.Terms(term);
 			}
@@ -606,30 +602,21 @@ namespace Lucene.Net.Index
 				// find the next field with terms, if any
 				if (fieldIterator == null)
 				{
-                    System.Collections.Comparer comparer = System.Collections.Comparer.Default;
-                    System.Collections.SortedList newList = new System.Collections.SortedList();
-                    if (Enclosing_Instance.fieldToReader != null)
+                    List<string> tmpList = new List<string>();
+                    bool m = false;
+                    //JAVA: fieldIterator = fieldToReader.tailMap(field).keySet().iterator();
+                    //JAVA: fieldIterator.next();  // Skip field to get next one
+                    foreach (string key in Enclosing_Instance.fieldToReader.Keys)
                     {
-                        if (Enclosing_Instance.fieldToReader.Count > 0)
-                        {
-                            int index = 0;
-                            while (comparer.Compare(Enclosing_Instance.fieldToReader.GetKey(index),
field) < 0)
-                                index++;
-                            for (; index < Enclosing_Instance.fieldToReader.Count; index++)
-                            {
-                                newList.Add(Enclosing_Instance.fieldToReader.GetKey(index),
Enclosing_Instance.fieldToReader[Enclosing_Instance.fieldToReader.GetKey(index)]);
-                            }
-                        }
+                        if (key == field && m==false) m = true;
+                        if (m) tmpList.Add(key);
                     }
-
-                    fieldIterator = newList.Keys.GetEnumerator();
-                    fieldIterator.MoveNext();
-					System.Object generatedAux = fieldIterator.Current; // Skip field to get next one
+                    fieldIterator = tmpList.GetEnumerator();
 				}
 				while (fieldIterator.MoveNext())
 				{
-					field = ((System.String) fieldIterator.Current);
-					termEnum = ((IndexReader) Enclosing_Instance.fieldToReader[field]).Terms(new Term(field));
+					field =  fieldIterator.Current;
+					termEnum = Enclosing_Instance.fieldToReader[field].Terms(new Term(field));
 					Term term = termEnum.Term();
 					if (term != null && (System.Object) term.Field() == (System.Object) field)
 						return true;
@@ -705,7 +692,7 @@ namespace Lucene.Net.Index
 			
 			public virtual void  Seek(Term term)
 			{
-				IndexReader reader = ((IndexReader) Enclosing_Instance.fieldToReader[term.Field()]);
+				IndexReader reader = Enclosing_Instance.fieldToReader[term.Field()];
 				termDocs = reader != null?reader.TermDocs(term):null;
 			}
 			
@@ -773,7 +760,7 @@ namespace Lucene.Net.Index
 			
 			public override void  Seek(Term term)
 			{
-				IndexReader reader = ((IndexReader) Enclosing_Instance.fieldToReader[term.Field()]);
+				IndexReader reader = Enclosing_Instance.fieldToReader[term.Field()];
 				termDocs = reader != null?reader.TermPositions(term):null;
 			}
 			

Modified: incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Search/DisjunctionMaxQuery.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Search/DisjunctionMaxQuery.cs?rev=1100634&r1=1100633&r2=1100634&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Search/DisjunctionMaxQuery.cs
(original)
+++ incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Search/DisjunctionMaxQuery.cs
Sat May  7 21:36:56 2011
@@ -85,7 +85,7 @@ namespace Lucene.Net.Search
 		}
 
         /// <summary>An Iterator&lt;Query&gt; over the disjuncts </summary>
-		public virtual System.Collections.IEnumerator Iterator()
+		public virtual IEnumerator<Query> Iterator()
 		{
 			return disjuncts.GetEnumerator();
 		}
@@ -266,10 +266,10 @@ namespace Lucene.Net.Search
 		// inherit javadoc
 		public override void  ExtractTerms(Support.Set<Lucene.Net.Index.Term> terms)
 		{
-			for (System.Collections.IEnumerator iter = disjuncts.GetEnumerator(); iter.MoveNext();
)
-			{
-				((Query) iter.Current).ExtractTerms(terms);
-			}
+            foreach (Query q in disjuncts)
+            {
+                q.ExtractTerms(terms);
+            }
 		}
 		
 		/// <summary>Prettyprint us.</summary>

Modified: incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Search/Payloads/PayloadNearQuery.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Search/Payloads/PayloadNearQuery.cs?rev=1100634&r1=1100633&r2=1100634&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Search/Payloads/PayloadNearQuery.cs
(original)
+++ incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Search/Payloads/PayloadNearQuery.cs
Sat May  7 21:36:56 2011
@@ -88,15 +88,15 @@ namespace Lucene.Net.Search.Payloads
 		{
 			System.Text.StringBuilder buffer = new System.Text.StringBuilder();
 			buffer.Append("payloadNear([");
-			System.Collections.IEnumerator i = clauses.GetEnumerator();
-			while (i.MoveNext())
+            int j = 0;
+            foreach (SpanQuery clause in clauses)
 			{
-				SpanQuery clause = (SpanQuery) i.Current;
+                j++;
 				buffer.Append(clause.ToString(field));
-				if (i.MoveNext())
-				{
-					buffer.Append(", ");
-				}
+                if (j < clauses.Count)
+                {
+                    buffer.Append(", ");
+                }
 			}
 			buffer.Append("], ");
 			buffer.Append(slop);

Modified: incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Search/Payloads/PayloadSpanUtil.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Search/Payloads/PayloadSpanUtil.cs?rev=1100634&r1=1100633&r2=1100634&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Search/Payloads/PayloadSpanUtil.cs
(original)
+++ incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Search/Payloads/PayloadSpanUtil.cs
Sat May  7 21:36:56 2011
@@ -124,11 +124,10 @@ namespace Lucene.Net.Search.Payloads
 			}
 			else if (query is DisjunctionMaxQuery)
 			{
-				
-				for (System.Collections.IEnumerator iterator = ((DisjunctionMaxQuery) query).Iterator();
iterator.MoveNext(); )
-				{
-					QueryToSpanQuery((Query) iterator.Current, payloads);
-				}
+                for (IEnumerator<Query> iterator = ((DisjunctionMaxQuery) query).Iterator();
iterator.MoveNext(); )
+                {
+                    QueryToSpanQuery(iterator.Current, payloads);
+                }
 			}
 			else if (query is MultiPhraseQuery)
 			{

Modified: incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Search/Similarity.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Search/Similarity.cs?rev=1100634&r1=1100633&r2=1100634&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Search/Similarity.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Search/Similarity.cs Sat May
 7 21:36:56 2011
@@ -717,10 +717,9 @@ namespace Lucene.Net.Search
 		public virtual float Idf(IList<Lucene.Net.Index.Term> terms, Searcher searcher)
 		{
 			float idf = 0.0f;
-			System.Collections.IEnumerator i = terms.GetEnumerator();
-			while (i.MoveNext())
+            foreach(Term term in terms)
 			{
-				idf += Idf((Term) i.Current, searcher);
+				idf += Idf(term, searcher);
 			}
 			return idf;
 		}

Modified: incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Support/Dictionary.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Support/Dictionary.cs?rev=1100634&r1=1100633&r2=1100634&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Support/Dictionary.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Support/Dictionary.cs Sat May
 7 21:36:56 2011
@@ -146,5 +146,17 @@ namespace Lucene.Net.Support
         {
             throw new NotImplementedException();
         }
+
+        public K FirstKey
+        {
+            get
+            {
+                foreach (K k in _Dict.Keys)
+                {
+                    return k;
+                }
+                return default(K);
+            }
+        }
     }
 }
\ No newline at end of file



Mime
View raw message