lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From synhers...@apache.org
Subject [1/2] lucenenet git commit: Various cleanups and API .NETification
Date Wed, 18 Feb 2015 05:29:45 GMT
Repository: lucenenet
Updated Branches:
  refs/heads/master 4b24d4c8c -> f26f7649b


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/f26f7649/src/Lucene.Net.Tests/core/Index/TestPayloads.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/core/Index/TestPayloads.cs b/src/Lucene.Net.Tests/core/Index/TestPayloads.cs
index 1d8d8fd..ce1168a 100644
--- a/src/Lucene.Net.Tests/core/Index/TestPayloads.cs
+++ b/src/Lucene.Net.Tests/core/Index/TestPayloads.cs
@@ -190,10 +190,10 @@ namespace Lucene.Net.Index
 
             var verifyPayloadData = new byte[payloadDataLength];
             offset = 0;
-            DocsAndPositionsEnum[] tps = new DocsAndPositionsEnum[numTerms];
+            var tps = new DocsAndPositionsEnum[numTerms];
             for (int i = 0; i < numTerms; i++)
             {
-                tps[i] = MultiFields.GetTermPositionsEnum(reader, MultiFields.GetLiveDocs(reader),
terms[i].Field(), new BytesRef(terms[i].Text()));
+                tps[i] = MultiFields.GetTermPositionsEnum(reader, MultiFields.GetLiveDocs(reader),
terms[i].Field, new BytesRef(terms[i].Text()));
             }
 
             while (tps[0].NextDoc() != DocIdSetIterator.NO_MORE_DOCS)
@@ -224,7 +224,7 @@ namespace Lucene.Net.Index
             /*
              *  test lazy skipping
              */
-            DocsAndPositionsEnum tp = MultiFields.GetTermPositionsEnum(reader, MultiFields.GetLiveDocs(reader),
terms[0].Field(), new BytesRef(terms[0].Text()));
+            DocsAndPositionsEnum tp = MultiFields.GetTermPositionsEnum(reader, MultiFields.GetLiveDocs(reader),
terms[0].Field, new BytesRef(terms[0].Text()));
             tp.NextDoc();
             tp.NextPosition();
             // NOTE: prior rev of this test was failing to first
@@ -248,7 +248,7 @@ namespace Lucene.Net.Index
             /*
              * Test different lengths at skip points
              */
-            tp = MultiFields.GetTermPositionsEnum(reader, MultiFields.GetLiveDocs(reader),
terms[1].Field(), new BytesRef(terms[1].Text()));
+            tp = MultiFields.GetTermPositionsEnum(reader, MultiFields.GetLiveDocs(reader),
terms[1].Field, new BytesRef(terms[1].Text()));
             tp.NextDoc();
             tp.NextPosition();
             Assert.AreEqual(1, tp.Payload.Length, "Wrong payload length.");

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/f26f7649/src/Lucene.Net.Tests/core/Index/TestPerSegmentDeletes.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/core/Index/TestPerSegmentDeletes.cs b/src/Lucene.Net.Tests/core/Index/TestPerSegmentDeletes.cs
index 6503b1b..cb0e594 100644
--- a/src/Lucene.Net.Tests/core/Index/TestPerSegmentDeletes.cs
+++ b/src/Lucene.Net.Tests/core/Index/TestPerSegmentDeletes.cs
@@ -245,7 +245,7 @@ namespace Lucene.Net.Index
         public virtual int[] ToDocsArray(Term term, Bits bits, IndexReader reader)
         {
             Fields fields = MultiFields.GetFields(reader);
-            Terms cterms = fields.Terms(term.Field());
+            Terms cterms = fields.Terms(term.Field);
             TermsEnum ctermsEnum = cterms.Iterator(null);
             if (ctermsEnum.SeekExact(new BytesRef(term.Text())))
             {

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/f26f7649/src/Lucene.Net.Tests/core/Index/TestSegmentTermDocs.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/core/Index/TestSegmentTermDocs.cs b/src/Lucene.Net.Tests/core/Index/TestSegmentTermDocs.cs
index c266adc..cfc4eb6 100644
--- a/src/Lucene.Net.Tests/core/Index/TestSegmentTermDocs.cs
+++ b/src/Lucene.Net.Tests/core/Index/TestSegmentTermDocs.cs
@@ -148,7 +148,7 @@ namespace Lucene.Net.Index
 
             IndexReader reader = DirectoryReader.Open(dir, indexDivisor);
 
-            DocsEnum tdocs = TestUtil.Docs(Random(), reader, ta.Field(), new BytesRef(ta.Text()),
MultiFields.GetLiveDocs(reader), null, DocsEnum.FLAG_FREQS);
+            DocsEnum tdocs = TestUtil.Docs(Random(), reader, ta.Field, new BytesRef(ta.Text()),
MultiFields.GetLiveDocs(reader), null, DocsEnum.FLAG_FREQS);
 
             // without optimization (assumption skipInterval == 16)
 
@@ -168,7 +168,7 @@ namespace Lucene.Net.Index
             Assert.IsFalse(tdocs.Advance(10) != DocIdSetIterator.NO_MORE_DOCS);
 
             // without next
-            tdocs = TestUtil.Docs(Random(), reader, ta.Field(), new BytesRef(ta.Text()),
MultiFields.GetLiveDocs(reader), null, 0);
+            tdocs = TestUtil.Docs(Random(), reader, ta.Field, new BytesRef(ta.Text()), MultiFields.GetLiveDocs(reader),
null, 0);
 
             Assert.IsTrue(tdocs.Advance(0) != DocIdSetIterator.NO_MORE_DOCS);
             Assert.AreEqual(0, tdocs.DocID());
@@ -181,7 +181,7 @@ namespace Lucene.Net.Index
             // exactly skipInterval documents and therefore with optimization
 
             // with next
-            tdocs = TestUtil.Docs(Random(), reader, tb.Field(), new BytesRef(tb.Text()),
MultiFields.GetLiveDocs(reader), null, DocsEnum.FLAG_FREQS);
+            tdocs = TestUtil.Docs(Random(), reader, tb.Field, new BytesRef(tb.Text()), MultiFields.GetLiveDocs(reader),
null, DocsEnum.FLAG_FREQS);
 
             Assert.IsTrue(tdocs.NextDoc() != DocIdSetIterator.NO_MORE_DOCS);
             Assert.AreEqual(10, tdocs.DocID());
@@ -200,7 +200,7 @@ namespace Lucene.Net.Index
             Assert.IsFalse(tdocs.Advance(26) != DocIdSetIterator.NO_MORE_DOCS);
 
             // without next
-            tdocs = TestUtil.Docs(Random(), reader, tb.Field(), new BytesRef(tb.Text()),
MultiFields.GetLiveDocs(reader), null, DocsEnum.FLAG_FREQS);
+            tdocs = TestUtil.Docs(Random(), reader, tb.Field, new BytesRef(tb.Text()), MultiFields.GetLiveDocs(reader),
null, DocsEnum.FLAG_FREQS);
 
             Assert.IsTrue(tdocs.Advance(5) != DocIdSetIterator.NO_MORE_DOCS);
             Assert.AreEqual(10, tdocs.DocID());
@@ -215,7 +215,7 @@ namespace Lucene.Net.Index
             // much more than skipInterval documents and therefore with optimization
 
             // with next
-            tdocs = TestUtil.Docs(Random(), reader, tc.Field(), new BytesRef(tc.Text()),
MultiFields.GetLiveDocs(reader), null, DocsEnum.FLAG_FREQS);
+            tdocs = TestUtil.Docs(Random(), reader, tc.Field, new BytesRef(tc.Text()), MultiFields.GetLiveDocs(reader),
null, DocsEnum.FLAG_FREQS);
 
             Assert.IsTrue(tdocs.NextDoc() != DocIdSetIterator.NO_MORE_DOCS);
             Assert.AreEqual(26, tdocs.DocID());
@@ -236,7 +236,7 @@ namespace Lucene.Net.Index
             Assert.IsFalse(tdocs.Advance(76) != DocIdSetIterator.NO_MORE_DOCS);
 
             //without next
-            tdocs = TestUtil.Docs(Random(), reader, tc.Field(), new BytesRef(tc.Text()),
MultiFields.GetLiveDocs(reader), null, 0);
+            tdocs = TestUtil.Docs(Random(), reader, tc.Field, new BytesRef(tc.Text()), MultiFields.GetLiveDocs(reader),
null, 0);
             Assert.IsTrue(tdocs.Advance(5) != DocIdSetIterator.NO_MORE_DOCS);
             Assert.AreEqual(26, tdocs.DocID());
             Assert.IsTrue(tdocs.Advance(40) != DocIdSetIterator.NO_MORE_DOCS);

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/f26f7649/src/Lucene.Net.Tests/core/Search/TestMinShouldMatch2.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/core/Search/TestMinShouldMatch2.cs b/src/Lucene.Net.Tests/core/Search/TestMinShouldMatch2.cs
index b485737..8ea7fc5 100644
--- a/src/Lucene.Net.Tests/core/Search/TestMinShouldMatch2.cs
+++ b/src/Lucene.Net.Tests/core/Search/TestMinShouldMatch2.cs
@@ -353,7 +353,7 @@ namespace Lucene.Net.Search
                     Debug.Assert(!clause.Prohibited);
                     Debug.Assert(!clause.Required);
                     Term term = ((TermQuery)clause.Query).Term;
-                    long ord = Dv.LookupTerm(term.Bytes());
+                    long ord = Dv.LookupTerm(term.Bytes);
                     if (ord >= 0)
                     {
                         bool success = Ords.Add(ord);

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/f26f7649/src/Lucene.Net.Tests/core/Search/TestPrefixRandom.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/core/Search/TestPrefixRandom.cs b/src/Lucene.Net.Tests/core/Search/TestPrefixRandom.cs
index a36369b..06bdf3a 100644
--- a/src/Lucene.Net.Tests/core/Search/TestPrefixRandom.cs
+++ b/src/Lucene.Net.Tests/core/Search/TestPrefixRandom.cs
@@ -57,7 +57,7 @@ namespace Lucene.Net.Search
             Dir = NewDirectory();
             RandomIndexWriter writer = new RandomIndexWriter(Random(), Dir, NewIndexWriterConfig(TEST_VERSION_CURRENT,
new MockAnalyzer(Random(), MockTokenizer.KEYWORD, false)).SetMaxBufferedDocs(TestUtil.NextInt(Random(),
50, 1000)));
 
-            Document doc = new Document();
+            var doc = new Document();
             Field field = NewStringField("field", "", Field.Store.NO);
             doc.Add(field);
 
@@ -89,13 +89,13 @@ namespace Lucene.Net.Search
         {
             private readonly TestPrefixRandom OuterInstance;
 
-            internal readonly BytesRef Prefix;
+            private readonly BytesRef Prefix;
 
             internal DumbPrefixQuery(TestPrefixRandom outerInstance, Term term)
-                : base(term.Field())
+                : base(term.Field)
             {
                 this.OuterInstance = outerInstance;
-                Prefix = term.Bytes();
+                Prefix = term.Bytes;
             }
 
             public override TermsEnum GetTermsEnum(Terms terms, AttributeSource atts)

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/f26f7649/src/Lucene.Net.Tests/core/Search/TestRegexpRandom2.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/core/Search/TestRegexpRandom2.cs b/src/Lucene.Net.Tests/core/Search/TestRegexpRandom2.cs
index 61df4e5..6171c87 100644
--- a/src/Lucene.Net.Tests/core/Search/TestRegexpRandom2.cs
+++ b/src/Lucene.Net.Tests/core/Search/TestRegexpRandom2.cs
@@ -109,14 +109,11 @@ namespace Lucene.Net.Search
         /// a stupid regexp query that just blasts thru the terms </summary>
         private class DumbRegexpQuery : MultiTermQuery
         {
-            private readonly TestRegexpRandom2 OuterInstance;
+            private readonly Automaton Automaton;
 
-            internal readonly Automaton Automaton;
-
-            internal DumbRegexpQuery(TestRegexpRandom2 outerInstance, Term term, int flags)
-                : base(term.Field())
+            internal DumbRegexpQuery(Term term, int flags)
+                : base(term.Field)
             {
-                this.OuterInstance = outerInstance;
                 RegExp re = new RegExp(term.Text(), flags);
                 Automaton = re.ToAutomaton();
             }
@@ -126,11 +123,11 @@ namespace Lucene.Net.Search
                 return new SimpleAutomatonTermsEnum(this, terms.Iterator(null));
             }
 
-            private class SimpleAutomatonTermsEnum : FilteredTermsEnum
+            private sealed class SimpleAutomatonTermsEnum : FilteredTermsEnum
             {
-                internal bool InstanceFieldsInitialized = false;
+                private bool InstanceFieldsInitialized = false;
 
-                internal virtual void InitializeInstanceFields()
+                private void InitializeInstanceFields()
                 {
                     RunAutomaton = new CharacterRunAutomaton(OuterInstance.Automaton);
                 }
@@ -192,7 +189,7 @@ namespace Lucene.Net.Search
         protected internal virtual void AssertSame(string regexp)
         {
             RegexpQuery smart = new RegexpQuery(new Term(FieldName, regexp), RegExp.NONE);
-            DumbRegexpQuery dumb = new DumbRegexpQuery(this, new Term(FieldName, regexp),
RegExp.NONE);
+            DumbRegexpQuery dumb = new DumbRegexpQuery(new Term(FieldName, regexp), RegExp.NONE);
 
             TopDocs smartDocs = Searcher1.Search(smart, 25);
             TopDocs dumbDocs = Searcher2.Search(dumb, 25);


Mime
View raw message