Return-Path: X-Original-To: apmail-lucene-lucene-net-commits-archive@www.apache.org Delivered-To: apmail-lucene-lucene-net-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 214AD9F09 for ; Sat, 12 Nov 2011 10:45:04 +0000 (UTC) Received: (qmail 81712 invoked by uid 500); 12 Nov 2011 10:45:03 -0000 Delivered-To: apmail-lucene-lucene-net-commits-archive@lucene.apache.org Received: (qmail 81644 invoked by uid 500); 12 Nov 2011 10:45:03 -0000 Mailing-List: contact lucene-net-commits-help@lucene.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: lucene-net-dev@lucene.apache.org Delivered-To: mailing list lucene-net-commits@lucene.apache.org Received: (qmail 81561 invoked by uid 99); 12 Nov 2011 10:45:03 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 12 Nov 2011 10:45:03 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 12 Nov 2011 10:44:58 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id CCCA22388A9C; Sat, 12 Nov 2011 10:44:38 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Date: Sat, 12 Nov 2011 10:44:27 -0000 To: lucene-net-commits@lucene.apache.org From: ccurrens@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20111112104438.CCCA22388A9C@eris.apache.org> Subject: [Lucene.Net] svn commit: r1201243 [4/8] - in /incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk: src/core/ src/core/Analysis/ src/core/Analysis/Standard/ src/core/Analysis/Tokenattributes/ src/core/Document/ src/core/Index/ src/core/QueryParser/ src/core/Search/... Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/FieldsReader.cs URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/FieldsReader.cs?rev=1201243&r1=1201242&r2=1201243&view=diff ============================================================================== --- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/FieldsReader.cs (original) +++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/FieldsReader.cs Sat Nov 12 10:44:21 2011 @@ -16,6 +16,7 @@ */ using System; +using Lucene.Net.Support; using Lucene.Net.Util; using TokenStream = Lucene.Net.Analysis.TokenStream; using Lucene.Net.Documents; @@ -433,9 +434,9 @@ namespace Lucene.Net.Index { int size = fieldsStream.ReadVInt(), bytesize = binary || compressed?size:2 * size; byte[] sizebytes = new byte[4]; - sizebytes[0] = (byte) (SupportClass.Number.URShift(bytesize, 24)); - sizebytes[1] = (byte) (SupportClass.Number.URShift(bytesize, 16)); - sizebytes[2] = (byte) (SupportClass.Number.URShift(bytesize, 8)); + sizebytes[0] = (byte) (Number.URShift(bytesize, 24)); + sizebytes[1] = (byte) (Number.URShift(bytesize, 16)); + sizebytes[2] = (byte) (Number.URShift(bytesize, 8)); sizebytes[3] = (byte) bytesize; doc.Add(new Field(fi.name, sizebytes, Field.Store.YES)); return size; Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/FreqProxFieldMergeState.cs URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/FreqProxFieldMergeState.cs?rev=1201243&r1=1201242&r2=1201243&view=diff ============================================================================== --- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/FreqProxFieldMergeState.cs (original) +++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/FreqProxFieldMergeState.cs Sat Nov 12 10:44:21 2011 @@ -16,6 +16,7 @@ */ using System; +using Lucene.Net.Support; namespace Lucene.Net.Index { @@ -101,7 +102,7 @@ namespace Lucene.Net.Index docID += code; else { - docID += SupportClass.Number.URShift(code, 1); + docID += Number.URShift(code, 1); if ((code & 1) != 0) termFreq = 1; else Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/FreqProxTermsWriterPerField.cs URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/FreqProxTermsWriterPerField.cs?rev=1201243&r1=1201242&r2=1201243&view=diff ============================================================================== --- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/FreqProxTermsWriterPerField.cs (original) +++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/FreqProxTermsWriterPerField.cs Sat Nov 12 10:44:21 2011 @@ -89,9 +89,9 @@ namespace Lucene.Net.Index internal override void Start(Fieldable f) { - if (fieldState.attributeSource.HasAttribute(typeof(PayloadAttribute))) + if (fieldState.attributeSource.HasAttribute()) { - payloadAttribute = (PayloadAttribute) fieldState.attributeSource.GetAttribute(typeof(PayloadAttribute)); + payloadAttribute = fieldState.attributeSource.GetAttribute(); } else { Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/IndexFileDeleter.cs URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/IndexFileDeleter.cs?rev=1201243&r1=1201242&r2=1201243&view=diff ============================================================================== --- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/IndexFileDeleter.cs (original) +++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/IndexFileDeleter.cs Sat Nov 12 10:44:21 2011 @@ -17,6 +17,7 @@ using System; using System.Collections.Generic; +using Lucene.Net.Support; using Directory = Lucene.Net.Store.Directory; namespace Lucene.Net.Index @@ -70,7 +71,7 @@ namespace Lucene.Net.Index //// Reference count for all files in the index. /// Counts how many existing commits reference a file. /// Maps String to RefCount (class below) instances: //// - private IDictionary refCounts = new SupportClass.HashMap(); + private IDictionary refCounts = new HashMap(); //// Holds all commits (segments_N) currently in the index. /// This will have just 1 commit if you are using the @@ -112,7 +113,7 @@ namespace Lucene.Net.Index private void Message(System.String message) { - infoStream.WriteLine("IFD [" + new DateTime().ToString() + "; " + SupportClass.ThreadClass.Current().Name + "]: " + message); + infoStream.WriteLine("IFD [" + new DateTime().ToString() + "; " + ThreadClass.Current().Name + "]: " + message); } /// Initialize the deleter: find all previous commits in Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/IndexFileNames.cs URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/IndexFileNames.cs?rev=1201243&r1=1201242&r2=1201243&view=diff ============================================================================== --- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/IndexFileNames.cs (original) +++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/IndexFileNames.cs Sat Nov 12 10:44:21 2011 @@ -16,6 +16,7 @@ */ using System; +using Lucene.Net.Support; namespace Lucene.Net.Index { @@ -139,7 +140,7 @@ namespace Lucene.Net.Index else { #if !PRE_LUCENE_NET_2_0_0_COMPATIBLE - return base_Renamed + "_" + SupportClass.Number.ToString(gen) + extension; + return base_Renamed + "_" + Number.ToString(gen) + extension; #else return base_Renamed + "_" + System.Convert.ToString(gen, 16) + extension; #endif Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/IndexWriter.cs URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/IndexWriter.cs?rev=1201243&r1=1201242&r2=1201243&view=diff ============================================================================== --- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/IndexWriter.cs (original) +++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/IndexWriter.cs Sat Nov 12 10:44:21 2011 @@ -17,6 +17,7 @@ using System; using System.Collections.Generic; +using Lucene.Net.Support; using Analyzer = Lucene.Net.Analysis.Analyzer; using Document = Lucene.Net.Documents.Document; using IndexingChain = Lucene.Net.Index.DocumentsWriter.IndexingChain; @@ -228,7 +229,7 @@ namespace Lucene.Net.Index private long lastCommitChangeCount; // last changeCount that was committed private SegmentInfos rollbackSegmentInfos; // segmentInfos we will fallback to if the commit fails - private SupportClass.HashMap rollbackSegments; + private HashMap rollbackSegments; internal volatile SegmentInfos pendingCommit; // set when a commit is pending (after prepareCommit() & before commit()) internal volatile uint pendingCommitChangeCount; @@ -269,7 +270,7 @@ namespace Lucene.Net.Index // Used to only allow one addIndexes to proceed at once // TODO: use ReadWriteLock once we are on 5.0 private int readCount; // count of how many threads are holding read lock - private SupportClass.ThreadClass writeThread; // non-null if any thread holds write lock + private ThreadClass writeThread; // non-null if any thread holds write lock internal ReaderPool readerPool; private int upgradeCount; @@ -753,14 +754,14 @@ namespace Lucene.Net.Index { lock (this) { - System.Diagnostics.Debug.Assert(writeThread != SupportClass.ThreadClass.Current()); + System.Diagnostics.Debug.Assert(writeThread != ThreadClass.Current()); while (writeThread != null || readCount > 0) DoWait(); // We could have been closed while we were waiting: EnsureOpen(); - writeThread = SupportClass.ThreadClass.Current(); + writeThread = ThreadClass.Current(); } } @@ -768,7 +769,7 @@ namespace Lucene.Net.Index { lock (this) { - System.Diagnostics.Debug.Assert(SupportClass.ThreadClass.Current() == writeThread); + System.Diagnostics.Debug.Assert(ThreadClass.Current() == writeThread); writeThread = null; System.Threading.Monitor.PulseAll(this); } @@ -778,7 +779,7 @@ namespace Lucene.Net.Index { lock (this) { - SupportClass.ThreadClass current = SupportClass.ThreadClass.Current(); + ThreadClass current = ThreadClass.Current(); while (writeThread != null && writeThread != current) DoWait(); @@ -800,7 +801,7 @@ namespace Lucene.Net.Index DoWait(); } - writeThread = SupportClass.ThreadClass.Current(); + writeThread = ThreadClass.Current(); readCount--; upgradeCount--; } @@ -855,7 +856,7 @@ namespace Lucene.Net.Index public virtual void Message(System.String message) { if (infoStream != null) - infoStream.WriteLine("IW " + messageID + " [" + DateTime.Now.ToString() + "; " + SupportClass.ThreadClass.Current().Name + "]: " + message); + infoStream.WriteLine("IW " + messageID + " [" + DateTime.Now.ToString() + "; " + ThreadClass.Current().Name + "]: " + message); } private void SetMessageID(System.IO.StreamWriter infoStream) @@ -1344,7 +1345,7 @@ namespace Lucene.Net.Index { rollbackSegmentInfos = (SegmentInfos) infos.Clone(); System.Diagnostics.Debug.Assert(!rollbackSegmentInfos.HasExternalSegments(directory)); - rollbackSegments = new SupportClass.HashMap(); + rollbackSegments = new HashMap(); int size = rollbackSegmentInfos.Count; for (int i = 0; i < size; i++) rollbackSegments[rollbackSegmentInfos.Info(i)] = i; @@ -2546,7 +2547,7 @@ namespace Lucene.Net.Index // name that was previously returned which can cause // problems at least with ConcurrentMergeScheduler. changeCount++; - return "_" + SupportClass.Number.ToString(segmentInfos.counter++); + return "_" + Number.ToString(segmentInfos.counter++); } } @@ -4530,7 +4531,7 @@ namespace Lucene.Net.Index merge.info.SetHasProx(merger.HasProx()); - ((System.Collections.IList) ((System.Collections.ArrayList) segmentInfos).GetRange(start, start + merge.segments.Count - start)).Clear(); + segmentInfos.RemoveRange(start, start + merge.segments.Count - start); System.Diagnostics.Debug.Assert(!segmentInfos.Contains(merge.info)); segmentInfos.Insert(start, merge.info); Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/InvertedDocConsumer.cs URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/InvertedDocConsumer.cs?rev=1201243&r1=1201242&r2=1201243&view=diff ============================================================================== --- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/InvertedDocConsumer.cs (original) +++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/InvertedDocConsumer.cs Sat Nov 12 10:44:21 2011 @@ -16,6 +16,7 @@ */ using System; +using System.Collections.Generic; namespace Lucene.Net.Index { @@ -28,9 +29,11 @@ namespace Lucene.Net.Index /// Abort (called after hitting AbortException) public abstract void Abort(); - - /// Flush a new segment - internal abstract void Flush(System.Collections.IDictionary threadsAndFields, SegmentWriteState state); + + /// Flush a new segment + internal abstract void Flush( + IDictionary> threadsAndFields, + SegmentWriteState state); /// Close doc stores internal abstract void CloseDocStore(SegmentWriteState state); Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/MergeDocIDRemapper.cs URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/MergeDocIDRemapper.cs?rev=1201243&r1=1201242&r2=1201243&view=diff ============================================================================== --- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/MergeDocIDRemapper.cs (original) +++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/MergeDocIDRemapper.cs Sat Nov 12 10:44:21 2011 @@ -16,6 +16,7 @@ */ using System; +using Lucene.Net.Support; namespace Lucene.Net.Index { @@ -97,7 +98,7 @@ namespace Lucene.Net.Index while (hi >= lo) { - int mid = SupportClass.Number.URShift((lo + hi), 1); + int mid = Number.URShift((lo + hi), 1); int midValue = starts[mid]; if (oldDocID < midValue) hi = mid - 1; Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/MultiReader.cs URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/MultiReader.cs?rev=1201243&r1=1201242&r2=1201243&view=diff ============================================================================== --- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/MultiReader.cs (original) +++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/MultiReader.cs Sat Nov 12 10:44:21 2011 @@ -17,6 +17,7 @@ using System; using System.Linq; +using Lucene.Net.Support; using Document = Lucene.Net.Documents.Document; using FieldSelector = Lucene.Net.Documents.FieldSelector; using MultiTermDocs = Lucene.Net.Index.DirectoryReader.MultiTermDocs; @@ -35,7 +36,7 @@ namespace Lucene.Net.Index protected internal IndexReader[] subReaders; private int[] starts; // 1st docno for each segment private bool[] decrefOnClose; // remember which subreaders to decRef on close - private System.Collections.Generic.IDictionary normsCache = new SupportClass.HashMap(); + private System.Collections.Generic.IDictionary normsCache = new HashMap(); private int maxDoc = 0; private int numDocs = - 1; private bool hasDeletions = false; Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/NormsWriter.cs URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/NormsWriter.cs?rev=1201243&r1=1201242&r2=1201243&view=diff ============================================================================== --- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/NormsWriter.cs (original) +++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/NormsWriter.cs Sat Nov 12 10:44:21 2011 @@ -17,6 +17,7 @@ using System; using System.Collections.Generic; +using Lucene.Net.Support; using IndexOutput = Lucene.Net.Store.IndexOutput; using Similarity = Lucene.Net.Search.Similarity; @@ -60,7 +61,7 @@ namespace Lucene.Net.Index public override void Flush(IDictionary> threadsAndFields, SegmentWriteState state) { - IDictionary> byField = new SupportClass.HashMap>(); + IDictionary> byField = new HashMap>(); // Typically, each thread will have encountered the same // field. So first we collate by field, ie, all Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/ReusableStringReader.cs URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/ReusableStringReader.cs?rev=1201243&r1=1201242&r2=1201243&view=diff ============================================================================== --- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/ReusableStringReader.cs (original) +++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/ReusableStringReader.cs Sat Nov 12 10:44:21 2011 @@ -16,6 +16,7 @@ */ using System; +using Lucene.Net.Support; namespace Lucene.Net.Index { @@ -43,7 +44,7 @@ namespace Lucene.Net.Index { if (left > len) { - SupportClass.TextSupport.GetCharsFromString(s, upto, upto + len, c, off); + TextSupport.GetCharsFromString(s, upto, upto + len, c, off); upto += len; left -= len; return len; @@ -55,7 +56,7 @@ namespace Lucene.Net.Index } else { - SupportClass.TextSupport.GetCharsFromString(s, upto, upto + left, c, off); + TextSupport.GetCharsFromString(s, upto, upto + left, c, off); int r = left; left = 0; upto = s.Length; Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/SegmentInfo.cs URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/SegmentInfo.cs?rev=1201243&r1=1201242&r2=1201243&view=diff ============================================================================== --- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/SegmentInfo.cs (original) +++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/SegmentInfo.cs Sat Nov 12 10:44:21 2011 @@ -17,6 +17,7 @@ using System; using System.Collections.Generic; +using Lucene.Net.Support; using Directory = Lucene.Net.Store.Directory; using IndexInput = Lucene.Net.Store.IndexInput; using IndexOutput = Lucene.Net.Store.IndexOutput; @@ -366,7 +367,7 @@ namespace Lucene.Net.Index si.hasProx = hasProx; si.preLockless = preLockless; si.hasSingleNormFile = hasSingleNormFile; - si.diagnostics = new SupportClass.HashMap(this.diagnostics); + si.diagnostics = new HashMap(this.diagnostics); if (this.diagnostics != null) { si.diagnostics = new System.Collections.Generic.Dictionary(); Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/SegmentInfos.cs URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/SegmentInfos.cs?rev=1201243&r1=1201242&r2=1201243&view=diff ============================================================================== --- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/SegmentInfos.cs (original) +++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/SegmentInfos.cs Sat Nov 12 10:44:21 2011 @@ -16,7 +16,8 @@ */ using System; - +using System.Collections.Generic; +using Lucene.Net.Support; using ChecksumIndexInput = Lucene.Net.Store.ChecksumIndexInput; using ChecksumIndexOutput = Lucene.Net.Store.ChecksumIndexOutput; using Directory = Lucene.Net.Store.Directory; @@ -34,7 +35,7 @@ namespace Lucene.Net.Index /// (subject to change suddenly in the next release)

///

[Serializable] - public sealed class SegmentInfos : System.Collections.ArrayList + public sealed class SegmentInfos : List, ICloneable/*ConcurrentBag is thread-safety a requirement of SegmentInfos?*/ { private class AnonymousClassFindSegmentsFile:FindSegmentsFile { @@ -224,7 +225,7 @@ namespace Lucene.Net.Index } else if (fileName.StartsWith(IndexFileNames.SEGMENTS)) { - return SupportClass.Number.ToInt64(fileName.Substring(1 + IndexFileNames.SEGMENTS.Length)); + return Number.ToInt64(fileName.Substring(1 + IndexFileNames.SEGMENTS.Length)); } else { @@ -435,18 +436,18 @@ namespace Lucene.Net.Index /// SegmentInfo. /// - public override System.Object Clone() + public System.Object Clone() { SegmentInfos sis = new SegmentInfos(); for (int i = 0; i < this.Count; i++) { - sis.Add(((SegmentInfo) this[i]).Clone()); + sis.Add((SegmentInfo)this[i].Clone()); } sis.counter = this.counter; sis.generation = this.generation; sis.lastGeneration = this.lastGeneration; // sis.pendingSegnOutput = this.pendingSegnOutput; // {{Aroush-2.9}} needed? - sis.userData = new SupportClass.HashMap(userData); + sis.userData = new HashMap(userData); sis.version = this.version; return sis; } @@ -566,7 +567,7 @@ namespace Lucene.Net.Index { if (infoStream != null) { - infoStream.WriteLine("SIS [" + SupportClass.ThreadClass.Current().Name + "]: " + message); + infoStream.WriteLine("SIS [" + ThreadClass.Current().Name + "]: " + message); } } @@ -844,7 +845,7 @@ namespace Lucene.Net.Index public SegmentInfos Range(int first, int last) { SegmentInfos infos = new SegmentInfos(); - infos.AddRange((System.Collections.IList) ((System.Collections.ArrayList) this).GetRange(first, last - first)); + infos.AddRange(this.GetRange(first, last - first)); return infos; } Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/SegmentReader.cs URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/SegmentReader.cs?rev=1201243&r1=1201242&r2=1201243&view=diff ============================================================================== --- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/SegmentReader.cs (original) +++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/SegmentReader.cs Sat Nov 12 10:44:21 2011 @@ -16,6 +16,7 @@ */ using System; +using Lucene.Net.Support; using Lucene.Net.Util; using Document = Lucene.Net.Documents.Document; using FieldSelector = Lucene.Net.Documents.FieldSelector; @@ -767,7 +768,7 @@ namespace Lucene.Net.Index } } - internal System.Collections.Generic.IDictionary norms = new SupportClass.HashMap(); + internal System.Collections.Generic.IDictionary norms = new HashMap(); /// CorruptIndexException if the index is corrupt /// IOException if there is a low-level IO error @@ -969,7 +970,7 @@ namespace Lucene.Net.Index } } - clone.norms = new SupportClass.HashMap(); + clone.norms = new HashMap(); // Clone norms for (int i = 0; i < fieldNormsChanged.Length; i++) Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/SegmentTermDocs.cs URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/SegmentTermDocs.cs?rev=1201243&r1=1201242&r2=1201243&view=diff ============================================================================== --- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/SegmentTermDocs.cs (original) +++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/SegmentTermDocs.cs Sat Nov 12 10:44:21 2011 @@ -16,7 +16,7 @@ */ using System; - +using Lucene.Net.Support; using IndexInput = Lucene.Net.Store.IndexInput; using BitVector = Lucene.Net.Util.BitVector; @@ -144,7 +144,7 @@ namespace Lucene.Net.Index } else { - doc += SupportClass.Number.URShift(docCode, 1); // shift off low bit + doc += Number.URShift(docCode, 1); // shift off low bit if ((docCode & 1) != 0) // if low bit is set freq = 1; @@ -177,7 +177,7 @@ namespace Lucene.Net.Index { // manually inlined call to next() for speed int docCode = freqStream.ReadVInt(); - doc += SupportClass.Number.URShift(docCode, 1); // shift off low bit + doc += Number.URShift(docCode, 1); // shift off low bit if ((docCode & 1) != 0) // if low bit is set freq = 1; Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/SegmentTermPositions.cs URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/SegmentTermPositions.cs?rev=1201243&r1=1201242&r2=1201243&view=diff ============================================================================== --- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/SegmentTermPositions.cs (original) +++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/SegmentTermPositions.cs Sat Nov 12 10:44:21 2011 @@ -16,7 +16,7 @@ */ using System; - +using Lucene.Net.Support; using IndexInput = Lucene.Net.Store.IndexInput; namespace Lucene.Net.Index @@ -87,7 +87,7 @@ namespace Lucene.Net.Index { payloadLength = proxStream.ReadVInt(); } - delta = SupportClass.Number.URShift(delta, 1); + delta = Number.URShift(delta, 1); needToLoadPayload = true; } return delta; Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/TermBuffer.cs URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/TermBuffer.cs?rev=1201243&r1=1201242&r2=1201243&view=diff ============================================================================== --- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/TermBuffer.cs (original) +++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/TermBuffer.cs Sat Nov 12 10:44:21 2011 @@ -16,7 +16,7 @@ */ using System; - +using Lucene.Net.Support; using IndexInput = Lucene.Net.Store.IndexInput; using UnicodeUtil = Lucene.Net.Util.UnicodeUtil; @@ -111,7 +111,7 @@ namespace Lucene.Net.Index System.String termText = term.Text(); int termLen = termText.Length; text.SetLength(termLen); - SupportClass.TextSupport.GetCharsFromString(termText, 0, termLen, text.result, 0); + TextSupport.GetCharsFromString(termText, 0, termLen, text.result, 0); dirty = true; field = term.Field(); this.term = term; Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/TermInfosReader.cs URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/TermInfosReader.cs?rev=1201243&r1=1201242&r2=1201243&view=diff ============================================================================== --- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/TermInfosReader.cs (original) +++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/TermInfosReader.cs Sat Nov 12 10:44:21 2011 @@ -16,6 +16,7 @@ */ using System; +using Lucene.Net.Support; using Lucene.Net.Util; using Lucene.Net.Util.Cache; using Directory = Lucene.Net.Store.Directory; @@ -174,7 +175,7 @@ namespace Lucene.Net.Index while (hi >= lo) { - int mid = SupportClass.Number.URShift((lo + hi), 1); + int mid = Number.URShift((lo + hi), 1); int delta = term.CompareTo(indexTerms[mid]); if (delta < 0) hi = mid - 1; Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/TermVectorsTermsWriterPerField.cs URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/TermVectorsTermsWriterPerField.cs?rev=1201243&r1=1201242&r2=1201243&view=diff ============================================================================== --- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/TermVectorsTermsWriterPerField.cs (original) +++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/TermVectorsTermsWriterPerField.cs Sat Nov 12 10:44:21 2011 @@ -225,7 +225,7 @@ namespace Lucene.Net.Index { if (doVectorOffsets) { - offsetAttribute = (OffsetAttribute) fieldState.attributeSource.AddAttribute(typeof(OffsetAttribute)); + offsetAttribute = fieldState.attributeSource.AddAttribute(); } else { Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/TermsHash.cs URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/TermsHash.cs?rev=1201243&r1=1201242&r2=1201243&view=diff ============================================================================== --- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/TermsHash.cs (original) +++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/TermsHash.cs Sat Nov 12 10:44:21 2011 @@ -16,7 +16,7 @@ */ using System; - +using System.Collections.Generic; using ArrayUtil = Lucene.Net.Util.ArrayUtil; namespace Lucene.Net.Index @@ -30,8 +30,7 @@ namespace Lucene.Net.Index ///, write their own byte streams /// under each term. /// - - sealed class TermsHash:InvertedDocConsumer + sealed class TermsHash : InvertedDocConsumer { internal TermsHashConsumer consumer; @@ -39,7 +38,6 @@ namespace Lucene.Net.Index internal int bytesPerPosting; internal int postingsFreeChunk; internal DocumentsWriter docWriter; - private RawPostingList[] postingsFreeList = new RawPostingList[1]; private int postingsFreeCount; private int postingsAllocCount; @@ -87,7 +85,7 @@ namespace Lucene.Net.Index nextTermsHash.Abort(); } - internal void ShrinkFreePostings(System.Collections.IDictionary threadsAndFields, SegmentWriteState state) + internal void ShrinkFreePostings(IDictionary> threadsAndFields, SegmentWriteState state) { System.Diagnostics.Debug.Assert(postingsFreeCount == postingsAllocCount, "Thread.currentThread().getName()" + ": postingsFreeCount=" + postingsFreeCount + " postingsAllocCount=" + postingsAllocCount + " consumer=" + consumer); @@ -121,47 +119,43 @@ namespace Lucene.Net.Index } } - internal override void Flush(System.Collections.IDictionary threadsAndFields, SegmentWriteState state) + internal override void Flush(IDictionary> threadsAndFields, SegmentWriteState state) { lock (this) { - System.Collections.IDictionary childThreadsAndFields = new System.Collections.Hashtable(); - System.Collections.IDictionary nextThreadsAndFields; + var childThreadsAndFields = new Dictionary>(); + Dictionary> nextThreadsAndFields; if (nextTermsHash != null) { - nextThreadsAndFields = new System.Collections.Hashtable(); + nextThreadsAndFields = new Dictionary>(); } else nextThreadsAndFields = null; - System.Collections.IEnumerator it = new System.Collections.Hashtable(threadsAndFields).GetEnumerator(); - while (it.MoveNext()) + foreach (var entry in threadsAndFields) { - - System.Collections.DictionaryEntry entry = (System.Collections.DictionaryEntry) it.Current; - TermsHashPerThread perThread = (TermsHashPerThread) entry.Key; - System.Collections.ICollection fields = (System.Collections.ICollection) entry.Value; + ICollection fields = entry.Value; - System.Collections.IEnumerator fieldsIt = fields.GetEnumerator(); - System.Collections.Hashtable childFields = new System.Collections.Hashtable(); - System.Collections.Hashtable nextChildFields; + var fieldsIt = fields.GetEnumerator(); + ICollection childFields = new HashSet(); + ICollection nextChildFields; if (nextTermsHash != null) { - nextChildFields = new System.Collections.Hashtable(); + nextChildFields = new HashSet(); } else nextChildFields = null; while (fieldsIt.MoveNext()) { - TermsHashPerField perField = (TermsHashPerField) ((System.Collections.DictionaryEntry) fieldsIt.Current).Key; - childFields[perField.consumer] = perField.consumer; + TermsHashPerField perField = (TermsHashPerField) fieldsIt.Current; + childFields.Add(perField.consumer); if (nextTermsHash != null) - nextChildFields[perField.nextPerField] = perField.nextPerField; + nextChildFields.Add(perField.nextPerField); } childThreadsAndFields[perThread.consumer] = childFields; Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/TermsHashPerField.cs URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/TermsHashPerField.cs?rev=1201243&r1=1201242&r2=1201243&view=diff ============================================================================== --- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/TermsHashPerField.cs (original) +++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/TermsHashPerField.cs Sat Nov 12 10:44:21 2011 @@ -16,7 +16,7 @@ */ using System; - +using Lucene.Net.Support; using TermAttribute = Lucene.Net.Analysis.Tokenattributes.TermAttribute; using Fieldable = Lucene.Net.Documents.Fieldable; using UnicodeUtil = Lucene.Net.Util.UnicodeUtil; @@ -173,7 +173,7 @@ namespace Lucene.Net.Index return ; } - int mid = SupportClass.Number.URShift((lo + hi), 1); + int mid = Number.URShift((lo + hi), 1); if (ComparePostings(postings[lo], postings[mid]) > 0) { @@ -287,7 +287,7 @@ namespace Lucene.Net.Index internal override void Start(Fieldable f) { - termAtt = (TermAttribute) fieldState.attributeSource.AddAttribute(typeof(TermAttribute)); + termAtt = fieldState.attributeSource.AddAttribute(); consumer.Start(f); if (nextPerField != null) { @@ -573,7 +573,7 @@ namespace Lucene.Net.Index while ((i & ~ 0x7F) != 0) { WriteByte(stream, (byte) ((i & 0x7f) | 0x80)); - i = SupportClass.Number.URShift(i, 7); + i = Number.URShift(i, 7); } WriteByte(stream, (byte) i); } Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Lucene.Net.csproj URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Lucene.Net.csproj?rev=1201243&r1=1201242&r2=1201243&view=diff ============================================================================== --- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Lucene.Net.csproj (original) +++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Lucene.Net.csproj Sat Nov 12 10:44:21 2011 @@ -126,7 +126,6 @@ - @@ -170,7 +169,6 @@ Code - Code @@ -188,7 +186,6 @@ Code - Code @@ -213,7 +210,6 @@ Code - Code @@ -889,9 +885,36 @@ Code - - Code - + + + + + + + + + + + + + + + + + + + + + + + + Code + + + + + + @@ -907,6 +930,7 @@ + @@ -950,8 +974,10 @@ + + Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/QueryParser/ParseException.cs URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/QueryParser/ParseException.cs?rev=1201243&r1=1201242&r2=1201243&view=diff ============================================================================== --- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/QueryParser/ParseException.cs (original) +++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/QueryParser/ParseException.cs Sat Nov 12 10:44:21 2011 @@ -19,6 +19,7 @@ /* JavaCCOptions:KEEP_LINE_COL=null */ using System; +using Lucene.Net.Support; namespace Lucene.Net.QueryParsers { @@ -172,7 +173,7 @@ namespace Lucene.Net.QueryParsers public System.String[] tokenImage; /// The end of line string for this machine. - protected internal System.String eol = SupportClass.AppSettings.Get("line.separator", "\n"); + protected internal System.String eol = AppSettings.Get("line.separator", "\n"); /// Used to convert raw characters to their escaped version /// when these raw version cannot be used as part of an ASCII Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/QueryParser/QueryParser.cs URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/QueryParser/QueryParser.cs?rev=1201243&r1=1201242&r2=1201243&view=diff ============================================================================== --- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/QueryParser/QueryParser.cs (original) +++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/QueryParser/QueryParser.cs Sat Nov 12 10:44:21 2011 @@ -20,6 +20,7 @@ using System; using System.Collections.Generic; using System.Linq; +using Lucene.Net.Support; using Lucene.Net.Util; using Analyzer = Lucene.Net.Analysis.Analyzer; using CachingTokenFilter = Lucene.Net.Analysis.CachingTokenFilter; @@ -38,6 +39,7 @@ using MultiTermQuery = Lucene.Net.Search using PhraseQuery = Lucene.Net.Search.PhraseQuery; using PrefixQuery = Lucene.Net.Search.PrefixQuery; using Query = Lucene.Net.Search.Query; +using Single = Lucene.Net.Support.Single; using TermQuery = Lucene.Net.Search.TermQuery; using TermRangeQuery = Lucene.Net.Search.TermRangeQuery; using WildcardQuery = Lucene.Net.Search.WildcardQuery; @@ -582,13 +584,13 @@ namespace Lucene.Net.QueryParsers } if (success) { - if (buffer.HasAttribute(typeof(TermAttribute))) + if (buffer.HasAttribute()) { - termAtt = buffer.GetAttribute(typeof(TermAttribute)); + termAtt = buffer.GetAttribute(); } - if (buffer.HasAttribute(typeof(PositionIncrementAttribute))) + if (buffer.HasAttribute()) { - posIncrAtt = buffer.GetAttribute(typeof(PositionIncrementAttribute)); + posIncrAtt = buffer.GetAttribute(); } } @@ -991,7 +993,7 @@ namespace Lucene.Net.QueryParsers /// /// throw in overridden method to disallow /// - protected internal virtual Query GetBooleanQuery(System.Collections.IList clauses) + protected internal virtual Query GetBooleanQuery(IList clauses) { return GetBooleanQuery(clauses, false); } @@ -1022,7 +1024,7 @@ namespace Lucene.Net.QueryParsers BooleanQuery query = NewBooleanQuery(disableCoord); foreach(BooleanClause clause in clauses) { - query.Add(clauses); + query.Add(clause); } return query; } @@ -1164,7 +1166,7 @@ namespace Lucene.Net.QueryParsers if (codePointMultiplier > 0) { codePoint += HexToInt(curChar) * codePointMultiplier; - codePointMultiplier = SupportClass.Number.URShift(codePointMultiplier, 4); + codePointMultiplier = Number.URShift(codePointMultiplier, 4); if (codePointMultiplier == 0) { output[length++] = (char) codePoint; @@ -1514,7 +1516,7 @@ label_1_brk: ; // {{Aroush-2.9}} this l float f = (float) 1.0; try { - f = (float) SupportClass.Single.Parse(boost.image); + f = (float) Single.Parse(boost.image); q.SetBoost(f); } catch (System.Exception ignored) @@ -1631,7 +1633,7 @@ label_1_brk: ; // {{Aroush-2.9}} this l float fms = fuzzyMinSim; try { - fms = (float) SupportClass.Single.Parse(fuzzySlop.image.Substring(1)); + fms = (float) Single.Parse(fuzzySlop.image.Substring(1)); } catch (System.Exception ignored) { @@ -1837,7 +1839,7 @@ label_1_brk: ; // {{Aroush-2.9}} this l { try { - s = (int) SupportClass.Single.Parse(fuzzySlop.image.Substring(1)); + s = (int) Single.Parse(fuzzySlop.image.Substring(1)); } catch (System.Exception ignored) { @@ -1857,7 +1859,7 @@ label_1_brk: ; // {{Aroush-2.9}} this l float f = (float) 1.0; try { - f = (float) SupportClass.Single.Parse(boost.image); + f = (float) Single.Parse(boost.image); } catch (System.Exception ignored) { Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/BooleanQuery.cs URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/BooleanQuery.cs?rev=1201243&r1=1201242&r2=1201243&view=diff ============================================================================== --- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/BooleanQuery.cs (original) +++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/BooleanQuery.cs Sat Nov 12 10:44:21 2011 @@ -18,6 +18,7 @@ using System; using System.Collections; using Lucene.Net.Index; +using Lucene.Net.Support; using IndexReader = Lucene.Net.Index.IndexReader; using ToStringUtils = Lucene.Net.Util.ToStringUtils; using Occur = Lucene.Net.Search.BooleanClause.Occur; @@ -99,7 +100,7 @@ namespace Lucene.Net.Search BooleanQuery.maxClauseCount = maxClauseCount; } - private SupportClass.EquatableList clauses = new SupportClass.EquatableList(); + private EquatableList clauses = new EquatableList(); private bool disableCoord; /// Constructs an empty boolean query. @@ -519,7 +520,7 @@ namespace Lucene.Net.Search public override System.Object Clone() { BooleanQuery clone = (BooleanQuery) base.Clone(); - clone.clauses = (SupportClass.EquatableList) this.clauses.Clone(); + clone.clauses = (EquatableList) this.clauses.Clone(); return clone; } Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/CachingWrapperFilter.cs URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/CachingWrapperFilter.cs?rev=1201243&r1=1201242&r2=1201243&view=diff ============================================================================== --- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/CachingWrapperFilter.cs (original) +++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/CachingWrapperFilter.cs Sat Nov 12 10:44:21 2011 @@ -18,6 +18,7 @@ using System; using System.Collections; using System.Collections.Generic; +using Lucene.Net.Support; using IndexReader = Lucene.Net.Index.IndexReader; using OpenBitSetDISI = Lucene.Net.Util.OpenBitSetDISI; using Lucene.Net.Util; @@ -83,7 +84,7 @@ namespace Lucene.Net.Search if (cache == null) { - cache = new SupportClass.WeakHashMap(); + cache = new WeakDictionary(); } if (deletesMode == DeletesMode.IGNORE) Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/DisjunctionMaxQuery.cs URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/DisjunctionMaxQuery.cs?rev=1201243&r1=1201242&r2=1201243&view=diff ============================================================================== --- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/DisjunctionMaxQuery.cs (original) +++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/DisjunctionMaxQuery.cs Sat Nov 12 10:44:21 2011 @@ -17,6 +17,7 @@ using System; using Lucene.Net.Index; +using Lucene.Net.Support; using IndexReader = Lucene.Net.Index.IndexReader; namespace Lucene.Net.Search @@ -40,7 +41,7 @@ namespace Lucene.Net.Search { /* The subqueries */ - private SupportClass.EquatableList disjuncts = new SupportClass.EquatableList(); + private EquatableList disjuncts = new EquatableList(); /* Multiple of the non-max disjunct scores added into our final score. Non-zero values support tie-breaking. */ private float tieBreakerMultiplier = 0.0f; @@ -263,7 +264,7 @@ namespace Lucene.Net.Search public override System.Object Clone() { DisjunctionMaxQuery clone = (DisjunctionMaxQuery) base.Clone(); - clone.disjuncts = (SupportClass.EquatableList) this.disjuncts.Clone(); + clone.disjuncts = (EquatableList) this.disjuncts.Clone(); return clone; } Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/FieldCache.cs URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/FieldCache.cs?rev=1201243&r1=1201242&r2=1201243&view=diff ============================================================================== --- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/FieldCache.cs (original) +++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/FieldCache.cs Sat Nov 12 10:44:21 2011 @@ -16,12 +16,14 @@ */ using System; - +using Lucene.Net.Support; +using Double = Lucene.Net.Support.Double; using NumericTokenStream = Lucene.Net.Analysis.NumericTokenStream; using NumericField = Lucene.Net.Documents.NumericField; using IndexReader = Lucene.Net.Index.IndexReader; using NumericUtils = Lucene.Net.Util.NumericUtils; using RamUsageEstimator = Lucene.Net.Util.RamUsageEstimator; +using Single = Lucene.Net.Support.Single; namespace Lucene.Net.Search { @@ -56,7 +58,7 @@ namespace Lucene.Net.Search while (low <= high) { - int mid = SupportClass.Number.URShift((low + high), 1); + int mid = Number.URShift((low + high), 1); int cmp = String.CompareOrdinal(lookup[mid], key); if (cmp < 0) @@ -250,7 +252,7 @@ namespace Lucene.Net.Search { try { - return SupportClass.Single.Parse(value_Renamed); + return Single.Parse(value_Renamed); } catch (System.OverflowException) { @@ -287,7 +289,7 @@ namespace Lucene.Net.Search { public virtual double ParseDouble(System.String value_Renamed) { - return SupportClass.Double.Parse(value_Renamed); + return Double.Parse(value_Renamed); } protected internal virtual System.Object ReadResolve() { Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/FieldCacheImpl.cs URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/FieldCacheImpl.cs?rev=1201243&r1=1201242&r2=1201243&view=diff ============================================================================== --- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/FieldCacheImpl.cs (original) +++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/FieldCacheImpl.cs Sat Nov 12 10:44:21 2011 @@ -16,20 +16,21 @@ */ using System; - +using Lucene.Net.Support; using NumericField = Lucene.Net.Documents.NumericField; using IndexReader = Lucene.Net.Index.IndexReader; using Term = Lucene.Net.Index.Term; using TermDocs = Lucene.Net.Index.TermDocs; using TermEnum = Lucene.Net.Index.TermEnum; using FieldCacheSanityChecker = Lucene.Net.Util.FieldCacheSanityChecker; +using Single = Lucene.Net.Support.Single; using StringHelper = Lucene.Net.Util.StringHelper; namespace Lucene.Net.Search { /// Expert: The default cache implementation, storing all values in memory. - /// A WeakHashMap is used for storage. + /// A WeakDictionary is used for storage. /// ///

Created: May 19, 2004 4:40:36 PM /// @@ -92,7 +93,7 @@ namespace Lucene.Net.Search { // we've now materialized a hard ref System.Object readerKey = innerKeys.Current; - // innerKeys was backed by WeakHashMap, sanity check + // innerKeys was backed by WeakDictionary, sanity check // that it wasn't GCed before we made hard ref if (null != readerKey && cache.readerCache.Contains(readerKey)) { @@ -210,7 +211,7 @@ namespace Lucene.Net.Search internal FieldCache wrapper; - internal System.Collections.IDictionary readerCache = new SupportClass.WeakHashTable(); + internal System.Collections.IDictionary readerCache = new WeakHashTable(); protected internal abstract System.Object CreateValue(IndexReader reader, Entry key); @@ -982,7 +983,7 @@ namespace Lucene.Net.Search { try { - SupportClass.Single.Parse(termtext); + Single.Parse(termtext); ret = wrapper.GetFloats(reader, field); } catch (System.FormatException nfe3) Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/FieldCacheRangeFilter.cs URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/FieldCacheRangeFilter.cs?rev=1201243&r1=1201242&r2=1201243&view=diff ============================================================================== --- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/FieldCacheRangeFilter.cs (original) +++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/FieldCacheRangeFilter.cs Sat Nov 12 10:44:21 2011 @@ -16,7 +16,7 @@ */ using System; - +using Lucene.Net.Support; using NumericField = Lucene.Net.Documents.NumericField; using IndexReader = Lucene.Net.Index.IndexReader; using TermDocs = Lucene.Net.Index.TermDocs; @@ -766,7 +766,7 @@ namespace Lucene.Net.Search { int h = field.GetHashCode(); h ^= ((lowerVal != null)?lowerVal.GetHashCode():550356204); - h = (h << 1) | (SupportClass.Number.URShift(h, 31)); // rotate to distinguish lower from upper + h = (h << 1) | (Number.URShift(h, 31)); // rotate to distinguish lower from upper h ^= ((upperVal != null)?upperVal.GetHashCode():- 1674416163); h ^= ((parser != null)?parser.GetHashCode():- 1572457324); h ^= (includeLower?1549299360:- 365038026) ^ (includeUpper?1721088258:1948649653); Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/FieldComparator.cs URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/FieldComparator.cs?rev=1201243&r1=1201242&r2=1201243&view=diff ============================================================================== --- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/FieldComparator.cs (original) +++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/FieldComparator.cs Sat Nov 12 10:44:21 2011 @@ -16,7 +16,7 @@ */ using System; - +using Lucene.Net.Support; using IndexReader = Lucene.Net.Index.IndexReader; using ByteParser = Lucene.Net.Search.ByteParser; using DoubleParser = Lucene.Net.Search.DoubleParser; @@ -953,7 +953,7 @@ namespace Lucene.Net.Search while (low <= high) { - int mid = SupportClass.Number.URShift((low + high), 1); + int mid = Number.URShift((low + high), 1); System.String midVal = a[mid]; int cmp; if (midVal != null) Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/FilterManager.cs URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/FilterManager.cs?rev=1201243&r1=1201242&r2=1201243&view=diff ============================================================================== --- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/FilterManager.cs (original) +++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/FilterManager.cs Sat Nov 12 10:44:21 2011 @@ -17,6 +17,7 @@ using System; using System.Collections.Generic; +using Lucene.Net.Support; namespace Lucene.Net.Search { @@ -71,7 +72,7 @@ namespace Lucene.Net.Search cleanSleepTime = DEFAULT_CACHE_SLEEP_TIME; // 10 minutes between cleanings filterCleaner = new FilterCleaner(this); - SupportClass.ThreadClass fcThread = new SupportClass.ThreadClass(new System.Threading.ThreadStart(filterCleaner.Run)); + ThreadClass fcThread = new ThreadClass(new System.Threading.ThreadStart(filterCleaner.Run)); // setto be a Daemon so it doesn't have to be stopped fcThread.IsBackground = true; fcThread.Start(); @@ -222,7 +223,7 @@ namespace Lucene.Net.Search } catch (System.Threading.ThreadInterruptedException ie) { - SupportClass.ThreadClass.Current().Interrupt(); + ThreadClass.Current().Interrupt(); throw new System.SystemException(ie.Message, ie); } } Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/FuzzyQuery.cs URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/FuzzyQuery.cs?rev=1201243&r1=1201242&r2=1201243&view=diff ============================================================================== --- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/FuzzyQuery.cs (original) +++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/FuzzyQuery.cs Sat Nov 12 10:44:21 2011 @@ -16,8 +16,10 @@ */ using System; +using Lucene.Net.Support; using Lucene.Net.Util; using IndexReader = Lucene.Net.Index.IndexReader; +using Single = Lucene.Net.Support.Single; using Term = Lucene.Net.Index.Term; using ToStringUtils = Lucene.Net.Util.ToStringUtils; @@ -201,7 +203,7 @@ namespace Lucene.Net.Search } buffer.Append(term.Text()); buffer.Append('~'); - buffer.Append(SupportClass.Single.ToString(minimumSimilarity)); + buffer.Append(Single.ToString(minimumSimilarity)); buffer.Append(ToStringUtils.Boost(GetBoost())); return buffer.ToString(); } Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/MultiPhraseQuery.cs URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/MultiPhraseQuery.cs?rev=1201243&r1=1201242&r2=1201243&view=diff ============================================================================== --- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/MultiPhraseQuery.cs (original) +++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/MultiPhraseQuery.cs Sat Nov 12 10:44:21 2011 @@ -16,7 +16,7 @@ */ using System; - +using Lucene.Net.Support; using IndexReader = Lucene.Net.Index.IndexReader; using MultipleTermPositions = Lucene.Net.Index.MultipleTermPositions; using Term = Lucene.Net.Index.Term; @@ -390,7 +390,7 @@ namespace Lucene.Net.Search for (int i = 0; i < this.termArrays.Count; i++) { - if (!SupportClass.Compare.CompareTermArrays((Term[])this.termArrays[i], (Term[])other.termArrays[i])) + if (!Compare.CompareTermArrays((Term[])this.termArrays[i], (Term[])other.termArrays[i])) { return false; } Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/MultiSearcher.cs URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/MultiSearcher.cs?rev=1201243&r1=1201242&r2=1201243&view=diff ============================================================================== --- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/MultiSearcher.cs (original) +++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/MultiSearcher.cs Sat Nov 12 10:44:21 2011 @@ -16,7 +16,9 @@ */ using System; - +using System.Collections.Generic; +using System.Linq; +using Lucene.Net.Util; using Document = Lucene.Net.Documents.Document; using FieldSelector = Lucene.Net.Documents.FieldSelector; using CorruptIndexException = Lucene.Net.Index.CorruptIndexException; @@ -29,8 +31,8 @@ namespace Lucene.Net.Search ///

Implements search over a set of Searchables. /// - ///

Applications usually need only call the inherited - /// or methods. + ///

Applications usually need only call the inherited + /// or methods. ///

public class MultiSearcher:Searcher { @@ -81,10 +83,10 @@ namespace Lucene.Net.Search ///
private class CachedDfSource:Searcher { - private System.Collections.IDictionary dfMap; // Map from Terms to corresponding doc freqs - private int maxDoc; // document count + private readonly Dictionary dfMap; // Map from Terms to corresponding doc freqs + private readonly int maxDoc; // document count - public CachedDfSource(System.Collections.IDictionary dfMap, int maxDoc, Similarity similarity) + public CachedDfSource(Dictionary dfMap, int maxDoc, Similarity similarity) { this.dfMap = dfMap; this.maxDoc = maxDoc; @@ -96,9 +98,9 @@ namespace Lucene.Net.Search int df; try { - df = ((System.Int32) dfMap[term]); + df = dfMap[term]; } - catch (System.NullReferenceException e) + catch (KeyNotFoundException e) // C# equiv. of java code. { throw new System.ArgumentException("df for term " + term.Text() + " not available"); } @@ -178,7 +180,7 @@ namespace Lucene.Net.Search private int maxDoc = 0; /// Creates a searcher which searches searchers. - public MultiSearcher(Searchable[] searchables) + public MultiSearcher(params Searchable[] searchables) { this.searchables = searchables; @@ -263,30 +265,21 @@ namespace Lucene.Net.Search public override TopDocs Search(Weight weight, Filter filter, int nDocs) { - HitQueue hq = new HitQueue(nDocs, false); int totalHits = 0; for (int i = 0; i < searchables.Length; i++) { // search each searcher - TopDocs docs = searchables[i].Search(weight, filter, nDocs); + // use new object() for lock, we don't care about synchronization for these + TopDocs docs = MultiSearcherCallableNoSort(new object(), searchables[i], weight, filter, nDocs, hq, i, starts); totalHits += docs.TotalHits; // update totalHits - ScoreDoc[] scoreDocs = docs.ScoreDocs; - for (int j = 0; j < scoreDocs.Length; j++) - { - // merge scoreDocs into hq - ScoreDoc scoreDoc = scoreDocs[j]; - scoreDoc.doc += starts[i]; // convert doc - if (!hq.Insert(scoreDoc)) - break; // no more scores > minScore - } } ScoreDoc[] scoreDocs2 = new ScoreDoc[hq.Size()]; for (int i = hq.Size() - 1; i >= 0; i--) // put docs in array - scoreDocs2[i] = (ScoreDoc) hq.Pop(); + scoreDocs2[i] = hq.Pop(); float maxScore = (totalHits == 0)?System.Single.NegativeInfinity:scoreDocs2[0].score; @@ -295,7 +288,7 @@ namespace Lucene.Net.Search public override TopFieldDocs Search(Weight weight, Filter filter, int n, Sort sort) { - FieldDocSortedHitQueue hq = null; + var hq = new FieldDocSortedHitQueue(n); int totalHits = 0; float maxScore = System.Single.NegativeInfinity; @@ -303,47 +296,22 @@ namespace Lucene.Net.Search for (int i = 0; i < searchables.Length; i++) { // search each searcher - TopFieldDocs docs = searchables[i].Search(weight, filter, n, sort); - // If one of the Sort fields is FIELD_DOC, need to fix its values, so that - // it will break ties by doc Id properly. Otherwise, it will compare to - // 'relative' doc Ids, that belong to two different searchers. - for (int j = 0; j < docs.fields.Length; j++) - { - if (docs.fields[j].GetType() == SortField.DOC) - { - // iterate over the score docs and change their fields value - for (int j2 = 0; j2 < docs.ScoreDocs.Length; j2++) - { - FieldDoc fd = (FieldDoc) docs.ScoreDocs[j2]; - fd.fields[j] = (System.Int32) (((System.Int32) fd.fields[j]) + starts[i]); - } - break; - } - } - if (hq == null) - hq = new FieldDocSortedHitQueue(docs.fields, n); - totalHits += docs.TotalHits; // update totalHits + // use new object() for lock, we don't care about synchronization for these + TopFieldDocs docs = MultiSearcherCallableWithSort(new object(), searchables[i], weight, filter, n, hq, sort, + i, starts); + totalHits += docs.TotalHits; maxScore = System.Math.Max(maxScore, docs.GetMaxScore()); - ScoreDoc[] scoreDocs = docs.ScoreDocs; - for (int j = 0; j < scoreDocs.Length; j++) - { - // merge scoreDocs into hq - ScoreDoc scoreDoc = scoreDocs[j]; - scoreDoc.doc += starts[i]; // convert doc - if (!hq.Insert(scoreDoc)) - break; // no more scores > minScore - } } ScoreDoc[] scoreDocs2 = new ScoreDoc[hq.Size()]; for (int i = hq.Size() - 1; i >= 0; i--) // put docs in array - scoreDocs2[i] = (ScoreDoc) hq.Pop(); + scoreDocs2[i] = hq.Pop(); return new TopFieldDocs(totalHits, scoreDocs2, hq.GetFields(), maxScore); } - // inherit javadoc + /// public override void Search(Weight weight, Filter filter, Collector collector) { for (int i = 0; i < searchables.Length; i++) @@ -394,15 +362,11 @@ namespace Lucene.Net.Search Query rewrittenQuery = Rewrite(original); // step 2 - System.Collections.Hashtable terms = new System.Collections.Hashtable(); + ISet terms = new HashSet(); rewrittenQuery.ExtractTerms(terms); // step3 - Term[] allTermsArray = new Term[terms.Count]; - int index = 0; - System.Collections.IEnumerator e = terms.Keys.GetEnumerator(); - while (e.MoveNext()) - allTermsArray[index++] = e.Current as Term; + Term[] allTermsArray = terms.ToArray(); int[] aggregatedDfs = new int[terms.Count]; for (int i = 0; i < searchables.Length; i++) { @@ -413,10 +377,10 @@ namespace Lucene.Net.Search } } - System.Collections.Hashtable dfMap = new System.Collections.Hashtable(); + var dfMap = new Dictionary(); for (int i = 0; i < allTermsArray.Length; i++) { - dfMap[allTermsArray[i]] = (System.Int32) aggregatedDfs[i]; + dfMap[allTermsArray[i]] = aggregatedDfs[i]; } // step4 @@ -425,5 +389,66 @@ namespace Lucene.Net.Search return rewrittenQuery.Weight(cacheSim); } + + internal Func MultiSearcherCallableNoSort = + (theLock, searchable, weight, filter, nDocs, hq, i, starts) => + { + TopDocs docs = searchable.Search(weight, filter, nDocs); + ScoreDoc[] scoreDocs = docs.scoreDocs; + for(int j = 0; j < scoreDocs.Length; j++) // merge scoreDocs into hq + { + ScoreDoc scoreDoc = scoreDocs[j]; + scoreDoc.doc += starts[i]; //convert doc + //it would be so nice if we had a thread-safe insert + lock (theLock) + { + if (scoreDoc == hq.InsertWithOverflow(scoreDoc)) + break; + } + } + return docs; + }; + + internal Func + MultiSearcherCallableWithSort = (theLock, searchable, weight, filter, nDocs, hq, sort, i, starts) => + { + TopFieldDocs docs = searchable.Search(weight, filter, nDocs, sort); + // if one of the Sort fields is FIELD_DOC, need to fix its values, so that + // it will break ties by doc Id properly. Otherwise, it will compare to + // 'relative' doc Ids, that belong to two different searchables. + for (int j = 0; j < docs.fields.Length; j++) + { + if (docs.fields[j].GetType() == SortField.DOC) + { + // iterate over the score docs and change their fields value + for (int j2 = 0; j2 < docs.scoreDocs.Length; j2++) + { + FieldDoc fd = (FieldDoc) docs.scoreDocs[j2]; + fd.fields[j] = (int)fd.fields[j] + starts[i]; + } + break; + } + } + + lock (theLock) + { + hq.SetFields(docs.fields); + } + + ScoreDoc[] scoreDocs = docs.scoreDocs; + for (int j = 0; j < scoreDocs.Length; j++) // merge scoreDocs into hq + { + FieldDoc fieldDoc = (FieldDoc) scoreDocs[i]; + fieldDoc.doc += starts[i]; //convert doc + //it would be so nice if we had a thread-safe insert + lock (theLock) + { + if (fieldDoc == hq.InsertWithOverflow(fieldDoc)) + break; + + } + } + return docs; + }; } } \ No newline at end of file Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/ParallelMultiSearcher.cs URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/ParallelMultiSearcher.cs?rev=1201243&r1=1201242&r2=1201243&view=diff ============================================================================== --- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/ParallelMultiSearcher.cs (original) +++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/ParallelMultiSearcher.cs Sat Nov 12 10:44:21 2011 @@ -16,19 +16,22 @@ */ using System; +using System.Threading.Tasks; +using System.Linq; +using Lucene.Net.Support; using Lucene.Net.Util; using IndexReader = Lucene.Net.Index.IndexReader; using Term = Lucene.Net.Index.Term; +//TODO: This is an experimental change to ParallelMultiSearcher, attempting to use the TPL namespace Lucene.Net.Search { - /// Implements parallel search over a set of Searchables. /// ///

Applications usually need only call the inherited /// or methods. ///

- public class ParallelMultiSearcher:MultiSearcher + public class ParallelMultiSearcher : MultiSearcher/*, IDisposable*/ //No need to implement IDisposable like java, nothing to dispose with the TPL { private class AnonymousClassCollector1:Collector { @@ -74,69 +77,61 @@ namespace Lucene.Net.Search private Searchable[] searchables; private int[] starts; - /// Creates a searchable which searches searchables. - public ParallelMultiSearcher(params Searchable[] searchables):base(searchables) + /// Creates a which searches searchables. + public ParallelMultiSearcher(params Searchable[] searchables) + : base(searchables) { - this.searchables = searchables; - this.starts = GetStarts(); + this.searchables = searchables; + this.starts = GetStarts(); } - - /// TODO: parallelize this one too + + /// + /// Executes each 's docFreq() in its own thread and + /// waits for each search to complete and merge the results back together. + /// public override int DocFreq(Term term) - { - return base.DocFreq(term); - } + { + Task[] tasks = new Task[searchables.Length]; + for (int i = 0; i < searchables.Length; i++) + { + Searchable searchable = searchables[i]; + tasks[i] = Task.Factory.StartNew(() => searchable.DocFreq(term)); + } + + return tasks.Sum(task => task.Result); + } - /// A search implementation which spans a new thread for each - /// Searchable, waits for each search to complete and merge - /// the results back together. + /// A search implementation which executes each + /// in its own thread and waits for each search to complete + /// and merge the results back together. /// public override TopDocs Search(Weight weight, Filter filter, int nDocs) { - HitQueue hq = new HitQueue(nDocs, false); - int totalHits = 0; - MultiSearcherThread[] msta = new MultiSearcherThread[searchables.Length]; - for (int i = 0; i < searchables.Length; i++) - { - // search each searchable - // Assume not too many searchables and cost of creating a thread is by far inferior to a search - msta[i] = new MultiSearcherThread(searchables[i], weight, filter, nDocs, hq, i, starts, "MultiSearcher thread #" + (i + 1)); - msta[i].Start(); - } - - for (int i = 0; i < searchables.Length; i++) - { - try - { - msta[i].Join(); - } - catch (System.Threading.ThreadInterruptedException ie) - { - // In 3.0 we will change this to throw - // InterruptedException instead - SupportClass.ThreadClass.Current().Interrupt(); - throw new System.SystemException(ie.Message, ie); - } - System.IO.IOException ioe = msta[i].GetIOException(); - if (ioe == null) - { - totalHits += msta[i].Hits(); - } - else - { - // if one search produced an IOException, rethrow it - throw ioe; - } - } - - ScoreDoc[] scoreDocs = new ScoreDoc[hq.Size()]; - for (int i = hq.Size() - 1; i >= 0; i--) - // put docs in array - scoreDocs[i] = (ScoreDoc) hq.Pop(); - - float maxScore = (totalHits == 0)?System.Single.NegativeInfinity:scoreDocs[0].score; - - return new TopDocs(totalHits, scoreDocs, maxScore); + HitQueue hq = new HitQueue(nDocs, false); + object lockObj = new object(); + + Task[] tasks = new Task[searchables.Length]; + //search each searchable + for (int i = 0; i < searchables.Length; i++) + { + tasks[i] = + Task.Factory.StartNew(() => MultiSearcherCallableNoSort(lockObj, searchables[i], weight, filter, + nDocs, hq, i, starts)); + } + + int totalHits = 0; + float maxScore = float.NegativeInfinity; + foreach(TopDocs topDocs in tasks.Select(x => x.Result)) + { + totalHits += topDocs.totalHits; + maxScore = Math.Max(maxScore, topDocs.GetMaxScore()); + } + + ScoreDoc[] scoreDocs = new ScoreDoc[hq.Size()]; + for (int i = hq.Size() - 1; i >= 0; i--) // put docs in array + scoreDocs[i] = hq.Pop(); + + return new TopDocs(totalHits, scoreDocs, maxScore); } /// A search implementation allowing sorting which spans a new thread for each @@ -145,52 +140,33 @@ namespace Lucene.Net.Search /// public override TopFieldDocs Search(Weight weight, Filter filter, int nDocs, Sort sort) { - // don't specify the fields - we'll wait to do this until we get results - FieldDocSortedHitQueue hq = new FieldDocSortedHitQueue(nDocs); - int totalHits = 0; - MultiSearcherThread[] msta = new MultiSearcherThread[searchables.Length]; - for (int i = 0; i < searchables.Length; i++) - { - // search each searchable - // Assume not too many searchables and cost of creating a thread is by far inferior to a search - msta[i] = new MultiSearcherThread(searchables[i], weight, filter, nDocs, hq, sort, i, starts, "MultiSearcher thread #" + (i + 1)); - msta[i].Start(); - } - - float maxScore = System.Single.NegativeInfinity; - - for (int i = 0; i < searchables.Length; i++) - { - try - { - msta[i].Join(); - } - catch (System.Threading.ThreadInterruptedException ie) - { - // In 3.0 we will change this to throw - // InterruptedException instead - SupportClass.ThreadClass.Current().Interrupt(); - throw new System.SystemException(ie.Message, ie); - } - System.IO.IOException ioe = msta[i].GetIOException(); - if (ioe == null) - { - totalHits += msta[i].Hits(); - maxScore = System.Math.Max(maxScore, msta[i].GetMaxScore()); - } - else - { - // if one search produced an IOException, rethrow it - throw ioe; - } - } - - ScoreDoc[] scoreDocs = new ScoreDoc[hq.Size()]; - for (int i = hq.Size() - 1; i >= 0; i--) - // put docs in array - scoreDocs[i] = hq.Pop(); - - return new TopFieldDocs(totalHits, scoreDocs, hq.GetFields(), maxScore); + if (sort == null) throw new ArgumentNullException("sort"); + + FieldDocSortedHitQueue hq = new FieldDocSortedHitQueue(nDocs); + object lockObj = new object(); + + Task[] tasks = new Task[searchables.Length]; + for (int i = 0; i < searchables.Length; i++) // search each searchable + { + tasks[i] = + Task.Factory.StartNew( + () => + MultiSearcherCallableWithSort(lockObj, searchables[i], weight, filter, nDocs, hq, sort, i, + starts)); + } + + int totalHits = 0; + float maxScore = float.NegativeInfinity; + foreach (TopFieldDocs topFieldDocs in tasks.Select(x => x.Result)) + { + totalHits += topFieldDocs.totalHits; + maxScore = Math.Max(maxScore, topFieldDocs.GetMaxScore()); + } + ScoreDoc[] scoreDocs = new ScoreDoc[hq.Size()]; + for (int i = hq.Size() - 1; i >= 0; i--) + scoreDocs[i] = hq.Pop(); + + return new TopFieldDocs(totalHits, scoreDocs, hq.GetFields(), maxScore); } /// Lower-level search API. @@ -198,10 +174,11 @@ namespace Lucene.Net.Search ///

is called for every matching document. /// ///

Applications should only use this if they need all of the - /// matching documents. The high-level search API () + /// matching documents. The high-level search API () /// is usually more efficient, as it skips /// non-high-scoring hits. - /// + ///

This method cannot be parallelized, because + /// supports no concurrent access. ///

/// to match documents /// @@ -223,123 +200,5 @@ namespace Lucene.Net.Search searchables[i].Search(weight, filter, hc); } } - - /// - /// TODO: this one could be parallelized too - /// - /// - public override Query Rewrite(Query original) - { - return base.Rewrite(original); - } - } - - /// A thread subclass for searching a single searchable - class MultiSearcherThread:SupportClass.ThreadClass - { - - private Searchable searchable; - private Weight weight; - private Filter filter; - private int nDocs; - private TopDocs docs; - private int i; - private HitQueue hq; - private int[] starts; - private System.Exception ioe; - private Sort sort; - - public MultiSearcherThread(Searchable searchable, Weight weight, Filter filter, int nDocs, HitQueue hq, int i, int[] starts, System.String name):base(name) - { - this.searchable = searchable; - this.weight = weight; - this.filter = filter; - this.nDocs = nDocs; - this.hq = hq; - this.i = i; - this.starts = starts; - } - - public MultiSearcherThread(Searchable searchable, Weight weight, Filter filter, int nDocs, FieldDocSortedHitQueue hq, Sort sort, int i, int[] starts, System.String name):base(name) - { - this.searchable = searchable; - this.weight = weight; - this.filter = filter; - this.nDocs = nDocs; - this.hq = hq; - this.i = i; - this.starts = starts; - this.sort = sort; - } - - override public void Run() - { - try - { - docs = (sort == null)?searchable.Search(weight, filter, nDocs):searchable.Search(weight, filter, nDocs, sort); - } - // Store the IOException for later use by the caller of this thread - catch (System.Exception e) - { - this.ioe = e; - } - if (this.ioe == null) - { - // if we are sorting by fields, we need to tell the field sorted hit queue - // the actual type of fields, in case the original list contained AUTO. - // if the searchable returns null for fields, we'll have problems. - if (sort != null) - { - TopFieldDocs docsFields = (TopFieldDocs) docs; - // If one of the Sort fields is FIELD_DOC, need to fix its values, so that - // it will break ties by doc Id properly. Otherwise, it will compare to - // 'relative' doc Ids, that belong to two different searchables. - for (int j = 0; j < docsFields.fields.Length; j++) - { - if (docsFields.fields[j].GetType() == SortField.DOC) - { - // iterate over the score docs and change their fields value - for (int j2 = 0; j2 < docs.ScoreDocs.Length; j2++) - { - FieldDoc fd = (FieldDoc) docs.ScoreDocs[j2]; - fd.fields[j] = (System.Int32) (((System.Int32) fd.fields[j]) + starts[i]); - } - break; - } - } - - ((FieldDocSortedHitQueue) hq).SetFields(docsFields.fields); - } - ScoreDoc[] scoreDocs = docs.ScoreDocs; - for (int j = 0; j < scoreDocs.Length; j++) - { - // merge scoreDocs into hq - ScoreDoc scoreDoc = scoreDocs[j]; - scoreDoc.doc += starts[i]; // convert doc - //it would be so nice if we had a thread-safe insert - lock (hq) - { - if (!hq.Insert(scoreDoc)) - break; - } // no more scores > minScore - } - } - } - - public virtual int Hits() - { - return docs.TotalHits; - } - - public virtual float GetMaxScore() - { - return docs.GetMaxScore(); - } - - public virtual System.IO.IOException GetIOException() - { - if (ioe == null) return null; - return new System.IO.IOException(ioe.Message); - } } } \ No newline at end of file Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/PhraseQuery.cs URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/PhraseQuery.cs?rev=1201243&r1=1201242&r2=1201243&view=diff ============================================================================== --- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/PhraseQuery.cs (original) +++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/PhraseQuery.cs Sat Nov 12 10:44:21 2011 @@ -16,7 +16,7 @@ */ using System; - +using Lucene.Net.Support; using IndexReader = Lucene.Net.Index.IndexReader; using Term = Lucene.Net.Index.Term; using TermPositions = Lucene.Net.Index.TermPositions; @@ -35,8 +35,8 @@ namespace Lucene.Net.Search public class PhraseQuery:Query { private System.String field; - private SupportClass.EquatableList terms = new SupportClass.EquatableList(4); - private SupportClass.EquatableList positions = new SupportClass.EquatableList(4); + private EquatableList terms = new EquatableList(4); + private EquatableList positions = new EquatableList(4); private int maxPosition = 0; private int slop = 0; Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/QueryTermVector.cs URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/QueryTermVector.cs?rev=1201243&r1=1201242&r2=1201243&view=diff ============================================================================== --- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/QueryTermVector.cs (original) +++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/QueryTermVector.cs Sat Nov 12 10:44:21 2011 @@ -61,7 +61,7 @@ namespace Lucene.Net.Search bool hasMoreTokens = false; stream.Reset(); - TermAttribute termAtt = (TermAttribute) stream.AddAttribute(typeof(TermAttribute)); + TermAttribute termAtt = stream.AddAttribute(); hasMoreTokens = stream.IncrementToken(); while (hasMoreTokens) Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/SloppyPhraseScorer.cs URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/SloppyPhraseScorer.cs?rev=1201243&r1=1201242&r2=1201243&view=diff ============================================================================== --- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/SloppyPhraseScorer.cs (original) +++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/SloppyPhraseScorer.cs Sat Nov 12 10:44:21 2011 @@ -17,6 +17,7 @@ using System; using System.Linq; +using Lucene.Net.Support; using TermPositions = Lucene.Net.Index.TermPositions; namespace Lucene.Net.Search @@ -157,7 +158,7 @@ namespace Lucene.Net.Search { checkedRepeats = true; // check for repeats - SupportClass.HashMap m = null; + HashMap m = null; for (PhrasePositions pp = first; pp != null; pp = pp.next) { int tpPos = pp.position + pp.offset; @@ -168,7 +169,7 @@ namespace Lucene.Net.Search { if (m == null) { - m = new SupportClass.HashMap(); + m = new HashMap(); } pp.repeats = true; pp2.repeats = true;