From 262f4e2849f58e57130cce0e2200cfdb3efb393b Mon Sep 17 00:00:00 2001 From: tohidemyname Date: Wed, 5 Jun 2024 10:36:20 +0800 Subject: [PATCH 1/5] Fix SegmentInfos replace doesn't update userData https://github.com/apache/lucenenet/issues/947 --- src/Lucene.Net.Tests/Index/TestIndexWriter.cs | 59 +++++++++++++++++++ src/Lucene.Net/Index/SegmentInfos.cs | 3 +- 2 files changed, 61 insertions(+), 1 deletion(-) diff --git a/src/Lucene.Net.Tests/Index/TestIndexWriter.cs b/src/Lucene.Net.Tests/Index/TestIndexWriter.cs index 8cf738904c..ed36930e87 100644 --- a/src/Lucene.Net.Tests/Index/TestIndexWriter.cs +++ b/src/Lucene.Net.Tests/Index/TestIndexWriter.cs @@ -816,6 +816,65 @@ public virtual void TestMaxThreadPriority() } } + private Dictionary GetCommitData(IndexWriter writer) + { + Dictionary data = new Dictionary(); + foreach (var ent in writer.CommitData) + { + data.Put(ent.Key, ent.Value); + } + return data; + } + + [Test] + public void testGetCommitDataFromOldSnapshot() + { + Directory dir = NewDirectory(); + IndexWriterConfig conf = NewIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(Random)).SetMaxBufferedDocs(2).SetMergePolicy(NewLogMergePolicy()); + conf.SetIndexDeletionPolicy(new SnapshotDeletionPolicy(NoDeletionPolicy.INSTANCE)); + IndexWriter writer = new IndexWriter(dir, conf); + writer.SetCommitData( + new Dictionary() + { + { "key", "value" }, + }); + assertEquals("value", GetCommitData(writer).GetValueOrDefault("key")); + writer.Commit(); + // Snapshot this commit to open later + IndexCommit indexCommit = + ((SnapshotDeletionPolicy)writer.Config.IndexDeletionPolicy).Snapshot(); + writer.Dispose(); + + // Modify the commit data and commit on close so the most recent commit data is different + conf = NewIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(Random)).SetMaxBufferedDocs(2).SetMergePolicy(NewLogMergePolicy()); + conf.SetIndexDeletionPolicy(new SnapshotDeletionPolicy(NoDeletionPolicy.INSTANCE)); + writer = new IndexWriter(dir, conf); + writer.SetCommitData( + new Dictionary() + { + {"key", "value2" }, + }); + + assertEquals("value2", GetCommitData(writer).GetValueOrDefault("key")); + writer.Dispose(); + + // validate that when opening writer from older snapshotted index commit, the old commit data is + // visible + conf = NewIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(Random)).SetMaxBufferedDocs(2).SetMergePolicy(NewLogMergePolicy()); + conf.SetIndexDeletionPolicy(new SnapshotDeletionPolicy(NoDeletionPolicy.INSTANCE)); + writer = + new IndexWriter( + dir, + conf + .SetOpenMode(OpenMode.APPEND) + .SetIndexCommit(indexCommit)); + assertEquals("value", GetCommitData(writer).GetValueOrDefault("key")); + writer.Dispose(); + + dir.Dispose(); + } + + [Test] public virtual void TestVariableSchema() { diff --git a/src/Lucene.Net/Index/SegmentInfos.cs b/src/Lucene.Net/Index/SegmentInfos.cs index 1295df946a..06c77a77ab 100644 --- a/src/Lucene.Net/Index/SegmentInfos.cs +++ b/src/Lucene.Net/Index/SegmentInfos.cs @@ -1452,6 +1452,7 @@ internal void Replace(SegmentInfos other) { RollbackSegmentInfos(other.AsList()); lastGeneration = other.lastGeneration; + userData = other.userData; } /// @@ -1632,4 +1633,4 @@ internal int IndexOf(SegmentCommitInfo si) return segments.IndexOf(si); } } -} \ No newline at end of file +} From 180411aedd6fb861d278e1286d8a1e56d8b3df20 Mon Sep 17 00:00:00 2001 From: Paul Irwin Date: Mon, 28 Oct 2024 19:42:28 -0600 Subject: [PATCH 2/5] Add LUCENENET-specific backport comment, fix test name --- src/Lucene.Net.Tests/Index/TestIndexWriter.cs | 13 +++++++------ src/Lucene.Net/Index/SegmentInfos.cs | 9 +++++---- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/Lucene.Net.Tests/Index/TestIndexWriter.cs b/src/Lucene.Net.Tests/Index/TestIndexWriter.cs index ed36930e87..9716bee0ad 100644 --- a/src/Lucene.Net.Tests/Index/TestIndexWriter.cs +++ b/src/Lucene.Net.Tests/Index/TestIndexWriter.cs @@ -818,23 +818,24 @@ public virtual void TestMaxThreadPriority() private Dictionary GetCommitData(IndexWriter writer) { - Dictionary data = new Dictionary(); + Dictionary data = new Dictionary(); foreach (var ent in writer.CommitData) { data.Put(ent.Key, ent.Value); - } + } return data; } + // LUCENENET-specific: backport fix and test from Lucene 9.9.0 (lucene#12626, lucene#12637) [Test] - public void testGetCommitDataFromOldSnapshot() + public void TestGetCommitDataFromOldSnapshot() { Directory dir = NewDirectory(); IndexWriterConfig conf = NewIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(Random)).SetMaxBufferedDocs(2).SetMergePolicy(NewLogMergePolicy()); conf.SetIndexDeletionPolicy(new SnapshotDeletionPolicy(NoDeletionPolicy.INSTANCE)); IndexWriter writer = new IndexWriter(dir, conf); writer.SetCommitData( - new Dictionary() + new Dictionary() { { "key", "value" }, }); @@ -850,11 +851,11 @@ public void testGetCommitDataFromOldSnapshot() conf.SetIndexDeletionPolicy(new SnapshotDeletionPolicy(NoDeletionPolicy.INSTANCE)); writer = new IndexWriter(dir, conf); writer.SetCommitData( - new Dictionary() + new Dictionary() { {"key", "value2" }, }); - + assertEquals("value2", GetCommitData(writer).GetValueOrDefault("key")); writer.Dispose(); diff --git a/src/Lucene.Net/Index/SegmentInfos.cs b/src/Lucene.Net/Index/SegmentInfos.cs index 06c77a77ab..a6167f3672 100644 --- a/src/Lucene.Net/Index/SegmentInfos.cs +++ b/src/Lucene.Net/Index/SegmentInfos.cs @@ -305,8 +305,8 @@ internal static string SegmentNumberToString(long segment, bool allowLegacyNames private JCG.List segments = new JCG.List(); /// - /// If non-null, information about loading segments_N files - /// will be printed here. + /// If non-null, information about loading segments_N files + /// will be printed here. /// private static TextWriter infoStream = null; @@ -891,7 +891,7 @@ public object Clone() /// If non-null, information about retries when loading /// the segments file will be printed to this. /// - public static TextWriter InfoStream + public static TextWriter InfoStream { set => // LUCENENET specific - use a SafeTextWriterWrapper to ensure that if the TextWriter @@ -1452,6 +1452,7 @@ internal void Replace(SegmentInfos other) { RollbackSegmentInfos(other.AsList()); lastGeneration = other.lastGeneration; + // LUCENENET-specific: backport fix from Lucene 9.9.0 (lucene#12626, lucene#12637) userData = other.userData; } @@ -1612,7 +1613,7 @@ internal void Remove(int index) } /// - /// Return true if the provided + /// Return true if the provided /// is contained. /// /// WARNING: O(N) cost From a08e10973181e88824a6104532d65ffc131f6a8e Mon Sep 17 00:00:00 2001 From: Paul Irwin Date: Mon, 28 Oct 2024 20:15:31 -0600 Subject: [PATCH 3/5] Relocate test and update name of GetCommitData --- src/Lucene.Net.Tests/Index/TestIndexWriter.cs | 125 +++++++++--------- 1 file changed, 64 insertions(+), 61 deletions(-) diff --git a/src/Lucene.Net.Tests/Index/TestIndexWriter.cs b/src/Lucene.Net.Tests/Index/TestIndexWriter.cs index 9716bee0ad..93a39d5cf9 100644 --- a/src/Lucene.Net.Tests/Index/TestIndexWriter.cs +++ b/src/Lucene.Net.Tests/Index/TestIndexWriter.cs @@ -816,66 +816,6 @@ public virtual void TestMaxThreadPriority() } } - private Dictionary GetCommitData(IndexWriter writer) - { - Dictionary data = new Dictionary(); - foreach (var ent in writer.CommitData) - { - data.Put(ent.Key, ent.Value); - } - return data; - } - - // LUCENENET-specific: backport fix and test from Lucene 9.9.0 (lucene#12626, lucene#12637) - [Test] - public void TestGetCommitDataFromOldSnapshot() - { - Directory dir = NewDirectory(); - IndexWriterConfig conf = NewIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(Random)).SetMaxBufferedDocs(2).SetMergePolicy(NewLogMergePolicy()); - conf.SetIndexDeletionPolicy(new SnapshotDeletionPolicy(NoDeletionPolicy.INSTANCE)); - IndexWriter writer = new IndexWriter(dir, conf); - writer.SetCommitData( - new Dictionary() - { - { "key", "value" }, - }); - assertEquals("value", GetCommitData(writer).GetValueOrDefault("key")); - writer.Commit(); - // Snapshot this commit to open later - IndexCommit indexCommit = - ((SnapshotDeletionPolicy)writer.Config.IndexDeletionPolicy).Snapshot(); - writer.Dispose(); - - // Modify the commit data and commit on close so the most recent commit data is different - conf = NewIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(Random)).SetMaxBufferedDocs(2).SetMergePolicy(NewLogMergePolicy()); - conf.SetIndexDeletionPolicy(new SnapshotDeletionPolicy(NoDeletionPolicy.INSTANCE)); - writer = new IndexWriter(dir, conf); - writer.SetCommitData( - new Dictionary() - { - {"key", "value2" }, - }); - - assertEquals("value2", GetCommitData(writer).GetValueOrDefault("key")); - writer.Dispose(); - - // validate that when opening writer from older snapshotted index commit, the old commit data is - // visible - conf = NewIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(Random)).SetMaxBufferedDocs(2).SetMergePolicy(NewLogMergePolicy()); - conf.SetIndexDeletionPolicy(new SnapshotDeletionPolicy(NoDeletionPolicy.INSTANCE)); - writer = - new IndexWriter( - dir, - conf - .SetOpenMode(OpenMode.APPEND) - .SetIndexCommit(indexCommit)); - assertEquals("value", GetCommitData(writer).GetValueOrDefault("key")); - writer.Dispose(); - - dir.Dispose(); - } - - [Test] public virtual void TestVariableSchema() { @@ -2616,12 +2556,26 @@ public virtual void TestCommitWithUserDataOnly() dir.Dispose(); } + // LUCENENET-specific: backport fix and test from Lucene 9.9.0 (lucene#12626, lucene#12637) + private Dictionary GetLiveCommitData(IndexWriter writer) + { + Dictionary data = new Dictionary(); + // LUCENENET TODO: in a post-4.8 port, this should use LiveCommitData + foreach (var ent in writer.CommitData) + { + data.Put(ent.Key, ent.Value); + } + + return data; + } + [Test] public virtual void TestGetCommitData() { Directory dir = NewDirectory(); IndexWriter writer = new IndexWriter(dir, NewIndexWriterConfig(TEST_VERSION_CURRENT, null)); - writer.SetCommitData(new Dictionary() { + writer.SetCommitData(new Dictionary() + { {"key", "value"} }); Assert.AreEqual("value", writer.CommitData["key"]); @@ -2635,6 +2589,55 @@ public virtual void TestGetCommitData() dir.Dispose(); } + // LUCENENET-specific: backport fix and test from Lucene 9.9.0 (lucene#12626, lucene#12637) + [Test] + public void TestGetCommitDataFromOldSnapshot() + { + Directory dir = NewDirectory(); + IndexWriterConfig conf = NewIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(Random)).SetMaxBufferedDocs(2).SetMergePolicy(NewLogMergePolicy()); + conf.SetIndexDeletionPolicy(new SnapshotDeletionPolicy(NoDeletionPolicy.INSTANCE)); + IndexWriter writer = new IndexWriter(dir, conf); + // LUCENENET TODO: in a post-4.8 port, this should use SetLiveCommitData + writer.SetCommitData(new Dictionary + { + { "key", "value" }, + }); + assertEquals("value", GetLiveCommitData(writer)["key"]); + writer.Commit(); + // Snapshot this commit to open later + IndexCommit indexCommit = + ((SnapshotDeletionPolicy)writer.Config.IndexDeletionPolicy).Snapshot(); + writer.Dispose(); + + // Modify the commit data and commit on close so the most recent commit data is different + conf = NewIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(Random)).SetMaxBufferedDocs(2).SetMergePolicy(NewLogMergePolicy()); + conf.SetIndexDeletionPolicy(new SnapshotDeletionPolicy(NoDeletionPolicy.INSTANCE)); + writer = new IndexWriter(dir, conf); + // LUCENENET TODO: in a post-4.8 port, this should use SetLiveCommitData + writer.SetCommitData(new Dictionary() + { + { "key", "value2" }, + }); + + assertEquals("value2", GetLiveCommitData(writer)["key"]); + writer.Dispose(); + + // validate that when opening writer from older snapshotted index commit, the old commit data is + // visible + conf = NewIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(Random)).SetMaxBufferedDocs(2).SetMergePolicy(NewLogMergePolicy()); + conf.SetIndexDeletionPolicy(new SnapshotDeletionPolicy(NoDeletionPolicy.INSTANCE)); + writer = + new IndexWriter( + dir, + conf + .SetOpenMode(OpenMode.APPEND) + .SetIndexCommit(indexCommit)); + assertEquals("value", GetLiveCommitData(writer)["key"]); + writer.Dispose(); + + dir.Dispose(); + } + [Test] public virtual void TestIterableThrowsException() { From 50240bd470fabe2a606b932df49642f2bd579eb7 Mon Sep 17 00:00:00 2001 From: Paul Irwin Date: Mon, 28 Oct 2024 20:23:38 -0600 Subject: [PATCH 4/5] Add NewSnapshotIndexWriterConfig method --- .../Util/LuceneTestCase.cs | 48 +++++++++++++------ src/Lucene.Net.Tests/Index/TestIndexWriter.cs | 12 ++--- 2 files changed, 36 insertions(+), 24 deletions(-) diff --git a/src/Lucene.Net.TestFramework/Util/LuceneTestCase.cs b/src/Lucene.Net.TestFramework/Util/LuceneTestCase.cs index 988b63faf4..210aa689a0 100644 --- a/src/Lucene.Net.TestFramework/Util/LuceneTestCase.cs +++ b/src/Lucene.Net.TestFramework/Util/LuceneTestCase.cs @@ -105,9 +105,9 @@ namespace Lucene.Net.Util /// It is recommended to configure the culture also, since they are randomly picked from a list /// of cultures installed on a given machine, so the culture will vary from one machine to the next. /// - /// + /// ///

.runsettings File Configuration Example

- /// + /// /// /// <RunSettings> /// <TestRunParameters> @@ -120,9 +120,9 @@ namespace Lucene.Net.Util /// See the .runsettings documentation at: /// https://docs.microsoft.com/en-us/visualstudio/test/configure-unit-tests-by-using-a-dot-runsettings-file. /// - /// + /// ///

Attribute Configuration Example

- /// + /// /// /// [assembly: Lucene.Net.Util.RandomSeed("0x1ffa1d067056b0e6")] /// [assembly: NUnit.Framework.SetCulture("sw-TZ")] @@ -134,7 +134,7 @@ namespace Lucene.Net.Util /// Add a file named lucene.testSettings.config to the executable directory or /// any directory between the executable and the root of the drive with the following contents. /// - /// + /// /// /// { /// "tests": { @@ -160,7 +160,7 @@ namespace Lucene.Net.Util /// sw-TZ /// /// - /// + /// ///
[TestFixture] public abstract partial class LuceneTestCase //: Assert // Wait long for leaked threads to complete before failure. zk needs this. - See LUCENE-3995 for rationale. @@ -510,7 +510,7 @@ public SystemPropertyData() /// /// TODO: javadoc? - public bool UseInfoStream { get; } + public bool UseInfoStream { get; } /// /// A random multiplier which you should use when writing random tests: @@ -1271,6 +1271,24 @@ public static void DumpArray(string label, object[] objs, TextWriter stream) DumpEnumerator(label, iter, stream); } + /// + /// Creates a new with a . + /// + /// The Lucene compatibility Version + /// The analyzer to use + /// Returns a new . + /// + /// This was backported as a result of fixing lucene#12626 from Lucene 9.9.0 in Lucene.NET. + /// The later versions of this code do not have the version parameter, but keeping it here + /// for consistency with below. + /// + public static IndexWriterConfig NewSnapshotIndexWriterConfig(LuceneVersion v, Analyzer analyzer) + { + IndexWriterConfig c = NewIndexWriterConfig(v, analyzer); + c.SetIndexDeletionPolicy(new SnapshotDeletionPolicy(NoDeletionPolicy.INSTANCE)); + return c; + } + /// /// Create a new with random defaults. /// @@ -1731,7 +1749,7 @@ public static Field NewField(Random random, string name, string value, FieldType } /// - /// Return a random from the available cultures on the system. + /// Return a random from the available cultures on the system. /// /// See https://issues.apache.org/jira/browse/LUCENE-4020. /// @@ -1741,7 +1759,7 @@ public static CultureInfo RandomCulture(Random random) // LUCENENET specific ren } /// - /// Return a random from the available timezones on the system + /// Return a random from the available timezones on the system /// /// See https://issues.apache.org/jira/browse/LUCENE-4020. /// @@ -2037,7 +2055,7 @@ public static IndexSearcher NewSearcher(IndexReader r, bool maybeWrap, bool wrap /// /// Gets a resource from the classpath as . This method should only /// be used, if a real file is needed. To get a stream, code should prefer - /// using + /// using /// this.GetType().Assembly and this.GetType(). /// protected virtual Stream GetDataFile(string name) @@ -2879,7 +2897,7 @@ public virtual void AssertFieldInfosEquals(string info, IndexReader leftReader, /// /// Returns true if the file exists (can be opened), false - /// if it cannot be opened, and (unlike .NET's + /// if it cannot be opened, and (unlike .NET's /// ) if there's some /// unexpected error, returns false. /// @@ -2921,7 +2939,7 @@ public static DirectoryInfo CreateTempDir() /// /// Creates an empty, temporary folder with the given name under the /// system's or if supplied, the tempDir system property. - /// + /// /// The folder will be automatically removed after the /// test class completes successfully. The test should close any file handles that would prevent /// the folder from being removed. @@ -2940,7 +2958,7 @@ public static DirectoryInfo CreateTempDir(string prefix) { throw RuntimeException.Create("Failed to get a temporary name too many times, check your temp directory and consider manually cleaning it: " + System.IO.Path.GetTempPath()); } - // LUCENENET specific - need to use a random file name instead of a sequential one or two threads may attempt to do + // LUCENENET specific - need to use a random file name instead of a sequential one or two threads may attempt to do // two operations on a file at the same time. //f = new DirectoryInfo(Path.Combine(System.IO.Path.GetTempPath(), "LuceneTemp", prefix + "-" + attempt)); f = new DirectoryInfo(Path.Combine(@base, "LuceneTemp", prefix + "-" + Path.GetFileNameWithoutExtension(Path.GetRandomFileName()))); @@ -3157,7 +3175,7 @@ internal static void LogNativeFSFactoryDebugInfo() /// value, chosen from (approximately) the usual /// normal distribution with mean 0.0 and standard deviation /// 1.0, is pseudorandomly generated and returned. - /// + /// /// This uses the polar method of G. E. P. Box, M. E. Muller, and /// G. Marsaglia, as described by Donald E. Knuth in The Art of /// Computer Programming, Volume 3: Seminumerical Algorithms, @@ -3193,4 +3211,4 @@ public void OnDispose(IndexReader reader) } } } -} \ No newline at end of file +} diff --git a/src/Lucene.Net.Tests/Index/TestIndexWriter.cs b/src/Lucene.Net.Tests/Index/TestIndexWriter.cs index 93a39d5cf9..737f5e9cf0 100644 --- a/src/Lucene.Net.Tests/Index/TestIndexWriter.cs +++ b/src/Lucene.Net.Tests/Index/TestIndexWriter.cs @@ -2594,9 +2594,7 @@ public virtual void TestGetCommitData() public void TestGetCommitDataFromOldSnapshot() { Directory dir = NewDirectory(); - IndexWriterConfig conf = NewIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(Random)).SetMaxBufferedDocs(2).SetMergePolicy(NewLogMergePolicy()); - conf.SetIndexDeletionPolicy(new SnapshotDeletionPolicy(NoDeletionPolicy.INSTANCE)); - IndexWriter writer = new IndexWriter(dir, conf); + IndexWriter writer = new IndexWriter(dir, NewSnapshotIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(Random))); // LUCENENET TODO: in a post-4.8 port, this should use SetLiveCommitData writer.SetCommitData(new Dictionary { @@ -2610,9 +2608,7 @@ public void TestGetCommitDataFromOldSnapshot() writer.Dispose(); // Modify the commit data and commit on close so the most recent commit data is different - conf = NewIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(Random)).SetMaxBufferedDocs(2).SetMergePolicy(NewLogMergePolicy()); - conf.SetIndexDeletionPolicy(new SnapshotDeletionPolicy(NoDeletionPolicy.INSTANCE)); - writer = new IndexWriter(dir, conf); + writer = new IndexWriter(dir, NewSnapshotIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(Random))); // LUCENENET TODO: in a post-4.8 port, this should use SetLiveCommitData writer.SetCommitData(new Dictionary() { @@ -2624,12 +2620,10 @@ public void TestGetCommitDataFromOldSnapshot() // validate that when opening writer from older snapshotted index commit, the old commit data is // visible - conf = NewIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(Random)).SetMaxBufferedDocs(2).SetMergePolicy(NewLogMergePolicy()); - conf.SetIndexDeletionPolicy(new SnapshotDeletionPolicy(NoDeletionPolicy.INSTANCE)); writer = new IndexWriter( dir, - conf + NewSnapshotIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(Random)) .SetOpenMode(OpenMode.APPEND) .SetIndexCommit(indexCommit)); assertEquals("value", GetLiveCommitData(writer)["key"]); From 69bacf3950e87eb2363f7b213217bc36882586dd Mon Sep 17 00:00:00 2001 From: Paul Irwin Date: Mon, 4 Nov 2024 12:30:03 -0700 Subject: [PATCH 5/5] PR feedback --- src/Lucene.Net.Tests/Index/TestIndexWriter.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Lucene.Net.Tests/Index/TestIndexWriter.cs b/src/Lucene.Net.Tests/Index/TestIndexWriter.cs index 737f5e9cf0..a482874c78 100644 --- a/src/Lucene.Net.Tests/Index/TestIndexWriter.cs +++ b/src/Lucene.Net.Tests/Index/TestIndexWriter.cs @@ -2560,7 +2560,7 @@ public virtual void TestCommitWithUserDataOnly() private Dictionary GetLiveCommitData(IndexWriter writer) { Dictionary data = new Dictionary(); - // LUCENENET TODO: in a post-4.8 port, this should use LiveCommitData + // LUCENENET UPGRADE TODO: in a post-4.8 port, this should use LiveCommitData foreach (var ent in writer.CommitData) { data.Put(ent.Key, ent.Value); @@ -2594,8 +2594,8 @@ public virtual void TestGetCommitData() public void TestGetCommitDataFromOldSnapshot() { Directory dir = NewDirectory(); - IndexWriter writer = new IndexWriter(dir, NewSnapshotIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(Random))); - // LUCENENET TODO: in a post-4.8 port, this should use SetLiveCommitData + IndexWriter writer = new IndexWriter(dir, NewSnapshotIndexWriterConfig(TEST_VERSION_CURRENT, null)); + // LUCENENET UPGRADE TODO: in a post-4.8 port, this should use SetLiveCommitData writer.SetCommitData(new Dictionary { { "key", "value" }, @@ -2608,8 +2608,8 @@ public void TestGetCommitDataFromOldSnapshot() writer.Dispose(); // Modify the commit data and commit on close so the most recent commit data is different - writer = new IndexWriter(dir, NewSnapshotIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(Random))); - // LUCENENET TODO: in a post-4.8 port, this should use SetLiveCommitData + writer = new IndexWriter(dir, NewSnapshotIndexWriterConfig(TEST_VERSION_CURRENT, null)); + // LUCENENET UPGRADE TODO: in a post-4.8 port, this should use SetLiveCommitData writer.SetCommitData(new Dictionary() { { "key", "value2" }, @@ -2623,7 +2623,7 @@ public void TestGetCommitDataFromOldSnapshot() writer = new IndexWriter( dir, - NewSnapshotIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(Random)) + NewSnapshotIndexWriterConfig(TEST_VERSION_CURRENT, null) .SetOpenMode(OpenMode.APPEND) .SetIndexCommit(indexCommit)); assertEquals("value", GetLiveCommitData(writer)["key"]);