You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucenenet.apache.org by "tohidemyname (via GitHub)" <gi...@apache.org> on 2024/06/05 02:38:12 UTC
[PR] Fix SegmentInfos replace doesn't update userData [lucenenet]
tohidemyname opened a new pull request, #948:
URL: https://github.com/apache/lucenenet/pull/948
<!-- Thank you for submitting a pull request to our repo. -->
<!-- Please do NOT submit PRs for features in newer versions of Lucene. We should keep the target version consistent across our repository to make the upgrade process to newer versions of Lucene go smoothly. -->
<!-- If this is your first PR in the Lucene.NET repo, please run through the checklist
below to ensure a smooth review and merge process for your PR. -->
- [ ] You've read the [Contributor Guide](https://github.com/apache/lucenenet/blob/main/CONTRIBUTING.md) and [Code of Conduct](https://www.apache.org/foundation/policies/conduct.html).
- [ ] You've included unit or integration tests for your change, where applicable.
- [ ] You've included inline docs for your change, where applicable.
- [ ] There's an open issue for the PR that you are making. If you'd like to propose a change, please [open an issue](https://github.com/apache/lucenenet/issues/new/choose) to discuss the change or find an existing issue.
<!-- Once all that is done, you're ready to go. Open the PR with the content below. -->
Summary of the changes (Less than 80 chars)
Fixes #{bug number} (in this specific format)
https://github.com/apache/lucenenet/issues/947
## Description
{Detail}
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@lucenenet.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix SegmentInfos replace doesn't update userData [lucenenet]
Posted by "NightOwl888 (via GitHub)" <gi...@apache.org>.
NightOwl888 merged PR #948:
URL: https://github.com/apache/lucenenet/pull/948
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@lucenenet.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix SegmentInfos replace doesn't update userData [lucenenet]
Posted by "paulirwin (via GitHub)" <gi...@apache.org>.
paulirwin commented on code in PR #948:
URL: https://github.com/apache/lucenenet/pull/948#discussion_r1828294249
##########
src/Lucene.Net.Tests/Index/TestIndexWriter.cs:
##########
@@ -2575,6 +2589,49 @@ 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();
+ 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<string, string>
+ {
+ { "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
+ writer = new IndexWriter(dir, NewSnapshotIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(Random)));
Review Comment:
Tests pass with null, so made that change.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@lucenenet.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix SegmentInfos replace doesn't update userData [lucenenet]
Posted by "paulirwin (via GitHub)" <gi...@apache.org>.
paulirwin commented on PR #948:
URL: https://github.com/apache/lucenenet/pull/948#issuecomment-2430467495
@NightOwl888 My thoughts exactly, thanks for writing that all out. I'll make those changes to this PR.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@lucenenet.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix SegmentInfos replace doesn't update userData [lucenenet]
Posted by "NightOwl888 (via GitHub)" <gi...@apache.org>.
NightOwl888 commented on PR #948:
URL: https://github.com/apache/lucenenet/pull/948#issuecomment-2428428333
@paulirwin - Thanks for finding that PR. The fact that a link or mention of it was missing from both the issue and PR was the primary thing holding this up.
I see a few issues that should be addressed before merging it.
- [ ] 1. The production change is missing a `LUCENENET` comment indicating where the change (which diverges from 4.8.0) came from. Ideally, there would be a link back to the PR or commit where the code was ported from.
- [ ] 2. The name of the test method should be Pascal case. NUnit doesn't automatically detect test methods based on a naming convention, so there is no need to stick with that casing in .NET.
- [ ] 3. The test method and `GetCommitData()` method are not in the same order in the file as they were in Lucene. In Lucene, `TestVariableSchema()` (the following test in this PR) is on [line 593](https://github.com/Shibi-bala/lucene/blob/e98cc333e2131ca9d39f81a2da9fed5ab0d1d5bb/lucene/core/src/test/org/apache/lucene/index/TestIndexWriter.java#L593) and `TestGetCommitDataFromOldSnapshot()` is on [line 2064](https://github.com/Shibi-bala/lucene/blob/e98cc333e2131ca9d39f81a2da9fed5ab0d1d5bb/lucene/core/src/test/org/apache/lucene/index/TestIndexWriter.java#L2064).
- [ ] 4. The original test used `getLiveCommitData()`, not `getCommitData()`. It's fine if `setLiveCommitData()` doesn't exist in 4.8.0, but we should `LUCENENET` comment to make it clear why we diverged (and that it has diverged) on each of the lines that call `GetCommitData()` and `SetCommitData()`, since these will need to be changed back when we upgrade.
- [ ] 5. The original test used [`newSnapshotIndexWriterConfig(null)`](https://github.com/Shibi-bala/lucene/blob/e98cc333e2131ca9d39f81a2da9fed5ab0d1d5bb/lucene/test-framework/src/java/org/apache/lucene/tests/util/LuceneTestCase.java#L935-L940). We should port that method in `LuceneTestCase` rather than inlining the configuration, and add a `LUCENENET` comment indicating where the diverging method came from.
- [ ] 6. The `TestGetCommitDataFromOldSnapshot()` and `GetCommitData()` methods also don't have a `LUCENENET` comment indicating where these diverging changes came from.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@lucenenet.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix SegmentInfos replace doesn't update userData [lucenenet]
Posted by "paulirwin (via GitHub)" <gi...@apache.org>.
paulirwin commented on PR #948:
URL: https://github.com/apache/lucenenet/pull/948#issuecomment-2428137413
@tohidemyname Thanks for this PR!
@NightOwl888 This appears to be a pretty straightforward port of https://github.com/apache/lucene/pull/12626 which was in Lucene 9.9.0. Given the single-line nature of the change, I think this is probably safe to backport. Let me know if you agree. I'll tidy it up with a comment explaining the backport so we're aware for future porting efforts.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@lucenenet.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix SegmentInfos replace doesn't update userData [lucenenet]
Posted by "NightOwl888 (via GitHub)" <gi...@apache.org>.
NightOwl888 commented on code in PR #948:
URL: https://github.com/apache/lucenenet/pull/948#discussion_r1827590212
##########
src/Lucene.Net.Tests/Index/TestIndexWriter.cs:
##########
@@ -2575,6 +2589,49 @@ 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();
+ 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<string, string>
+ {
+ { "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
+ writer = new IndexWriter(dir, NewSnapshotIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(Random)));
Review Comment:
In the upstream code the analyzer was `null` rather than `new MockAnalyzer(Random)`. Looking at the `LiveIndexWriterConfig`, it should accept that, although I am not sure about the code that uses `IndexWriterConfig`. Did you try `null`, and if so, what happened?
If it doesn't work, then maybe we should patch this inside of `NewSnapshotIndexWriterConfig` for the time being, since that will come up as a new method that we need to port, anyway.
Either way, this diverges from upstream and we will need a `LUCENENET UPGRADE TODO` comment (unless `null` works).
##########
src/Lucene.Net.Tests/Index/TestIndexWriter.cs:
##########
@@ -2556,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<string, string> GetLiveCommitData(IndexWriter writer)
+ {
+ Dictionary<string, string> data = new Dictionary<string, string>();
+ // LUCENENET TODO: in a post-4.8 port, this should use LiveCommitData
Review Comment:
`LUCENENET TODO` is generally reserved for work to do *prior to the 4.8.0 release* (except Ron also committed a bunch of them that will apply to an upgrade just like these). We should have a different convention for future work than for things that are pending for the current release. We specifically mention in the CONTRIBUTING section that `LUCENENET TODO` are up for grabs, but we definitely don't want this work done until later.
Maybe we should make it `LUCENENET UPGRADE TODO` to ensure it doesn't come up in a search for `LUCENENET TODO` (and change all of those that Ron added as well in a separate PR). It would then be easy to do a find and replace before we begin upgrading to change them to `LUCENENET TODO`.
##########
src/Lucene.Net.Tests/Index/TestIndexWriter.cs:
##########
@@ -2575,6 +2589,49 @@ 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();
+ IndexWriter writer = new IndexWriter(dir, NewSnapshotIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(Random)));
+ // LUCENENET TODO: in a post-4.8 port, this should use SetLiveCommitData
Review Comment:
See my other comment about why `LUCENENET TODO` is not appropriate here.
##########
src/Lucene.Net.Tests/Index/TestIndexWriter.cs:
##########
@@ -2575,6 +2589,49 @@ 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();
+ 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<string, string>
+ {
+ { "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
+ writer = new IndexWriter(dir, NewSnapshotIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(Random)));
+ // LUCENENET TODO: in a post-4.8 port, this should use SetLiveCommitData
Review Comment:
See my other comment about why `LUCENENET TODO` is not appropriate here.
##########
src/Lucene.Net.Tests/Index/TestIndexWriter.cs:
##########
@@ -2575,6 +2589,49 @@ 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();
+ 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<string, string>
+ {
+ { "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
+ 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<string, string>()
+ {
+ { "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
+ writer =
+ new IndexWriter(
+ dir,
+ NewSnapshotIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(Random))
Review Comment:
See my other comment about `null` vs `new MockAnalyzer(Random)`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@lucenenet.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org