You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucenenet.apache.org by cc...@apache.org on 2012/02/28 23:43:28 UTC
[Lucene.Net] svn commit: r1294875 [20/45] - in /incubator/lucene.net/trunk: ./ build/
build/vs2010/contrib/ build/vs2010/test/ doc/ src/ src/contrib/Analyzers/
src/contrib/Analyzers/AR/ src/contrib/Analyzers/BR/
src/contrib/Analyzers/CJK/ src/contrib/Analyzers/Cn/ ...
Modified: incubator/lucene.net/trunk/src/core/Index/TermInfosWriter.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Index/TermInfosWriter.cs?rev=1294875&r1=1294874&r2=1294875&view=diff
==============================================================================
--- incubator/lucene.net/trunk/src/core/Index/TermInfosWriter.cs (original)
+++ incubator/lucene.net/trunk/src/core/Index/TermInfosWriter.cs Tue Feb 28 22:43:08 2012
@@ -28,7 +28,7 @@ namespace Lucene.Net.Index
/// Directory. A TermInfos can be written once, in order.
/// </summary>
- sealed class TermInfosWriter
+ sealed class TermInfosWriter : IDisposable
{
/// <summary>The file format version, a negative number. </summary>
public const int FORMAT = - 3;
@@ -39,7 +39,9 @@ namespace Lucene.Net.Index
// NOTE: always change this if you switch to a new format!
public static readonly int FORMAT_CURRENT = FORMAT_VERSION_UTF8_LENGTH_IN_BYTES;
-
+
+ private bool isDisposed;
+
private FieldInfos fieldInfos;
private IndexOutput output;
private TermInfo lastTi = new TermInfo();
@@ -230,14 +232,19 @@ namespace Lucene.Net.Index
}
/// <summary>Called to complete TermInfos creation. </summary>
- internal void Close()
+ public void Dispose()
{
+ // Move to protected method if class becomes unsealed
+ if (isDisposed) return;
+
output.Seek(4); // write size after format
output.WriteLong(size);
- output.Close();
+ output.Dispose();
if (!isIndex)
- other.Close();
+ other.Dispose();
+
+ isDisposed = true;
}
}
}
\ No newline at end of file
Modified: incubator/lucene.net/trunk/src/core/Index/TermPositions.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Index/TermPositions.cs?rev=1294875&r1=1294874&r2=1294875&view=diff
==============================================================================
--- incubator/lucene.net/trunk/src/core/Index/TermPositions.cs (original)
+++ incubator/lucene.net/trunk/src/core/Index/TermPositions.cs Tue Feb 28 22:43:08 2012
@@ -29,7 +29,7 @@ namespace Lucene.Net.Index
/// <seealso cref="IndexReader.TermPositions()">
/// </seealso>
- public interface TermPositions:TermDocs
+ public interface TermPositions : TermDocs
{
/// <summary>Returns next position in the current document. It is an error to call
/// this more than <see cref="TermDocs.Freq()" /> times
Modified: incubator/lucene.net/trunk/src/core/Index/TermVectorEntryFreqSortedComparator.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Index/TermVectorEntryFreqSortedComparator.cs?rev=1294875&r1=1294874&r2=1294875&view=diff
==============================================================================
--- incubator/lucene.net/trunk/src/core/Index/TermVectorEntryFreqSortedComparator.cs (original)
+++ incubator/lucene.net/trunk/src/core/Index/TermVectorEntryFreqSortedComparator.cs Tue Feb 28 22:43:08 2012
@@ -25,14 +25,11 @@ namespace Lucene.Net.Index
///
///
/// </summary>
- //public class TermVectorEntryFreqSortedComparator : System.Collections.IComparer
- public class TermVectorEntryFreqSortedComparator : System.Collections.Generic.IComparer<System.Object>
+ public class TermVectorEntryFreqSortedComparator : System.Collections.Generic.IComparer<TermVectorEntry>
{
- public virtual int Compare(System.Object object_Renamed, System.Object object1)
+ public virtual int Compare(TermVectorEntry entry, TermVectorEntry entry1)
{
int result = 0;
- TermVectorEntry entry = (TermVectorEntry) object_Renamed;
- TermVectorEntry entry1 = (TermVectorEntry) object1;
result = entry1.GetFrequency() - entry.GetFrequency();
if (result == 0)
{
Modified: incubator/lucene.net/trunk/src/core/Index/TermVectorsReader.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Index/TermVectorsReader.cs?rev=1294875&r1=1294874&r2=1294875&view=diff
==============================================================================
--- incubator/lucene.net/trunk/src/core/Index/TermVectorsReader.cs (original)
+++ incubator/lucene.net/trunk/src/core/Index/TermVectorsReader.cs Tue Feb 28 22:43:08 2012
@@ -23,10 +23,7 @@ using IndexInput = Lucene.Net.Store.Inde
namespace Lucene.Net.Index
{
-
- /// <version> $Id: TermVectorsReader.java 687046 2008-08-19 13:01:11Z mikemccand $
- /// </version>
- public class TermVectorsReader : System.ICloneable
+ class TermVectorsReader : System.ICloneable, IDisposable
{
// NOTE: if you make a new format, it must be larger than
@@ -61,8 +58,9 @@ namespace Lucene.Net.Index
private int docStoreOffset;
private int format;
-
- public /*internal*/ TermVectorsReader(Directory d, System.String segment, FieldInfos fieldInfos):this(d, segment, fieldInfos, BufferedIndexInput.BUFFER_SIZE)
+ private bool isDisposed;
+
+ internal TermVectorsReader(Directory d, System.String segment, FieldInfos fieldInfos):this(d, segment, fieldInfos, BufferedIndexInput.BUFFER_SIZE)
{
}
@@ -136,7 +134,7 @@ namespace Lucene.Net.Index
// wait for a GC to do so.
if (!success)
{
- Close();
+ Dispose();
}
}
}
@@ -239,45 +237,57 @@ namespace Lucene.Net.Index
return format;
}
- internal virtual void Close()
+ public void Dispose()
+ {
+ Dispose(true);
+ }
+
+ protected virtual void Dispose(bool disposing)
{
- // make all effort to close up. Keep the first exception
- // and throw it as a new one.
- System.IO.IOException keep = null;
- if (tvx != null)
- try
- {
- tvx.Close();
- }
- catch (System.IO.IOException e)
- {
- if (keep == null)
- keep = e;
- }
- if (tvd != null)
- try
- {
- tvd.Close();
- }
- catch (System.IO.IOException e)
- {
- if (keep == null)
- keep = e;
- }
- if (tvf != null)
- try
- {
- tvf.Close();
- }
- catch (System.IO.IOException e)
- {
- if (keep == null)
- keep = e;
- }
- if (keep != null)
- {
- throw new System.IO.IOException(keep.StackTrace);
- }
+ if (isDisposed) return;
+
+ if (disposing)
+ {
+ // make all effort to close up. Keep the first exception
+ // and throw it as a new one.
+ System.IO.IOException keep = null;
+ if (tvx != null)
+ try
+ {
+ tvx.Close();
+ }
+ catch (System.IO.IOException e)
+ {
+ if (keep == null)
+ keep = e;
+ }
+ if (tvd != null)
+ try
+ {
+ tvd.Close();
+ }
+ catch (System.IO.IOException e)
+ {
+ if (keep == null)
+ keep = e;
+ }
+ if (tvf != null)
+ try
+ {
+ tvf.Close();
+ }
+ catch (System.IO.IOException e)
+ {
+ if (keep == null)
+ keep = e;
+ }
+ if (keep != null)
+ {
+ throw new System.IO.IOException(keep.StackTrace);
+ }
+ }
+
+ isDisposed = true;
}
/// <summary> </summary>
Modified: incubator/lucene.net/trunk/src/core/Index/TermVectorsTermsWriter.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Index/TermVectorsTermsWriter.cs?rev=1294875&r1=1294874&r2=1294875&view=diff
==============================================================================
--- incubator/lucene.net/trunk/src/core/Index/TermVectorsTermsWriter.cs (original)
+++ incubator/lucene.net/trunk/src/core/Index/TermVectorsTermsWriter.cs Tue Feb 28 22:43:08 2012
@@ -16,14 +16,13 @@
*/
using System;
-
+using System.Collections.Generic;
using IndexOutput = Lucene.Net.Store.IndexOutput;
using RAMOutputStream = Lucene.Net.Store.RAMOutputStream;
using ArrayUtil = Lucene.Net.Util.ArrayUtil;
namespace Lucene.Net.Index
{
-
sealed class TermVectorsTermsWriter:TermsHashConsumer
{
private void InitBlock()
@@ -57,8 +56,8 @@ namespace Lucene.Net.Index
for (int i = start; i < end; i++)
postings[i] = new PostingList();
}
-
- public override void Flush(System.Collections.IDictionary threadsAndFields, SegmentWriteState state)
+
+ public override void Flush(IDictionary<TermsHashConsumerPerThread, ICollection<TermsHashConsumerPerField>> threadsAndFields, SegmentWriteState state)
{
lock (this)
{
@@ -82,14 +81,11 @@ namespace Lucene.Net.Index
tvf.Flush();
}
- 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;
- System.Collections.IEnumerator it2 = ((System.Collections.ICollection) entry.Value).GetEnumerator();
- while (it2.MoveNext())
+ foreach(var field in entry.Value)
{
- TermVectorsTermsWriterPerField perField = (TermVectorsTermsWriterPerField) ((System.Collections.DictionaryEntry) it2.Current).Key;
+ TermVectorsTermsWriterPerField perField = (TermVectorsTermsWriterPerField)field;
perField.termsHashPerField.Reset();
perField.ShrinkHash();
}
@@ -118,9 +114,9 @@ namespace Lucene.Net.Index
if (4 + ((long) state.numDocsInStore) * 16 != state.directory.FileLength(fileName))
throw new System.SystemException("after flush: tvx size mismatch: " + state.numDocsInStore + " docs vs " + state.directory.FileLength(fileName) + " length in bytes of " + fileName + " file exists?=" + state.directory.FileExists(fileName));
- SupportClass.CollectionsHelper.AddIfNotContains(state.flushedFiles, state.docStoreSegmentName + "." + IndexFileNames.VECTORS_INDEX_EXTENSION);
- SupportClass.CollectionsHelper.AddIfNotContains(state.flushedFiles, state.docStoreSegmentName + "." + IndexFileNames.VECTORS_FIELDS_EXTENSION);
- SupportClass.CollectionsHelper.AddIfNotContains(state.flushedFiles, state.docStoreSegmentName + "." + IndexFileNames.VECTORS_DOCUMENTS_EXTENSION);
+ state.flushedFiles.Add(state.docStoreSegmentName + "." + IndexFileNames.VECTORS_INDEX_EXTENSION);
+ state.flushedFiles.Add(state.docStoreSegmentName + "." + IndexFileNames.VECTORS_FIELDS_EXTENSION);
+ state.flushedFiles.Add(state.docStoreSegmentName + "." + IndexFileNames.VECTORS_DOCUMENTS_EXTENSION);
docWriter.RemoveOpenFile(state.docStoreSegmentName + "." + IndexFileNames.VECTORS_INDEX_EXTENSION);
docWriter.RemoveOpenFile(state.docStoreSegmentName + "." + IndexFileNames.VECTORS_FIELDS_EXTENSION);
Modified: incubator/lucene.net/trunk/src/core/Index/TermVectorsTermsWriterPerField.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Index/TermVectorsTermsWriterPerField.cs?rev=1294875&r1=1294874&r2=1294875&view=diff
==============================================================================
--- incubator/lucene.net/trunk/src/core/Index/TermVectorsTermsWriterPerField.cs (original)
+++ incubator/lucene.net/trunk/src/core/Index/TermVectorsTermsWriterPerField.cs Tue Feb 28 22:43:08 2012
@@ -225,7 +225,7 @@ namespace Lucene.Net.Index
{
if (doVectorOffsets)
{
- offsetAttribute = (OffsetAttribute) fieldState.attributeSource.AddAttribute(typeof(OffsetAttribute));
+ offsetAttribute = fieldState.attributeSource.AddAttribute<OffsetAttribute>();
}
else
{
Modified: incubator/lucene.net/trunk/src/core/Index/TermVectorsWriter.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Index/TermVectorsWriter.cs?rev=1294875&r1=1294874&r2=1294875&view=diff
==============================================================================
--- incubator/lucene.net/trunk/src/core/Index/TermVectorsWriter.cs (original)
+++ incubator/lucene.net/trunk/src/core/Index/TermVectorsWriter.cs Tue Feb 28 22:43:08 2012
@@ -24,8 +24,7 @@ using UnicodeUtil = Lucene.Net.Util.Unic
namespace Lucene.Net.Index
{
-
- sealed class TermVectorsWriter
+ sealed class TermVectorsWriter : IDisposable
{
private IndexOutput tvx = null, tvd = null, tvf = null;
@@ -201,8 +200,10 @@ namespace Lucene.Net.Index
}
/// <summary>Close all streams. </summary>
- internal void Close()
+ public void Dispose()
{
+ // Move to a protected method if class becomes unsealed
+
// make an effort to close all streams we can but remember and re-throw
// the first exception encountered in this process
System.IO.IOException keep = null;
Modified: incubator/lucene.net/trunk/src/core/Index/TermsHash.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Index/TermsHash.cs?rev=1294875&r1=1294874&r2=1294875&view=diff
==============================================================================
--- incubator/lucene.net/trunk/src/core/Index/TermsHash.cs (original)
+++ incubator/lucene.net/trunk/src/core/Index/TermsHash.cs Tue Feb 28 22:43:08 2012
@@ -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.
/// </summary>
-
- 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<InvertedDocConsumerPerThread, ICollection<InvertedDocConsumerPerField>> 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<InvertedDocConsumerPerThread, ICollection<InvertedDocConsumerPerField>> threadsAndFields, SegmentWriteState state)
{
lock (this)
{
- System.Collections.IDictionary childThreadsAndFields = new System.Collections.Hashtable();
- System.Collections.IDictionary nextThreadsAndFields;
+ var childThreadsAndFields = new Dictionary<TermsHashConsumerPerThread, ICollection<TermsHashConsumerPerField>>();
+ Dictionary<InvertedDocConsumerPerThread, ICollection<InvertedDocConsumerPerField>> nextThreadsAndFields;
if (nextTermsHash != null)
{
- nextThreadsAndFields = new System.Collections.Hashtable();
+ nextThreadsAndFields = new Dictionary<InvertedDocConsumerPerThread, ICollection<InvertedDocConsumerPerField>>();
}
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<InvertedDocConsumerPerField> 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<TermsHashConsumerPerField> childFields = new HashSet<TermsHashConsumerPerField>();
+ ICollection<InvertedDocConsumerPerField> nextChildFields;
if (nextTermsHash != null)
{
- nextChildFields = new System.Collections.Hashtable();
+ nextChildFields = new HashSet<InvertedDocConsumerPerField>();
}
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/trunk/src/core/Index/TermsHashConsumer.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Index/TermsHashConsumer.cs?rev=1294875&r1=1294874&r2=1294875&view=diff
==============================================================================
--- incubator/lucene.net/trunk/src/core/Index/TermsHashConsumer.cs (original)
+++ incubator/lucene.net/trunk/src/core/Index/TermsHashConsumer.cs Tue Feb 28 22:43:08 2012
@@ -16,6 +16,7 @@
*/
using System;
+using System.Collections.Generic;
namespace Lucene.Net.Index
{
@@ -25,7 +26,7 @@ namespace Lucene.Net.Index
internal abstract int BytesPerPosting();
internal abstract void CreatePostings(RawPostingList[] postings, int start, int count);
public abstract TermsHashConsumerPerThread AddThread(TermsHashPerThread perThread);
- public abstract void Flush(System.Collections.IDictionary threadsAndFields, SegmentWriteState state);
+ public abstract void Flush(IDictionary<TermsHashConsumerPerThread, ICollection<TermsHashConsumerPerField>> threadsAndFields, SegmentWriteState state);
public abstract void Abort();
internal abstract void CloseDocStore(SegmentWriteState state);
Modified: incubator/lucene.net/trunk/src/core/Index/TermsHashPerField.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Index/TermsHashPerField.cs?rev=1294875&r1=1294874&r2=1294875&view=diff
==============================================================================
--- incubator/lucene.net/trunk/src/core/Index/TermsHashPerField.cs (original)
+++ incubator/lucene.net/trunk/src/core/Index/TermsHashPerField.cs Tue Feb 28 22:43:08 2012
@@ -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<TermAttribute>();
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/trunk/src/core/Lucene.Net.csproj
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Lucene.Net.csproj?rev=1294875&r1=1294874&r2=1294875&view=diff
==============================================================================
--- incubator/lucene.net/trunk/src/core/Lucene.Net.csproj (original)
+++ incubator/lucene.net/trunk/src/core/Lucene.Net.csproj Tue Feb 28 22:43:08 2012
@@ -19,7 +19,6 @@
under the License.
-->
-
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
<PropertyGroup>
<ProjectType>Local</ProjectType>
@@ -87,6 +86,8 @@
<WarningLevel>4</WarningLevel>
<DebugType>full</DebugType>
<ErrorReport>prompt</ErrorReport>
+ <CodeAnalysisRuleSet>BasicDesignGuidelineRules.ruleset</CodeAnalysisRuleSet>
+ <RunCodeAnalysis>true</RunCodeAnalysis>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<OutputPath>..\..\build\bin\core\Release\</OutputPath>
@@ -99,14 +100,16 @@
<DocumentationFile>..\..\build\bin\core\Release\Lucene.Net.XML</DocumentationFile>
<FileAlignment>4096</FileAlignment>
<NoStdLib>false</NoStdLib>
- <NoWarn>618</NoWarn>
+ <NoWarn>618,1591</NoWarn>
<Optimize>true</Optimize>
<RegisterForComInterop>false</RegisterForComInterop>
<RemoveIntegerChecks>false</RemoveIntegerChecks>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
<WarningLevel>4</WarningLevel>
- <DebugType>none</DebugType>
+ <DebugType>pdbonly</DebugType>
<ErrorReport>prompt</ErrorReport>
+ <DebugSymbols>true</DebugSymbols>
+ <CodeAnalysisRuleSet>JustDesign.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup>
<SignAssembly>true</SignAssembly>
@@ -116,13 +119,6 @@
<Name>System</Name>
</Reference>
<Reference Include="System.configuration" />
- <Reference Include="System.Data">
- <Name>System.Data</Name>
- </Reference>
- <Reference Include="System.Runtime.Remoting">
- <Name>System.Runtime.Remoting</Name>
- </Reference>
- <Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml">
<Name>System.XML</Name>
</Reference>
@@ -134,7 +130,6 @@
<Compile Include="Analysis\ASCIIFoldingFilter.cs" />
<Compile Include="Analysis\BaseCharFilter.cs" />
<Compile Include="Analysis\CachingTokenFilter.cs" />
- <Compile Include="Analysis\CharacterCache.cs" />
<Compile Include="Analysis\CharArraySet.cs" />
<Compile Include="Analysis\CharFilter.cs" />
<Compile Include="Analysis\CharReader.cs" />
@@ -178,7 +173,6 @@
<Compile Include="Analysis\SimpleAnalyzer.cs">
<SubType>Code</SubType>
</Compile>
- <Compile Include="Analysis\SinkTokenizer.cs" />
<Compile Include="Analysis\Standard\StandardAnalyzer.cs">
<SubType>Code</SubType>
</Compile>
@@ -196,7 +190,6 @@
<SubType>Code</SubType>
</Compile>
<Compile Include="Analysis\TeeSinkTokenFilter.cs" />
- <Compile Include="Analysis\TeeTokenFilter.cs" />
<Compile Include="Analysis\Token.cs">
<SubType>Code</SubType>
</Compile>
@@ -221,7 +214,6 @@
<Compile Include="Analysis\TokenStream.cs">
<SubType>Code</SubType>
</Compile>
- <Compile Include="Analysis\TokenWrapper.cs" />
<Compile Include="Analysis\WhitespaceAnalyzer.cs">
<SubType>Code</SubType>
</Compile>
@@ -290,7 +282,6 @@
<Compile Include="Index\CorruptIndexException.cs" />
<Compile Include="Index\DefaultSkipListReader.cs" />
<Compile Include="Index\DefaultSkipListWriter.cs" />
- <Compile Include="Index\DirectoryOwningReader.cs" />
<Compile Include="Index\DirectoryReader.cs" />
<Compile Include="Index\DocConsumer.cs" />
<Compile Include="Index\DocConsumerPerThread.cs" />
@@ -341,7 +332,6 @@
<Compile Include="Index\FreqProxTermsWriterPerField.cs" />
<Compile Include="Index\FreqProxTermsWriterPerThread.cs" />
<Compile Include="Index\IndexCommit.cs" />
- <Compile Include="Index\IndexCommitPoint.cs" />
<Compile Include="Index\IndexDeletionPolicy.cs" />
<Compile Include="Index\IndexFileDeleter.cs">
<SubType>Code</SubType>
@@ -352,9 +342,6 @@
<Compile Include="Index\IndexFileNames.cs">
<SubType>Code</SubType>
</Compile>
- <Compile Include="Index\IndexModifier.cs">
- <SubType>Code</SubType>
- </Compile>
<Compile Include="Index\IndexReader.cs">
<SubType>Code</SubType>
</Compile>
@@ -546,9 +533,6 @@
<Compile Include="Search\ConstantScoreQuery.cs">
<SubType>Code</SubType>
</Compile>
- <Compile Include="Search\ConstantScoreRangeQuery.cs">
- <SubType>Code</SubType>
- </Compile>
<Compile Include="Search\DefaultSimilarity.cs">
<SubType>Code</SubType>
</Compile>
@@ -569,7 +553,6 @@
<Compile Include="Search\Explanation.cs">
<SubType>Code</SubType>
</Compile>
- <Compile Include="Search\ExtendedFieldCache.cs" />
<Compile Include="Search\FieldCache.cs">
<SubType>Code</SubType>
</Compile>
@@ -586,9 +569,6 @@
<Compile Include="Search\FieldDocSortedHitQueue.cs">
<SubType>Code</SubType>
</Compile>
- <Compile Include="Search\FieldSortedHitQueue.cs">
- <SubType>Code</SubType>
- </Compile>
<Compile Include="Search\FieldValueHitQueue.cs" />
<Compile Include="Search\Filter.cs">
<SubType>Code</SubType>
@@ -610,7 +590,6 @@
<Compile Include="Search\Function\FieldScoreQuery.cs" />
<Compile Include="Search\Function\FloatFieldSource.cs" />
<Compile Include="Search\Function\IntFieldSource.cs" />
- <Compile Include="Search\Function\MultiValueSource.cs" />
<Compile Include="Search\Function\OrdFieldSource.cs" />
<Compile Include="Search\Function\ReverseOrdFieldSource.cs" />
<Compile Include="Search\Function\ShortFieldSource.cs" />
@@ -622,22 +601,9 @@
<Compile Include="Search\FuzzyTermEnum.cs">
<SubType>Code</SubType>
</Compile>
- <Compile Include="Search\Hit.cs">
- <SubType>Code</SubType>
- </Compile>
- <Compile Include="Search\HitCollector.cs">
- <SubType>Code</SubType>
- </Compile>
- <Compile Include="Search\HitCollectorWrapper.cs" />
- <Compile Include="Search\HitIterator.cs">
- <SubType>Code</SubType>
- </Compile>
<Compile Include="Search\HitQueue.cs">
<SubType>Code</SubType>
</Compile>
- <Compile Include="Search\Hits.cs">
- <SubType>Code</SubType>
- </Compile>
<Compile Include="Search\IndexSearcher.cs">
<SubType>Code</SubType>
</Compile>
@@ -660,7 +626,6 @@
<SubType>Code</SubType>
</Compile>
<Compile Include="Search\Payloads\AveragePayloadFunction.cs" />
- <Compile Include="Search\Payloads\BoostingTermQuery.cs" />
<Compile Include="Search\Payloads\MaxPayloadFunction.cs" />
<Compile Include="Search\Payloads\MinPayloadFunction.cs" />
<Compile Include="Search\Payloads\PayloadFunction.cs" />
@@ -690,19 +655,10 @@
<Compile Include="Search\Query.cs">
<SubType>Code</SubType>
</Compile>
- <Compile Include="Search\QueryFilter.cs">
- <SubType>Code</SubType>
- </Compile>
<Compile Include="Search\QueryTermVector.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Search\QueryWrapperFilter.cs" />
- <Compile Include="Search\RangeFilter.cs">
- <SubType>Code</SubType>
- </Compile>
- <Compile Include="Search\RangeQuery.cs">
- <SubType>Code</SubType>
- </Compile>
<Compile Include="Search\ReqExclScorer.cs">
<SubType>Code</SubType>
</Compile>
@@ -713,9 +669,6 @@
<Compile Include="Search\ScoreDoc.cs">
<SubType>Code</SubType>
</Compile>
- <Compile Include="Search\ScoreDocComparator.cs">
- <SubType>Code</SubType>
- </Compile>
<Compile Include="Search\Scorer.cs">
<SubType>Code</SubType>
</Compile>
@@ -731,18 +684,13 @@
<Compile Include="Search\SimilarityDelegator.cs">
<SubType>Code</SubType>
</Compile>
+ <Compile Include="Search\SingleTermEnum.cs" />
<Compile Include="Search\SloppyPhraseScorer.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Search\Sort.cs">
<SubType>Code</SubType>
</Compile>
- <Compile Include="Search\SortComparator.cs">
- <SubType>Code</SubType>
- </Compile>
- <Compile Include="Search\SortComparatorSource.cs">
- <SubType>Code</SubType>
- </Compile>
<Compile Include="Search\SortField.cs">
<SubType>Code</SubType>
</Compile>
@@ -793,19 +741,12 @@
<Compile Include="Search\TermScorer.cs">
<SubType>Code</SubType>
</Compile>
- <Compile Include="Search\TimeLimitedCollector.cs" />
<Compile Include="Search\TimeLimitingCollector.cs" />
- <Compile Include="Search\TopDocCollector.cs">
- <SubType>Code</SubType>
- </Compile>
<Compile Include="Search\TopDocs.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Search\TopDocsCollector.cs" />
<Compile Include="Search\TopFieldCollector.cs" />
- <Compile Include="Search\TopFieldDocCollector.cs">
- <SubType>Code</SubType>
- </Compile>
<Compile Include="Search\TopFieldDocs.cs">
<SubType>Code</SubType>
</Compile>
@@ -819,23 +760,33 @@
<Compile Include="Search\WildcardTermEnum.cs">
<SubType>Code</SubType>
</Compile>
- <Compile Include="Store\AlreadyClosedException.cs" />
+ <Compile Include="Store\AlreadyClosedException.cs">
+ <SubType>Code</SubType>
+ </Compile>
<Compile Include="Store\BufferedIndexInput.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Store\BufferedIndexOutput.cs">
<SubType>Code</SubType>
</Compile>
- <Compile Include="Store\CheckSumIndexInput.cs" />
- <Compile Include="Store\CheckSumIndexOutput.cs" />
+ <Compile Include="Store\CheckSumIndexInput.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Store\CheckSumIndexOutput.cs">
+ <SubType>Code</SubType>
+ </Compile>
<Compile Include="Store\Directory.cs">
<SubType>Code</SubType>
</Compile>
- <Compile Include="Store\FileSwitchDirectory.cs" />
+ <Compile Include="Store\FileSwitchDirectory.cs">
+ <SubType>Code</SubType>
+ </Compile>
<Compile Include="Store\FSDirectory.cs">
<SubType>Code</SubType>
</Compile>
- <Compile Include="Store\FSLockFactory.cs" />
+ <Compile Include="Store\FSLockFactory.cs">
+ <SubType>Code</SubType>
+ </Compile>
<Compile Include="Store\IndexInput.cs">
<SubType>Code</SubType>
</Compile>
@@ -848,21 +799,33 @@
<Compile Include="Store\LockFactory.cs">
<SubType>Code</SubType>
</Compile>
- <Compile Include="Store\LockObtainFailedException.cs" />
- <Compile Include="Store\LockReleaseFailedException.cs" />
- <Compile Include="Store\LockStressTest.cs" />
- <Compile Include="Store\LockVerifyServer.cs" />
+ <Compile Include="Store\LockObtainFailedException.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Store\LockReleaseFailedException.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Store\LockStressTest.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Store\LockVerifyServer.cs">
+ <SubType>Code</SubType>
+ </Compile>
<Compile Include="Store\MMapDirectory.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Store\NativeFSLockFactory.cs">
<SubType>Code</SubType>
</Compile>
- <Compile Include="Store\NIOFSDirectory.cs" />
+ <Compile Include="Store\NIOFSDirectory.cs">
+ <SubType>Code</SubType>
+ </Compile>
<Compile Include="Store\NoLockFactory.cs">
<SubType>Code</SubType>
</Compile>
- <Compile Include="Store\NoSuchDirectoryException.cs" />
+ <Compile Include="Store\NoSuchDirectoryException.cs">
+ <SubType>Code</SubType>
+ </Compile>
<Compile Include="Store\RAMDirectory.cs">
<SubType>Code</SubType>
</Compile>
@@ -875,17 +838,48 @@
<Compile Include="Store\RAMOutputStream.cs">
<SubType>Code</SubType>
</Compile>
- <Compile Include="Store\SimpleFSDirectory.cs" />
+ <Compile Include="Store\SimpleFSDirectory.cs">
+ <SubType>Code</SubType>
+ </Compile>
<Compile Include="Store\SimpleFSLockFactory.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Store\SingleInstanceLockFactory.cs">
<SubType>Code</SubType>
</Compile>
- <Compile Include="Store\VerifyingLockFactory.cs" />
- <Compile Include="SupportClass.cs">
+ <Compile Include="Store\VerifyingLockFactory.cs">
<SubType>Code</SubType>
</Compile>
+ <Compile Include="Support\AppSettings.cs" />
+ <Compile Include="Support\AttributeImplItem.cs" />
+ <Compile Include="Support\BitSetSupport.cs" />
+ <Compile Include="Support\BuildType.cs" />
+ <Compile Include="Support\Character.cs" />
+ <Compile Include="Support\CloseableThreadLocalProfiler.cs" />
+ <Compile Include="Support\CollectionsHelper.cs" />
+ <Compile Include="Support\Compare.cs" />
+ <Compile Include="Support\CRC32.cs" />
+ <Compile Include="Support\Cryptography.cs" />
+ <Compile Include="Support\Deflater.cs" />
+ <Compile Include="Support\Double.cs" />
+ <Compile Include="Support\EquatableList.cs" />
+ <Compile Include="Support\FileSupport.cs" />
+ <Compile Include="Support\GeneralKeyedCollection.cs" />
+ <Compile Include="Support\HashMap.cs" />
+ <Compile Include="Support\Inflater.cs" />
+ <Compile Include="Support\IThreadRunnable.cs" />
+ <Compile Include="Support\Number.cs" />
+ <Compile Include="Support\OS.cs" />
+ <Compile Include="Support\SharpZipLib.cs" />
+ <Compile Include="Support\Single.cs" />
+ <Compile Include="Support\IChecksum.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Support\TextSupport.cs" />
+ <Compile Include="Support\ThreadClass.cs" />
+ <Compile Include="Support\WeakDictionary.cs" />
+ <Compile Include="Support\WeakHashTable.cs" />
+ <Compile Include="Support\WeakReference.cs" />
<Compile Include="Util\ArrayUtil.cs" />
<Compile Include="Util\Attribute.cs" />
<Compile Include="Util\AttributeImpl.cs" />
@@ -901,6 +895,7 @@
</Compile>
<Compile Include="Util\DocIdBitSet.cs" />
<Compile Include="Util\FieldCacheSanityChecker.cs" />
+ <Compile Include="Util\IdentityDictionary.cs" />
<Compile Include="Util\IndexableBinaryStringTools.cs" />
<Compile Include="Util\MapOfSets.cs" />
<Compile Include="Util\MemoryModel.cs" />
@@ -941,21 +936,10 @@
<None Include="Lucene.Net.Search.RemoteSearchable.config" />
<None Include="Lucene.Net.Search.TestSort.config" />
<None Include="Lucene.Net.snk" />
+ <Content Include="Analysis\Standard\READ_BEFORE_REGENERATING.txt" />
+ <Content Include="ChangeNotes.txt" />
+ <Content Include="FileDiffs.txt" />
<None Include="QueryParser\QueryParser.jj" />
- <Content Include="Analysis\Package.html" />
- <Content Include="Analysis\Standard\Package.html" />
- <Content Include="Document\Package.html" />
- <Content Include="Index\Package.html" />
- <Content Include="Messages\Package.html" />
- <Content Include="Overview.html" />
- <Content Include="Package.html" />
- <Content Include="QueryParser\Package.html" />
- <Content Include="Search\Function\Package.html" />
- <Content Include="Search\Package.html" />
- <Content Include="Search\Payloads\Package.html" />
- <Content Include="Search\Spans\Package.html" />
- <Content Include="Store\Package.html" />
- <Content Include="Util\Package.html" />
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include=".NETFramework,Version=v4.0">
Modified: incubator/lucene.net/trunk/src/core/Messages/MessageImpl.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Messages/MessageImpl.cs?rev=1294875&r1=1294874&r2=1294875&view=diff
==============================================================================
--- incubator/lucene.net/trunk/src/core/Messages/MessageImpl.cs (original)
+++ incubator/lucene.net/trunk/src/core/Messages/MessageImpl.cs Tue Feb 28 22:43:08 2012
@@ -16,6 +16,7 @@
*/
using System;
+using System.Text;
namespace Lucene.Net.Messages
{
@@ -38,7 +39,7 @@ namespace Lucene.Net.Messages
this.key = key;
}
- public MessageImpl(System.String key, System.Object[] args):this(key)
+ public MessageImpl(System.String key, params System.Object[] args):this(key)
{
this.arguments = args;
}
@@ -66,15 +67,15 @@ namespace Lucene.Net.Messages
public override System.String ToString()
{
System.Object[] args = GetArguments();
- System.String argsString = "";
+ StringBuilder argsString = new StringBuilder();
if (args != null)
{
for (int i = 0; i < args.Length; i++)
{
- argsString += (args[i] + (i < args.Length?"":", "));
+ argsString.Append(i == 0 ? " " : ", ").Append(args[i]);
}
}
- return GetKey() + " " + argsString;
+ return argsString.ToString();
}
}
}
\ No newline at end of file
Modified: incubator/lucene.net/trunk/src/core/Messages/NLS.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Messages/NLS.cs?rev=1294875&r1=1294874&r2=1294875&view=diff
==============================================================================
--- incubator/lucene.net/trunk/src/core/Messages/NLS.cs (original)
+++ incubator/lucene.net/trunk/src/core/Messages/NLS.cs Tue Feb 28 22:43:08 2012
@@ -16,6 +16,8 @@
*/
using System;
+using System.Collections.Generic;
+using Lucene.Net.Support;
namespace Lucene.Net.Messages
{
@@ -62,7 +64,7 @@ namespace Lucene.Net.Messages
}
}
- private static System.Collections.IDictionary bundles = new System.Collections.Hashtable(0);
+ private static IDictionary<string, Type> bundles = new HashMap<string, Type>(0);
protected internal NLS()
{
@@ -84,7 +86,7 @@ namespace Lucene.Net.Messages
return message.ToString();
}
- public static System.String GetLocalizedMessage(System.String key, System.Globalization.CultureInfo locale, System.Object[] args)
+ public static System.String GetLocalizedMessage(System.String key, System.Globalization.CultureInfo locale, params System.Object[] args)
{
System.String str = GetLocalizedMessage(key, locale);
@@ -96,7 +98,7 @@ namespace Lucene.Net.Messages
return str;
}
- public static System.String GetLocalizedMessage(System.String key, System.Object[] args)
+ public static System.String GetLocalizedMessage(System.String key, params System.Object[] args)
{
return GetLocalizedMessage(key, System.Threading.Thread.CurrentThread.CurrentCulture, args);
}
@@ -110,13 +112,13 @@ namespace Lucene.Net.Messages
/// <param name="clazz">where constants will reside
/// </param>
//@SuppressWarnings("unchecked")
- protected internal static void InitializeMessages(System.String bundleName, System.Type clazz)
+ protected internal static void InitializeMessages<T>(System.String bundleName)
{
try
{
- Load(clazz);
- if (!bundles.Contains(bundleName))
- bundles[bundleName] = clazz;
+ Load<T>();
+ if (!bundles.ContainsKey(bundleName))
+ bundles[bundleName] = typeof(T);
}
catch (System.Exception e)
{
@@ -130,9 +132,9 @@ namespace Lucene.Net.Messages
// slow resource checking
// need to loop thru all registered resource bundles
- for (System.Collections.IEnumerator it = bundles.Keys.GetEnumerator(); it.MoveNext(); )
+ for (var it = bundles.Keys.GetEnumerator(); it.MoveNext(); )
{
- System.Type clazz = (System.Type) bundles[(System.String) it.Current];
+ System.Type clazz = bundles[it.Current];
System.Threading.Thread.CurrentThread.CurrentUICulture = locale;
System.Resources.ResourceManager resourceBundle = System.Resources.ResourceManager.CreateFileBasedResourceManager(clazz.Name, "Messages", null); //{{Lucene.Net-2.9.1}} Can we make resourceDir "Messages" more general?
if (resourceBundle != null)
@@ -153,31 +155,28 @@ namespace Lucene.Net.Messages
return null;
}
- /// <param name="clazz">
- /// </param>
- private static void Load(System.Type clazz)
+ private static void Load<T>()
{
- System.Reflection.FieldInfo[] fieldArray = clazz.GetFields(System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.DeclaredOnly | System.Reflection.BindingFlags.Static);
+ var clazz = typeof (T);
+ System.Reflection.FieldInfo[] fieldArray = clazz.GetFields(System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.DeclaredOnly | System.Reflection.BindingFlags.Static);
bool isFieldAccessible = clazz.IsPublic;
// build a map of field names to Field objects
int len = fieldArray.Length;
- System.Collections.IDictionary fields = new System.Collections.Hashtable(len * 2);
+ var fields = new HashMap<string, System.Reflection.FieldInfo>(len * 2);
for (int i = 0; i < len; i++)
{
fields[fieldArray[i].Name] = fieldArray[i];
- LoadfieldValue(fieldArray[i], isFieldAccessible, clazz);
+ LoadfieldValue<T>(fieldArray[i], isFieldAccessible);
}
}
- /// <param name="field">
- /// </param>
- /// <param name="isFieldAccessible">
- /// </param>
- /// <param name="clazz"></param>
- private static void LoadfieldValue(System.Reflection.FieldInfo field, bool isFieldAccessible, System.Type clazz)
- {
+ /// <param name="field"></param>
+ /// <param name="isFieldAccessible"></param>
+ private static void LoadfieldValue<T>(System.Reflection.FieldInfo field, bool isFieldAccessible)
+ {
+ var clazz = typeof (T);
/*
int MOD_EXPECTED = Modifier.PUBLIC | Modifier.STATIC;
int MOD_MASK = MOD_EXPECTED | Modifier.FINAL;
@@ -193,7 +192,7 @@ namespace Lucene.Net.Messages
try
{
field.SetValue(null, field.Name);
- ValidateMessage(field.Name, clazz);
+ ValidateMessage<T>(field.Name);
}
catch (System.ArgumentException e)
{
@@ -207,9 +206,10 @@ namespace Lucene.Net.Messages
/// <param name="key">- Message Key
/// </param>
- private static void ValidateMessage(System.String key, System.Type clazz)
+ private static void ValidateMessage<T>(System.String key)
{
// Test if the message is present in the resource bundle
+ var clazz = typeof (T);
try
{
System.Threading.Thread.CurrentThread.CurrentUICulture = System.Threading.Thread.CurrentThread.CurrentCulture;
Modified: incubator/lucene.net/trunk/src/core/QueryParser/CharStream.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/QueryParser/CharStream.cs?rev=1294875&r1=1294874&r2=1294875&view=diff
==============================================================================
--- incubator/lucene.net/trunk/src/core/QueryParser/CharStream.cs (original)
+++ incubator/lucene.net/trunk/src/core/QueryParser/CharStream.cs Tue Feb 28 22:43:08 2012
@@ -39,7 +39,6 @@ namespace Lucene.Net.QueryParsers
public interface CharStream
{
-
/// <summary> Returns the next character from the selected input. The method
/// of selecting the input is the responsibility of the class
/// implementing this interface. Can throw any java.io.IOException.
@@ -121,5 +120,5 @@ namespace Lucene.Net.QueryParsers
/// </summary>
void Done();
}
- /* JavaCC - OriginalChecksum=a83909a2403f969f94d18375f9f143e4 (do not edit this line) */
+ /* JavaCC - OriginalChecksum=32a89423891f765dde472f7ef0e3ef7b (do not edit this line) */
}
\ No newline at end of file
Modified: incubator/lucene.net/trunk/src/core/QueryParser/MultiFieldQueryParser.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/QueryParser/MultiFieldQueryParser.cs?rev=1294875&r1=1294874&r2=1294875&view=diff
==============================================================================
--- incubator/lucene.net/trunk/src/core/QueryParser/MultiFieldQueryParser.cs (original)
+++ incubator/lucene.net/trunk/src/core/QueryParser/MultiFieldQueryParser.cs Tue Feb 28 22:43:08 2012
@@ -16,7 +16,7 @@
*/
using System;
-
+using System.Collections.Generic;
using Analyzer = Lucene.Net.Analysis.Analyzer;
using BooleanClause = Lucene.Net.Search.BooleanClause;
using BooleanQuery = Lucene.Net.Search.BooleanQuery;
@@ -31,12 +31,12 @@ namespace Lucene.Net.QueryParsers
/// <summary> A QueryParser which constructs queries to search multiple fields.
///
/// </summary>
- /// <version> $Revision: 829134 $
+ /// <version> $Revision: 829231 $
/// </version>
public class MultiFieldQueryParser:QueryParser
{
- protected internal System.String[] fields;
- protected internal System.Collections.IDictionary boosts;
+ protected internal string[] fields;
+ protected internal IDictionary<string, float> boosts;
/// <summary> Creates a MultiFieldQueryParser. Allows passing of a map with term to
/// Boost, and the boost to apply to each term.
@@ -71,92 +71,13 @@ namespace Lucene.Net.QueryParsers
/// In other words, all the query's terms must appear, but it doesn't matter
/// in what fields they appear.
/// <p/>
- ///
/// </summary>
- /// <deprecated> Please use
- /// <see cref="MultiFieldQueryParser(Version, String[], Analyzer, System.Collections.IDictionary)" />
- /// instead
- /// </deprecated>
- [Obsolete("Please use MultiFieldQueryParser(Version, String[], Analyzer, IDictionary) instead")]
- public MultiFieldQueryParser(System.String[] fields, Analyzer analyzer, System.Collections.IDictionary boosts):this(Version.LUCENE_24, fields, analyzer)
+ public MultiFieldQueryParser(Version matchVersion, string[] fields, Analyzer analyzer, IDictionary<string,float> boosts)
+ : this(matchVersion, fields, analyzer)
{
this.boosts = boosts;
}
- /// <summary> Creates a MultiFieldQueryParser. Allows passing of a map with term to
- /// Boost, and the boost to apply to each term.
- ///
- /// <p/>
- /// It will, when parse(String query) is called, construct a query like this
- /// (assuming the query consists of two terms and you specify the two fields
- /// <c>title</c> and <c>body</c>):
- /// <p/>
- ///
- /// <code>
- /// (title:term1 body:term1) (title:term2 body:term2)
- /// </code>
- ///
- /// <p/>
- /// When setDefaultOperator(AND_OPERATOR) is set, the result will be:
- /// <p/>
- ///
- /// <code>
- /// +(title:term1 body:term1) +(title:term2 body:term2)
- /// </code>
- ///
- /// <p/>
- /// When you pass a boost (title=>5 body=>10) you can get
- /// <p/>
- ///
- /// <code>
- /// +(title:term1^5.0 body:term1^10.0) +(title:term2^5.0 body:term2^10.0)
- /// </code>
- ///
- /// <p/>
- /// In other words, all the query's terms must appear, but it doesn't matter
- /// in what fields they appear.
- /// <p/>
- /// </summary>
- public MultiFieldQueryParser(Version matchVersion, System.String[] fields, Analyzer analyzer, System.Collections.IDictionary boosts):this(matchVersion, fields, analyzer)
- {
- this.boosts = boosts;
- }
-
- /// <summary> Creates a MultiFieldQueryParser.
- ///
- /// <p/>
- /// It will, when parse(String query) is called, construct a query like this
- /// (assuming the query consists of two terms and you specify the two fields
- /// <c>title</c> and <c>body</c>):
- /// <p/>
- ///
- /// <code>
- /// (title:term1 body:term1) (title:term2 body:term2)
- /// </code>
- ///
- /// <p/>
- /// When setDefaultOperator(AND_OPERATOR) is set, the result will be:
- /// <p/>
- ///
- /// <code>
- /// +(title:term1 body:term1) +(title:term2 body:term2)
- /// </code>
- ///
- /// <p/>
- /// In other words, all the query's terms must appear, but it doesn't matter
- /// in what fields they appear.
- /// <p/>
- ///
- /// </summary>
- /// <deprecated> Please use
- /// <see cref="MultiFieldQueryParser(Version, String[], Analyzer)" />
- /// instead
- /// </deprecated>
- [Obsolete("Please use MultiFieldQueryParser(Version, String[], Analyzer) instead")]
- public MultiFieldQueryParser(System.String[] fields, Analyzer analyzer):this(Version.LUCENE_24, fields, analyzer)
- {
- }
-
/// <summary> Creates a MultiFieldQueryParser.
///
/// <p/>
@@ -187,11 +108,11 @@ namespace Lucene.Net.QueryParsers
this.fields = fields;
}
- protected internal override Query GetFieldQuery(System.String field, System.String queryText, int slop)
+ protected internal override Query GetFieldQuery(string field, string queryText, int slop)
{
if (field == null)
{
- System.Collections.IList clauses = new System.Collections.ArrayList();
+ IList<BooleanClause> clauses = new List<BooleanClause>();
for (int i = 0; i < fields.Length; i++)
{
Query q = base.GetFieldQuery(fields[i], queryText);
@@ -201,11 +122,8 @@ namespace Lucene.Net.QueryParsers
if (boosts != null)
{
//Get the boost from the map and apply them
- if (boosts.Contains(fields[i]))
- {
- System.Single boost = (System.Single) boosts[fields[i]];
- q.SetBoost((float) boost);
- }
+ Single boost = boosts[fields[i]];
+ q.SetBoost(boost);
}
ApplySlop(q, slop);
clauses.Add(new BooleanClause(q, BooleanClause.Occur.SHOULD));
@@ -244,7 +162,7 @@ namespace Lucene.Net.QueryParsers
{
if (field == null)
{
- System.Collections.IList clauses = new System.Collections.ArrayList();
+ IList<BooleanClause> clauses = new List<BooleanClause>();
for (int i = 0; i < fields.Length; i++)
{
clauses.Add(new BooleanClause(GetFuzzyQuery(fields[i], termStr, minSimilarity), BooleanClause.Occur.SHOULD));
@@ -258,7 +176,7 @@ namespace Lucene.Net.QueryParsers
{
if (field == null)
{
- System.Collections.IList clauses = new System.Collections.ArrayList();
+ IList<BooleanClause> clauses = new List<BooleanClause>();
for (int i = 0; i < fields.Length; i++)
{
clauses.Add(new BooleanClause(GetPrefixQuery(fields[i], termStr), BooleanClause.Occur.SHOULD));
@@ -272,7 +190,7 @@ namespace Lucene.Net.QueryParsers
{
if (field == null)
{
- System.Collections.IList clauses = new System.Collections.ArrayList();
+ IList<BooleanClause> clauses = new List<BooleanClause>();
for (int i = 0; i < fields.Length; i++)
{
clauses.Add(new BooleanClause(GetWildcardQuery(fields[i], termStr), BooleanClause.Occur.SHOULD));
@@ -287,7 +205,7 @@ namespace Lucene.Net.QueryParsers
{
if (field == null)
{
- System.Collections.IList clauses = new System.Collections.ArrayList();
+ IList<BooleanClause> clauses = new List<BooleanClause>();
for (int i = 0; i < fields.Length; i++)
{
clauses.Add(new BooleanClause(GetRangeQuery(fields[i], part1, part2, inclusive), BooleanClause.Occur.SHOULD));
@@ -301,37 +219,6 @@ namespace Lucene.Net.QueryParsers
/// <p/>
/// If x fields are specified, this effectively constructs:
///
- /// <code>
- /// (field1:query1) (field2:query2) (field3:query3)...(fieldx:queryx)
- /// </code>
- ///
- /// </summary>
- /// <param name="queries">Queries strings to parse
- /// </param>
- /// <param name="fields">Fields to search on
- /// </param>
- /// <param name="analyzer">Analyzer to use
- /// </param>
- /// <throws> ParseException </throws>
- /// <summary> if query parsing fails
- /// </summary>
- /// <throws> IllegalArgumentException </throws>
- /// <summary> if the length of the queries array differs from the length of
- /// the fields array
- /// </summary>
- /// <deprecated> Use <see cref="Parse(Version,String[],String[],Analyzer)" />
- /// instead
- /// </deprecated>
- [Obsolete("Use Parse(Version,String[],String[],Analyzer) instead")]
- public static Query Parse(System.String[] queries, System.String[] fields, Analyzer analyzer)
- {
- return Parse(Version.LUCENE_24, queries, fields, analyzer);
- }
-
- /// <summary> Parses a query which searches on the fields specified.
- /// <p/>
- /// If x fields are specified, this effectively constructs:
- ///
/// <code>
/// (field1:query1) (field2:query2) (field3:query3)...(fieldx:queryx)
/// </code>
@@ -370,47 +257,6 @@ namespace Lucene.Net.QueryParsers
return bQuery;
}
- /// <summary> Parses a query, searching on the fields specified.
- /// Use this if you need to specify certain fields as required,
- /// and others as prohibited.
- /// <p/>
- /// Usage:
- /// <code>
- /// String[] fields = {"filename", "contents", "description"};
- /// BooleanClause.Occur[] flags = {BooleanClause.Occur.SHOULD,
- /// BooleanClause.Occur.MUST,
- /// BooleanClause.Occur.MUST_NOT};
- /// MultiFieldQueryParser.parse("query", fields, flags, analyzer);
- /// </code>
- /// <p/>
- /// The code above would construct a query:
- /// <code>
- /// (filename:query) +(contents:query) -(description:query)
- /// </code>
- ///
- /// </summary>
- /// <param name="query">Query string to parse
- /// </param>
- /// <param name="fields">Fields to search on
- /// </param>
- /// <param name="flags">Flags describing the fields
- /// </param>
- /// <param name="analyzer">Analyzer to use
- /// </param>
- /// <throws> ParseException if query parsing fails </throws>
- /// <throws> IllegalArgumentException if the length of the fields array differs </throws>
- /// <summary> from the length of the flags array
- /// </summary>
- /// <deprecated> Use
- /// <see cref="Parse(Version, String, String[], BooleanClause.Occur[], Analyzer)" />
- /// instead
- /// </deprecated>
- [Obsolete("Use Parse(Version, String, String[], BooleanClause.Occur[], Analyzer) instead")]
- public static Query Parse(System.String query, System.String[] fields, BooleanClause.Occur[] flags, Analyzer analyzer)
- {
- return Parse(Version.LUCENE_24, query, fields, flags, analyzer);
- }
-
/// <summary> Parses a query, searching on the fields specified. Use this if you need
/// to specify certain fields as required, and others as prohibited.
/// <p/>
@@ -465,48 +311,6 @@ namespace Lucene.Net.QueryParsers
return bQuery;
}
- /// <summary> Parses a query, searching on the fields specified.
- /// Use this if you need to specify certain fields as required,
- /// and others as prohibited.
- /// <p/>
- /// Usage:
- /// <code>
- /// String[] query = {"query1", "query2", "query3"};
- /// String[] fields = {"filename", "contents", "description"};
- /// BooleanClause.Occur[] flags = {BooleanClause.Occur.SHOULD,
- /// BooleanClause.Occur.MUST,
- /// BooleanClause.Occur.MUST_NOT};
- /// MultiFieldQueryParser.parse(query, fields, flags, analyzer);
- /// </code>
- /// <p/>
- /// The code above would construct a query:
- /// <code>
- /// (filename:query1) +(contents:query2) -(description:query3)
- /// </code>
- ///
- /// </summary>
- /// <param name="queries">Queries string to parse
- /// </param>
- /// <param name="fields">Fields to search on
- /// </param>
- /// <param name="flags">Flags describing the fields
- /// </param>
- /// <param name="analyzer">Analyzer to use
- /// </param>
- /// <throws> ParseException if query parsing fails </throws>
- /// <throws> IllegalArgumentException if the length of the queries, fields, </throws>
- /// <summary> and flags array differ
- /// </summary>
- /// <deprecated> Used
- /// <see cref="Parse(Version, String[], String[], BooleanClause.Occur[], Analyzer)" />
- /// instead
- /// </deprecated>
- [Obsolete("Use Parse(Version, String[], String[], BooleanClause.Occur[], Analyzer) instead")]
- public static Query Parse(System.String[] queries, System.String[] fields, BooleanClause.Occur[] flags, Analyzer analyzer)
- {
- return Parse(Version.LUCENE_24, queries, fields, flags, analyzer);
- }
-
/// <summary> Parses a query, searching on the fields specified. Use this if you need
/// to specify certain fields as required, and others as prohibited.
/// <p/>
Modified: incubator/lucene.net/trunk/src/core/QueryParser/ParseException.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/QueryParser/ParseException.cs?rev=1294875&r1=1294874&r2=1294875&view=diff
==============================================================================
--- incubator/lucene.net/trunk/src/core/QueryParser/ParseException.cs (original)
+++ incubator/lucene.net/trunk/src/core/QueryParser/ParseException.cs Tue Feb 28 22:43:08 2012
@@ -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;
/// <summary> The end of line string for this machine.</summary>
- protected internal System.String eol = SupportClass.AppSettings.Get("line.separator", "\n");
+ protected internal System.String eol = AppSettings.Get("line.separator", "\n");
/// <summary> Used to convert raw characters to their escaped version
/// when these raw version cannot be used as part of an ASCII
@@ -239,5 +240,5 @@ namespace Lucene.Net.QueryParsers
return retval.ToString();
}
}
- /* JavaCC - OriginalChecksum=c63b396885c4ff44d7aa48d3feae60cd (do not edit this line) */
+ /* JavaCC - OriginalChecksum=c7631a240f7446940695eac31d9483ca (do not edit this line) */
}
\ No newline at end of file
Modified: incubator/lucene.net/trunk/src/core/QueryParser/QueryParser.JJ
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/QueryParser/QueryParser.JJ?rev=1294875&r1=1294874&r2=1294875&view=diff
==============================================================================
--- incubator/lucene.net/trunk/src/core/QueryParser/QueryParser.JJ (original)
+++ incubator/lucene.net/trunk/src/core/QueryParser/QueryParser.JJ Tue Feb 28 22:43:08 2012
@@ -36,7 +36,6 @@ import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
-import java.util.Vector;
import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.CachingTokenFilter;
@@ -58,7 +57,6 @@ import org.apache.lucene.search.Query;
import org.apache.lucene.search.TermRangeQuery;
import org.apache.lucene.search.TermQuery;
import org.apache.lucene.search.WildcardQuery;
-import org.apache.lucene.util.Parameter;
import org.apache.lucene.util.Version;
/**
@@ -170,7 +168,7 @@ public class QueryParser {
// the default date resolution
DateTools.Resolution dateResolution = null;
// maps field names to date resolutions
- Map fieldToDateResolution = null;
+ Map<String,DateTools.Resolution> fieldToDateResolution = null;
// The collator to use when determining range inclusion,
// for use when constructing RangeQuerys.
@@ -179,23 +177,7 @@ public class QueryParser {
/** The default operator for parsing queries.
* Use {@link QueryParser#setDefaultOperator} to change it.
*/
- static public final class Operator extends Parameter {
- private Operator(String name) {
- super(name);
- }
- static public final Operator OR = new Operator("OR");
- static public final Operator AND = new Operator("AND");
- }
-
-
- /** Constructs a query parser.
- * @param f the default field for query terms.
- * @param a used to find terms in the query text.
- * @deprecated Use {@link #QueryParser(Version, String, Analyzer)} instead
- */
- public QueryParser(String f, Analyzer a) {
- this(Version.LUCENE_24, f, a);
- }
+ static public enum Operator { OR, AND }
/** Constructs a query parser.
* @param matchVersion Lucene version to match. See {@link <a href="#version">above</a>)
@@ -384,29 +366,6 @@ public class QueryParser {
}
/**
- * @deprecated Please use {@link #setMultiTermRewriteMethod} instead.
- */
- public void setUseOldRangeQuery(boolean useOldRangeQuery) {
- if (useOldRangeQuery) {
- setMultiTermRewriteMethod(MultiTermQuery.SCORING_BOOLEAN_QUERY_REWRITE);
- } else {
- setMultiTermRewriteMethod(MultiTermQuery.CONSTANT_SCORE_AUTO_REWRITE_DEFAULT);
- }
- }
-
-
- /**
- * @deprecated Please use {@link #getMultiTermRewriteMethod} instead.
- */
- public boolean getUseOldRangeQuery() {
- if (getMultiTermRewriteMethod() == MultiTermQuery.SCORING_BOOLEAN_QUERY_REWRITE) {
- return true;
- } else {
- return false;
- }
- }
-
- /**
* By default QueryParser uses {@link MultiTermQuery#CONSTANT_SCORE_AUTO_REWRITE_DEFAULT}
* when creating a PrefixQuery, WildcardQuery or RangeQuery. This implementation is generally preferable because it
* a) Runs faster b) Does not have the scarcity of terms unduly influence score
@@ -466,7 +425,7 @@ public class QueryParser {
if (fieldToDateResolution == null) {
// lazily initialize HashMap
- fieldToDateResolution = new HashMap();
+ fieldToDateResolution = new HashMap<String,DateTools.Resolution>();
}
fieldToDateResolution.put(fieldName, dateResolution);
@@ -488,7 +447,7 @@ public class QueryParser {
return this.dateResolution;
}
- DateTools.Resolution resolution = (DateTools.Resolution) fieldToDateResolution.get(fieldName);
+ DateTools.Resolution resolution = fieldToDateResolution.get(fieldName);
if (resolution == null) {
// no date resolutions set for the given field; return default date resolution instead
resolution = this.dateResolution;
@@ -521,20 +480,13 @@ public class QueryParser {
return rangeCollator;
}
- /**
- * @deprecated use {@link #addClause(List, int, int, Query)} instead.
- */
- protected void addClause(Vector clauses, int conj, int mods, Query q) {
- addClause((List) clauses, conj, mods, q);
- }
-
- protected void addClause(List clauses, int conj, int mods, Query q) {
+ protected void addClause(List<BooleanClause> clauses, int conj, int mods, Query q) {
boolean required, prohibited;
// If this term is introduced by AND, make the preceding term required,
// unless it's already prohibited
if (clauses.size() > 0 && conj == CONJ_AND) {
- BooleanClause c = (BooleanClause) clauses.get(clauses.size()-1);
+ BooleanClause c = clauses.get(clauses.size()-1);
if (!c.isProhibited())
c.setOccur(BooleanClause.Occur.MUST);
}
@@ -544,7 +496,7 @@ public class QueryParser {
// unless it's prohibited (that means we leave -a OR b but +a OR b-->a OR b)
// notice if the input is a OR b, first term is parsed as required; without
// this modification a OR b would parsed as +a OR b
- BooleanClause c = (BooleanClause) clauses.get(clauses.size()-1);
+ BooleanClause c = clauses.get(clauses.size()-1);
if (!c.isProhibited())
c.setOccur(BooleanClause.Occur.SHOULD);
}
@@ -607,10 +559,10 @@ public class QueryParser {
}
if (success) {
if (buffer.hasAttribute(TermAttribute.class)) {
- termAtt = (TermAttribute) buffer.getAttribute(TermAttribute.class);
+ termAtt = buffer.getAttribute(TermAttribute.class);
}
if (buffer.hasAttribute(PositionIncrementAttribute.class)) {
- posIncrAtt = (PositionIncrementAttribute) buffer.getAttribute(PositionIncrementAttribute.class);
+ posIncrAtt = buffer.getAttribute(PositionIncrementAttribute.class);
}
}
@@ -683,7 +635,7 @@ public class QueryParser {
// phrase query:
MultiPhraseQuery mpq = newMultiPhraseQuery();
mpq.setSlop(phraseSlop);
- List multiTerms = new ArrayList();
+ List<Term> multiTerms = new ArrayList<Term>();
int position = -1;
for (int i = 0; i < numTokens; i++) {
String term = null;
@@ -701,9 +653,9 @@ public class QueryParser {
if (positionIncrement > 0 && multiTerms.size() > 0) {
if (enablePositionIncrements) {
- mpq.add((Term[])multiTerms.toArray(new Term[0]),position);
+ mpq.add(multiTerms.toArray(new Term[0]),position);
} else {
- mpq.add((Term[])multiTerms.toArray(new Term[0]));
+ mpq.add(multiTerms.toArray(new Term[0]));
}
multiTerms.clear();
}
@@ -711,9 +663,9 @@ public class QueryParser {
multiTerms.add(new Term(field, term));
}
if (enablePositionIncrements) {
- mpq.add((Term[])multiTerms.toArray(new Term[0]),position);
+ mpq.add(multiTerms.toArray(new Term[0]),position);
} else {
- mpq.add((Term[])multiTerms.toArray(new Term[0]));
+ mpq.add(multiTerms.toArray(new Term[0]));
}
return mpq;
}
@@ -933,26 +885,8 @@ public class QueryParser {
*
* @return Resulting {@link Query} object.
* @exception ParseException throw in overridden method to disallow
- * @deprecated use {@link #getBooleanQuery(List)} instead
*/
- protected Query getBooleanQuery(Vector clauses) throws ParseException {
- return getBooleanQuery((List) clauses, false);
- }
-
- /**
- * Factory method for generating query, given a set of clauses.
- * By default creates a boolean query composed of clauses passed in.
- *
- * Can be overridden by extending classes, to modify query being
- * returned.
- *
- * @param clauses List that contains {@link BooleanClause} instances
- * to join.
- *
- * @return Resulting {@link Query} object.
- * @exception ParseException throw in overridden method to disallow
- */
- protected Query getBooleanQuery(List clauses) throws ParseException {
+ protected Query getBooleanQuery(List<BooleanClause> clauses) throws ParseException {
return getBooleanQuery(clauses, false);
}
@@ -969,37 +903,16 @@ public class QueryParser {
*
* @return Resulting {@link Query} object.
* @exception ParseException throw in overridden method to disallow
- * @deprecated use {@link #getBooleanQuery(List, boolean)} instead
- */
- protected Query getBooleanQuery(Vector clauses, boolean disableCoord)
- throws ParseException
- {
- return getBooleanQuery((List) clauses, disableCoord);
- }
-
- /**
- * Factory method for generating query, given a set of clauses.
- * By default creates a boolean query composed of clauses passed in.
- *
- * Can be overridden by extending classes, to modify query being
- * returned.
- *
- * @param clauses List that contains {@link BooleanClause} instances
- * to join.
- * @param disableCoord true if coord scoring should be disabled.
- *
- * @return Resulting {@link Query} object.
- * @exception ParseException throw in overridden method to disallow
*/
- protected Query getBooleanQuery(List clauses, boolean disableCoord)
+ protected Query getBooleanQuery(List<BooleanClause> clauses, boolean disableCoord)
throws ParseException
{
if (clauses.size()==0) {
return null; // all clause words were filtered away by the analyzer.
}
BooleanQuery query = newBooleanQuery(disableCoord);
- for (int i = 0; i < clauses.size(); i++) {
- query.add((BooleanClause)clauses.get(i));
+ for(final BooleanClause clause: clauses) {
+ query.add(clause);
}
return query;
}
@@ -1179,7 +1092,7 @@ public class QueryParser {
* expects to be escaped are escaped by a preceding <code>\</code>.
*/
public static String escape(String s) {
- StringBuffer sb = new StringBuffer();
+ StringBuilder sb = new StringBuilder();
for (int i = 0; i < s.length(); i++) {
char c = s.charAt(i);
// These characters are part of the query syntax and must be escaped
@@ -1310,7 +1223,7 @@ Query TopLevelQuery(String field) :
Query Query(String field) :
{
- List clauses = new ArrayList();
+ List<BooleanClause> clauses = new ArrayList<BooleanClause>();
Query q, firstQuery=null;
int conj, mods;
}