You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucenenet.apache.org by "NightOwl888 (via GitHub)" <gi...@apache.org> on 2026/08/30 06:33:17 UTC
Re: [PR] Port trivial production fixes from Lucene 4.8.1, #1381 Batch 1 [lucenenet]
NightOwl888 commented on code in PR #1413:
URL: https://github.com/apache/lucenenet/pull/1413#discussion_r3888624865
##########
src/Lucene.Net.Tests/Index/TestTieredMergePolicy.cs:
##########
@@ -274,5 +278,39 @@ public virtual void TestSetters()
// TODO: Add more checks for other non-double setters!
}
+
+ // LUCENE-5668
+ [Test]
+ public void TestUnbalancedMergeSelection()
+ {
+ using Directory dir = NewDirectory();
+ IndexWriterConfig iwc = new IndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(Random));
+ TieredMergePolicy tmp = (TieredMergePolicy)iwc.MergePolicy;
+ tmp.FloorSegmentMB = 0.00001;
+ iwc.MergeScheduler = new SerialMergeScheduler();
+ iwc.MaxBufferedDocs = 100;
+ iwc.RAMBufferSizeMB = -1;
+ using IndexWriter w = new IndexWriter(dir, iwc);
+ for (int i = 0; i < 100000; i++)
+ {
+ Document doc = new Document();
+ doc.Add(NewTextField("id", Random.NextInt64() + "" + Random.NextInt64(), Field.Store.YES));
Review Comment:
Not sure whether it matters for the test, but `Random.NextInt64()` produces both positive and negative values. Converting it to a string in a culture-sensitive way like this means that it will sometimes insert an alternative negative sign. So, this isn't going to be the exact same test as in Java given the same random numbers if the random culture is one with a non-default negative sign.
##########
src/Lucene.Net/Index/SegmentReader.cs:
##########
@@ -199,14 +199,13 @@ private void InitDocValuesProducers(Codec codec)
long gen = e.Key;
IList<FieldInfo> infos = e.Value;
DocValuesProducer dvp = segDocValues.GetDocValuesProducer(gen, si, IOContext.READ, dir, dvFormat, infos, TermInfosIndexDivisor);
+ dvGens.Add(gen);
Review Comment:
Please add a comment here with a commit hash and JIRA number to indicate why we diverged from Lucene 4.8.0 here.
##########
src/Lucene.Net.Tests/Index/TestTieredMergePolicy.cs:
##########
@@ -274,5 +278,39 @@ public virtual void TestSetters()
// TODO: Add more checks for other non-double setters!
}
+
+ // LUCENE-5668
+ [Test]
+ public void TestUnbalancedMergeSelection()
+ {
+ using Directory dir = NewDirectory();
+ IndexWriterConfig iwc = new IndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(Random));
+ TieredMergePolicy tmp = (TieredMergePolicy)iwc.MergePolicy;
+ tmp.FloorSegmentMB = 0.00001;
+ iwc.MergeScheduler = new SerialMergeScheduler();
+ iwc.MaxBufferedDocs = 100;
Review Comment:
It is not critical to fix, but do note that there is an `IndexWriterConfigExtensions` class that can be used to bring the syntax closer to Lucene. We primarily use this in tests - for users it is an optional add-on in most cases. But there may be use cases where the fluent builder pattern is also useful.
##########
src/Lucene.Net/Index/DocumentsWriterPerThreadPool.cs:
##########
@@ -283,6 +283,9 @@ internal void DeactivateUnreleasedStates()
threadState.Unlock();
}
}
+
+ // In case any threads are waiting for indexing:
+ UninterruptableMonitor.PulseAll(this);
Review Comment:
Please add a comment here with a commit hash and/or JIRA number to indicate why we diverged from Lucene 4.8.0 here.
##########
src/Lucene.Net/Index/DocInverterPerField.cs:
##########
@@ -103,11 +103,12 @@ public override void ProcessFields(IIndexableField[] fields, int count)
bool succeededInProcessingField = false;
TokenStream stream = field.GetTokenStream(docState.analyzer);
- // reset the TokenStream to the first token
- stream.Reset();
try
{
+ // reset the TokenStream to the first token
Review Comment:
Please add a comment here with a commit hash and JIRA number to indicate why we diverged from Lucene 4.8.0 here.
##########
src/Lucene.Net/Index/SegmentReader.cs:
##########
@@ -199,14 +199,13 @@ private void InitDocValuesProducers(Codec codec)
long gen = e.Key;
IList<FieldInfo> infos = e.Value;
DocValuesProducer dvp = segDocValues.GetDocValuesProducer(gen, si, IOContext.READ, dir, dvFormat, infos, TermInfosIndexDivisor);
+ dvGens.Add(gen);
foreach (FieldInfo fi in infos)
{
dvProducersByField[fi.Name] = dvp;
dvProducers.Add(dvp);
}
}
-
- dvGens.AddRange(genInfos.Keys);
Review Comment:
Please add a comment here with a commit hash and JIRA number to indicate why we diverged from Lucene 4.8.0 here.
##########
src/Lucene.Net/Index/TieredMergePolicy.cs:
##########
@@ -412,7 +412,7 @@ public override MergeSpecification FindMerges(MergeTrigger mergeTrigger, Segment
return spec;
}
- if (eligible.Count >= allowedSegCountInt)
+ if (eligible.Count > allowedSegCountInt)
Review Comment:
Please add a comment here with a commit hash and JIRA number to indicate why we diverged from Lucene 4.8.0 here.
--
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