You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucenenet.apache.org by ni...@apache.org on 2017/07/20 21:49:22 UTC

[1/8] lucenenet git commit: BUG: Lucene.Net.Store.NativeFSLockFactory: Fixed concurrency issue with locks across multiple instances (solution provided by Vincent Van Den Burghe).

Repository: lucenenet
Updated Branches:
  refs/heads/master 012ffaab3 -> e67244aa2


BUG: Lucene.Net.Store.NativeFSLockFactory: Fixed concurrency issue with locks across multiple instances (solution provided by Vincent Van Den Burghe).


Project: http://git-wip-us.apache.org/repos/asf/lucenenet/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucenenet/commit/95a7505d
Tree: http://git-wip-us.apache.org/repos/asf/lucenenet/tree/95a7505d
Diff: http://git-wip-us.apache.org/repos/asf/lucenenet/diff/95a7505d

Branch: refs/heads/master
Commit: 95a7505d04e21d22e307cac5d0a1f6a957a0cf92
Parents: 012ffaa
Author: Shad Storhaug <sh...@shadstorhaug.com>
Authored: Thu Jul 20 16:46:51 2017 +0700
Committer: Shad Storhaug <sh...@shadstorhaug.com>
Committed: Thu Jul 20 16:46:51 2017 +0700

----------------------------------------------------------------------
 src/Lucene.Net/Store/NativeFSLockFactory.cs | 22 +++++-----------------
 1 file changed, 5 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/95a7505d/src/Lucene.Net/Store/NativeFSLockFactory.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net/Store/NativeFSLockFactory.cs b/src/Lucene.Net/Store/NativeFSLockFactory.cs
index 3459747..47b5233 100644
--- a/src/Lucene.Net/Store/NativeFSLockFactory.cs
+++ b/src/Lucene.Net/Store/NativeFSLockFactory.cs
@@ -89,16 +89,12 @@ namespace Lucene.Net.Store
 
         // LUCENENET: NativeFSLocks in Java are infact singletons; this is how we mimick that to track instances and make sure
         // IW.Unlock and IW.IsLocked works correctly
-        internal readonly ConcurrentDictionary<string, NativeFSLock> _locks = new ConcurrentDictionary<string, NativeFSLock>(); 
+        internal static readonly ConcurrentDictionary<string, Lazy<NativeFSLock>> _locks = new ConcurrentDictionary<string, Lazy<NativeFSLock>>();
 
         public override Lock MakeLock(string lockName)
         {
-            if (m_lockPrefix != null)
-            {
-                lockName = m_lockPrefix + "-" + lockName;
-            }
-
-            return _locks.GetOrAdd(lockName, (s) => new NativeFSLock(this, m_lockDir, s));
+            var path = new DirectoryInfo(System.IO.Path.Combine(m_lockDir.FullName, lockName));
+            return _locks.GetOrAdd(path.FullName, s => new Lazy<NativeFSLock>(() => new NativeFSLock(this, m_lockDir, s))).Value;
         }
 
         public override void ClearLock(string lockName)
@@ -191,16 +187,8 @@ namespace Lucene.Net.Store
                 {
                     if (channel != null)
                     {
-                        try
-                        {
-                            NativeFSLock _;
-                            outerInstance._locks.TryRemove(path.FullName, out _);
-                        }
-                        finally
-                        {
-                            IOUtils.DisposeWhileHandlingException(channel);
-                            channel = null;
-                        }
+                        IOUtils.DisposeWhileHandlingException(channel);
+                        channel = null;
 
                         bool tmpBool;
                         if (File.Exists(path.FullName))


[2/8] lucenenet git commit: BUG: Lucene.Net.Store.LockVerifyServer: Read/write 1 byte instead of 1 int (4 bytes). Also, we don't need 2 streams in .NET for input/output (solution provided by Vincent Van Den Berghe).

Posted by ni...@apache.org.
BUG: Lucene.Net.Store.LockVerifyServer: Read/write 1 byte instead of 1 int (4 bytes). Also, we don't need 2 streams in .NET for input/output (solution provided by Vincent Van Den Berghe).


Project: http://git-wip-us.apache.org/repos/asf/lucenenet/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucenenet/commit/425d5e71
Tree: http://git-wip-us.apache.org/repos/asf/lucenenet/tree/425d5e71
Diff: http://git-wip-us.apache.org/repos/asf/lucenenet/diff/425d5e71

Branch: refs/heads/master
Commit: 425d5e7152aa1f501b7a849333e6554c59073526
Parents: 95a7505
Author: Shad Storhaug <sh...@shadstorhaug.com>
Authored: Thu Jul 20 16:48:43 2017 +0700
Committer: Shad Storhaug <sh...@shadstorhaug.com>
Committed: Thu Jul 20 17:40:25 2017 +0700

----------------------------------------------------------------------
 src/Lucene.Net/Store/LockStressTest.cs       | 10 +++++-----
 src/Lucene.Net/Store/LockVerifyServer.cs     | 15 +++++++--------
 src/Lucene.Net/Store/VerifyingLockFactory.cs | 17 +++++++----------
 3 files changed, 19 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/425d5e71/src/Lucene.Net/Store/LockStressTest.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net/Store/LockStressTest.cs b/src/Lucene.Net/Store/LockStressTest.cs
index 341bb69..ebd3de9 100644
--- a/src/Lucene.Net/Store/LockStressTest.cs
+++ b/src/Lucene.Net/Store/LockStressTest.cs
@@ -124,16 +124,16 @@ namespace Lucene.Net.Store
                 socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, 1);
                 socket.Connect(verifierHost, verifierPort);
 
-                using (Stream @out = new NetworkStream(socket), @in = new NetworkStream(socket))
+                using (Stream stream = new NetworkStream(socket))
                 {
-                    BinaryReader intReader = new BinaryReader(@in);
-                    BinaryWriter intWriter = new BinaryWriter(@out);
+                    BinaryReader intReader = new BinaryReader(stream);
+                    BinaryWriter intWriter = new BinaryWriter(stream);
 
                     intWriter.Write(myID);
-                    @out.Flush();
+                    stream.Flush();
 
                     lockFactory.LockPrefix = "test";
-                    LockFactory verifyLF = new VerifyingLockFactory(lockFactory, @in, @out);
+                    LockFactory verifyLF = new VerifyingLockFactory(lockFactory, stream);
                     Lock l = verifyLF.MakeLock("test.lock");
                     Random rnd = new Random();
 

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/425d5e71/src/Lucene.Net/Store/LockVerifyServer.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net/Store/LockVerifyServer.cs b/src/Lucene.Net/Store/LockVerifyServer.cs
index 93a1a52..0060606 100644
--- a/src/Lucene.Net/Store/LockVerifyServer.cs
+++ b/src/Lucene.Net/Store/LockVerifyServer.cs
@@ -113,10 +113,10 @@ namespace Lucene.Net.Store
 
             public override void Run()
             {
-                using (Stream @in = new NetworkStream(cs), os = new NetworkStream(cs))
+                using (Stream stream = new NetworkStream(cs))
                 {
-                    BinaryReader intReader = new BinaryReader(@in);
-                    BinaryWriter intWriter = new BinaryWriter(os);
+                    BinaryReader intReader = new BinaryReader(stream);
+                    BinaryWriter intWriter = new BinaryWriter(stream);
                     try
                     {
                         int id = intReader.ReadInt32();
@@ -125,14 +125,13 @@ namespace Lucene.Net.Store
                             throw new IOException("Client closed connection before communication started.");
                         }
 
-                        //LUCENE TO-DO NOt sure about this
                         startingGun.Wait();
                         intWriter.Write(43);
-                        os.Flush();
+                        stream.Flush();
 
                         while (true)
                         {
-                            int command = intReader.Read();
+                            int command = stream.ReadByte();
                             if (command < 0)
                             {
                                 return; // closed
@@ -170,8 +169,8 @@ namespace Lucene.Net.Store
                                     default:
                                         throw new Exception("Unrecognized command: " + command);
                                 }
-                                intWriter.Write(command);
-                                os.Flush();
+                                intWriter.Write((byte)command);
+                                stream.Flush();
                             }
                         }
                     }

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/425d5e71/src/Lucene.Net/Store/VerifyingLockFactory.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net/Store/VerifyingLockFactory.cs b/src/Lucene.Net/Store/VerifyingLockFactory.cs
index 731283f..188352b 100644
--- a/src/Lucene.Net/Store/VerifyingLockFactory.cs
+++ b/src/Lucene.Net/Store/VerifyingLockFactory.cs
@@ -35,8 +35,7 @@ namespace Lucene.Net.Store
     public class VerifyingLockFactory : LockFactory
     {
         internal readonly LockFactory lf;
-        internal readonly Stream @in;
-        internal readonly Stream @out;
+        internal readonly Stream stream;
 
         private class CheckedLock : Lock
         {
@@ -52,9 +51,9 @@ namespace Lucene.Net.Store
 
             private void Verify(byte message)
             {
-                outerInstance.@out.WriteByte(message);
-                outerInstance.@out.Flush();
-                int ret = outerInstance.@in.ReadByte();
+                outerInstance.stream.WriteByte(message);
+                outerInstance.stream.Flush();
+                int ret = outerInstance.stream.ReadByte();
                 if (ret < 0)
                 {
                     throw new InvalidOperationException("Lock server died because of locking error.");
@@ -106,13 +105,11 @@ namespace Lucene.Net.Store
         /// Creates a new <see cref="VerifyingLockFactory"/> instance.
         /// </summary>
         /// <param name="lf"> the <see cref="LockFactory"/> that we are testing </param>
-        /// <param name="in"> the socket's input to <see cref="LockVerifyServer"/> </param>
-        /// <param name="out"> the socket's output to <see cref="LockVerifyServer"/> </param>
-        public VerifyingLockFactory(LockFactory lf, Stream @in, Stream @out)
+        /// <param name="stream"> the socket's stream input/output to <see cref="LockVerifyServer"/> </param>
+        public VerifyingLockFactory(LockFactory lf, Stream stream)
         {
             this.lf = lf;
-            this.@in = @in;
-            this.@out = @out;
+            this.stream = stream;
         }
 
         public override Lock MakeLock(string lockName)


[4/8] lucenenet git commit: BUG: Lucene.Net.TestFramework.Store.MockDirectoryWrapper.IndexInputSlicerAnonymousInnerClassHelper: Fixed Dispose().

Posted by ni...@apache.org.
BUG: Lucene.Net.TestFramework.Store.MockDirectoryWrapper.IndexInputSlicerAnonymousInnerClassHelper: Fixed Dispose().


Project: http://git-wip-us.apache.org/repos/asf/lucenenet/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucenenet/commit/aa849d8f
Tree: http://git-wip-us.apache.org/repos/asf/lucenenet/tree/aa849d8f
Diff: http://git-wip-us.apache.org/repos/asf/lucenenet/diff/aa849d8f

Branch: refs/heads/master
Commit: aa849d8f0e7e59ec91bd18565f210712dab16d82
Parents: 380b05f
Author: Shad Storhaug <sh...@shadstorhaug.com>
Authored: Fri Jul 21 03:36:03 2017 +0700
Committer: Shad Storhaug <sh...@shadstorhaug.com>
Committed: Fri Jul 21 03:36:03 2017 +0700

----------------------------------------------------------------------
 src/Lucene.Net.TestFramework/Store/MockDirectoryWrapper.cs | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/aa849d8f/src/Lucene.Net.TestFramework/Store/MockDirectoryWrapper.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.TestFramework/Store/MockDirectoryWrapper.cs b/src/Lucene.Net.TestFramework/Store/MockDirectoryWrapper.cs
index 6011990..d70a853 100644
--- a/src/Lucene.Net.TestFramework/Store/MockDirectoryWrapper.cs
+++ b/src/Lucene.Net.TestFramework/Store/MockDirectoryWrapper.cs
@@ -1360,7 +1360,7 @@ namespace Lucene.Net.Store
                     if (disposing)
                     {
                         DelegateHandle.Dispose();
-                        OuterInstance.RemoveOpenFile(OuterInstance, Name);
+                        OuterInstance.RemoveOpenFile(this, Name);
                     }
                 }
             }


[3/8] lucenenet git commit: lucene-cli: corrected description of lock verify-server MAX_CLIENTS in the documentation

Posted by ni...@apache.org.
lucene-cli: corrected description of lock verify-server MAX_CLIENTS in the documentation


Project: http://git-wip-us.apache.org/repos/asf/lucenenet/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucenenet/commit/380b05f7
Tree: http://git-wip-us.apache.org/repos/asf/lucenenet/tree/380b05f7
Diff: http://git-wip-us.apache.org/repos/asf/lucenenet/diff/380b05f7

Branch: refs/heads/master
Commit: 380b05f74ba532ea354e42325eab2143eae790f6
Parents: 425d5e7
Author: Shad Storhaug <sh...@shadstorhaug.com>
Authored: Fri Jul 21 03:21:53 2017 +0700
Committer: Shad Storhaug <sh...@shadstorhaug.com>
Committed: Fri Jul 21 03:21:53 2017 +0700

----------------------------------------------------------------------
 src/tools/lucene-cli/docs/lock/verify-server.md | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/380b05f7/src/tools/lucene-cli/docs/lock/verify-server.md
----------------------------------------------------------------------
diff --git a/src/tools/lucene-cli/docs/lock/verify-server.md b/src/tools/lucene-cli/docs/lock/verify-server.md
index a34dce1..9350580 100644
--- a/src/tools/lucene-cli/docs/lock/verify-server.md
+++ b/src/tools/lucene-cli/docs/lock/verify-server.md
@@ -20,7 +20,7 @@ Hostname or IP address that [verify-server](verify-server.md) will listen on.
 
 `MAX_CLIENTS`
 
-The maximum number of connected clients.
+The maximum number of threads that are observing the lock from within the verify-server process. When using [stress-test](stress-test.md), each thread will be used by a single connected client and the server won't start running until this number of clients is reached.
 
 ### Options
 
@@ -30,6 +30,6 @@ Prints out a short help for the command.
 
 ### Example
 
-Run the server on IP `127.0.0.4` with a maximum of 100 connected clients allowed:
+Run the server on IP `127.0.0.4` with a 10 connected clients:
 
-<code>dotnet lucene-cli.dll lock verify-server 127.0.0.4 100</code>
+<code>dotnet lucene-cli.dll lock verify-server 127.0.0.4 10</code>


[8/8] lucenenet git commit: Lucene.Net.Util.Automaton.BasicOperations: Removed unneeded TODO

Posted by ni...@apache.org.
Lucene.Net.Util.Automaton.BasicOperations: Removed unneeded TODO


Project: http://git-wip-us.apache.org/repos/asf/lucenenet/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucenenet/commit/e67244aa
Tree: http://git-wip-us.apache.org/repos/asf/lucenenet/tree/e67244aa
Diff: http://git-wip-us.apache.org/repos/asf/lucenenet/diff/e67244aa

Branch: refs/heads/master
Commit: e67244aa245f0dbc3b4f03f74f5462ae28758911
Parents: 81a4565
Author: Shad Storhaug <sh...@shadstorhaug.com>
Authored: Fri Jul 21 04:49:01 2017 +0700
Committer: Shad Storhaug <sh...@shadstorhaug.com>
Committed: Fri Jul 21 04:49:01 2017 +0700

----------------------------------------------------------------------
 src/Lucene.Net/Util/Automaton/BasicOperations.cs | 2 --
 1 file changed, 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/e67244aa/src/Lucene.Net/Util/Automaton/BasicOperations.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net/Util/Automaton/BasicOperations.cs b/src/Lucene.Net/Util/Automaton/BasicOperations.cs
index 62927dc..bc4b488 100644
--- a/src/Lucene.Net/Util/Automaton/BasicOperations.cs
+++ b/src/Lucene.Net/Util/Automaton/BasicOperations.cs
@@ -818,8 +818,6 @@ namespace Lucene.Net.Util.Automaton
             // like SortedMap<Integer,Integer>
             SortedInt32Set statesSet = new SortedInt32Set(5);
 
-            // LUCENENET TODO: THIS IS INFINITE LOOPING
-
             // LUCENENET NOTE: The problem here is almost certainly 
             // due to the conversion to FrozenIntSet along with its
             // differing equality checking.


[5/8] lucenenet git commit: Updated CONTRIBUTING.md with the latest status

Posted by ni...@apache.org.
Updated CONTRIBUTING.md with the latest status


Project: http://git-wip-us.apache.org/repos/asf/lucenenet/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucenenet/commit/40e91905
Tree: http://git-wip-us.apache.org/repos/asf/lucenenet/tree/40e91905
Diff: http://git-wip-us.apache.org/repos/asf/lucenenet/diff/40e91905

Branch: refs/heads/master
Commit: 40e919057b369c78e5b4e4c3db5d36dec1d55d53
Parents: aa849d8
Author: Shad Storhaug <sh...@shadstorhaug.com>
Authored: Fri Jul 21 03:56:55 2017 +0700
Committer: Shad Storhaug <sh...@shadstorhaug.com>
Committed: Fri Jul 21 03:56:55 2017 +0700

----------------------------------------------------------------------
 CONTRIBUTING.md | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/40e91905/CONTRIBUTING.md
----------------------------------------------------------------------
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 1ace445..226e681 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -38,7 +38,6 @@ Note that even though we are currently a port of Lucene 4.8.0, we recommend port
 
 ### Pending being ported from scratch (code + tests)
 
-* [Lucene.Net.Analysis.ICU](https://github.com/apache/lucene-solr/tree/releases/lucene-solr/4.8.1/lucene/analysis/icu) - See [JIRA issue 566](https://issues.apache.org/jira/browse/LUCENENET-566)
 * [Lucene.Net.Analysis.Kuromoji](https://github.com/apache/lucene-solr/tree/releases/lucene-solr/4.8.1/lucene/analysis/kuromoji) - See [JIRA issue 567](https://issues.apache.org/jira/browse/LUCENENET-567)
 
 ### Pending being ported from scratch (code + tests), but have additional dependencies that also either need to be sourced from the .NET ecosystem or ported.
@@ -74,6 +73,7 @@ and <https://github.com/apache/lucenenet/blob/master/src/Lucene.Net.TestFramewor
 
 * Making demos and tutorials, blogging about Lucene.Net, etc. (and providing feedback on how we can make the API better!). If you write a helpful Lucene.Net post on your blog, be sure to let us know so we can link to it.
 * Helping out with documentation. We are still trying to make the API docs easily navigable (see #206), and there are many files that are not formatted correctly (links not appearing, tables not very readable, etc). Also, we need help getting all of the Java-related documentation converted to use .NET methodologies.
+* Fixing TODOs. There are several TODOs throughout the code that need to be reviewed and action taken, if necessary. Search for `LUCENENET TODO|LUCENE TO-DO` using the regular expression option in Visual Studio to find them. Do note there are a lot of TODOs left over from Java Lucene that are safe to ignore.
 * Reviewing code. Pick a random section, review line by line, comparing the code against the [original Lucene 4.8.0 code](https://github.com/apache/lucene-solr/tree/releases/lucene-solr/4.8.0/lucene). Many of the bugs have been found this way, as the tests are not showing them. Let us know if you find anything suspicious on the [dev mailing list](https://cwiki.apache.org/confluence/display/LUCENENET/Mailing+Lists) or submit a pull request.
 * Optimizing code. During porting we have ended up with some code that is less than optimal. We could use a hand getting everything up to speed (pun intended).
 * Helping update the API, or at least just providing feedback on what is important. There are several things on our radar, like integrating something like [Lucene.Net.Linq](https://github.com/themotleyfool/Lucene.Net.Linq) directly into our project, [converting the remaining public-facing iterator classes into `IEnumerator<T>`](https://issues.apache.org/jira/projects/LUCENENET/issues/LUCENENET-469?filter=allopenissues) so they can be used with foreach loops, adding extension methods to remove the need for casting, etc.


[7/8] lucenenet git commit: Lucene.Net.Tests.Querys.CommonTermsQueryTest: Added missing TestRandomIndex() test

Posted by ni...@apache.org.
Lucene.Net.Tests.Querys.CommonTermsQueryTest: Added missing TestRandomIndex() test


Project: http://git-wip-us.apache.org/repos/asf/lucenenet/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucenenet/commit/81a45650
Tree: http://git-wip-us.apache.org/repos/asf/lucenenet/tree/81a45650
Diff: http://git-wip-us.apache.org/repos/asf/lucenenet/diff/81a45650

Branch: refs/heads/master
Commit: 81a4565042b01ab413477b6db0cb277311128e82
Parents: d71d1a0
Author: Shad Storhaug <sh...@shadstorhaug.com>
Authored: Fri Jul 21 04:37:57 2017 +0700
Committer: Shad Storhaug <sh...@shadstorhaug.com>
Committed: Fri Jul 21 04:37:57 2017 +0700

----------------------------------------------------------------------
 .../CommonTermsQueryTest.cs                     | 46 ++++++++++----------
 1 file changed, 23 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/81a45650/src/Lucene.Net.Tests.Queries/CommonTermsQueryTest.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests.Queries/CommonTermsQueryTest.cs b/src/Lucene.Net.Tests.Queries/CommonTermsQueryTest.cs
index e4476ef..fc80980 100644
--- a/src/Lucene.Net.Tests.Queries/CommonTermsQueryTest.cs
+++ b/src/Lucene.Net.Tests.Queries/CommonTermsQueryTest.cs
@@ -384,52 +384,50 @@ namespace Lucene.Net.Tests.Queries
             dir.Dispose();
         }
 
-        /*
-         * LUCENENET TODO requires a better comparer implementation for PriorityQueue
         [Test]
         public void TestRandomIndex()
         {
             Directory dir = NewDirectory();
             MockAnalyzer analyzer = new MockAnalyzer(Random());
             analyzer.MaxTokenLength = TestUtil.NextInt(Random(), 1, IndexWriter.MAX_TERM_LENGTH);
-            RandomIndexWriter w = new RandomIndexWriter(Random(), dir, analyzer);
+            RandomIndexWriter w = new RandomIndexWriter(Random(), dir, analyzer, Similarity, TimeZone);
             CreateRandomIndex(AtLeast(50), w, Random().NextLong());
             DirectoryReader reader = w.Reader;
             AtomicReader wrapper = SlowCompositeReaderWrapper.Wrap(reader);
             string field = @"body";
-            Terms terms = wrapper.Terms(field);
+            Terms terms = wrapper.GetTerms(field);
             var lowFreqQueue = new AnonymousPriorityQueue(this, 5);
             Util.PriorityQueue<TermAndFreq> highFreqQueue = new AnonymousPriorityQueue1(this, 5);
             try
             {
-                TermsEnum iterator = terms.Iterator(null);
+                TermsEnum iterator = terms.GetIterator(null);
                 while (iterator.Next() != null)
                 {
-                    if (highFreqQueue.Size() < 5)
+                    if (highFreqQueue.Count < 5)
                     {
-                        highFreqQueue.Add(new TermAndFreq(BytesRef.DeepCopyOf(iterator.Term()), iterator.DocFreq()));
-                        lowFreqQueue.Add(new TermAndFreq(BytesRef.DeepCopyOf(iterator.Term()), iterator.DocFreq()));
+                        highFreqQueue.Add(new TermAndFreq(BytesRef.DeepCopyOf(iterator.Term), iterator.DocFreq));
+                        lowFreqQueue.Add(new TermAndFreq(BytesRef.DeepCopyOf(iterator.Term), iterator.DocFreq));
                     }
                     else
                     {
-                        if (highFreqQueue.Top().freq < iterator.DocFreq())
+                        if (highFreqQueue.Top.freq < iterator.DocFreq)
                         {
-                            highFreqQueue.Top().freq = iterator.DocFreq();
-                            highFreqQueue.Top().term = BytesRef.DeepCopyOf(iterator.Term());
+                            highFreqQueue.Top.freq = iterator.DocFreq;
+                            highFreqQueue.Top.term = BytesRef.DeepCopyOf(iterator.Term);
                             highFreqQueue.UpdateTop();
                         }
 
-                        if (lowFreqQueue.Top().freq > iterator.DocFreq())
+                        if (lowFreqQueue.Top.freq > iterator.DocFreq)
                         {
-                            lowFreqQueue.Top().freq = iterator.DocFreq();
-                            lowFreqQueue.Top().term = BytesRef.DeepCopyOf(iterator.Term());
+                            lowFreqQueue.Top.freq = iterator.DocFreq;
+                            lowFreqQueue.Top.term = BytesRef.DeepCopyOf(iterator.Term);
                             lowFreqQueue.UpdateTop();
                         }
                     }
                 }
 
-                int lowFreq = lowFreqQueue.Top().freq;
-                int highFreq = highFreqQueue.Top().freq;
+                int lowFreq = lowFreqQueue.Top.freq;
+                int highFreq = highFreqQueue.Top.freq;
                 AssumeTrue(@"unlucky index", highFreq - 1 > lowFreq);
                 List<TermAndFreq> highTerms = QueueToList(highFreqQueue);
                 List<TermAndFreq> lowTerms = QueueToList(lowFreqQueue);
@@ -462,10 +460,10 @@ namespace Lucene.Net.Tests.Queries
                     assertTrue(hits.Remove(doc.Doc));
                 }
 
-                assertTrue(hits.IsEmpty());
+                assertTrue(hits.Count == 0);
                 w.ForceMerge(1);
                 DirectoryReader reader2 = w.Reader;
-                QueryUtils.Check(Random(), cq, NewSearcher(reader2));
+                QueryUtils.Check(Random(), cq, NewSearcher(reader2), Similarity);
                 reader2.Dispose();
             }
             finally
@@ -477,9 +475,10 @@ namespace Lucene.Net.Tests.Queries
             }
         }
 
-        private sealed class AnonymousPriorityQueue : Support.PriorityQueue<TermAndFreq>
+        private sealed class AnonymousPriorityQueue : Util.PriorityQueue<TermAndFreq>
         {
-            public AnonymousPriorityQueue(CommonTermsQueryTest parent)
+            public AnonymousPriorityQueue(CommonTermsQueryTest parent, int maxSize)
+                : base(maxSize)
             {
                 this.parent = parent;
             }
@@ -491,9 +490,10 @@ namespace Lucene.Net.Tests.Queries
             }
         }
 
-        private sealed class AnonymousPriorityQueue1 : Support.PriorityQueue<TermAndFreq>
+        private sealed class AnonymousPriorityQueue1 : Util.PriorityQueue<TermAndFreq>
         {
-            public AnonymousPriorityQueue1(CommonTermsQueryTest parent)
+            public AnonymousPriorityQueue1(CommonTermsQueryTest parent, int maxSize)
+                : base(maxSize)
             {
                 this.parent = parent;
             }
@@ -503,7 +503,7 @@ namespace Lucene.Net.Tests.Queries
             {
                 return a.freq < b.freq;
             }
-        }*/
+        }
 
         private static List<TermAndFreq> QueueToList(Util.PriorityQueue<TermAndFreq> queue)
         {


[6/8] lucenenet git commit: BUG: Lucene.Net.Index.IndexWriter: Fixed string formatting of numeric values in InfoStream message.

Posted by ni...@apache.org.
BUG: Lucene.Net.Index.IndexWriter: Fixed string formatting of numeric values in InfoStream message.


Project: http://git-wip-us.apache.org/repos/asf/lucenenet/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucenenet/commit/d71d1a00
Tree: http://git-wip-us.apache.org/repos/asf/lucenenet/tree/d71d1a00
Diff: http://git-wip-us.apache.org/repos/asf/lucenenet/diff/d71d1a00

Branch: refs/heads/master
Commit: d71d1a0015a9d37d89ccf164692911cff44e7432
Parents: 40e9190
Author: Shad Storhaug <sh...@shadstorhaug.com>
Authored: Fri Jul 21 04:13:54 2017 +0700
Committer: Shad Storhaug <sh...@shadstorhaug.com>
Committed: Fri Jul 21 04:13:54 2017 +0700

----------------------------------------------------------------------
 src/Lucene.Net/Index/IndexWriter.cs | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/d71d1a00/src/Lucene.Net/Index/IndexWriter.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net/Index/IndexWriter.cs b/src/Lucene.Net/Index/IndexWriter.cs
index 66bb35c..b16e5b2 100644
--- a/src/Lucene.Net/Index/IndexWriter.cs
+++ b/src/Lucene.Net/Index/IndexWriter.cs
@@ -5225,8 +5225,8 @@ namespace Lucene.Net.Index
                 // lost...
 
                 if (infoStream.IsEnabled("IW"))
-                {// LUCENENET TODO: String formatting
-                    infoStream.Message("IW", string.Format(CultureInfo.InvariantCulture, "merged segment size=%.3f MB vs estimate=%.3f MB", merge.info.GetSizeInBytes() / 1024.0 / 1024.0, merge.EstimatedMergeBytes / 1024 / 1024.0));
+                {
+                    infoStream.Message("IW", string.Format(CultureInfo.InvariantCulture, "merged segment size={0:n3} MB vs estimate={1:n3} MB", merge.info.GetSizeInBytes() / 1024.0 / 1024.0, merge.EstimatedMergeBytes / 1024 / 1024.0));
                 }
 
                 IndexReaderWarmer mergedSegmentWarmer = config.MergedSegmentWarmer;