Skip to content

Commit

Permalink
Make MergeTrigger.NONE be 0, add back previously commented-out assert…
Browse files Browse the repository at this point in the history
… for null as NONE
  • Loading branch information
paulirwin committed Mar 13, 2024
1 parent 9be0d3e commit 2967e0c
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 25 deletions.
5 changes: 3 additions & 2 deletions src/Lucene.Net.Tests/Index/TestNoMergeScheduler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using NUnit.Framework;
using RandomizedTesting.Generators;
using System;
using System.Linq;
using System.Reflection;
using Assert = Lucene.Net.TestFramework.Assert;

Expand Down Expand Up @@ -34,7 +35,7 @@ public virtual void TestNoMergeScheduler_Mem()
{
MergeScheduler ms = NoMergeScheduler.INSTANCE;
ms.Dispose();
ms.Merge(null, RandomPicks.RandomFrom(Random, (MergeTrigger[])Enum.GetValues(typeof(MergeTrigger))), Random.NextBoolean());
ms.Merge(null, RandomPicks.RandomFrom(Random, ((MergeTrigger[])Enum.GetValues(typeof(MergeTrigger))).Where(i => i != MergeTrigger.NONE).ToArray()), Random.NextBoolean());
}

[Test]
Expand Down Expand Up @@ -69,4 +70,4 @@ public virtual void TestMethodsOverridden()
}
}
}
}
}
44 changes: 22 additions & 22 deletions src/Lucene.Net/Index/IndexWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,9 @@ namespace Lucene.Net.Index
/// the <see cref="mergePolicy"/> and the <see cref="mergeScheduler"/>.
/// The <see cref="mergePolicy"/> is invoked whenever there are
/// changes to the segments in the index. Its role is to
/// select which merges to do, if any, and return a
/// select which merges to do, if any, and return a
/// <see cref="MergePolicy.MergeSpecification"/> describing the merges.
/// The default is <see cref="LogByteSizeMergePolicy"/>. Then, the
/// The default is <see cref="LogByteSizeMergePolicy"/>. Then, the
/// <see cref="MergeScheduler"/> is invoked with the requested merges and
/// it decides when and how to run the merges. The default is
/// <see cref="ConcurrentMergeScheduler"/>. </para>
Expand All @@ -145,7 +145,7 @@ namespace Lucene.Net.Index
/// last commit. You can also just call <see cref="Rollback()"/>
/// directly.</para>
///
/// <a name="thread-safety"></a><para><b>NOTE</b>:
/// <a name="thread-safety"></a><para><b>NOTE</b>:
/// <see cref="IndexWriter"/> instances are completely thread
/// safe, meaning multiple threads can call any of its
/// methods, concurrently. If your application requires
Expand Down Expand Up @@ -1074,24 +1074,24 @@ private void MessageState()
/// something like this:</para>
///
/// <code>
/// try
/// try
/// {
/// writer.Dispose();
/// }
/// finally
/// }
/// finally
/// {
/// if (IndexWriter.IsLocked(directory))
/// if (IndexWriter.IsLocked(directory))
/// {
/// IndexWriter.Unlock(directory);
/// }
/// }
/// </code>
///
///
/// after which, you must be certain not to use the writer
/// instance anymore.
///
/// <para><b>NOTE</b>: if this method hits an <see cref="OutOfMemoryException"/>
/// you should immediately dispose the writer, again. See
/// you should immediately dispose the writer, again. See
/// <see cref="IndexWriter"/> for details.</para>
/// </summary>
/// <exception cref="IOException"> if there is a low-level IO error </exception>
Expand All @@ -1109,7 +1109,7 @@ public void Dispose()
/// threads.
///
/// <para><b>NOTE</b>: If this method hits an <see cref="OutOfMemoryException"/>
/// you should immediately dispose the writer, again. See
/// you should immediately dispose the writer, again. See
/// <see cref="IndexWriter"/> for details.</para>
///
/// <para><b>NOTE</b>: It is dangerous to always call
Expand Down Expand Up @@ -1160,7 +1160,7 @@ public void Dispose(bool waitForMerges)
/// set to <c>true</c>.</para>
///
/// <para><b>NOTE</b>: If this method hits an <see cref="OutOfMemoryException"/>
/// you should immediately dispose the writer, again. See
/// you should immediately dispose the writer, again. See
/// <see cref="IndexWriter"/> for details.</para>
///
/// <para><b>NOTE</b>: It is dangerous to always call
Expand Down Expand Up @@ -1594,7 +1594,7 @@ public virtual bool HasDeletions()
/// U+FFFD.</para>
///
/// <para><b>NOTE</b>: if this method hits an <see cref="OutOfMemoryException"/>
/// you should immediately dispose the writer. See
/// you should immediately dispose the writer. See
/// <see cref="IndexWriter"/> for details.</para>
/// </summary>
/// <exception cref="CorruptIndexException"> if the index is corrupt </exception>
Expand Down Expand Up @@ -1658,8 +1658,8 @@ public virtual void AddDocument(IEnumerable<IIndexableField> doc, Analyzer analy
/// <para><b>NOTE</b>: if this method hits an <see cref="OutOfMemoryException"/>
/// you should immediately dispose the writer. See
/// <see cref="IndexWriter"/> for details.</para>
///
/// @lucene.experimental
///
/// @lucene.experimental
/// </summary>
/// <exception cref="CorruptIndexException"> if the index is corrupt </exception>
/// <exception cref="IOException"> if there is a low-level IO error </exception>
Expand Down Expand Up @@ -1746,7 +1746,7 @@ public virtual void UpdateDocuments(Term delTerm, IEnumerable<IEnumerable<IIndex
/// Deletes the document(s) containing <paramref name="term"/>.
///
/// <para><b>NOTE</b>: if this method hits an <see cref="OutOfMemoryException"/>
/// you should immediately dispose the writer. See
/// you should immediately dispose the writer. See
/// <see cref="IndexWriter"/> for details.</para>
/// </summary>
/// <param name="term"> the term to identify the documents to be deleted </param>
Expand All @@ -1770,7 +1770,7 @@ public virtual void DeleteDocuments(Term term)

/// <summary>
/// Expert: attempts to delete by document ID, as long as
/// the provided <paramref name="readerIn"/> is a near-real-time reader (from
/// the provided <paramref name="readerIn"/> is a near-real-time reader (from
/// <see cref="DirectoryReader.Open(IndexWriter, bool)"/>. If the
/// provided <paramref name="readerIn"/> is an NRT reader obtained from this
/// writer, and its segment has not been merged away, then
Expand Down Expand Up @@ -2604,7 +2604,7 @@ private bool UpdatePendingMerges(MergeTrigger trigger, int maxNumSegments)
try
{
if (Debugging.AssertsEnabled) Debugging.Assert(maxNumSegments == -1 || maxNumSegments > 0);
//if (Debugging.AssertsEnabled) Debugging.Assert(trigger != null); // LUCENENET NOTE: Enum cannot be null in .NET
if (Debugging.AssertsEnabled) Debugging.Assert(trigger != MergeTrigger.NONE); // LUCENENET specific: using NONE instead of null
if (stopMerges)
{
return false;
Expand Down Expand Up @@ -2912,7 +2912,7 @@ private void RollbackInternal()
/// documents as deleted.</para>
///
/// <para>NOTE: this method will forcefully abort all merges
/// in progress. If other threads are running
/// in progress. If other threads are running
/// <see cref="ForceMerge(int)"/>, <see cref="AddIndexes(IndexReader[])"/> or
/// <see cref="ForceMergeDeletes()"/> methods, they may receive
/// <see cref="MergePolicy.MergeAbortedException"/>s.</para>
Expand Down Expand Up @@ -3852,8 +3852,8 @@ protected virtual void DoBeforeFlush()
/// steps necessary to commit changes since this writer
/// was opened: flushes pending added and deleted docs,
/// syncs the index files, writes most of next segments_N
/// file. After calling this you must call either
/// <see cref="Commit()"/> to finish the commit, or
/// file. After calling this you must call either
/// <see cref="Commit()"/> to finish the commit, or
/// <see cref="Rollback()"/> to revert the commit and undo all changes
/// done since the writer was opened.</para>
///
Expand Down Expand Up @@ -6136,7 +6136,7 @@ public static void Unlock(Directory directory)
/// after a merge completes.
/// <para/>
/// @lucene.experimental
///
///
/// <para/><b>NOTE</b>: <see cref="Warm(AtomicReader)"/> is called before any deletes have
/// been carried over to the merged segment.
/// </summary>
Expand Down Expand Up @@ -6485,4 +6485,4 @@ private static bool SlowFileExists(Directory dir, string fileName)
}
}
}
}
}
2 changes: 1 addition & 1 deletion src/Lucene.Net/Index/MergeTrigger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public enum MergeTrigger
/// <summary>
/// LUCENENET-specific value to be used instead of null.
/// </summary>
NONE = -1,
NONE = 0,

/// <summary>
/// Merge was triggered by a segment flush.
Expand Down

0 comments on commit 2967e0c

Please sign in to comment.