I believe we have a candidate for the Lucene.Net 2.3.1 release. It diverges
from the SVN HEAD by the list of patches below.
LUCENENET-135 SupportClass.patch
LUCENENET-143 TestStressIndexing2.patch, FieldsReader.patch
LUCENENET-145 DocumentsWriter.patch
LUCENENET-146 SegmentTermPositionVector.patch
LUCENENET-151 MultiPhraseQuery.patch
LUCENENET-152 SegmentInfos.patch, FSDirectory.patch
LUCENENET-154 TestIndexWriterLockRelease.patch
LUCENENET-155 SetUp.patch
LUCENENET-157 GetFieldNames.patch
LUCENENET-158 CheckHits.patch
I have attached a comprehensive patch to simplify things for those of you
who would like to try it out.
1) Get the latest from SVN HEAD (currently revision 702987)
2) Apply Comprehensive.patch from the root directory.
- Doug
Index: C#/src/Lucene.Net/Index/CheckIndex.cs
===================================================================
--- C#/src/Lucene.Net/Index/CheckIndex.cs (revision 693915)
+++ C#/src/Lucene.Net/Index/CheckIndex.cs (working copy)
@@ -179,8 +179,8 @@
out_Renamed.WriteLine("OK");
out_Renamed.Write(" test: fields, norms.......");
- System.Collections.IDictionary fieldNames = (System.Collections.IDictionary) reader.GetFieldNames(IndexReader.FieldOption.ALL);
- System.Collections.IEnumerator it = fieldNames.Keys.GetEnumerator();
+ System.Collections.ICollection fieldNames = reader.GetFieldNames(IndexReader.FieldOption.ALL);
+ System.Collections.IEnumerator it = fieldNames.GetEnumerator();
while (it.MoveNext())
{
System.String fieldName = (System.String) it.Current;
Index: C#/src/Lucene.Net/Index/DocumentsWriter.cs
===================================================================
--- C#/src/Lucene.Net/Index/DocumentsWriter.cs (revision 693915)
+++ C#/src/Lucene.Net/Index/DocumentsWriter.cs (working copy)
@@ -3464,7 +3464,7 @@
for (int i = 0; i < bufferUpto; i++)
// Fully zero fill buffers that we fully used
- Array.Clear(buffers[i], 0, buffers.Length);
+ Array.Clear(buffers[i], 0, buffers[i].Length);
// Partial zero fill the final buffer
Array.Clear(buffers[bufferUpto], 0, byteUpto);
@@ -3483,10 +3483,10 @@
public void NextBuffer()
{
- if (1 + bufferUpto == buffers.Length)
+ if (1 + bufferUpto == buffers.GetLength(0))
{
- byte[][] newBuffers = new byte[(int) (buffers.Length * 1.5)][];
- Array.Copy(buffers, 0, newBuffers, 0, buffers.Length);
+ byte[][] newBuffers = new byte[(int) (buffers.GetLength(0) * 1.5)][];
+ Array.Copy(buffers, 0, newBuffers, 0, buffers.GetLength(0));
buffers = newBuffers;
}
buffer = buffers[1 + bufferUpto] = Enclosing_Instance.GetByteBlock();
@@ -3579,10 +3579,10 @@
public void NextBuffer()
{
- if (1 + bufferUpto == buffers.Length)
+ if (1 + bufferUpto == buffers.GetLength(0))
{
- char[][] newBuffers = new char[(int) (buffers.Length * 1.5)][];
- Array.Copy(buffers, 0, newBuffers, 0, buffers.Length);
+ char[][] newBuffers = new char[(int) (buffers.GetLength(0) * 1.5)][];
+ Array.Copy(buffers, 0, newBuffers, 0, buffers.GetLength(0));
buffers = newBuffers;
}
buffer = buffers[1 + bufferUpto] = Enclosing_Instance.GetCharBlock();
@@ -3940,4 +3940,4 @@
docWriter.SetAborting();
}
}
-}
\ No newline at end of file
+}
Index: C#/src/Lucene.Net/Index/FieldsReader.cs
===================================================================
--- C#/src/Lucene.Net/Index/FieldsReader.cs (revision 693915)
+++ C#/src/Lucene.Net/Index/FieldsReader.cs (working copy)
@@ -156,7 +156,7 @@
public Document Doc(int n, FieldSelector fieldSelector)
{
- indexStream.Seek(n * 8L);
+ indexStream.Seek((n + docStoreOffset) * 8L);
long position = indexStream.ReadLong();
fieldsStream.Seek(position);
@@ -643,4 +643,4 @@
}
}
}
-}
\ No newline at end of file
+}
Index: C#/src/Lucene.Net/Index/MultiSegmentReader.cs
===================================================================
--- C#/src/Lucene.Net/Index/MultiSegmentReader.cs (revision 693915)
+++ C#/src/Lucene.Net/Index/MultiSegmentReader.cs (working copy)
@@ -516,14 +516,14 @@
for (int i = 0; i < subReaders.Length; i++)
{
IndexReader reader = subReaders[i];
- System.Collections.IEnumerator names = ((System.Collections.IDictionary)reader.GetFieldNames(fieldNames)).Keys.GetEnumerator();
- while (names.MoveNext())
+ System.Collections.IEnumerator names = reader.GetFieldNames(fieldNames).GetEnumerator();
+ while (names.MoveNext())
{
if (!fieldSet.ContainsKey(names.Current))
fieldSet.Add(names.Current, names.Current);
}
}
- return fieldSet;
+ return fieldSet.Keys;
}
// for testing
@@ -800,4 +800,4 @@
}
}
}
-}
\ No newline at end of file
+}
Index: C#/src/Lucene.Net/Index/ParallelReader.cs
===================================================================
--- C#/src/Lucene.Net/Index/ParallelReader.cs (revision 693915)
+++ C#/src/Lucene.Net/Index/ParallelReader.cs (working copy)
@@ -114,10 +114,11 @@
System.Collections.IEnumerator i = fields.GetEnumerator();
while (i.MoveNext())
{
- System.Collections.DictionaryEntry fi = (System.Collections.DictionaryEntry) i.Current;
+ //System.Collections.DictionaryEntry fi = (System.Collections.DictionaryEntry) i.Current;
- // update fieldToReader map
- System.String field = fi.Key.ToString();
+ //// update fieldToReader map
+ //System.String field = fi.Key.ToString();
+ System.String field = (String) i.Current;
if (fieldToReader[field] == null)
fieldToReader[field] = reader;
}
@@ -302,7 +303,7 @@
System.Collections.IEnumerator it = ((System.Collections.ICollection) readerToFields[reader]).GetEnumerator();
while (it.MoveNext())
{
- if (fieldSelector.Accept((System.String)((System.Collections.DictionaryEntry)it.Current).Value) != FieldSelectorResult.NO_LOAD)
+ if (fieldSelector.Accept((System.String)it.Current) != FieldSelectorResult.NO_LOAD)
{
include = true;
break;
@@ -522,15 +523,14 @@
System.Collections.ICollection names = reader.GetFieldNames(fieldNames);
for (System.Collections.IEnumerator iterator = names.GetEnumerator(); iterator.MoveNext(); )
{
- System.Collections.DictionaryEntry fi = (System.Collections.DictionaryEntry) iterator.Current;
- System.String s = fi.Key.ToString();
+ System.String s = (System.String)iterator.Current;
if (fieldSet.ContainsKey(s) == false)
{
fieldSet.Add(s, s);
}
}
}
- return fieldSet;
+ return fieldSet.Keys;
}
private class ParallelTermEnum : TermEnum
@@ -758,4 +758,4 @@
}
}
}
-}
\ No newline at end of file
+}
Index: C#/src/Lucene.Net/Index/SegmentInfos.cs
===================================================================
--- C#/src/Lucene.Net/Index/SegmentInfos.cs (revision 693915)
+++ C#/src/Lucene.Net/Index/SegmentInfos.cs (working copy)
@@ -620,19 +620,24 @@
for (int i = 0; i < Lucene.Net.Index.SegmentInfos.defaultGenFileRetryCount; i++)
{
IndexInput genInput = null;
- try
- {
- genInput = directory.OpenInput(IndexFileNames.SEGMENTS_GEN);
- }
- catch (System.IO.FileNotFoundException e)
- {
- Lucene.Net.Index.SegmentInfos.Message("segments.gen open: FileNotFoundException " + e);
- break;
- }
- catch (System.IO.IOException e)
- {
- Lucene.Net.Index.SegmentInfos.Message("segments.gen open: IOException " + e);
- }
+ try
+ {
+ genInput = directory.OpenInput(IndexFileNames.SEGMENTS_GEN);
+ }
+ catch (System.IO.FileNotFoundException e)
+ {
+ Lucene.Net.Index.SegmentInfos.Message("segments.gen open: FileNotFoundException " + e);
+ break;
+ }
+ catch (System.IO.IOException e)
+ {
+ Lucene.Net.Index.SegmentInfos.Message("segments.gen open: IOException " + e);
+ }
+ catch (UnauthorizedAccessException e)
+ {
+ Lucene.Net.Index.SegmentInfos.Message("segments.gen open: UnauthorizedAccessException " + e);
+ System.Threading.Thread.Sleep(10);
+ }
if (genInput != null)
{
@@ -830,4 +835,4 @@
return infos;
}
}
-}
\ No newline at end of file
+}
Index: C#/src/Lucene.Net/Index/SegmentReader.cs
===================================================================
--- C#/src/Lucene.Net/Index/SegmentReader.cs (revision 693915)
+++ C#/src/Lucene.Net/Index/SegmentReader.cs (working copy)
@@ -872,7 +872,7 @@
fieldSet.Add(fi.name, fi.name);
}
}
- return fieldSet;
+ return fieldSet.Keys;
}
@@ -1234,4 +1234,4 @@
}
}
}
-}
\ No newline at end of file
+}
Index: C#/src/Lucene.Net/Index/SegmentTermPositionVector.cs
===================================================================
--- C#/src/Lucene.Net/Index/SegmentTermPositionVector.cs (revision 693915)
+++ C#/src/Lucene.Net/Index/SegmentTermPositionVector.cs (working copy)
@@ -46,7 +46,7 @@
TermVectorOffsetInfo[] result = TermVectorOffsetInfo.EMPTY_OFFSET_INFO;
if (offsets == null)
return null;
- if (index >= 0 && index < offsets.Length)
+ if (index >= 0 && index < offsets.GetLength(0))
{
result = offsets[index];
}
@@ -62,7 +62,7 @@
int[] result = EMPTY_TERM_POS;
if (positions == null)
return null;
- if (index >= 0 && index < positions.Length)
+ if (index >= 0 && index < positions.GetLength(0))
{
result = positions[index];
}
@@ -70,4 +70,4 @@
return result;
}
}
-}
\ No newline at end of file
+}
Index: C#/src/Lucene.Net/Search/MultiPhraseQuery.cs
===================================================================
--- C#/src/Lucene.Net/Search/MultiPhraseQuery.cs (revision 693915)
+++ C#/src/Lucene.Net/Search/MultiPhraseQuery.cs (working copy)
@@ -137,7 +137,8 @@
Term[] arr = (Term[]) iter.Current;
for (int i = 0; i < arr.Length; i++)
{
- terms.Add(arr[i], arr[i]);
+ if (!terms.Contains(arr[i]))
+ terms.Add(arr[i], arr[i]);
}
}
}
Index: C#/src/Lucene.Net/Store/FSDirectory.cs
===================================================================
--- C#/src/Lucene.Net/Store/FSDirectory.cs (revision 693915)
+++ C#/src/Lucene.Net/Store/FSDirectory.cs (working copy)
@@ -726,10 +726,25 @@
public FSIndexInput(System.IO.FileInfo path) : this(path, BufferedIndexInput.BUFFER_SIZE)
{
}
-
+
public FSIndexInput(System.IO.FileInfo path, int bufferSize) : base(bufferSize)
{
- file = new Descriptor(this, path, System.IO.FileAccess.Read);
+ UnauthorizedAccessException ex = null;
+ for (int i = 0; i < 10; i++)
+ {
+ try
+ {
+ file = new Descriptor(this, path, System.IO.FileAccess.Read);
+ return;
+ }
+ catch (UnauthorizedAccessException e)
+ {
+ ex = e;
+ System.Threading.Thread.Sleep(100);
+ GC.Collect();
+ }
+ }
+ throw ex;
}
/// <summary>IndexInput methods </summary>
@@ -799,9 +814,24 @@
public FSIndexOutput(System.IO.FileInfo path)
{
- file = new System.IO.BinaryWriter(new System.IO.FileStream(path.FullName, System.IO.FileMode.OpenOrCreate, System.IO.FileAccess.Write, System.IO.FileShare.ReadWrite));
- isOpen = true;
- }
+ UnauthorizedAccessException ex = null;
+ for (int i = 0; i < 10; i++)
+ {
+ try
+ {
+ file = new System.IO.BinaryWriter(new System.IO.FileStream(path.FullName, System.IO.FileMode.OpenOrCreate, System.IO.FileAccess.Write, System.IO.FileShare.ReadWrite));
+ isOpen = true;
+ return;
+ }
+ catch (UnauthorizedAccessException e)
+ {
+ ex = e;
+ System.Threading.Thread.Sleep(100);
+ GC.Collect();
+ }
+ }
+ throw ex;
+ }
/// <summary>output methods: </summary>
public override void FlushBuffer(byte[] b, int offset, int size)
@@ -867,4 +897,4 @@
}
}
}
-}
\ No newline at end of file
+}
Index: C#/src/Lucene.Net/SupportClass.cs
===================================================================
--- C#/src/Lucene.Net/SupportClass.cs (revision 693915)
+++ C#/src/Lucene.Net/SupportClass.cs (working copy)
@@ -44,15 +44,17 @@
/// The instance of System.Threading.Thread
/// </summary>
private System.Threading.Thread threadField;
-
+
+
/// <summary>
/// Initializes a new instance of the ThreadClass class
/// </summary>
public ThreadClass()
{
threadField = new System.Threading.Thread(new System.Threading.ThreadStart(Run));
+ This = this;
}
-
+
/// <summary>
/// Initializes a new instance of the Thread class.
/// </summary>
@@ -61,8 +63,9 @@
{
threadField = new System.Threading.Thread(new System.Threading.ThreadStart(Run));
this.Name = Name;
+ This = this;
}
-
+
/// <summary>
/// Initializes a new instance of the Thread class.
/// </summary>
@@ -70,8 +73,9 @@
public ThreadClass(System.Threading.ThreadStart Start)
{
threadField = new System.Threading.Thread(Start);
+ This = this;
}
-
+
/// <summary>
/// Initializes a new instance of the Thread class.
/// </summary>
@@ -81,23 +85,29 @@
{
threadField = new System.Threading.Thread(Start);
this.Name = Name;
+ This = this;
}
-
+
/// <summary>
/// This method has no functionality unless the method is overridden
/// </summary>
public virtual void Run()
{
}
-
+
/// <summary>
/// Causes the operating system to change the state of the current thread instance to ThreadState.Running
/// </summary>
public virtual void Start()
{
threadField.Start();
+ if (This == null)
+ {
+ This = this;
+ This.Instance = threadField;
+ }
}
-
+
/// <summary>
/// Interrupts a thread that is in the WaitSleepJoin thread state
/// </summary>
@@ -105,7 +115,7 @@
{
threadField.Interrupt();
}
-
+
/// <summary>
/// Gets the current thread instance
/// </summary>
@@ -120,7 +130,7 @@
threadField = value;
}
}
-
+
/// <summary>
/// Gets or sets the name of the thread
/// </summary>
@@ -133,10 +143,10 @@
set
{
if (threadField.Name == null)
- threadField.Name = value;
+ threadField.Name = value;
}
}
-
+
/// <summary>
/// Gets or sets a value indicating the scheduling priority of a thread
/// </summary>
@@ -144,14 +154,26 @@
{
get
{
- return threadField.Priority;
+ try
+ {
+ return threadField.Priority;
+ }
+ catch
+ {
+ return System.Threading.ThreadPriority.Normal;
+ }
}
set
{
- threadField.Priority = value;
+ try
+ {
+ threadField.Priority = value;
+ }
+ catch{}
+
}
}
-
+
/// <summary>
/// Gets a value indicating the execution status of the current thread
/// </summary>
@@ -162,7 +184,7 @@
return threadField.IsAlive;
}
}
-
+
/// <summary>
/// Gets or sets a value indicating whether or not a thread is a background thread.
/// </summary>
@@ -171,13 +193,13 @@
get
{
return threadField.IsBackground;
- }
+ }
set
{
threadField.IsBackground = value;
}
}
-
+
/// <summary>
/// Blocks the calling thread until a thread terminates
/// </summary>
@@ -185,19 +207,19 @@
{
threadField.Join();
}
-
+
/// <summary>
/// Blocks the calling thread until a thread terminates or the specified time elapses
/// </summary>
/// <param name="MiliSeconds">Time of wait in milliseconds</param>
public void Join(long MiliSeconds)
{
- lock(this)
+ lock (this)
{
threadField.Join(new System.TimeSpan(MiliSeconds * 10000));
}
}
-
+
/// <summary>
/// Blocks the calling thread until a thread terminates or the specified time elapses
/// </summary>
@@ -205,12 +227,12 @@
/// <param name="NanoSeconds">Time of wait in nanoseconds</param>
public void Join(long MiliSeconds, int NanoSeconds)
{
- lock(this)
+ lock (this)
{
threadField.Join(new System.TimeSpan(MiliSeconds * 10000 + NanoSeconds * 100));
}
}
-
+
/// <summary>
/// Resumes a thread that has been suspended
/// </summary>
@@ -218,7 +240,7 @@
{
System.Threading.Monitor.PulseAll(threadField);
}
-
+
/// <summary>
/// Raises a ThreadAbortException in the thread on which it is invoked,
/// to begin the process of terminating the thread. Calling this method
@@ -228,7 +250,7 @@
{
threadField.Abort();
}
-
+
/// <summary>
/// Raises a ThreadAbortException in the thread on which it is invoked,
/// to begin the process of terminating the thread while also providing
@@ -238,12 +260,12 @@
/// <param name="stateInfo">An object that contains application-specific information, such as state, which can be used by the thread being aborted</param>
public void Abort(System.Object stateInfo)
{
- lock(this)
+ lock (this)
{
threadField.Abort(stateInfo);
}
}
-
+
/// <summary>
/// Suspends the thread, if the thread is already suspended it has no effect
/// </summary>
@@ -251,7 +273,7 @@
{
System.Threading.Monitor.Wait(threadField);
}
-
+
/// <summary>
/// Obtain a String that represents the current Object
/// </summary>
@@ -260,16 +282,22 @@
{
return "Thread[" + Name + "," + Priority.ToString() + "," + "" + "]";
}
-
+
+ [ThreadStatic]
+ static ThreadClass This = null;
+
/// <summary>
/// Gets the currently running thread
/// </summary>
/// <returns>The currently running thread</returns>
public static ThreadClass Current()
{
- ThreadClass CurrentThread = new ThreadClass();
- CurrentThread.Instance = System.Threading.Thread.CurrentThread;
- return CurrentThread;
+ if (This == null)
+ {
+ This = new ThreadClass();
+ This.Instance = System.Threading.Thread.CurrentThread;
+ }
+ return This;
}
}
@@ -972,4 +1000,4 @@
}
}
}
-}
\ No newline at end of file
+}
Index: C#/src/Test/Index/TestCompoundFile.cs
===================================================================
--- C#/src/Test/Index/TestCompoundFile.cs (revision 693915)
+++ C#/src/Test/Index/TestCompoundFile.cs (working copy)
@@ -62,6 +62,7 @@
[SetUp]
public override void SetUp()
{
+ base.SetUp();
System.IO.FileInfo file = new System.IO.FileInfo(System.IO.Path.Combine(SupportClass.AppSettings.Get("tempDir", ""), "testIndex"));
Lucene.Net.Util._TestUtil.RmDir(file);
dir = FSDirectory.GetDirectory(file);
Index: C#/src/Test/Index/TestDocumentWriter.cs
===================================================================
--- C#/src/Test/Index/TestDocumentWriter.cs (revision 693915)
+++ C#/src/Test/Index/TestDocumentWriter.cs (working copy)
@@ -187,6 +187,7 @@
[SetUp]
public override void SetUp()
{
+ base.SetUp();
dir = new RAMDirectory();
}
Index: C#/src/Test/Index/TestFieldInfos.cs
===================================================================
--- C#/src/Test/Index/TestFieldInfos.cs (revision 693915)
+++ C#/src/Test/Index/TestFieldInfos.cs (working copy)
@@ -42,6 +42,7 @@
[SetUp]
public override void SetUp()
{
+ base.SetUp();
DocHelper.SetupDoc(testDoc);
}
Index: C#/src/Test/Index/TestIndexReader.cs
===================================================================
--- C#/src/Test/Index/TestIndexReader.cs (revision 693915)
+++ C#/src/Test/Index/TestIndexReader.cs (working copy)
@@ -1373,17 +1373,17 @@
System.Collections.ICollection fields1 = index1.GetFieldNames(FieldOption.ALL);
System.Collections.ICollection fields2 = index2.GetFieldNames(FieldOption.ALL);
Assert.AreEqual(fields1.Count, fields2.Count, "IndexReaders have different numbers of fields.");
- System.Collections.IEnumerator it1 = ((System.Collections.IDictionary) fields1).Keys.GetEnumerator();
- System.Collections.IEnumerator it2 = ((System.Collections.IDictionary) fields2).Keys.GetEnumerator();
- while (it1.MoveNext())
+ System.Collections.IEnumerator it1 = fields1.GetEnumerator();
+ System.Collections.IEnumerator it2 = fields2.GetEnumerator();
+ while (it1.MoveNext())
{
Assert.IsTrue(it2.MoveNext());
Assert.AreEqual((System.String) it1.Current, (System.String) it2.Current, "Different field names.");
}
// check norms
- it1 = ((System.Collections.IDictionary) fields1).Keys.GetEnumerator();
- while (it1.MoveNext())
+ it1 = fields1.GetEnumerator();
+ while (it1.MoveNext())
{
System.String curField = (System.String) it1.Current;
byte[] norms1 = index1.Norms(curField);
Index: C#/src/Test/Index/TestIndexWriterLockRelease.cs
===================================================================
--- C#/src/Test/Index/TestIndexWriterLockRelease.cs (revision 693915)
+++ C#/src/Test/Index/TestIndexWriterLockRelease.cs (working copy)
@@ -44,7 +44,7 @@
base.SetUp();
if (this.__test_dir == null)
{
- System.String tmp_dir = SupportClass.AppSettings.Get("java.io.tmpdir", "tmp");
+ System.String tmp_dir = SupportClass.AppSettings.Get("tempDir", "");
this.__test_dir = new System.IO.FileInfo(System.IO.Path.Combine(tmp_dir, "testIndexWriter"));
bool tmpBool;
@@ -78,7 +78,7 @@
public override void TearDown()
{
base.TearDown();
- if (this.__test_dir != null)
+ if (this.__test_dir != null && System.IO.Directory.Exists(this.__test_dir.FullName))
{
System.IO.FileInfo[] files = SupportClass.FileSupport.GetFiles(this.__test_dir);
Index: C#/src/Test/Index/TestParallelReader.cs
===================================================================
--- C#/src/Test/Index/TestParallelReader.cs (revision 693915)
+++ C#/src/Test/Index/TestParallelReader.cs (working copy)
@@ -299,9 +299,8 @@
{
for (System.Collections.IEnumerator iterator = col.GetEnumerator(); iterator.MoveNext(); )
{
- System.Collections.DictionaryEntry fi = (System.Collections.DictionaryEntry) iterator.Current;
- System.String s = fi.Key.ToString();
- if (s == val)
+ System.String s = (System.String)iterator.Current;
+ if (s == val)
return true;
}
return false;
Index: C#/src/Test/Index/TestSegmentReader.cs
===================================================================
--- C#/src/Test/Index/TestSegmentReader.cs (revision 693915)
+++ C#/src/Test/Index/TestSegmentReader.cs (working copy)
@@ -129,24 +129,23 @@
Assert.IsTrue(result.Count == DocHelper.all.Count);
for (System.Collections.IEnumerator iter = result.GetEnumerator(); iter.MoveNext(); )
{
- System.Collections.DictionaryEntry fi = (System.Collections.DictionaryEntry) iter.Current;
- System.String s = fi.Key.ToString();
- //System.out.println("Name: " + s);
- Assert.IsTrue(DocHelper.nameValues.Contains(s) == true || s.Equals(""));
+ System.String s = (System.String)iter.Current;
+ Assert.IsTrue(DocHelper.nameValues.Contains(s) == true || s.Equals(""));
}
+
result = reader.GetFieldNames(IndexReader.FieldOption.INDEXED);
Assert.IsTrue(result != null);
Assert.IsTrue(result.Count == DocHelper.indexed.Count);
for (System.Collections.IEnumerator iter = result.GetEnumerator(); iter.MoveNext(); )
{
- System.Collections.DictionaryEntry fi = (System.Collections.DictionaryEntry) iter.Current;
- System.String s = fi.Key.ToString();
- Assert.IsTrue(DocHelper.indexed.Contains(s) == true || s.Equals(""));
+ System.String s = (System.String)iter.Current;
+ Assert.IsTrue(DocHelper.indexed.Contains(s) == true || s.Equals(""));
}
result = reader.GetFieldNames(IndexReader.FieldOption.UNINDEXED);
Assert.IsTrue(result != null);
Assert.IsTrue(result.Count == DocHelper.unindexed.Count);
+
//Get all indexed fields that are storing term vectors
result = reader.GetFieldNames(IndexReader.FieldOption.INDEXED_WITH_TERMVECTOR);
Assert.IsTrue(result != null);
Index: C#/src/Test/Index/TestStressIndexing2.cs
===================================================================
--- C#/src/Test/Index/TestStressIndexing2.cs (revision 693915)
+++ C#/src/Test/Index/TestStressIndexing2.cs (working copy)
@@ -32,9 +32,13 @@
{
internal class AnonymousClassComparator : System.Collections.IComparer
{
+ Fieldable f1, f2;
public virtual int Compare(System.Object o1, System.Object o2)
{
- return String.CompareOrdinal(((Fieldable) o1).Name(), ((Fieldable) o2).Name());
+ if (o1 == o2) return 0;
+ f1 = (Fieldable)o1;
+ f2 = (Fieldable)o2;
+ return String.CompareOrdinal(f1.Name() + f1.StringValue(), f2.Name() + f2.StringValue());
}
}
internal static int maxFields = 4;
@@ -47,21 +51,13 @@
internal static System.Random r = new System.Random((System.Int32) 0);
-
[Test]
public virtual void TestRandom()
{
Directory dir1 = new MockRAMDirectory();
- // dir1 = FSDirectory.getDirectory("foofoofoo");
Directory dir2 = new MockRAMDirectory();
- // mergeFactor=2; maxBufferedDocs=2; Map docs = indexRandom(1, 3, 2, dir1);
- System.Collections.IDictionary docs = IndexRandom(10, 100, 100, dir1);
+ System.Collections.IDictionary docs = IndexRandom(10, 100, 100, dir1);
IndexSerial(docs, dir2);
-
- // verifying verify
- // verifyEquals(dir1, dir1, "id");
- // verifyEquals(dir2, dir2, "id");
-
VerifyEquals(dir1, dir2, "id");
}
@@ -84,7 +80,7 @@
Directory dir1 = new MockRAMDirectory();
Directory dir2 = new MockRAMDirectory();
- System.Collections.IDictionary docs = IndexRandom(nThreads, iter, range, dir1);
+ System.Collections.IDictionary docs = IndexRandom(nThreads, iter, range, dir1);
IndexSerial(docs, dir2);
VerifyEquals(dir1, dir2, "id");
}
@@ -103,12 +99,6 @@
{
IndexWriter w = new IndexWriter(dir, autoCommit, new WhitespaceAnalyzer(), true);
w.SetUseCompoundFile(false);
- /***
- w.setMaxMergeDocs(Integer.MAX_VALUE);
- w.setMaxFieldLength(10000);
- w.setRAMBufferSizeMB(1);
- w.setMergeFactor(10);
- ***/
// force many merges
w.SetMergeFactor(mergeFactor);
@@ -167,8 +157,17 @@
Document d = (Document) iter.Current;
System.Collections.ArrayList fields = new System.Collections.ArrayList();
fields.AddRange(d.GetFields());
- // put fields in same order each time
- fields.Sort(fieldNameComparator);
+
+ // nonono - can't do this (below)
+ //
+ // if multiple fields w/ same name, each instance must be
+ // added in the same order as orginal doc, as the fields
+ // are effectively concatendated
+ //
+ // term position/offset information must be maintained
+
+ // put fields in same order each time
+ //fields.Sort(fieldNameComparator);
Document d1 = new Document();
d1.SetBoost(d.GetBoost());
@@ -347,9 +346,21 @@
if (ff1.Count != ff2.Count)
{
- System.Console.Out.WriteLine(ff1);
- System.Console.Out.WriteLine(ff2);
- Assert.AreEqual(ff1.Count, ff2.Count);
+ // print out whole doc on error
+ System.Console.Write("Doc 1:");
+ for (int j = 0; j < ff1.Count; j++)
+ {
+ Fieldable field = (Fieldable)ff1[j];
+ System.Console.Write(" {0}={1};", field.Name(), field.StringValue());
+ }
+ System.Console.WriteLine();
+ System.Console.Write("Doc 2:");
+ for (int j = 0; j < ff2.Count; j++)
+ {
+ Fieldable field = (Fieldable)ff2[j];
+ System.Console.Write(" {0}={1};", field.Name(), field.StringValue());
+ }
+ System.Console.WriteLine(); Assert.AreEqual(ff1.Count, ff2.Count);
}
for (int i = 0; i < ff1.Count; i++)
@@ -368,9 +379,21 @@
if (!s1.Equals(s2))
{
// print out whole doc on error
- System.Console.Out.WriteLine(ff1);
- System.Console.Out.WriteLine(ff2);
- Assert.AreEqual(s1, s2);
+ System.Console.Write("Doc 1:");
+ for (int j = 0; j < ff1.Count; j++)
+ {
+ Fieldable field = (Fieldable)ff1[j];
+ System.Console.Write(" {0}={1};", field.Name(), field.StringValue());
+ }
+ System.Console.WriteLine();
+ System.Console.Write("Doc 2:");
+ for (int j = 0; j < ff2.Count; j++)
+ {
+ Fieldable field = (Fieldable)ff2[j];
+ System.Console.Write(" {0}={1};", field.Name(), field.StringValue());
+ }
+ System.Console.WriteLine();
+ Assert.AreEqual(s1, s2);
}
}
}
@@ -420,7 +443,7 @@
Assert.IsTrue(offsets2 != null);
for (int k = 0; k < pos1.Length; k++)
{
- Assert.AreEqual(pos1[k], pos2[k]);
+ Assert.AreEqual(pos1[k], pos2[k]);
if (offsets1 != null)
{
Assert.AreEqual(offsets1[k].GetStartOffset(), offsets2[k].GetStartOffset());
@@ -475,46 +498,46 @@
{
Field.TermVector tvVal = Field.TermVector.NO;
- switch (NextInt(4))
- {
-
- case 0:
- tvVal = Field.TermVector.NO;
- break;
-
- case 1:
- tvVal = Field.TermVector.YES;
- break;
-
- case 2:
- tvVal = Field.TermVector.WITH_POSITIONS;
- break;
-
- case 3:
- tvVal = Field.TermVector.WITH_POSITIONS_OFFSETS;
- break;
- }
-
- switch (NextInt(4))
- {
-
- case 0:
- fields.Add(new Field("f0", GetString(1), Field.Store.YES, Field.Index.NO_NORMS, tvVal));
- break;
-
- case 1:
- fields.Add(new Field("f1", GetString(0), Field.Store.NO, Field.Index.TOKENIZED, tvVal));
- break;
-
- case 2:
- fields.Add(new Field("f2", GetString(0), Field.Store.YES, Field.Index.NO, Field.TermVector.NO));
- break;
-
- case 3:
- fields.Add(new Field("f3", GetString(Lucene.Net.Index.TestStressIndexing2.bigFieldSize), Field.Store.YES, Field.Index.TOKENIZED, tvVal));
- break;
- }
- }
+ switch (NextInt(4))
+ {
+
+ case 0:
+ tvVal = Field.TermVector.NO;
+ break;
+
+ case 1:
+ tvVal = Field.TermVector.YES;
+ break;
+
+ case 2:
+ tvVal = Field.TermVector.WITH_POSITIONS;
+ break;
+
+ case 3:
+ tvVal = Field.TermVector.WITH_POSITIONS_OFFSETS;
+ break;
+ }
+
+ switch (NextInt(4))
+ {
+
+ case 0:
+ fields.Add(new Field("f0", GetString(1), Field.Store.YES, Field.Index.NO_NORMS, tvVal));
+ break;
+
+ case 1:
+ fields.Add(new Field("f1", GetString(0), Field.Store.NO, Field.Index.TOKENIZED, tvVal));
+ break;
+
+ case 2:
+ fields.Add(new Field("f2", GetString(0), Field.Store.YES, Field.Index.NO, Field.TermVector.NO));
+ break;
+
+ case 3:
+ fields.Add(new Field("f3", GetString(Lucene.Net.Index.TestStressIndexing2.bigFieldSize), Field.Store.YES, Field.Index.TOKENIZED, tvVal));
+ break;
+ }
+ }
if (Lucene.Net.Index.TestStressIndexing2.sameFieldOrder)
{
@@ -523,7 +546,9 @@
else
{
// random placement of id field also
- fields[NextInt(fields.Count)] = 0;
+ int index = NextInt(fields.Count);
+ fields[0] = fields[index];
+ fields[index] = idField;
}
for (int i = 0; i < fields.Count; i++)
@@ -562,4 +587,4 @@
fieldNameComparator = new AnonymousClassComparator();
}
}
-}
\ No newline at end of file
+}
Index: C#/src/Test/Search/CheckHits.cs
===================================================================
--- C#/src/Test/Search/CheckHits.cs (revision 693915)
+++ C#/src/Test/Search/CheckHits.cs (working copy)
@@ -160,6 +160,8 @@
}
Assert.AreEqual(correct.Count, actual.Count);
+ correct.Sort();
+ actual.Sort();
for (int i = 0; i < correct.Count; i++)
{
Assert.AreEqual(correct[i], actual[i]);
@@ -519,4 +521,4 @@
}
}
}
-}
\ No newline at end of file
+}