Skip to content

Commit

Permalink
Use invariant culture for Convert.ToString in TestStressNRT
Browse files Browse the repository at this point in the history
  • Loading branch information
paulirwin committed Mar 13, 2024
1 parent f8def01 commit 9be0d3e
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions src/Lucene.Net.Tests/Index/TestStressNRT.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Globalization;
using System.Threading;
using JCG = J2N.Collections.Generic;
using Console = Lucene.Net.Util.SystemConsole;
Expand Down Expand Up @@ -352,16 +353,16 @@ public override void Run()
if (tombstones)
{
Document d = new Document();
d.Add(NewStringField("id", "-" + Convert.ToString(id), Field.Store.YES));
d.Add(NewField(field, Convert.ToString(nextVal), storedOnlyType));
writer.UpdateDocument(new Term("id", "-" + Convert.ToString(id)), d);
d.Add(NewStringField("id", "-" + Convert.ToString(id, CultureInfo.InvariantCulture), Field.Store.YES));
d.Add(NewField(field, Convert.ToString(nextVal, CultureInfo.InvariantCulture), storedOnlyType));
writer.UpdateDocument(new Term("id", "-" + Convert.ToString(id, CultureInfo.InvariantCulture)), d);
}

if (Verbose)
{
Console.WriteLine("TEST: " + Thread.CurrentThread.Name + ": term delDocs id:" + id + " nextVal=" + nextVal);
}
writer.DeleteDocuments(new Term("id", Convert.ToString(id)));
writer.DeleteDocuments(new Term("id", Convert.ToString(id, CultureInfo.InvariantCulture)));
outerInstance.model[id] = -nextVal;
}
else if (oper < commitPercent + deletePercent + deleteByQueryPercent)
Expand All @@ -372,33 +373,33 @@ public override void Run()
if (tombstones)
{
Document d = new Document();
d.Add(NewStringField("id", "-" + Convert.ToString(id), Field.Store.YES));
d.Add(NewField(field, Convert.ToString(nextVal), storedOnlyType));
writer.UpdateDocument(new Term("id", "-" + Convert.ToString(id)), d);
d.Add(NewStringField("id", "-" + Convert.ToString(id, CultureInfo.InvariantCulture), Field.Store.YES));
d.Add(NewField(field, Convert.ToString(nextVal, CultureInfo.InvariantCulture), storedOnlyType));
writer.UpdateDocument(new Term("id", "-" + Convert.ToString(id, CultureInfo.InvariantCulture)), d);
}

if (Verbose)
{
Console.WriteLine("TEST: " + Thread.CurrentThread.Name + ": query delDocs id:" + id + " nextVal=" + nextVal);
}
writer.DeleteDocuments(new TermQuery(new Term("id", Convert.ToString(id))));
writer.DeleteDocuments(new TermQuery(new Term("id", Convert.ToString(id, CultureInfo.InvariantCulture))));
outerInstance.model[id] = -nextVal;
}
else
{
// assertU(adoc("id",Integer.toString(id), field, Long.toString(nextVal)));
Document d = new Document();
d.Add(NewStringField("id", Convert.ToString(id), Field.Store.YES));
d.Add(NewField(field, Convert.ToString(nextVal), storedOnlyType));
d.Add(NewStringField("id", Convert.ToString(id, CultureInfo.InvariantCulture), Field.Store.YES));
d.Add(NewField(field, Convert.ToString(nextVal, CultureInfo.InvariantCulture), storedOnlyType));
if (Verbose)
{
Console.WriteLine("TEST: " + Thread.CurrentThread.Name + ": u id:" + id + " val=" + nextVal);
}
writer.UpdateDocument(new Term("id", Convert.ToString(id)), d);
writer.UpdateDocument(new Term("id", Convert.ToString(id, CultureInfo.InvariantCulture)), d);
if (tombstones)
{
// remove tombstone after new addition (this should be optional?)
writer.DeleteDocuments(new Term("id", "-" + Convert.ToString(id)));
writer.DeleteDocuments(new Term("id", "-" + Convert.ToString(id, CultureInfo.InvariantCulture)));
}
outerInstance.model[id] = nextVal;
}
Expand Down Expand Up @@ -493,13 +494,13 @@ public override void Run()
lastReader = r;
lastSearcher = searcher;
}
Query q = new TermQuery(new Term("id", Convert.ToString(id)));
Query q = new TermQuery(new Term("id", Convert.ToString(id, CultureInfo.InvariantCulture)));
TopDocs results = searcher.Search(q, 10);

if (results.TotalHits == 0 && tombstones)
{
// if we couldn't find the doc, look for its tombstone
q = new TermQuery(new Term("id", "-" + Convert.ToString(id)));
q = new TermQuery(new Term("id", "-" + Convert.ToString(id, CultureInfo.InvariantCulture)));
results = searcher.Search(q, 1);
if (results.TotalHits == 0)
{
Expand Down

0 comments on commit 9be0d3e

Please sign in to comment.