lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nightowl...@apache.org
Subject [05/23] lucenenet git commit: BUG: Lucene.Net.TestFramework.Codecs.MockIntBlock.MockVariableIntBlockPostingsFormat: Incorrect math setting baseBlockSize to 2 * baseBlockSize in general, not just for the base class. Also, made a private variable for Index
Date Sun, 19 Mar 2017 23:20:00 GMT
BUG: Lucene.Net.TestFramework.Codecs.MockIntBlock.MockVariableIntBlockPostingsFormat: Incorrect
math setting baseBlockSize to 2 * baseBlockSize in general, not just for the base class. Also,
made a private variable for IndexOutput in case the base class does something odd with it.


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

Branch: refs/heads/api-work
Commit: 6d3da67a89e4992c9a884d93281aa952c40eb100
Parents: d21561d
Author: Shad Storhaug <shad@shadstorhaug.com>
Authored: Sun Mar 19 21:04:02 2017 +0700
Committer: Shad Storhaug <shad@shadstorhaug.com>
Committed: Sun Mar 19 22:41:06 2017 +0700

----------------------------------------------------------------------
 .../MockVariableIntBlockPostingsFormat.cs       | 36 +++++++++++---------
 .../MockRandom/MockRandomPostingsFormat.cs      |  2 +-
 .../TestVariableIntBlockPostingsFormat.cs       |  2 +-
 3 files changed, 21 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/6d3da67a/src/Lucene.Net.TestFramework/Codecs/MockIntBlock/MockVariableIntBlockPostingsFormat.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.TestFramework/Codecs/MockIntBlock/MockVariableIntBlockPostingsFormat.cs
b/src/Lucene.Net.TestFramework/Codecs/MockIntBlock/MockVariableIntBlockPostingsFormat.cs
index b152a10..ff6353e 100644
--- a/src/Lucene.Net.TestFramework/Codecs/MockIntBlock/MockVariableIntBlockPostingsFormat.cs
+++ b/src/Lucene.Net.TestFramework/Codecs/MockIntBlock/MockVariableIntBlockPostingsFormat.cs
@@ -32,17 +32,17 @@ namespace Lucene.Net.Codecs.MockIntBlock
     /// int is &lt;= 3, else 2* baseBlockSize.
     /// </summary>
     [PostingsFormatName("MockVariableIntBlock")] // LUCENENET specific - using PostingsFormatName
attribute to ensure the default name passed from subclasses is the same as this class name
-    public class MockVariableIntBlockPostingsFormat : PostingsFormat
+    public class MockVariableInt32BlockPostingsFormat : PostingsFormat
     {
         private readonly int baseBlockSize;
         
-        public MockVariableIntBlockPostingsFormat()
+        public MockVariableInt32BlockPostingsFormat()
             : this(1)
         {
 
         }
 
-        public MockVariableIntBlockPostingsFormat(int baseBlockSize)
+        public MockVariableInt32BlockPostingsFormat(int baseBlockSize)
             : base()
         {
             this.baseBlockSize = baseBlockSize;
@@ -57,12 +57,12 @@ namespace Lucene.Net.Codecs.MockIntBlock
          * If the first value is &lt;= 3, writes baseBlockSize vInts at once,
          * otherwise writes 2*baseBlockSize vInts.
          */
-        public class MockIntFactory : Int32StreamFactory
+        public class MockInt32Factory : Int32StreamFactory
         {
 
             private readonly int baseBlockSize;
 
-            public MockIntFactory(int baseBlockSize)
+            public MockInt32Factory(int baseBlockSize)
             {
                 this.baseBlockSize = baseBlockSize;
             }
@@ -71,14 +71,14 @@ namespace Lucene.Net.Codecs.MockIntBlock
             {
                 IndexInput input = dir.OpenInput(fileName, context);
                 int baseBlockSize = input.ReadInt32();
-                return new VariableIntBlockIndexInputAnonymousHelper(input, baseBlockSize);
+                return new VariableInt32BlockIndexInputAnonymousHelper(input, baseBlockSize);
             }
 
-            private class VariableIntBlockIndexInputAnonymousHelper : VariableInt32BlockIndexInput
+            private class VariableInt32BlockIndexInputAnonymousHelper : VariableInt32BlockIndexInput
             {
                 private readonly int baseBlockSize;
 
-                public VariableIntBlockIndexInputAnonymousHelper(IndexInput input, int baseBlockSize)
+                public VariableInt32BlockIndexInputAnonymousHelper(IndexInput input, int
baseBlockSize)
                     : base(input)
                 {
                     this.baseBlockSize = baseBlockSize;
@@ -101,11 +101,11 @@ namespace Lucene.Net.Codecs.MockIntBlock
                         this.baseBlockSize = baseBlockSize;
                     }
 
-                    public void Seek(long pos)
+                    public virtual void Seek(long pos)
                     {
                     }
 
-                    public int ReadBlock()
+                    public virtual int ReadBlock()
                     {
                         buffer[0] = input.ReadVInt32();
                         int count = buffer[0] <= 3 ? baseBlockSize - 1 : 2 * baseBlockSize
- 1;
@@ -126,7 +126,7 @@ namespace Lucene.Net.Codecs.MockIntBlock
                 try
                 {
                     output.WriteInt32(baseBlockSize);
-                    VariableInt32BlockIndexOutput ret = new VariableIntBlockIndexOutputAnonymousHelper(output,
2 * baseBlockSize);
+                    VariableInt32BlockIndexOutput ret = new VariableInt32BlockIndexOutputAnonymousHelper(output,
baseBlockSize);
                     success = true;
                     return ret;
                 }
@@ -140,12 +140,14 @@ namespace Lucene.Net.Codecs.MockIntBlock
             }
         }
 
-        private class VariableIntBlockIndexOutputAnonymousHelper : VariableInt32BlockIndexOutput
+        private class VariableInt32BlockIndexOutputAnonymousHelper : VariableInt32BlockIndexOutput
         {
             private readonly int baseBlockSize;
-            public VariableIntBlockIndexOutputAnonymousHelper(IndexOutput output, int baseBlockSize)
-                : base(output, baseBlockSize)
+            private readonly IndexOutput output;
+            public VariableInt32BlockIndexOutputAnonymousHelper(IndexOutput output, int baseBlockSize)
+                : base(output, 2 * baseBlockSize)
             {
+                this.output = output;
                 this.baseBlockSize = baseBlockSize;
                 this.buffer = new int[2 + 2 * baseBlockSize];
             }
@@ -166,7 +168,7 @@ namespace Lucene.Net.Codecs.MockIntBlock
                 {
                     for (int i = 0; i < flushAt; i++)
                     {
-                        m_output.WriteVInt32(buffer[i]);
+                        this.output.WriteVInt32(buffer[i]);
                     }
                     buffer[0] = buffer[flushAt];
                     pendingCount = 1;
@@ -181,7 +183,7 @@ namespace Lucene.Net.Codecs.MockIntBlock
 
         public override FieldsConsumer FieldsConsumer(SegmentWriteState state)
         {
-            PostingsWriterBase postingsWriter = new SepPostingsWriter(state, new MockIntFactory(baseBlockSize));
+            PostingsWriterBase postingsWriter = new SepPostingsWriter(state, new MockInt32Factory(baseBlockSize));
 
             bool success = false;
             TermsIndexWriterBase indexWriter;
@@ -227,7 +229,7 @@ namespace Lucene.Net.Codecs.MockIntBlock
                                                                       state.FieldInfos,
                                                                       state.SegmentInfo,
                                                                       state.Context,
-                                                                      new MockIntFactory(baseBlockSize),
state.SegmentSuffix);
+                                                                      new MockInt32Factory(baseBlockSize),
state.SegmentSuffix);
 
             TermsIndexReaderBase indexReader;
             bool success = false;

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/6d3da67a/src/Lucene.Net.TestFramework/Codecs/MockRandom/MockRandomPostingsFormat.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.TestFramework/Codecs/MockRandom/MockRandomPostingsFormat.cs b/src/Lucene.Net.TestFramework/Codecs/MockRandom/MockRandomPostingsFormat.cs
index d2f39c5..069bd38 100644
--- a/src/Lucene.Net.TestFramework/Codecs/MockRandom/MockRandomPostingsFormat.cs
+++ b/src/Lucene.Net.TestFramework/Codecs/MockRandom/MockRandomPostingsFormat.cs
@@ -75,7 +75,7 @@ namespace Lucene.Net.Codecs.MockRandom
                 int blockSize = TestUtil.NextInt(random, 1, 2000);
                 delegates.Add(new MockFixedIntBlockPostingsFormat.MockIntFactory(blockSize));
                 int baseBlockSize = TestUtil.NextInt(random, 1, 127);
-                delegates.Add(new MockVariableIntBlockPostingsFormat.MockIntFactory(baseBlockSize));
+                delegates.Add(new MockVariableInt32BlockPostingsFormat.MockInt32Factory(baseBlockSize));
                 // TODO: others
             }
 

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/6d3da67a/src/Lucene.Net.Tests.Codecs/IntBlock/TestVariableIntBlockPostingsFormat.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests.Codecs/IntBlock/TestVariableIntBlockPostingsFormat.cs b/src/Lucene.Net.Tests.Codecs/IntBlock/TestVariableIntBlockPostingsFormat.cs
index 23bc8fd..2bf1e82 100644
--- a/src/Lucene.Net.Tests.Codecs/IntBlock/TestVariableIntBlockPostingsFormat.cs
+++ b/src/Lucene.Net.Tests.Codecs/IntBlock/TestVariableIntBlockPostingsFormat.cs
@@ -33,7 +33,7 @@ namespace Lucene.Net.Codecs.IntBlock
     public class TestVariableIntBlockPostingsFormat : BasePostingsFormatTestCase
     {
         // TODO: randomize blocksize
-        private readonly Codec codec = TestUtil.AlwaysPostingsFormat(new MockVariableIntBlockPostingsFormat());
+        private readonly Codec codec = TestUtil.AlwaysPostingsFormat(new MockVariableInt32BlockPostingsFormat());
 
         protected override Codec Codec
         {


Mime
View raw message