lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nightowl...@apache.org
Subject [04/20] lucenenet git commit: Lucene.Net.TestFramework: Implemented CheapBastardCodec
Date Tue, 28 Feb 2017 12:29:55 GMT
Lucene.Net.TestFramework: Implemented CheapBastardCodec


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

Branch: refs/heads/api-work
Commit: 4e4d17c1a5e00b833379298c43d2f3ed41eb4aa8
Parents: 28efcab
Author: Shad Storhaug <shad@shadstorhaug.com>
Authored: Mon Feb 27 23:40:51 2017 +0700
Committer: Shad Storhaug <shad@shadstorhaug.com>
Committed: Mon Feb 27 23:40:51 2017 +0700

----------------------------------------------------------------------
 .../Codecs/CheapBastard/CheapBastardCodec.cs    | 54 ++++++++++++++++++++
 .../Lucene.Net.TestFramework.csproj             |  1 +
 .../Util/TestRuleSetupAndRestoreClassEnv.cs     | 12 ++---
 3 files changed, 61 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4e4d17c1/src/Lucene.Net.TestFramework/Codecs/CheapBastard/CheapBastardCodec.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.TestFramework/Codecs/CheapBastard/CheapBastardCodec.cs b/src/Lucene.Net.TestFramework/Codecs/CheapBastard/CheapBastardCodec.cs
new file mode 100644
index 0000000..0479c66
--- /dev/null
+++ b/src/Lucene.Net.TestFramework/Codecs/CheapBastard/CheapBastardCodec.cs
@@ -0,0 +1,54 @@
+´╗┐using Lucene.Net.Codecs.DiskDV;
+using Lucene.Net.Codecs.Lucene40;
+using Lucene.Net.Codecs.Lucene41;
+using Lucene.Net.Codecs.Lucene46;
+
+namespace Lucene.Net.Codecs.CheapBastard
+{
+    /// <summary>
+    /// Codec that tries to use as little ram as possible because he spent all his money
on beer
+    /// </summary>
+    // TODO: better name :) 
+    // but if we named it "LowMemory" in codecs/ package, it would be irresistible like optimize()!
+    public class CheapBastardCodec : FilterCodec
+    {
+        // TODO: would be better to have no terms index at all and bsearch a terms dict
+        private readonly PostingsFormat postings = new Lucene41PostingsFormat(100, 200);
+        // uncompressing versions, waste lots of disk but no ram
+        private readonly StoredFieldsFormat storedFields = new Lucene40StoredFieldsFormat();
+        private readonly TermVectorsFormat termVectors = new Lucene40TermVectorsFormat();
+        // these go to disk for all docvalues/norms datastructures
+        private readonly DocValuesFormat docValues = new DiskDocValuesFormat();
+        private readonly NormsFormat norms = new DiskNormsFormat();
+
+        public CheapBastardCodec()
+            : base(new Lucene46Codec())
+        {
+        }
+
+        public override PostingsFormat PostingsFormat
+        {
+            get { return postings; }
+        }
+
+        public override DocValuesFormat DocValuesFormat
+        {
+            get { return docValues; }
+        }
+
+        public override NormsFormat NormsFormat
+        {
+            get { return norms; }
+        }
+
+        public override StoredFieldsFormat StoredFieldsFormat
+        {
+            get { return storedFields; }
+        }
+
+        public override TermVectorsFormat TermVectorsFormat
+        {
+            get { return termVectors; }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4e4d17c1/src/Lucene.Net.TestFramework/Lucene.Net.TestFramework.csproj
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.TestFramework/Lucene.Net.TestFramework.csproj b/src/Lucene.Net.TestFramework/Lucene.Net.TestFramework.csproj
index c972f03..a5c20b3 100644
--- a/src/Lucene.Net.TestFramework/Lucene.Net.TestFramework.csproj
+++ b/src/Lucene.Net.TestFramework/Lucene.Net.TestFramework.csproj
@@ -141,6 +141,7 @@
       <SubType>Code</SubType>
     </Compile>
     <Compile Include="Codecs\Bloom\TestBloomFilteredLucene41Postings.cs" />
+    <Compile Include="Codecs\CheapBastard\CheapBastardCodec.cs" />
     <Compile Include="Codecs\Compressing\CompressingCodec.cs">
       <SubType>Code</SubType>
     </Compile>

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4e4d17c1/src/Lucene.Net.TestFramework/Util/TestRuleSetupAndRestoreClassEnv.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.TestFramework/Util/TestRuleSetupAndRestoreClassEnv.cs b/src/Lucene.Net.TestFramework/Util/TestRuleSetupAndRestoreClassEnv.cs
index 0a34665..ce0ddfa 100644
--- a/src/Lucene.Net.TestFramework/Util/TestRuleSetupAndRestoreClassEnv.cs
+++ b/src/Lucene.Net.TestFramework/Util/TestRuleSetupAndRestoreClassEnv.cs
@@ -8,6 +8,7 @@ namespace Lucene.Net.Util
 {
     using Codecs;
     using Codecs.Asserting;
+    using Codecs.CheapBastard;
     using Codecs.Compressing;
     using Codecs.Lucene3x;
     using Codecs.Lucene40;
@@ -221,12 +222,11 @@ namespace Lucene.Net.Util
             {
                 codec = new SimpleTextCodec();
             }
-            // LUCENENET TODO: Implement CheapBastardCodec
-            //else if ("CheapBastard".equals(LuceneTestCase.TEST_CODEC) || ("random".equals(LuceneTestCase.TEST_CODEC)
&& randomVal == 8 && !ShouldAvoidCodec("CheapBastard") && !ShouldAvoidCodec("Lucene41")))
-            //{
-            //    // we also avoid this codec if Lucene41 is avoided, since thats the postings
format it uses.
-            //    codec = new CheapBastardCodec();
-            //}
+            else if ("CheapBastard".equals(LuceneTestCase.TEST_CODEC) || ("random".equals(LuceneTestCase.TEST_CODEC)
&& randomVal == 8 && !ShouldAvoidCodec("CheapBastard") && !ShouldAvoidCodec("Lucene41")))
+            {
+                // we also avoid this codec if Lucene41 is avoided, since thats the postings
format it uses.
+                codec = new CheapBastardCodec();
+            }
             else if ("Asserting".Equals(LuceneTestCase.TEST_CODEC) || ("random".Equals(LuceneTestCase.TEST_CODEC)
&& randomVal == 6 && !ShouldAvoidCodec("Asserting")))
             {
                 codec = new AssertingCodec();


Mime
View raw message