lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nightowl...@apache.org
Subject [13/27] lucenenet git commit: Lucene.Net.Core.Search.Spans.SpanNearQuery: Changed logic of GetHashCode() to combine the hash codes of all clauses. Changed datatype of m_clauses protected field from IList<SpanQuery> to List<SpanQuery> to ensure the hash c
Date Thu, 02 Mar 2017 01:10:56 GMT
Lucene.Net.Core.Search.Spans.SpanNearQuery: Changed logic of GetHashCode() to combine the hash
codes of all clauses. Changed datatype of m_clauses protected field from IList<SpanQuery>
to List<SpanQuery> to ensure the hash code is built this way by all subclasses.


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

Branch: refs/heads/api-work
Commit: 9a501d7388c57a6a825dea59feb787311b8c0bec
Parents: f2751a4
Author: Shad Storhaug <shad@shadstorhaug.com>
Authored: Wed Mar 1 23:37:17 2017 +0700
Committer: Shad Storhaug <shad@shadstorhaug.com>
Committed: Thu Mar 2 08:08:48 2017 +0700

----------------------------------------------------------------------
 src/Lucene.Net.Core/Search/Spans/SpanNearQuery.cs | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/9a501d73/src/Lucene.Net.Core/Search/Spans/SpanNearQuery.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Search/Spans/SpanNearQuery.cs b/src/Lucene.Net.Core/Search/Spans/SpanNearQuery.cs
index eac1aa2..541b3e3 100644
--- a/src/Lucene.Net.Core/Search/Spans/SpanNearQuery.cs
+++ b/src/Lucene.Net.Core/Search/Spans/SpanNearQuery.cs
@@ -36,7 +36,9 @@ namespace Lucene.Net.Search.Spans
     /// </summary>
     public class SpanNearQuery : SpanQuery
     {
-        protected readonly IList<SpanQuery> m_clauses;
+        // LUCENENET NOTE: The hash code needs to be made from the hash codes of all elements.

+        // So, we force all subclasses to use ValueList<SpanQuery> instead of IList<SpanQuery>
to ensure that logic is in place.
+        protected readonly ValueList<SpanQuery> m_clauses;
         protected int m_slop;
         protected bool m_inOrder;
 
@@ -60,7 +62,7 @@ namespace Lucene.Net.Search.Spans
         public SpanNearQuery(SpanQuery[] clauses, int slop, bool inOrder, bool collectPayloads)
         {
             // copy clauses array into an ArrayList
-            this.m_clauses = new List<SpanQuery>(clauses.Length);
+            this.m_clauses = new ValueList<SpanQuery>(clauses.Length);
             for (int i = 0; i < clauses.Length; i++)
             {
                 SpanQuery clause = clauses[i];
@@ -233,11 +235,10 @@ namespace Lucene.Net.Search.Spans
             return Boost == spanNearQuery.Boost;
         }
 
-        public override int GetHashCode() // LUCENENET TODO: Check whether this hash code
algorithm is close enough to the original to work
+        public override int GetHashCode()
         {
             int result;
-            //If this doesn't work, hash all elements together. This version was used to
improve the speed of hashing
-            result = HashHelpers.CombineHashCodes(m_clauses.First().GetHashCode(), m_clauses.Last().GetHashCode(),
m_clauses.Count);
+            result = m_clauses.GetHashCode();
             // Mix bits before folding in things like boost, since it could cancel the
             // last element of clauses.  this particular mix also serves to
             // differentiate SpanNearQuery hashcodes from others.


Mime
View raw message