lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From synhers...@apache.org
Subject [02/18] lucenenet git commit: Implemented missing Lucene41WithOrds class which was causing some random codec tests to fail sporadically.
Date Sun, 21 Aug 2016 06:54:41 GMT
Implemented missing Lucene41WithOrds class which was causing some random codec tests to fail
sporadically.


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

Branch: refs/heads/master
Commit: 406f88a6b778c3942707341902b1d6f5e263ce0f
Parents: 828819d
Author: Shad Storhaug <shad@shadstorhaug.com>
Authored: Sun Aug 21 07:21:46 2016 +0700
Committer: Shad Storhaug <shad@shadstorhaug.com>
Committed: Sun Aug 21 07:21:46 2016 +0700

----------------------------------------------------------------------
 .../Codecs/Lucene41Ords/Lucene41WithOrds.cs     | 126 +++++++++++++++++++
 .../Lucene.Net.TestFramework.csproj             |   1 +
 2 files changed, 127 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/406f88a6/src/Lucene.Net.TestFramework/Codecs/Lucene41Ords/Lucene41WithOrds.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.TestFramework/Codecs/Lucene41Ords/Lucene41WithOrds.cs b/src/Lucene.Net.TestFramework/Codecs/Lucene41Ords/Lucene41WithOrds.cs
new file mode 100644
index 0000000..37f8243
--- /dev/null
+++ b/src/Lucene.Net.TestFramework/Codecs/Lucene41Ords/Lucene41WithOrds.cs
@@ -0,0 +1,126 @@
+´╗┐using Lucene.Net.Codecs.BlockTerms;
+using Lucene.Net.Codecs.Lucene41;
+using Lucene.Net.Index;
+using Lucene.Net.Util;
+
+namespace Lucene.Net.Codecs.Lucene41Ords
+{
+    public sealed class Lucene41WithOrds : PostingsFormat
+    {
+        public Lucene41WithOrds()
+            : base("Lucene41WithOrds")
+        {
+        }
+
+        public override FieldsConsumer FieldsConsumer(SegmentWriteState state)
+        {
+            PostingsWriterBase docs = new Lucene41PostingsWriter(state);
+
+            // TODO: should we make the terms index more easily
+            // pluggable?  Ie so that this codec would record which
+            // index impl was used, and switch on loading?
+            // Or... you must make a new Codec for this?
+            TermsIndexWriterBase indexWriter;
+            bool success = false;
+            try
+            {
+                indexWriter = new FixedGapTermsIndexWriter(state);
+                success = true;
+            }
+            finally
+            {
+                if (!success)
+                {
+                    docs.Dispose();
+                }
+            }
+
+            success = false;
+            try
+            {
+                // Must use BlockTermsWriter (not BlockTree) because
+                // BlockTree doens't support ords (yet)...
+                FieldsConsumer ret = new BlockTermsWriter(indexWriter, state, docs);
+                success = true;
+                return ret;
+            }
+            finally
+            {
+                if (!success)
+                {
+                    try
+                    {
+                        docs.Dispose();
+                    }
+                    finally
+                    {
+                        indexWriter.Dispose();
+                    }
+                }
+            }
+        }
+
+        public override FieldsProducer FieldsProducer(SegmentReadState state)
+        {
+            PostingsReaderBase postings = new Lucene41PostingsReader(state.Directory, state.FieldInfos,
state.SegmentInfo, state.Context, state.SegmentSuffix);
+            TermsIndexReaderBase indexReader;
+
+            bool success = false;
+            try
+            {
+                indexReader = new FixedGapTermsIndexReader(state.Directory,
+                                                           state.FieldInfos,
+                                                           state.SegmentInfo.Name,
+                                                           state.TermsIndexDivisor,
+                                                           BytesRef.UTF8SortedAsUnicodeComparer,
+                                                           state.SegmentSuffix, state.Context);
+                success = true;
+            }
+            finally
+            {
+                if (!success)
+                {
+                    postings.Dispose();
+                }
+            }
+
+            success = false;
+            try
+            {
+                FieldsProducer ret = new BlockTermsReader(indexReader,
+                                                          state.Directory,
+                                                          state.FieldInfos,
+                                                          state.SegmentInfo,
+                                                          postings,
+                                                          state.Context,
+                                                          state.SegmentSuffix);
+                success = true;
+                return ret;
+            }
+            finally
+            {
+                if (!success)
+                {
+                    try
+                    {
+                        postings.Dispose();
+                    }
+                    finally
+                    {
+                        indexReader.Dispose();
+                    }
+                }
+            }
+        }
+
+        /// <summary>
+        /// Extension of freq postings file
+        /// </summary>
+        static readonly string FREQ_EXTENSION = "frq";
+
+        /// <summary>
+        /// Extension of prox postings file
+        /// </summary>
+        static readonly string PROX_EXTENSION = "prx";
+    }
+}

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/406f88a6/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 972bcce..f62716e 100644
--- a/src/Lucene.Net.TestFramework/Lucene.Net.TestFramework.csproj
+++ b/src/Lucene.Net.TestFramework/Lucene.Net.TestFramework.csproj
@@ -227,6 +227,7 @@
     <Compile Include="Codecs\lucene40\Lucene40SkipListWriter.cs">
       <SubType>Code</SubType>
     </Compile>
+    <Compile Include="Codecs\Lucene41Ords\Lucene41WithOrds.cs" />
     <Compile Include="Codecs\lucene41\Lucene41RWCodec.cs">
       <SubType>Code</SubType>
     </Compile>


Mime
View raw message