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 2011/11/16 09:33:39 UTC
[Lucene.Net] svn commit: r1202583 - in
/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk: src/core/Analysis/
src/core/Index/ src/core/QueryParser/ src/core/Store/ src/core/Support/
src/core/Util/ test/core/ test/core/Analysis/ test/core/Index/
test/core/QueryPa...
Author: ccurrens
Date: Wed Nov 16 08:33:37 2011
New Revision: 1202583
URL: http://svn.apache.org/viewvc?rev=1202583&view=rev
Log:
Fixed code to pass more tests
Modified:
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Analysis/CharArraySet.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Analysis/NormalizeCharMap.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Analysis/PerFieldAnalyzerWrapper.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Analysis/StopFilter.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Analysis/TokenStream.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/ConcurrentMergeScheduler.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/FreqProxTermsWriter.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/IndexWriter.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/TermVectorsTermsWriter.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/TermsHashConsumer.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/QueryParser/QueryParser.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Store/FSDirectory.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Store/SimpleFSDirectory.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Support/HashMap.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Support/WeakDictionary.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Util/AttributeSource.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Util/AverageGuessMemoryModel.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Analysis/TestCharArraySet.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Analysis/TestStopAnalyzer.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Index/TestBackwardsCompatibility.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Index/TestIndexCommit.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Index/TestIndexWriter.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Lucene.Net.Test.csproj
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/QueryParser/TestMultiAnalyzer.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/QueryParser/TestQueryParser.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Util/TestNumericUtils.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Util/TestVersion.cs
Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Analysis/CharArraySet.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Analysis/CharArraySet.cs?rev=1202583&r1=1202582&r2=1202583&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Analysis/CharArraySet.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Analysis/CharArraySet.cs Wed Nov 16 08:33:37 2011
@@ -359,9 +359,7 @@ namespace Lucene.Net.Analysis
public void Clear()
{
- if (_ReadOnly) throw new NotSupportedException();
- _Entries = null;
- _Count = 0;
+ throw new NotSupportedException("Remove not supported!");
}
public bool IsReadOnly
Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Analysis/NormalizeCharMap.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Analysis/NormalizeCharMap.cs?rev=1202583&r1=1202582&r2=1202583&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Analysis/NormalizeCharMap.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Analysis/NormalizeCharMap.cs Wed Nov 16 08:33:37 2011
@@ -16,6 +16,7 @@
*/
using System;
+using Lucene.Net.Support;
namespace Lucene.Net.Analysis
{
@@ -47,7 +48,7 @@ namespace Lucene.Net.Analysis
char c = singleMatch[i];
if (currMap.submap == null)
{
- currMap.submap = new System.Collections.Generic.Dictionary<char, NormalizeCharMap>(1);
+ currMap.submap = new HashMap<char, NormalizeCharMap>(1);
}
NormalizeCharMap map = currMap.submap[c];
if (map == null)
Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Analysis/PerFieldAnalyzerWrapper.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Analysis/PerFieldAnalyzerWrapper.cs?rev=1202583&r1=1202582&r2=1202583&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Analysis/PerFieldAnalyzerWrapper.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Analysis/PerFieldAnalyzerWrapper.cs Wed Nov 16 08:33:37 2011
@@ -17,6 +17,7 @@
using System;
using System.Collections.Generic;
+using Lucene.Net.Support;
namespace Lucene.Net.Analysis
{
@@ -43,7 +44,7 @@ namespace Lucene.Net.Analysis
public class PerFieldAnalyzerWrapper:Analyzer
{
private Analyzer defaultAnalyzer;
- private IDictionary<string, Analyzer> analyzerMap = new Dictionary<string, Analyzer>();
+ private IDictionary<string, Analyzer> analyzerMap = new HashMap<string, Analyzer>();
/// <summary> Constructs with default analyzer.
Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Analysis/StopFilter.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Analysis/StopFilter.cs?rev=1202583&r1=1202582&r2=1202583&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Analysis/StopFilter.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Analysis/StopFilter.cs Wed Nov 16 08:33:37 2011
@@ -60,10 +60,7 @@ namespace Lucene.Net.Analysis
else
{
this.stopWords = new CharArraySet(stopWords.Count, ignoreCase);
- foreach (var word in stopWords)
- {
- this.stopWords.Add(word);
- }
+ this.stopWords.AddAll(stopWords);
}
this.enablePositionIncrements = enablePositionIncrements;
termAtt = AddAttribute<TermAttribute>();
@@ -113,8 +110,7 @@ namespace Lucene.Net.Analysis
public static ISet<string> MakeStopSet(string[] stopWords, bool ignoreCase)
{
CharArraySet stopSet = new CharArraySet(stopWords.Length, ignoreCase);
- foreach(var s in stopWords)
- stopSet.Add(s);
+ stopSet.AddAll(stopWords);
return stopSet;
}
Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Analysis/TokenStream.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Analysis/TokenStream.cs?rev=1202583&r1=1202582&r2=1202583&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Analysis/TokenStream.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Analysis/TokenStream.cs Wed Nov 16 08:33:37 2011
@@ -80,7 +80,6 @@ namespace Lucene.Net.Analysis
{
/// <summary> A TokenStream using the default attribute factory.</summary>
protected internal TokenStream()
- : base()
{ }
/// <summary> A TokenStream that uses the same attributes as the supplied one.</summary>
Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/ConcurrentMergeScheduler.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/ConcurrentMergeScheduler.cs?rev=1202583&r1=1202582&r2=1202583&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/ConcurrentMergeScheduler.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/ConcurrentMergeScheduler.cs Wed Nov 16 08:33:37 2011
@@ -192,7 +192,6 @@ namespace Lucene.Net.Index
public override void Merge(IndexWriter writer)
{
-
// TODO: .NET doesn't support this - Look into it
// assert !Thread.holdsLock(writer);
@@ -262,7 +261,7 @@ namespace Lucene.Net.Index
if (Verbose())
Message(" consider merge " + merge.SegString(dir));
- System.Diagnostics.Debug.Assert(mergeThreadCount < maxThreadCount);
+ System.Diagnostics.Debug.Assert(MergeThreadCount() < maxThreadCount);
// OK to spawn a new merge thread to handle this
// merge:
Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/FreqProxTermsWriter.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/FreqProxTermsWriter.cs?rev=1202583&r1=1202582&r2=1202583&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/FreqProxTermsWriter.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/FreqProxTermsWriter.cs Wed Nov 16 08:33:37 2011
@@ -16,17 +16,13 @@
*/
using System;
-
-using IndexInput = Lucene.Net.Store.IndexInput;
-using IndexOutput = Lucene.Net.Store.IndexOutput;
+using System.Collections.Generic;
using UnicodeUtil = Lucene.Net.Util.UnicodeUtil;
namespace Lucene.Net.Index
{
-
- sealed class FreqProxTermsWriter:TermsHashConsumer
+ sealed class FreqProxTermsWriter : TermsHashConsumer
{
-
public override TermsHashConsumerPerThread AddThread(TermsHashPerThread perThread)
{
return new FreqProxTermsWriterPerThread(perThread);
@@ -71,27 +67,21 @@ namespace Lucene.Net.Index
// FreqProxFieldMergeState, and code to visit all Fields
// under the same FieldInfo together, up into TermsHash*.
// Other writers would presumably share alot of this...
-
- public override void Flush(System.Collections.IDictionary threadsAndFields, SegmentWriteState state)
+
+ public override void Flush(IDictionary<TermsHashConsumerPerThread, ICollection<TermsHashConsumerPerField>> threadsAndFields, SegmentWriteState state)
{
// Gather all FieldData's that have postings, across all
// ThreadStates
- System.Collections.ArrayList allFields = new System.Collections.ArrayList();
+ var allFields = new List<FreqProxTermsWriterPerField>();
- System.Collections.IEnumerator it = new System.Collections.Hashtable(threadsAndFields).GetEnumerator();
- while (it.MoveNext())
+ foreach(var entry in threadsAndFields)
{
+ var fields = entry.Value;
- System.Collections.DictionaryEntry entry = (System.Collections.DictionaryEntry) it.Current;
-
- System.Collections.ICollection fields = (System.Collections.ICollection) entry.Value;
-
- System.Collections.IEnumerator fieldsIt = fields.GetEnumerator();
-
- while (fieldsIt.MoveNext())
+ foreach(var i in fields)
{
- FreqProxTermsWriterPerField perField = (FreqProxTermsWriterPerField) ((System.Collections.DictionaryEntry) fieldsIt.Current).Key;
+ FreqProxTermsWriterPerField perField = (FreqProxTermsWriterPerField)i;
if (perField.termsHashPerField.numPostings > 0)
allFields.Add(perField);
}
@@ -118,17 +108,17 @@ namespace Lucene.Net.Index
int start = 0;
while (start < numAllFields)
{
- FieldInfo fieldInfo = ((FreqProxTermsWriterPerField) allFields[start]).fieldInfo;
+ FieldInfo fieldInfo = allFields[start].fieldInfo;
System.String fieldName = fieldInfo.name;
int end = start + 1;
- while (end < numAllFields && ((FreqProxTermsWriterPerField) allFields[end]).fieldInfo.name.Equals(fieldName))
+ while (end < numAllFields && allFields[end].fieldInfo.name.Equals(fieldName))
end++;
FreqProxTermsWriterPerField[] fields = new FreqProxTermsWriterPerField[end - start];
for (int i = start; i < end; i++)
{
- fields[i - start] = (FreqProxTermsWriterPerField) allFields[i];
+ fields[i - start] = allFields[i];
// Aggregate the storePayload as seen by the same
// field across multiple threads
@@ -151,10 +141,8 @@ namespace Lucene.Net.Index
start = end;
}
- it = new System.Collections.Hashtable(threadsAndFields).GetEnumerator();
- while (it.MoveNext())
+ foreach(var entry in threadsAndFields)
{
- System.Collections.DictionaryEntry entry = (System.Collections.DictionaryEntry) it.Current;
FreqProxTermsWriterPerThread perThread = (FreqProxTermsWriterPerThread) entry.Key;
perThread.termsHashPerThread.Reset(true);
}
@@ -297,15 +285,9 @@ namespace Lucene.Net.Index
termsConsumer.Finish();
}
-
- private TermInfo termInfo = new TermInfo(); // minimize consing
-
+
internal UnicodeUtil.UTF8Result termsUTF8 = new UnicodeUtil.UTF8Result();
- internal void Files(System.Collections.ICollection files)
- {
- }
-
internal sealed class PostingList:RawPostingList
{
internal int docFreq; // # times this term occurs in the current doc
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=1202583&r1=1202582&r2=1202583&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 Wed Nov 16 08:33:37 2011
@@ -422,7 +422,7 @@ namespace Lucene.Net.Index
}
- private IDictionary<SegmentInfo, SegmentReader> readerMap = new Dictionary<SegmentInfo, SegmentReader>();
+ private IDictionary<SegmentInfo, SegmentReader> readerMap = new HashMap<SegmentInfo, SegmentReader>();
/// <summary>Forcefully clear changes for the specifed segments,
/// and remove from the pool. This is called on succesful merge.
@@ -555,6 +555,7 @@ namespace Lucene.Net.Index
// TODO: assert Thread.holdsLock(IndexWriter.this);
lock (this)
{
+ var toRemove = new List<SegmentInfo>();
var iter = readerMap.GetEnumerator();
while (iter.MoveNext())
{
@@ -570,7 +571,7 @@ namespace Lucene.Net.Index
enclosingInstance.deleter.Checkpoint(enclosingInstance.segmentInfos, false);
}
- readerMap.Remove(ent.Key);
+ toRemove.Add(ent.Key);
// NOTE: it is allowed that this decRef does not
// actually close the SR; this can happen when a
@@ -578,6 +579,8 @@ namespace Lucene.Net.Index
// IndexWriter instance is closed
sr.DecRef();
}
+ foreach (var key in toRemove)
+ readerMap.Remove(key);
}
}
Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/TermVectorsTermsWriter.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/TermVectorsTermsWriter.cs?rev=1202583&r1=1202582&r2=1202583&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/TermVectorsTermsWriter.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/TermVectorsTermsWriter.cs Wed Nov 16 08:33:37 2011
@@ -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();
}
Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/TermsHashConsumer.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/TermsHashConsumer.cs?rev=1202583&r1=1202582&r2=1202583&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/TermsHashConsumer.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/TermsHashConsumer.cs Wed Nov 16 08:33:37 2011
@@ -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/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=1202583&r1=1202582&r2=1202583&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 Wed Nov 16 08:33:37 2011
@@ -433,7 +433,7 @@ namespace Lucene.Net.QueryParsers
if (fieldToDateResolution == null)
{
// lazily initialize Dictionary
- fieldToDateResolution = new Dictionary<string,DateTools.Resolution>();
+ fieldToDateResolution = new HashMap<string,DateTools.Resolution>();
}
fieldToDateResolution[fieldName] = dateResolution;
Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Store/FSDirectory.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Store/FSDirectory.cs?rev=1202583&r1=1202582&r2=1202583&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Store/FSDirectory.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Store/FSDirectory.cs Wed Nov 16 08:33:37 2011
@@ -486,7 +486,7 @@ namespace Lucene.Net.Store
/// </summary>
/// <seealso cref="SetReadChunkSize">
/// </seealso>
- public static readonly int DEFAULT_READ_CHUNK_SIZE;
+ public static readonly int DEFAULT_READ_CHUNK_SIZE = Constants.JRE_IS_64BIT ? int.MaxValue: 100 * 1024 * 1024;
// LUCENE-1566
private int chunkSize = DEFAULT_READ_CHUNK_SIZE;
Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Store/SimpleFSDirectory.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Store/SimpleFSDirectory.cs?rev=1202583&r1=1202582&r2=1202583&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Store/SimpleFSDirectory.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Store/SimpleFSDirectory.cs Wed Nov 16 08:33:37 2011
@@ -37,32 +37,22 @@ namespace Lucene.Net.Store
/// <param name="lockFactory">the lock factory to use, or null for the default.
/// </param>
/// <throws> IOException </throws>
- public SimpleFSDirectory(System.IO.DirectoryInfo path, LockFactory lockFactory) : base(path, lockFactory)
+ public SimpleFSDirectory(System.IO.DirectoryInfo path, LockFactory lockFactory)
+ : base(path, lockFactory)
{
}
-
- /// <summary>Create a new SimpleFSDirectory for the named location and the default lock factory.
- ///
- /// </summary>
- /// <param name="path">the path of the directory
- /// </param>
- /// <throws> IOException </throws>
- [System.Obsolete("Use the constructor that takes a DirectoryInfo, this will be removed in the 3.0 release")]
- public SimpleFSDirectory(System.IO.FileInfo path):base(new System.IO.DirectoryInfo(path.FullName), null)
- {
- }
-
- /// <summary>Create a new SimpleFSDirectory for the named location and the default lock factory.
+
+ /// <summary>Create a new SimpleFSDirectory for the named location and the default lock factory.
///
/// </summary>
/// <param name="path">the path of the directory
/// </param>
/// <throws> IOException </throws>
public SimpleFSDirectory(System.IO.DirectoryInfo path) : base(path, null)
- {
- }
+ {
+ }
- /// <summary>Creates an IndexOutput for the file with the given name. </summary>
+ /// <summary>Creates an IndexOutput for the file with the given name. </summary>
public override IndexOutput CreateOutput(System.String name)
{
InitOutput(name);
@@ -76,9 +66,9 @@ namespace Lucene.Net.Store
return new SimpleFSIndexInput(new System.IO.FileInfo(System.IO.Path.Combine(directory.FullName, name)), bufferSize, GetReadChunkSize());
}
- public /*protected internal*/class SimpleFSIndexInput:BufferedIndexInput, System.ICloneable
+ protected internal class SimpleFSIndexInput:BufferedIndexInput, System.ICloneable
{
-
+ // TODO: This is a bad way to handle memory and disposing
protected internal class Descriptor:System.IO.BinaryReader
{
// remember if the file is open, so that we don't try to close it
@@ -119,14 +109,15 @@ namespace Lucene.Net.Store
internal bool isClone;
// LUCENE-1566 - maximum read length on a 32bit JVM to prevent incorrect OOM
protected internal int chunkSize;
-
- public SimpleFSIndexInput(System.IO.FileInfo path, int bufferSize, int chunkSize):base(bufferSize)
- {
- file = new Descriptor(path, System.IO.FileAccess.Read);
- this.chunkSize = chunkSize;
- }
-
- /// <summary>IndexInput methods </summary>
+
+ public SimpleFSIndexInput(System.IO.FileInfo path, int bufferSize, int chunkSize)
+ : base(bufferSize)
+ {
+ file = new Descriptor(path, System.IO.FileAccess.Read);
+ this.chunkSize = chunkSize;
+ }
+
+ /// <summary>IndexInput methods </summary>
public override void ReadInternal(byte[] b, int offset, int len)
{
lock (file)
Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Support/HashMap.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Support/HashMap.cs?rev=1202583&r1=1202582&r2=1202583&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Support/HashMap.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Support/HashMap.cs Wed Nov 16 08:33:37 2011
@@ -29,6 +29,7 @@ namespace Lucene.Net.Support
/// </summary>
/// <typeparam name="TKey">The type of keys in the dictionary</typeparam>
/// <typeparam name="TValue">The type of values in the dictionary</typeparam>
+ [Serializable]
public class HashMap<TKey, TValue> : IDictionary<TKey, TValue>
{
private Dictionary<TKey, TValue> _dict;
@@ -49,6 +50,7 @@ namespace Lucene.Net.Support
}
public HashMap(IEnumerable<KeyValuePair<TKey, TValue>> other)
+ : this(0)
{
foreach (var kvp in other)
{
Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Support/WeakDictionary.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Support/WeakDictionary.cs?rev=1202583&r1=1202582&r2=1202583&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Support/WeakDictionary.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Support/WeakDictionary.cs Wed Nov 16 08:33:37 2011
@@ -11,7 +11,7 @@ namespace Lucene.Net.Support
private int _gcCollections = 0;
private int _changes = 0;
- public WeakDictionary(int initialCapacity)
+ public WeakDictionary(int initialCapacity) : this(initialCapacity, Enumerable.Empty<KeyValuePair<TKey, TValue>>())
{ }
public WeakDictionary() : this(32, Enumerable.Empty<KeyValuePair<TKey, TValue>>())
@@ -31,25 +31,26 @@ namespace Lucene.Net.Support
private void Clean()
{
- while (!_hm.Keys.Where(x => x != null).Any(x => !x.IsAlive))
+ if (_hm.Count == 0) return;
+ while (_hm.Keys.Where(x => x != null).Any(x => !x.IsAlive))
{
- _hm.Remove(_hm.Keys.Where(x => !x.IsAlive).First());
+ _hm.Remove(_hm.Keys.Where(x => x != null && !x.IsAlive).First());
}
}
private void CleanIfNeeded()
{
- _gcCollections = GC.CollectionCount(0);
- if (_gcCollections > 0)
+ int currentColCount = GC.CollectionCount(0);
+ if (currentColCount > _gcCollections)
{
Clean();
- _gcCollections = 0;
+ _gcCollections = currentColCount;
}
}
public IEnumerator<KeyValuePair<TKey, TValue>> GetEnumerator()
{
- foreach (var kvp in Enumerable.Where(_hm, x => x.Key.IsAlive))
+ foreach (var kvp in _hm.Where(x => x.Key.IsAlive))
{
yield return new KeyValuePair<TKey, TValue>(kvp.Key.Target, kvp.Value);
}
@@ -240,7 +241,7 @@ namespace Lucene.Net.Support
public override bool Equals(object obj)
{
- if (!reference.IsAlive) return false;
+ if (!reference.IsAlive || obj == null) return false;
if (GetHashCode() != obj.GetHashCode()) return false;
Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Util/AttributeSource.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Util/AttributeSource.cs?rev=1202583&r1=1202582&r2=1202583&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Util/AttributeSource.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Util/AttributeSource.cs Wed Nov 16 08:33:37 2011
@@ -65,24 +65,24 @@ namespace Lucene.Net.Util
{
throw new System.ArgumentException("Could not instantiate implementing class for " + typeof(TAttImpl).FullName);
}
- catch (System.Exception e)
- {
- throw new System.ArgumentException("Could not instantiate implementing class for " + typeof(TAttImpl).FullName);
- }
+ //catch (System.Exception e)
+ //{
+ // throw new System.ArgumentException("Could not instantiate implementing class for " + typeof(TAttImpl).FullName);
+ //}
}
- private static System.Type GetClassForInterface<TAttImpl>() where TAttImpl : Attribute
+ private static System.Type GetClassForInterface<T>() where T : Attribute
{
lock (attClassImplMap)
{
- var attClass = typeof (TAttImpl);
+ var attClass = typeof (T);
WeakReference refz = attClassImplMap[attClass];
System.Type clazz = (refz == null) ? null : ((System.Type) refz.Target);
if (clazz == null)
{
try
{
- string name = attClass.FullName + "Impl," + attClass.Assembly.FullName;
+ string name = attClass.FullName + "Impl, " + attClass.Assembly.FullName;
attClassImplMap.Add(attClass, new WeakReference( clazz = System.Type.GetType(name, true))); //OK
}
catch (System.TypeLoadException e) // was System.Exception
Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Util/AverageGuessMemoryModel.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Util/AverageGuessMemoryModel.cs?rev=1202583&r1=1202582&r2=1202583&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Util/AverageGuessMemoryModel.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Util/AverageGuessMemoryModel.cs Wed Nov 16 08:33:37 2011
@@ -31,9 +31,20 @@ namespace Lucene.Net.Util
}
private void InitBlock()
- {
- sizes = new IdentityDictionary<Type, int>();
- }
+ {
+ sizes = new IdentityDictionary<Type, int>()
+ {
+ {typeof (bool), 1},
+ {typeof (byte), 1},
+ {typeof(sbyte), 1},
+ {typeof (char), 2},
+ {typeof (short), 2},
+ {typeof (int), 4},
+ {typeof (float), 4},
+ {typeof (double), 8},
+ {typeof (long), 8}
+ };
+ }
// best guess primitive sizes
private System.Collections.Generic.Dictionary<Type, int> sizes;
Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Analysis/TestCharArraySet.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Analysis/TestCharArraySet.cs?rev=1202583&r1=1202582&r2=1202583&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Analysis/TestCharArraySet.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Analysis/TestCharArraySet.cs Wed Nov 16 08:33:37 2011
@@ -213,7 +213,7 @@ namespace Lucene.Net.Analysis
CharArraySet.UnmodifiableSet(null);
Assert.Fail("can not make null unmodifiable");
}
- catch (System.NullReferenceException e)
+ catch (System.ArgumentNullException e)
{
// expected
}
Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Analysis/TestStopAnalyzer.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Analysis/TestStopAnalyzer.cs?rev=1202583&r1=1202582&r2=1202583&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Analysis/TestStopAnalyzer.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Analysis/TestStopAnalyzer.cs Wed Nov 16 08:33:37 2011
@@ -16,7 +16,7 @@
*/
using System;
-
+using System.Collections.Generic;
using NUnit.Framework;
using PositionIncrementAttribute = Lucene.Net.Analysis.Tokenattributes.PositionIncrementAttribute;
@@ -31,7 +31,7 @@ namespace Lucene.Net.Analysis
{
private StopAnalyzer stop = new StopAnalyzer(Version.LUCENE_CURRENT);
- private System.Collections.Hashtable inValidTokens = new System.Collections.Hashtable();
+ private HashSet<string> inValidTokens = new HashSet<string>();
public TestStopAnalyzer(System.String s):base(s)
{
@@ -45,12 +45,7 @@ namespace Lucene.Net.Analysis
public override void SetUp()
{
base.SetUp();
-
- System.Collections.IEnumerator it = StopAnalyzer.ENGLISH_STOP_WORDS_SET.GetEnumerator();
- while (it.MoveNext())
- {
- inValidTokens.Add(it.Current, it.Current);
- }
+ inValidTokens.UnionWith(StopAnalyzer.ENGLISH_STOP_WORDS_SET);
}
[Test]
@@ -96,7 +91,7 @@ namespace Lucene.Net.Analysis
var stopWordsSet = new System.Collections.Generic.HashSet<string>();
stopWordsSet.Add("good");
stopWordsSet.Add("test");
- stopWordsSet.Add("analyzed");
+ stopWordsSet.Add("analyzer");
var newStop = new StopAnalyzer(Version.LUCENE_CURRENT, stopWordsSet);
var reader = new System.IO.StringReader("This is a good test of the english stop analyzer with positions");
int[] expectedIncr = { 1, 1, 1, 3, 1, 1, 1, 2, 1};
Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Index/TestBackwardsCompatibility.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Index/TestBackwardsCompatibility.cs?rev=1202583&r1=1202582&r2=1202583&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Index/TestBackwardsCompatibility.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Index/TestBackwardsCompatibility.cs Wed Nov 16 08:33:37 2011
@@ -453,7 +453,6 @@ namespace Lucene.Net.Index
* setNorm, and search */
public virtual void ChangeIndexNoAdds(System.String dirName)
{
-
dirName = FullDir(dirName);
Directory dir = FSDirectory.Open(new System.IO.DirectoryInfo(dirName));
@@ -527,7 +526,7 @@ namespace Lucene.Net.Index
writer.Close();
// Delete one doc so we get a .del file:
- IndexReader reader = IndexReader.Open(dir);
+ IndexReader reader = IndexReader.Open(dir, false);
Term searchTerm = new Term("id", "7");
int delCount = reader.DeleteDocuments(searchTerm);
Assert.AreEqual(1, delCount, "didn't delete the right number of documents");
Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Index/TestIndexCommit.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Index/TestIndexCommit.cs?rev=1202583&r1=1202582&r2=1202583&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Index/TestIndexCommit.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Index/TestIndexCommit.cs Wed Nov 16 08:33:37 2011
@@ -7,7 +7,7 @@ using Lucene.Net.Store;
using Lucene.Net.Util;
using NUnit.Framework;
-namespace Lucene.Net.Test.Index
+namespace Lucene.Net.Index
{
public class TestIndexCommit : LuceneTestCase
{
Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Index/TestIndexWriter.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Index/TestIndexWriter.cs?rev=1202583&r1=1202582&r2=1202583&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Index/TestIndexWriter.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Index/TestIndexWriter.cs Wed Nov 16 08:33:37 2011
@@ -61,10 +61,10 @@ namespace Lucene.Net.Index
[TestFixture]
public class TestIndexWriter : BaseTokenStreamTestCase
{
- public TestIndexWriter(System.String name)
- : base(name)
- {
- }
+ //public TestIndexWriter(System.String name)
+ // : base(name)
+ //{
+ //}
public class MyRAMDirectory : RAMDirectory
{
Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Lucene.Net.Test.csproj
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Lucene.Net.Test.csproj?rev=1202583&r1=1202582&r2=1202583&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Lucene.Net.Test.csproj (original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Lucene.Net.Test.csproj Wed Nov 16 08:33:37 2011
@@ -502,6 +502,8 @@
<None Include="Index\index.23.nocfs.zip" />
<None Include="Index\index.24.cfs.zip" />
<None Include="Index\index.24.nocfs.zip" />
+ <None Include="Index\index.29.cfs.zip" />
+ <None Include="Index\index.29.nocfs.zip" />
<None Include="Lucene.Net.snk" />
</ItemGroup>
<ItemGroup>
Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/QueryParser/TestMultiAnalyzer.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/QueryParser/TestMultiAnalyzer.cs?rev=1202583&r1=1202582&r2=1202583&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/QueryParser/TestMultiAnalyzer.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/QueryParser/TestMultiAnalyzer.cs Wed Nov 16 08:33:37 2011
@@ -115,7 +115,7 @@ namespace Lucene.Net.QueryParsers
[Test]
public virtual void TestPosIncrementAnalyzer()
{
- QueryParser qp = new QueryParser(Util.Version.LUCENE_CURRENT, "", new PosIncrementAnalyzer(this));
+ QueryParser qp = new QueryParser(Util.Version.LUCENE_24, "", new PosIncrementAnalyzer(this));
Assert.AreEqual("quick brown", qp.Parse("the quick brown").ToString());
Assert.AreEqual("\"quick brown\"", qp.Parse("\"the quick brown\"").ToString());
Assert.AreEqual("quick brown fox", qp.Parse("the quick brown fox").ToString());
Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/QueryParser/TestQueryParser.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/QueryParser/TestQueryParser.cs?rev=1202583&r1=1202582&r2=1202583&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/QueryParser/TestQueryParser.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/QueryParser/TestQueryParser.cs Wed Nov 16 08:33:37 2011
@@ -116,9 +116,15 @@ namespace Lucene.Net.QueryParsers
}
}
- public TestQueryParser(System.String name):base(name, dataTestWithDifferentLocals) // TODO: was commented out
+ public TestQueryParser(System.String name)
+ : base(name, dataTestWithDifferentLocals) // TODO: was commented out
{
}
+
+ public TestQueryParser() : base(string.Empty, dataTestWithDifferentLocals)
+ {
+
+ }
public static Analyzer qpAnalyzer = new QPTestAnalyzer();
Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Util/TestNumericUtils.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Util/TestNumericUtils.cs?rev=1202583&r1=1202582&r2=1202583&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Util/TestNumericUtils.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Util/TestNumericUtils.cs Wed Nov 16 08:33:37 2011
@@ -79,9 +79,9 @@ namespace Lucene.Net.Util
neededBounds.MoveNext();
unchecked
{
- Assert.AreEqual((long)neededBounds.Current, (ulong) Number.URShift(min, shift), "inner min bound");
+ Assert.AreEqual((long)neededBounds.Current, Number.URShift(min, shift), "inner min bound");
neededBounds.MoveNext();
- Assert.AreEqual((long)neededBounds.Current, (ulong)Number.URShift(max, shift), "inner max bound");
+ Assert.AreEqual((long)neededBounds.Current, Number.URShift(max, shift), "inner max bound");
}
}
}
Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Util/TestVersion.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Util/TestVersion.cs?rev=1202583&r1=1202582&r2=1202583&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Util/TestVersion.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Util/TestVersion.cs Wed Nov 16 08:33:37 2011
@@ -32,7 +32,7 @@ namespace Lucene.Net.Util
}
Assert.IsTrue(Version.LUCENE_30.OnOrAfter(Version.LUCENE_29));
Assert.IsTrue(Version.LUCENE_30.OnOrAfter(Version.LUCENE_30));
- Assert.IsTrue(Version.LUCENE_29.OnOrAfter(Version.LUCENE_30));
+ Assert.IsFalse(Version.LUCENE_29.OnOrAfter(Version.LUCENE_30));
}
}
}
\ No newline at end of file