Skip to content

Commit

Permalink
Test review of TestSegmentMerger
Browse files Browse the repository at this point in the history
  • Loading branch information
paulirwin committed Mar 10, 2024
1 parent faadc67 commit b9c047b
Showing 1 changed file with 23 additions and 20 deletions.
43 changes: 23 additions & 20 deletions src/Lucene.Net.Tests/Index/TestSegmentMerger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,15 @@ public class TestSegmentMerger : LuceneTestCase
{
//The variables for the new merged segment
private Directory mergedDir;

private string mergedSegment = "test";

//First segment to be merged
private Directory merge1Dir;

private Document doc1;
private SegmentReader reader1;

//Second Segment to be merged
private Directory merge2Dir;

private Document doc2;
private SegmentReader reader2;

Expand Down Expand Up @@ -113,7 +110,12 @@ public virtual void TestMerge()
Assert.IsTrue(newDoc2 != null);
Assert.IsTrue(DocHelper.NumFields(newDoc2) == DocHelper.NumFields(doc2) - DocHelper.Unstored.Count);

DocsEnum termDocs = TestUtil.Docs(Random, mergedReader, DocHelper.TEXT_FIELD_2_KEY, new BytesRef("field"), MultiFields.GetLiveDocs(mergedReader), null, 0);
DocsEnum termDocs = TestUtil.Docs(Random, mergedReader,
DocHelper.TEXT_FIELD_2_KEY,
new BytesRef("field"),
MultiFields.GetLiveDocs(mergedReader),
null,
0);
Assert.IsTrue(termDocs != null);
Assert.IsTrue(termDocs.NextDoc() != DocIdSetIterator.NO_MORE_DOCS);

Expand Down Expand Up @@ -149,21 +151,22 @@ public virtual void TestMerge()
mergedReader.Dispose();
}

private static bool Equals(MergeState.DocMap map1, MergeState.DocMap map2)
{
if (map1.MaxDoc != map2.MaxDoc)
{
return false;
}
for (int i = 0; i < map1.MaxDoc; ++i)
{
if (map1.Get(i) != map2.Get(i))
{
return false;
}
}
return true;
}
// LUCENENET: commenting out as this method is unused, even in the upstream Java code
// private static bool Equals(MergeState.DocMap map1, MergeState.DocMap map2)
// {
// if (map1.MaxDoc != map2.MaxDoc)
// {
// return false;
// }
// for (int i = 0; i < map1.MaxDoc; ++i)
// {
// if (map1.Get(i) != map2.Get(i))
// {
// return false;
// }
// }
// return true;
// }

[Test]
public virtual void TestBuildDocMap()
Expand Down Expand Up @@ -205,4 +208,4 @@ public virtual void TestBuildDocMap()
}
}
}
}
}

0 comments on commit b9c047b

Please sign in to comment.