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 2019/09/22 21:48:28 UTC

[lucenenet] branch master updated (4c74b6e -> f630a54)

This is an automated email from the ASF dual-hosted git repository.

nightowl888 pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/lucenenet.git.


    from 4c74b6e  Lucene.Net.ICU: Removed inapplicable release notes about icu.net
     new 51491e4  Fix OpenBitSet.Union and .Xor methods.
     new f630a54  Lucene.Net.Util.OpenBitSet: Added comments to indicate these changes differ from Lucene (closes #154)

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 src/Lucene.Net.Tests/Util/TestOpenBitSet.cs | 19 +++++++++++++++++++
 src/Lucene.Net/Util/OpenBitSet.cs           | 26 ++++++++++++++++++--------
 2 files changed, 37 insertions(+), 8 deletions(-)


[lucenenet] 02/02: Lucene.Net.Util.OpenBitSet: Added comments to indicate these changes differ from Lucene (closes #154)

Posted by ni...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

nightowl888 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/lucenenet.git

commit f630a542f9abc5b0eb9b22f3737faf8285617a59
Author: Shad Storhaug <sh...@shadstorhaug.com>
AuthorDate: Mon Sep 23 03:30:31 2019 +0700

    Lucene.Net.Util.OpenBitSet: Added comments to indicate these changes differ from Lucene (closes #154)
---
 src/Lucene.Net.Tests/Util/TestOpenBitSet.cs |  2 +-
 src/Lucene.Net/Util/OpenBitSet.cs           | 10 ++++++++++
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/src/Lucene.Net.Tests/Util/TestOpenBitSet.cs b/src/Lucene.Net.Tests/Util/TestOpenBitSet.cs
index dc873c3..abfc039 100644
--- a/src/Lucene.Net.Tests/Util/TestOpenBitSet.cs
+++ b/src/Lucene.Net.Tests/Util/TestOpenBitSet.cs
@@ -515,7 +515,7 @@ namespace Lucene.Net.Util
             Assert.IsTrue(bits.FastGet(bit - 1));
         }
 
-        [Test]
+        [Test, LuceneNetSpecific] // https://github.com/apache/lucenenet/pull/154
         public virtual void TestXorWithDifferentCapacity()
         {
             OpenBitSet smaller = new OpenBitSet(2);
diff --git a/src/Lucene.Net/Util/OpenBitSet.cs b/src/Lucene.Net/Util/OpenBitSet.cs
index 092d800..8bf7253 100644
--- a/src/Lucene.Net/Util/OpenBitSet.cs
+++ b/src/Lucene.Net/Util/OpenBitSet.cs
@@ -932,6 +932,11 @@ namespace Lucene.Net.Util
         public virtual void Union(OpenBitSet other)
         {
             int newLen = Math.Max(m_wlen, other.m_wlen);
+            // LUCENENET specific: Since EnsureCapacityWords
+            // sets m_wlen, we need to save the value here to ensure the
+            // tail of the array is copied. Also removed the double-set
+            // after Array.Copy.
+            // https://github.com/apache/lucenenet/pull/154
             int oldLen = m_wlen;
             EnsureCapacityWords(newLen);
             Debug.Assert((numBits = Math.Max(other.numBits, numBits)) >= 0);
@@ -967,6 +972,11 @@ namespace Lucene.Net.Util
         public virtual void Xor(OpenBitSet other)
         {
             int newLen = Math.Max(m_wlen, other.m_wlen);
+            // LUCENENET specific: Since EnsureCapacityWords
+            // sets m_wlen, we need to save the value here to ensure the
+            // tail of the array is copied. Also removed the double-set
+            // after Array.Copy.
+            // https://github.com/apache/lucenenet/pull/154
             int oldLen = m_wlen;
             EnsureCapacityWords(newLen);
             Debug.Assert((numBits = Math.Max(other.numBits, numBits)) >= 0);


[lucenenet] 01/02: Fix OpenBitSet.Union and .Xor methods.

Posted by ni...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

nightowl888 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/lucenenet.git

commit 51491e4cfc17764dd12d93d52bae2f670ea922ed
Author: uppi <he...@ispras.ru>
AuthorDate: Tue Oct 6 15:14:03 2015 +0300

    Fix OpenBitSet.Union and .Xor methods.
    
    EnsureCapacityWords method changes this.Wlen to newLen,
    so we have to save this.Wlen value before calling it.
    
    Bugged version never copied the tail of the bigger array.
---
 src/Lucene.Net.Tests/Util/TestOpenBitSet.cs | 19 +++++++++++++++++++
 src/Lucene.Net/Util/OpenBitSet.cs           | 16 ++++++++--------
 2 files changed, 27 insertions(+), 8 deletions(-)

diff --git a/src/Lucene.Net.Tests/Util/TestOpenBitSet.cs b/src/Lucene.Net.Tests/Util/TestOpenBitSet.cs
index 717809a..dc873c3 100644
--- a/src/Lucene.Net.Tests/Util/TestOpenBitSet.cs
+++ b/src/Lucene.Net.Tests/Util/TestOpenBitSet.cs
@@ -514,5 +514,24 @@ namespace Lucene.Net.Util
             bits.FastSet(bit - 1);
             Assert.IsTrue(bits.FastGet(bit - 1));
         }
+
+        [Test]
+        public virtual void TestXorWithDifferentCapacity()
+        {
+            OpenBitSet smaller = new OpenBitSet(2);
+            OpenBitSet larger = new OpenBitSet(64 * 10000);
+
+            larger.Set(64 * 10000 - 1);
+            larger.Set(65);
+            larger.Set(3);
+            smaller.Set(3);
+            smaller.Set(66);
+
+            smaller.Xor(larger);
+            Assert.IsTrue(smaller.Get(64 * 10000 - 1));
+            Assert.IsTrue(smaller.Get(65));
+            Assert.IsFalse(smaller.Get(3));
+            Assert.IsTrue(smaller.Get(66));
+        }
     }
 }
\ No newline at end of file
diff --git a/src/Lucene.Net/Util/OpenBitSet.cs b/src/Lucene.Net/Util/OpenBitSet.cs
index 9f1f14b..092d800 100644
--- a/src/Lucene.Net/Util/OpenBitSet.cs
+++ b/src/Lucene.Net/Util/OpenBitSet.cs
@@ -932,21 +932,21 @@ namespace Lucene.Net.Util
         public virtual void Union(OpenBitSet other)
         {
             int newLen = Math.Max(m_wlen, other.m_wlen);
+            int oldLen = m_wlen;
             EnsureCapacityWords(newLen);
             Debug.Assert((numBits = Math.Max(other.numBits, numBits)) >= 0);
 
             long[] thisArr = this.m_bits;
             long[] otherArr = other.m_bits;
-            int pos = Math.Min(m_wlen, other.m_wlen);
+            int pos = Math.Min(oldLen, other.m_wlen);
             while (--pos >= 0)
             {
                 thisArr[pos] |= otherArr[pos];
             }
-            if (this.m_wlen < newLen)
+            if (oldLen < newLen)
             {
-                Array.Copy(otherArr, this.m_wlen, thisArr, this.m_wlen, newLen - this.m_wlen);
+                Array.Copy(otherArr, oldLen, thisArr, oldLen, newLen - oldLen);
             }
-            this.m_wlen = newLen;
         }
 
         /// <summary>
@@ -967,21 +967,21 @@ namespace Lucene.Net.Util
         public virtual void Xor(OpenBitSet other)
         {
             int newLen = Math.Max(m_wlen, other.m_wlen);
+            int oldLen = m_wlen;
             EnsureCapacityWords(newLen);
             Debug.Assert((numBits = Math.Max(other.numBits, numBits)) >= 0);
 
             long[] thisArr = this.m_bits;
             long[] otherArr = other.m_bits;
-            int pos = Math.Min(m_wlen, other.m_wlen);
+            int pos = Math.Min(oldLen, other.m_wlen);
             while (--pos >= 0)
             {
                 thisArr[pos] ^= otherArr[pos];
             }
-            if (this.m_wlen < newLen)
+            if (oldLen < newLen)
             {
-                Array.Copy(otherArr, this.m_wlen, thisArr, this.m_wlen, newLen - this.m_wlen);
+                Array.Copy(otherArr, oldLen, thisArr, oldLen, newLen - oldLen);
             }
-            this.m_wlen = newLen;
         }
 
         // some BitSet compatability methods