You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucenenet.apache.org by sy...@apache.org on 2015/01/27 12:11:58 UTC

[1/4] lucenenet git commit: Adding CONTRIBUTING.md

Repository: lucenenet
Updated Branches:
  refs/heads/master 7e9e30921 -> b5be9c0b8


Adding CONTRIBUTING.md

Thanks @SeanKilleen - closes #52


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

Branch: refs/heads/master
Commit: e3c1ef75854145cf5c1c79cd5a9f2013388d44a1
Parents: 7e9e309
Author: Itamar Syn-Hershko <it...@code972.com>
Authored: Tue Jan 27 13:06:56 2015 +0200
Committer: Itamar Syn-Hershko <it...@code972.com>
Committed: Tue Jan 27 13:06:56 2015 +0200

----------------------------------------------------------------------
 CONTRIBUTING.md | 102 +++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 102 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/e3c1ef75/CONTRIBUTING.md
----------------------------------------------------------------------
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
new file mode 100644
index 0000000..9c65bfb
--- /dev/null
+++ b/CONTRIBUTING.md
@@ -0,0 +1,102 @@
+#Lucene.NET Contributor's Guide
+Hello new contributors, thanks for getting on board!
+
+Before anything else, please read
+[The Getting Involved article at apache.org](https://cwiki.apache.org/confluence/display/LUCENENET/Getting+Involved). In
+particular, we will need you to have an ICLA with Apache and to feel
+comfortable with Git and GitHub.
+
+Start by forking [Lucene.NET on GitHub](https://github.com/apache/lucenenet). For every
+contribution you are about to make, you should create a branch (tracking
+master!) with some descriptive name, and send us a Pull Request once it is
+ready to be reviewed and merged.
+
+And please git rebase when pulling from origin/master instead of merging :) [More information can be found over at Atlassian](https://www.atlassian.com/git/tutorials/rewriting-history/git-rebase).
+
+##If You are Willing to Help with Porting Code
+
+* Please make sure nobody else is working on porting it already. We would
+like to avoid doing redundant work. We ask that you communicate clearly in
+this list that you are going to work on some part of the project. A PMC
+member will then either approve or alert you someone else is working on
+that part already.
+
+* Use automated tools to do the basic porting work, and then start a manual
+clean-up process. For automatic conversion we are using [Tangible's Java to C# Converter](http://www.tangiblesoftwaresolutions.com/Product_Details/Java_to_CSharp_Converter.html).
+We have licenses to give to committers) and it proved to work quite nicely, but I also hear good things on Sharpen. [Check it out here](https://github.com/imazen/sharpen) and pick the tool you are more comfortable
+with.
+
+* Conventions & standards: not too picky at this point, but we should
+definitely align with the common conventions in .NET: PascalCase and not
+camelCase for method names, properties instead of getters/setters of fields
+etc. I'm not going to list all the differences now but we probably want to
+have such a document up in the future. For reference have a look at
+Lucene.Net.Core, while not perfect it is starting to shape up the way we
+want it.
+
+* In general, prefer .NETified code over code resembling Java. Enumerators
+over Iterators, yields when possible, Linq, BCL data structures and so on.
+We are targeting .NET 4.5.1, use this fact. Sometimes you will have to
+resort to Java-like code to ensure compatibility; it's ok. We would rather
+ship fast and then iterate on improving later.
+
+* While porting tests, we don't care about all those conventions and
+.NETification. Porting tests should be reduced to a copy-paste procedure
+with minimal cleaning up procedure. We are working on tools and code
+helpers to help with that, see for examples see our [Java style methods to avoid many search-replace in porting tests](https://github.com/apache/lucenenet/tree/master/src/Lucene.Net.TestFramework/JavaCompatibility), and a
+[R# plugin that will help making some stuff auto-port when pasting](https://resharper-plugins.jetbrains.com/packages/ReSharper.ExJava/).
+
+###Code that is currently pending being ported from scratch (+ tests) == up for grabs:
+
+* [QueryParser](https://github.com/apache/lucene-solr/tree/lucene_solr_4_8_0/lucene/queryparser)
+* [Join](https://github.com/apache/lucene-solr/tree/lucene_solr_4_8_0/lucene/join)
+* [Lucene.Net.Classification](<https://github.com/apache/lucenenet/tree/master/src/Lucene.Net.Classification) (missing tests)
+* [Lucene.Net.Queries](https://github.com/apache/lucenenet/tree/master/src/Lucene.Net.Queries) (missing tests)
+* The spatial module (the situation there is a bit subtle, if you are interested let me know)
+
+Also, some analysis modules:
+
+* [Analysis](https://github.com/apache/lucene-solr/tree/trunk/lucene/analysis) (common is already mid-porting, see below)
+* [Lucene.Net.Misc](https://github.com/apache/lucenenet/tree/master/src/Lucene.Net.Misc) (missing tests)
+* [Lucene.Net.Memory](https://github.com/apache/lucenenet/tree/master/src/Lucene.Net.Memory) (missing tests)
+
+###Code that is ported and now pending manual cleanup, and then once its compiling porting of its tests == up for grabs:
+
+*  [Lucene.Net.Analysis.Common](https://github.com/apache/lucenenet/tree/master/src/Lucene.Net.Analysis.Common)
+* [Lucene.Net.Suggest](https://github.com/apache/lucenenet/tree/master/src/Lucene.Net.Suggest) (depends on Analysis.Common)
+
+The rest is pretty much under control already.
+
+##If you are more into Fixing Existing Tests
+
+* First we want to get all the Core tests green. We are about 200 (out of
+~2300) short of that. Since tests are using randomized testing, failures
+are changing.
+
+* Start by cloning Lucene.NET locally. The set VERBOSE to false and you
+probably may also want to set a constant seed for working locally. See
+<https://github.com/apache/lucenenet/blob/master/src/Lucene.Net.TestFramework/Util/LuceneTestCase.cs#L295>
+and
+<https://github.com/apache/lucenenet/blob/master/src/Lucene.Net.TestFramework/Util/LuceneTestCase.cs#L610>
+
+* Run, debug, iterate. When you think you fixed a bug or a test, please
+send a PR as fast as possible. There are multiple people working in this
+area, and we want to make sure your contribution doesn't go stale. Any such
+PR should have a descriptive name and a short description of what happened
+and what is your solution. There are [some good past examples here](https://github.com/apache/lucenenet/pulls?q=is%3Apr+is%3Aclosed).
+
+
+* If we will have comments, we will use github's excellent interface and
+you will receive notifications also via this list.
+
+* Once we got all core tests passing reliably, we will go to testing the
+other sub-projects. Some are already up for grabs if you want to have a
+stab at them.
+
+##Other types of help
+
+We will definitely need more help (like normalizing tabs/spaces, license headers, automating stuff, etc) but we are not there yet!
+
+##Thank You!
+
+Again, thank you very much for your contribution. May the fork be with you!
\ No newline at end of file


[4/4] lucenenet git commit: Closes #61

Posted by sy...@apache.org.
Closes #61


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

Branch: refs/heads/master
Commit: b5be9c0b87f83c200107d76ed53f5904ccceaa61
Parents: 4b9f3eb
Author: Itamar Syn-Hershko <it...@code972.com>
Authored: Tue Jan 27 13:11:30 2015 +0200
Committer: Itamar Syn-Hershko <it...@code972.com>
Committed: Tue Jan 27 13:11:30 2015 +0200

----------------------------------------------------------------------

----------------------------------------------------------------------



[2/4] lucenenet git commit: (1) Increased the timeout of one test. It required more time to complete.

Posted by sy...@apache.org.
(1) Increased the timeout of one test. It required more time to complete.

(2) Fixed the Clear method of OpenBitSet, FixedBitSet and LongBitSet classes.
	Masks computation was wrong, since endMask was always 0.
	Added new tests for all of them.

(3) Fixed TestSmall from TestOpenBitSet class. The test assumed that BitArray
	operations were	size-independent (they are in Java's BitSet class). Since
	some of the indexes could be out of	bounds, it failed. To fix this
	I manually enlarged the arrays, if necessary.


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

Branch: refs/heads/master
Commit: a9e8fe7d338a40ae4c63f200e3bdf8ab8605a316
Parents: e3c1ef7
Author: Guido Tagliavini Ponce <t-...@microsoft.com>
Authored: Mon Jan 26 13:55:16 2015 -0800
Committer: Itamar Syn-Hershko <it...@code972.com>
Committed: Tue Jan 27 13:09:25 2015 +0200

----------------------------------------------------------------------
 src/Lucene.Net.Core/Util/FixedBitSet.cs         | 10 ++-
 src/Lucene.Net.Core/Util/LongBitSet.cs          | 12 +--
 src/Lucene.Net.Core/Util/OpenBitSet.cs          | 11 +--
 .../Util/BaseDocIdSetTestCase.cs                |  2 +-
 .../core/Util/TestFixedBitSet.cs                | 59 +++++++++++++
 .../core/Util/TestLongBitSet.cs                 | 58 +++++++++++++
 .../core/Util/TestOpenBitSet.cs                 | 89 +++++++++++++++++++-
 7 files changed, 222 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/a9e8fe7d/src/Lucene.Net.Core/Util/FixedBitSet.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Util/FixedBitSet.cs b/src/Lucene.Net.Core/Util/FixedBitSet.cs
index 99858af..f37c0d6 100644
--- a/src/Lucene.Net.Core/Util/FixedBitSet.cs
+++ b/src/Lucene.Net.Core/Util/FixedBitSet.cs
@@ -681,12 +681,14 @@ namespace Lucene.Net.Util
             int startWord = startIndex >> 6;
             int endWord = (endIndex - 1) >> 6;
 
-            long startmask = -1L << startIndex;
-            long endmask = -(int)((uint)1L >> -endIndex); // 64-(endIndex&0x3f) is the same as -endIndex due to wrap
+            long startmask = (-1L) << startIndex;  // -1 << (startIndex mod 64)
+            long endmask = (-1L) << endIndex;      // -1 << (endIndex mod 64)
+            if ((endIndex & 0x3f) == 0)
+            {
+                endmask = 0;
+            }
 
-            // invert masks since we are clearing
             startmask = ~startmask;
-            endmask = ~endmask;
 
             if (startWord == endWord)
             {

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/a9e8fe7d/src/Lucene.Net.Core/Util/LongBitSet.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Util/LongBitSet.cs b/src/Lucene.Net.Core/Util/LongBitSet.cs
index 6c0093b..927e712 100644
--- a/src/Lucene.Net.Core/Util/LongBitSet.cs
+++ b/src/Lucene.Net.Core/Util/LongBitSet.cs
@@ -390,13 +390,15 @@ namespace Lucene.Net.Util
             int startWord = (int)(startIndex >> 6);
             int endWord = (int)((endIndex - 1) >> 6);
 
-            //LUCENE TO-DO
-            long startmask = -1L << (int)startIndex;
-            long endmask = -(int)((uint)1L >> (int)-endIndex); // 64-(endIndex&0x3f) is the same as -endIndex due to wrap
+            // Casting long to int discards MSBs, so it is no problem because we are taking mod 64.
+            long startmask = (-1L) << (int)startIndex;  // -1 << (startIndex mod 64)
+            long endmask = (-1L) << (int)endIndex;            // -1 << (endIndex mod 64)
+            if ((endIndex & 0x3f) == 0)
+            {
+                endmask = 0;
+            }
 
-            // invert masks since we are clearing
             startmask = ~startmask;
-            endmask = ~endmask;
 
             if (startWord == endWord)
             {

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/a9e8fe7d/src/Lucene.Net.Core/Util/OpenBitSet.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Util/OpenBitSet.cs b/src/Lucene.Net.Core/Util/OpenBitSet.cs
index 2e3d265..cae4546 100644
--- a/src/Lucene.Net.Core/Util/OpenBitSet.cs
+++ b/src/Lucene.Net.Core/Util/OpenBitSet.cs
@@ -436,13 +436,14 @@ namespace Lucene.Net.Util
             // word to be changed.
             int endWord = ((endIndex - 1) >> 6);
 
-            //LUCENE TO-DO
-            long startmask = -1L << startIndex;
-            long endmask = -(int)((uint)1L >> -endIndex); // 64-(endIndex&0x3f) is the same as -endIndex due to wrap
+            long startmask = (-1L) << startIndex;  // -1 << (startIndex mod 64)
+            long endmask = (-1L) << endIndex;      // -1 << (endIndex mod 64)
+            if ((endIndex & 0x3f) == 0)
+            {
+                endmask = 0;
+            }
 
-            // invert masks since we are clearing
             startmask = ~startmask;
-            endmask = ~endmask;
 
             if (startWord == endWord)
             {

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/a9e8fe7d/src/Lucene.Net.TestFramework/Util/BaseDocIdSetTestCase.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.TestFramework/Util/BaseDocIdSetTestCase.cs b/src/Lucene.Net.TestFramework/Util/BaseDocIdSetTestCase.cs
index 8c69a3f..a4b23ba 100644
--- a/src/Lucene.Net.TestFramework/Util/BaseDocIdSetTestCase.cs
+++ b/src/Lucene.Net.TestFramework/Util/BaseDocIdSetTestCase.cs
@@ -121,7 +121,7 @@ namespace Lucene.Net.Util
         /// <summary>
         /// Compare the content of the set against a <seealso cref="BitSet"/>.
         /// </summary>
-        [Test, Timeout(40000)]
+        [Test, Timeout(150000)]
         public void TestAgainstBitSet()
         {
             int numBits = TestUtil.NextInt(Random(), 100, 1 << 20);

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/a9e8fe7d/src/Lucene.Net.Tests/core/Util/TestFixedBitSet.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/core/Util/TestFixedBitSet.cs b/src/Lucene.Net.Tests/core/Util/TestFixedBitSet.cs
index a8a42fb..90bd19c 100644
--- a/src/Lucene.Net.Tests/core/Util/TestFixedBitSet.cs
+++ b/src/Lucene.Net.Tests/core/Util/TestFixedBitSet.cs
@@ -1,3 +1,4 @@
+using System;
 using Lucene.Net.Randomized.Generators;
 using Lucene.Net.Support;
 using NUnit.Framework;
@@ -266,6 +267,64 @@ namespace Lucene.Net.Util
             DoRandomSets(AtLeast(1200), AtLeast(1000), 2);
         }
 
+        [Test]
+        public void TestClearSmall()
+        {
+            FixedBitSet a = new FixedBitSet(30);   // 0110010111001000101101001001110...0
+            int[] onesA = { 1, 2, 5, 7, 8, 9, 12, 16, 18, 19, 21, 24, 27, 28, 29 };
+
+            for (int i = 0; i < onesA.size(); i++)
+            {
+                a.Set(onesA[i]);
+            }
+
+            FixedBitSet b = new FixedBitSet(30);   // 0110000001001000101101001001110...0
+            int[] onesB = { 1, 2, 9, 12, 16, 18, 19, 21, 24, 27, 28, 29 };
+
+            for (int i = 0; i < onesB.size(); i++)
+            {
+                b.Set(onesB[i]);
+            }
+
+            a.Clear(5, 9);
+            Assert.True(a.Equals(b));
+
+            a.Clear(9, 10);
+            Assert.False(a.Equals(b));
+
+            a.Set(9);
+            Assert.True(a.Equals(b));
+        }
+
+        [Test]
+        public void TestClearLarge()
+        {
+            int iters = AtLeast(1000);
+            for (int it = 0; it < iters; it++)
+            {
+                Random random = new Random();
+                int sz = AtLeast(1200);
+                FixedBitSet a = new FixedBitSet(sz);
+                FixedBitSet b = new FixedBitSet(sz);
+                int from = random.Next(sz - 1);
+                int to = random.Next(from, sz);
+
+                for (int i = 0; i < sz / 2; i++)
+                {
+                    int index = random.Next(sz - 1);
+                    a.Set(index);
+
+                    if (index < from || index >= to)
+                    {
+                        b.Set(index);
+                    }
+                }
+
+                a.Clear(from, to);
+                Assert.True(a.Equals(b));
+            }
+        }
+
         // uncomment to run a bigger test (~2 minutes).
         /*
         public void testBig() {

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/a9e8fe7d/src/Lucene.Net.Tests/core/Util/TestLongBitSet.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/core/Util/TestLongBitSet.cs b/src/Lucene.Net.Tests/core/Util/TestLongBitSet.cs
index 94d2e9e..6c3e1c6 100644
--- a/src/Lucene.Net.Tests/core/Util/TestLongBitSet.cs
+++ b/src/Lucene.Net.Tests/core/Util/TestLongBitSet.cs
@@ -210,6 +210,64 @@ namespace Lucene.Net.Util
             DoRandomSets(AtLeast(1200), AtLeast(1000), 2);
         }
 
+        [Test]
+        public void TestClearSmall()
+        {
+            LongBitSet a = new LongBitSet(30);   // 0110010111001000101101001001110...0
+            int[] onesA = { 1, 2, 5, 7, 8, 9, 12, 16, 18, 19, 21, 24, 27, 28, 29 };
+
+            for (int i = 0; i < onesA.size(); i++)
+            {
+                a.Set(onesA[i]);
+            }
+
+            LongBitSet b = new LongBitSet(30);   // 0110000001001000101101001001110...0
+            int[] onesB = { 1, 2, 9, 12, 16, 18, 19, 21, 24, 27, 28, 29 };
+
+            for (int i = 0; i < onesB.size(); i++)
+            {
+                b.Set(onesB[i]);
+            }
+
+            a.Clear(5, 9);
+            Assert.True(a.Equals(b));
+
+            a.Clear(9, 10);
+            Assert.False(a.Equals(b));
+
+            a.Set(9);
+            Assert.True(a.Equals(b));
+        }
+
+        [Test]
+        public void TestClearLarge()
+        {
+            int iters = AtLeast(1000);
+            for (int it = 0; it < iters; it++)
+            {
+                Random random = new Random();
+                int sz = AtLeast(1200);
+                LongBitSet a = new LongBitSet(sz);
+                LongBitSet b = new LongBitSet(sz);
+                int from = random.Next(sz - 1);
+                int to = random.Next(from, sz);
+
+                for (int i = 0; i < sz / 2; i++)
+                {
+                    int index = random.Next(sz - 1);
+                    a.Set(index);
+
+                    if (index < from || index >= to)
+                    {
+                        b.Set(index);
+                    }
+                }
+
+                a.Clear(from, to);
+                Assert.True(a.Equals(b));
+            }
+        }
+
         // uncomment to run a bigger test (~2 minutes).
         /*
         public void testBig() {

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/a9e8fe7d/src/Lucene.Net.Tests/core/Util/TestOpenBitSet.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/core/Util/TestOpenBitSet.cs b/src/Lucene.Net.Tests/core/Util/TestOpenBitSet.cs
index db033a1..5d4dbb8 100644
--- a/src/Lucene.Net.Tests/core/Util/TestOpenBitSet.cs
+++ b/src/Lucene.Net.Tests/core/Util/TestOpenBitSet.cs
@@ -15,6 +15,7 @@
  * limitations under the License.
  */
 
+using System;
 using Lucene.Net.Randomized.Generators;
 using Lucene.Net.Support;
 using NUnit.Framework;
@@ -232,7 +233,14 @@ namespace Lucene.Net.Util
                 int fromIndex, toIndex;
                 fromIndex = Random().Next(sz + 80);
                 toIndex = fromIndex + Random().Next((sz >> 1) + 1);
+
                 BitArray aa = (BitArray)a.Clone();
+                // C# BitArray class does not support dynamic sizing.
+                // We have to explicitly change its size using the Length attribute.
+                if (toIndex > aa.Length)
+                {
+                    aa.Length = toIndex;
+                }
                 aa.Flip(fromIndex, toIndex);
                 OpenBitSet bb = (OpenBitSet)b.Clone();
                 bb.Flip(fromIndex, toIndex);
@@ -242,6 +250,10 @@ namespace Lucene.Net.Util
                 fromIndex = Random().Next(sz + 80);
                 toIndex = fromIndex + Random().Next((sz >> 1) + 1);
                 aa = (BitArray)a.Clone();
+                if (toIndex > aa.Length)
+                {
+                    aa.Length = toIndex;
+                }
                 aa.Clear(fromIndex, toIndex);
                 bb = (OpenBitSet)b.Clone();
                 bb.Clear(fromIndex, toIndex);
@@ -255,6 +267,10 @@ namespace Lucene.Net.Util
                 fromIndex = Random().Next(sz + 80);
                 toIndex = fromIndex + Random().Next((sz >> 1) + 1);
                 aa = (BitArray)a.Clone();
+                if (toIndex > aa.Length)
+                {
+                    aa.Length = toIndex;
+                }
                 aa.Set(fromIndex, toIndex);
                 bb = (OpenBitSet)b.Clone();
                 bb.Set(fromIndex, toIndex);
@@ -267,16 +283,23 @@ namespace Lucene.Net.Util
 
                 if (a0 != null)
                 {
-                    Assert.AreEqual(a.BitWiseEquals(a0), b.Equals(b0));
+                    aa = (BitArray)a.Clone();
+                    BitArray aa0 = (BitArray) a0.Clone();
+                    int largest = Math.Max(a.Length, a0.Length);
+                    aa.Length = aa0.Length = largest;
+                    // BitWiseEquals needs both arrays to be the same size for succeeding.
+                    // We could enlarge the smallest of a and a0, but then the tests below
+                    // won't test "UnequalLengths" operations.
+                    Assert.AreEqual(aa.BitWiseEquals(aa0), b.Equals(b0));
 
                     Assert.AreEqual(a.Cardinality(), b.Cardinality());
 
                     BitArray a_and = (BitArray)a.Clone();
-                    a_and = a_and.And(a0);
+                    a_and = a_and.And_UnequalLengths(a0);
                     BitArray a_or = (BitArray)a.Clone();
-                    a_or = a_or.Or(a0);
+                    a_or = a_or.Or_UnequalLengths(a0);
                     BitArray a_xor = (BitArray)a.Clone();
-                    a_xor = a_xor.Xor(a0);
+                    a_xor = a_xor.Xor_UnequalLengths(a0);
                     BitArray a_andn = (BitArray)a.Clone();
                     a_andn.AndNot(a0);
 
@@ -321,6 +344,64 @@ namespace Lucene.Net.Util
             DoRandomSets(AtLeast(1200), AtLeast(1000), 2);
         }
 
+        [Test]
+        public void TestClearSmall()
+        {
+            OpenBitSet a = new OpenBitSet(30);   // 0110010111001000101101001001110...0
+            int[] onesA = { 1, 2, 5, 7, 8, 9, 12, 16, 18, 19, 21, 24, 27, 28, 29 };
+
+            for (int i = 0; i < onesA.size(); i++)
+            {
+                a.Set(onesA[i]);
+            }
+
+            OpenBitSet b = new OpenBitSet(30);   // 0110000001001000101101001001110...0
+            int[] onesB = { 1, 2, 9, 12, 16, 18, 19, 21, 24, 27, 28, 29 };
+
+            for (int i = 0; i < onesB.size(); i++)
+            {
+                b.Set(onesB[i]);
+            }
+
+            a.Clear(5, 9);
+            Assert.True(a.Equals(b));
+
+            a.Clear(9, 10);
+            Assert.False(a.Equals(b));
+
+            a.Set(9);
+            Assert.True(a.Equals(b));
+        }
+
+        [Test]
+        public void TestClearLarge()
+        {
+            int iters = AtLeast(1000);
+            for (int it = 0; it < iters; it++)
+            {
+                Random random = new Random();
+                int sz = AtLeast(1200);
+                OpenBitSet a = new OpenBitSet(sz);
+                OpenBitSet b = new OpenBitSet(sz);
+                int from = random.Next(sz - 1);
+                int to = random.Next(from, sz);
+
+                for (int i = 0; i < sz / 2; i++)
+                {
+                    int index = random.Next(sz - 1);
+                    a.Set(index);
+
+                    if (index < from || index >= to)
+                    {
+                        b.Set(index);
+                    }
+                }
+
+                a.Clear(from, to);
+                Assert.True(a.Equals(b));
+            }
+        }
+
         // uncomment to run a bigger test (~2 minutes).
         /*
         public void TestBig() {


[3/4] lucenenet git commit: Minor

Posted by sy...@apache.org.
Minor


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

Branch: refs/heads/master
Commit: 4b9f3ebb65e3354cdf4dc2cad9247f5c6342f2ca
Parents: a9e8fe7
Author: Itamar Syn-Hershko <it...@code972.com>
Authored: Tue Jan 27 13:09:45 2015 +0200
Committer: Itamar Syn-Hershko <it...@code972.com>
Committed: Tue Jan 27 13:09:45 2015 +0200

----------------------------------------------------------------------
 src/Lucene.Net.Core/Codecs/DocValuesConsumer.cs | 51 ++++++++------------
 1 file changed, 21 insertions(+), 30 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b9f3ebb/src/Lucene.Net.Core/Codecs/DocValuesConsumer.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Codecs/DocValuesConsumer.cs b/src/Lucene.Net.Core/Codecs/DocValuesConsumer.cs
index 89693c5..9c13a1f 100644
--- a/src/Lucene.Net.Core/Codecs/DocValuesConsumer.cs
+++ b/src/Lucene.Net.Core/Codecs/DocValuesConsumer.cs
@@ -1,14 +1,11 @@
 using System.IO;
 using System.Linq;
-using Lucene.Net.Support;
 using System;
 using System.Collections.Generic;
 using System.Diagnostics;
 
 namespace Lucene.Net.Codecs
 {
-    using ArrayUtil = Lucene.Net.Util.ArrayUtil;
-
     /*
          * Licensed to the Apache Software Foundation (ASF) under one or more
          * contributor license agreements.  See the NOTICE file distributed with
@@ -39,6 +36,7 @@ namespace Lucene.Net.Codecs
     using SortedDocValues = Lucene.Net.Index.SortedDocValues;
     using SortedSetDocValues = Lucene.Net.Index.SortedSetDocValues;
     using TermsEnum = Lucene.Net.Index.TermsEnum;
+    using ArrayUtil = Lucene.Net.Util.ArrayUtil;
 
     /// <summary>
     /// Abstract API that consumes numeric, binary and
@@ -110,7 +108,7 @@ namespace Lucene.Net.Codecs
         /// Merges the numeric docvalues from <code>toMerge</code>.
         /// <p>
         /// The default implementation calls <seealso cref="#addNumericField"/>, passing
-        /// an Iterable that merges and filters deleted documents on the fly.
+        /// an Iterable that merges and filters deleted documents on the fly.</p>
         /// </summary>
         public virtual void MergeNumericField(FieldInfo fieldInfo, MergeState mergeState, IList<NumericDocValues> toMerge, IList<Bits> docsWithField)
         {
@@ -211,7 +209,7 @@ namespace Lucene.Net.Codecs
 
                 if (currentLiveDocs == null || currentLiveDocs.Get(docIDUpto))
                 {
-                    BytesRef nextValue = new BytesRef();
+                    var nextValue = new BytesRef();
 
                     if (currentDocsWithField.Get(docIDUpto))
                     {
@@ -235,7 +233,7 @@ namespace Lucene.Net.Codecs
         /// Merges the sorted docvalues from <code>toMerge</code>.
         /// <p>
         /// The default implementation calls <seealso cref="#addSortedField"/>, passing
-        /// an Iterable that merges ordinals and values and filters deleted documents .
+        /// an Iterable that merges ordinals and values and filters deleted documents.</p>
         /// </summary>
         public virtual void MergeSortedField(FieldInfo fieldInfo, MergeState mergeState, IList<SortedDocValues> toMerge)
         {
@@ -243,7 +241,7 @@ namespace Lucene.Net.Codecs
             SortedDocValues[] dvs = toMerge.ToArray();
 
             // step 1: iterate thru each sub and mark terms still in use
-            TermsEnum[] liveTerms = new TermsEnum[dvs.Length];
+            var liveTerms = new TermsEnum[dvs.Length];
             for (int sub = 0; sub < liveTerms.Length; sub++)
             {
                 AtomicReader reader = readers[sub];
@@ -255,7 +253,7 @@ namespace Lucene.Net.Codecs
                 }
                 else
                 {
-                    LongBitSet bitset = new LongBitSet(dv.ValueCount);
+                    var bitset = new LongBitSet(dv.ValueCount);
                     for (int i = 0; i < reader.MaxDoc; i++)
                     {
                         if (liveDocs.Get(i))
@@ -272,7 +270,7 @@ namespace Lucene.Net.Codecs
             }
 
             // step 2: create ordinal map (this conceptually does the "merging")
-            OrdinalMap map = new OrdinalMap(this, liveTerms);
+            var map = new OrdinalMap(this, liveTerms);
 
             // step 3: add field
             AddSortedField(fieldInfo, GetMergeSortValuesEnumerable(map, dvs),
@@ -283,13 +281,13 @@ namespace Lucene.Net.Codecs
 
         private IEnumerable<BytesRef> GetMergeSortValuesEnumerable(OrdinalMap map, SortedDocValues[] dvs)
         {
-            BytesRef scratch = new BytesRef();
+            var scratch = new BytesRef();
             int currentOrd = 0;
 
             while (currentOrd < map.ValueCount)
             {
                 int segmentNumber = map.GetFirstSegmentNumber(currentOrd);
-                int segmentOrd = (int)map.GetFirstSegmentOrd(currentOrd);
+                var segmentOrd = (int)map.GetFirstSegmentOrd(currentOrd);
                 dvs[segmentNumber].LookupOrd(segmentOrd, scratch);
                 currentOrd++;
                 yield return scratch;
@@ -497,23 +495,23 @@ namespace Lucene.Net.Codecs
         /// </summary>
         public virtual void MergeSortedSetField(FieldInfo fieldInfo, MergeState mergeState, IList<SortedSetDocValues> toMerge)
         {
-            AtomicReader[] readers = mergeState.Readers.ToArray();
-            SortedSetDocValues[] dvs = toMerge.ToArray();
+            var readers = mergeState.Readers.ToArray();
+            var dvs = toMerge.ToArray();
 
             // step 1: iterate thru each sub and mark terms still in use
-            TermsEnum[] liveTerms = new TermsEnum[dvs.Length];
+            var liveTerms = new TermsEnum[dvs.Length];
             for (int sub = 0; sub < liveTerms.Length; sub++)
             {
-                AtomicReader reader = readers[sub];
-                SortedSetDocValues dv = dvs[sub];
-                Bits liveDocs = reader.LiveDocs;
+                var reader = readers[sub];
+                var dv = dvs[sub];
+                var liveDocs = reader.LiveDocs;
                 if (liveDocs == null)
                 {
                     liveTerms[sub] = dv.TermsEnum();
                 }
                 else
                 {
-                    LongBitSet bitset = new LongBitSet(dv.ValueCount);
+                    var bitset = new LongBitSet(dv.ValueCount);
                     for (int i = 0; i < reader.MaxDoc; i++)
                     {
                         if (liveDocs.Get(i))
@@ -531,7 +529,7 @@ namespace Lucene.Net.Codecs
             }
 
             // step 2: create ordinal map (this conceptually does the "merging")
-            OrdinalMap map = new OrdinalMap(this, liveTerms);
+            var map = new OrdinalMap(this, liveTerms);
 
             // step 3: add field
             AddSortedSetField(fieldInfo, GetMergeSortedSetValuesEnumerable(map, dvs),
@@ -544,7 +542,7 @@ namespace Lucene.Net.Codecs
 
         private IEnumerable<BytesRef> GetMergeSortedSetValuesEnumerable(OrdinalMap map, SortedSetDocValues[] dvs)
         {
-            BytesRef scratch = new BytesRef();
+            var scratch = new BytesRef();
             long currentOrd = 0;
 
             while (currentOrd < map.ValueCount)
@@ -607,7 +605,7 @@ namespace Lucene.Net.Codecs
             int docIDUpto = 0;
             AtomicReader currentReader = null;
             Bits currentLiveDocs = null;
-            long[] ords = new long[8];
+            var ords = new long[8];
             int ordUpto = 0;
             int ordLength = 0;
 
@@ -947,19 +945,12 @@ namespace Lucene.Net.Codecs
                 : base(@in, false)
             {
                 Debug.Assert(liveTerms != null);
-                this.LiveTerms = liveTerms;
+                LiveTerms = liveTerms;
             }
 
             protected internal override AcceptStatus Accept(BytesRef term)
             {
-                if (LiveTerms.Get(Ord()))
-                {
-                    return AcceptStatus.YES;
-                }
-                else
-                {
-                    return AcceptStatus.NO;
-                }
+                return LiveTerms.Get(Ord()) ? AcceptStatus.YES : AcceptStatus.NO;
             }
         }