lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From synhers...@apache.org
Subject lucenenet git commit: fix overflow resulting in negative values
Date Sun, 25 Jan 2015 02:03:43 GMT
Repository: lucenenet
Updated Branches:
  refs/heads/master c2cd0e11c -> 593231b3b


fix overflow resulting in negative values


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

Branch: refs/heads/master
Commit: 593231b3b39cb81dfcd29ea81cf98dc1ba9a026a
Parents: c2cd0e1
Author: Laimonas Simutis <laimis@gmail.com>
Authored: Sat Jan 24 20:22:04 2015 -0500
Committer: Laimonas Simutis <laimis@gmail.com>
Committed: Sat Jan 24 20:22:04 2015 -0500

----------------------------------------------------------------------
 .../Index/LogByteSizeMergePolicy.cs             | 21 +++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/593231b3/src/Lucene.Net.Core/Index/LogByteSizeMergePolicy.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Index/LogByteSizeMergePolicy.cs b/src/Lucene.Net.Core/Index/LogByteSizeMergePolicy.cs
index 4002cc7..4b25740 100644
--- a/src/Lucene.Net.Core/Index/LogByteSizeMergePolicy.cs
+++ b/src/Lucene.Net.Core/Index/LogByteSizeMergePolicy.cs
@@ -44,7 +44,14 @@ namespace Lucene.Net.Index
         {
             MinMergeSize = (long)(DEFAULT_MIN_MERGE_MB * 1024 * 1024);
             MaxMergeSize = (long)(DEFAULT_MAX_MERGE_MB * 1024 * 1024);
-            MaxMergeSizeForForcedMerge = (long)(DEFAULT_MAX_MERGE_MB_FOR_FORCED_MERGE * 1024
* 1024);
+            
+            // .Net port, original line is inappropriate, overflows in .NET 
+            // and the property gets set to a negative value.
+            // In Java however such statements results in long.MaxValue
+
+            //MaxMergeSizeForForcedMerge = (long)(DEFAULT_MAX_MERGE_MB_FOR_FORCED_MERGE *
1024 * 1024);
+            MaxMergeSizeForForcedMerge = long.MaxValue;
+            
         }
 
         protected internal override long Size(SegmentCommitInfo info)
@@ -70,6 +77,10 @@ namespace Lucene.Net.Index
             set
             {
                 MaxMergeSize = (long)(value * 1024 * 1024);
+                if (MaxMergeSize < 0)
+                {
+                    MaxMergeSize = long.MaxValue;
+                }
             }
             get
             {
@@ -89,6 +100,10 @@ namespace Lucene.Net.Index
             set
             {
                 MaxMergeSizeForForcedMerge = (long)(value * 1024 * 1024);
+                if (MaxMergeSizeForForcedMerge < 0)
+                {
+                    MaxMergeSizeForForcedMerge = long.MaxValue;
+                }
             }
             get
             {
@@ -112,6 +127,10 @@ namespace Lucene.Net.Index
             set
             {
                 MinMergeSize = (long)(value * 1024 * 1024);
+                if (MinMergeSize < 0)
+                {
+                    MinMergeSize = long.MaxValue;
+                }
             }
             get
             {


Mime
View raw message