lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nightowl...@apache.org
Subject [03/28] lucenenet git commit: Lucene.Net.Misc refactor: made public fields into properties
Date Wed, 01 Feb 2017 10:22:00 GMT
Lucene.Net.Misc refactor: made public fields into properties


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

Branch: refs/heads/api-work
Commit: 81158d88286ab8f51b55463b50d50f9309605a77
Parents: 754202c
Author: Shad Storhaug <shad@shadstorhaug.com>
Authored: Wed Feb 1 13:17:05 2017 +0700
Committer: Shad Storhaug <shad@shadstorhaug.com>
Committed: Wed Feb 1 13:17:05 2017 +0700

----------------------------------------------------------------------
 src/Lucene.Net.Misc/Index/IndexSplitter.cs      | 28 ++++++++++----------
 .../Util/Fst/UpToTwoPositiveIntOutputs.cs       | 19 +++++++++----
 .../Index/TestIndexSplitter.cs                  |  2 +-
 .../Util/Fst/TestFSTsMisc.cs                    |  4 +--
 4 files changed, 31 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/81158d88/src/Lucene.Net.Misc/Index/IndexSplitter.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Misc/Index/IndexSplitter.cs b/src/Lucene.Net.Misc/Index/IndexSplitter.cs
index f0d573f..92b3ba2 100644
--- a/src/Lucene.Net.Misc/Index/IndexSplitter.cs
+++ b/src/Lucene.Net.Misc/Index/IndexSplitter.cs
@@ -43,7 +43,7 @@ namespace Lucene.Net.Index
     /// </summary>
     public class IndexSplitter
     {
-        public SegmentInfos infos;
+        public SegmentInfos Infos { get; set; }
 
         internal FSDirectory fsDir;
 
@@ -93,15 +93,15 @@ namespace Lucene.Net.Index
         {
             this.dir = dir;
             fsDir = FSDirectory.Open(dir);
-            infos = new SegmentInfos();
-            infos.Read(fsDir);
+            Infos = new SegmentInfos();
+            Infos.Read(fsDir);
         }
 
         public virtual void ListSegments()
         {
-            for (int x = 0; x < infos.Count; x++)
+            for (int x = 0; x < Infos.Count; x++)
             {
-                SegmentCommitInfo info = infos.Info(x);
+                SegmentCommitInfo info = Infos.Info(x);
                 string sizeStr = string.Format(CultureInfo.InvariantCulture, "{0:###,###.###}",
info.SizeInBytes());
                 Console.WriteLine(info.Info.Name + " " + sizeStr);
             }
@@ -109,9 +109,9 @@ namespace Lucene.Net.Index
 
         private int GetIdx(string name)
         {
-            for (int x = 0; x < infos.Count; x++)
+            for (int x = 0; x < Infos.Count; x++)
             {
-                if (name.Equals(infos.Info(x).Info.Name))
+                if (name.Equals(Infos.Info(x).Info.Name))
                 {
                     return x;
                 }
@@ -121,11 +121,11 @@ namespace Lucene.Net.Index
 
         private SegmentCommitInfo GetInfo(string name)
         {
-            for (int x = 0; x < infos.Count; x++)
+            for (int x = 0; x < Infos.Count; x++)
             {
-                if (name.Equals(infos.Info(x).Info.Name))
+                if (name.Equals(Infos.Info(x).Info.Name))
                 {
-                    return infos.Info(x);
+                    return Infos.Info(x);
                 }
             }
             return null;
@@ -136,10 +136,10 @@ namespace Lucene.Net.Index
             foreach (string n in segs)
             {
                 int idx = GetIdx(n);
-                infos.Remove(idx);
+                Infos.Remove(idx);
             }
-            infos.Changed();
-            infos.Commit(fsDir);
+            Infos.Changed();
+            Infos.Commit(fsDir);
         }
 
         public virtual void Split(DirectoryInfo destDir, string[] segs)
@@ -147,7 +147,7 @@ namespace Lucene.Net.Index
             destDir.Create();
             FSDirectory destFSDir = FSDirectory.Open(destDir);
             SegmentInfos destInfos = new SegmentInfos();
-            destInfos.Counter = infos.Counter;
+            destInfos.Counter = Infos.Counter;
             foreach (string n in segs)
             {
                 SegmentCommitInfo infoPerCommit = GetInfo(n);

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/81158d88/src/Lucene.Net.Misc/Util/Fst/UpToTwoPositiveIntOutputs.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Misc/Util/Fst/UpToTwoPositiveIntOutputs.cs b/src/Lucene.Net.Misc/Util/Fst/UpToTwoPositiveIntOutputs.cs
index 21d5fe1..cf3596e 100644
--- a/src/Lucene.Net.Misc/Util/Fst/UpToTwoPositiveIntOutputs.cs
+++ b/src/Lucene.Net.Misc/Util/Fst/UpToTwoPositiveIntOutputs.cs
@@ -54,8 +54,17 @@ namespace Lucene.Net.Util.Fst
         /// Holds two long outputs. </summary>
         public sealed class TwoLongs
         {
-            public readonly long first;
-            public readonly long second;
+            public long First
+            {
+                get { return first; }
+            }
+            private readonly long first;
+
+            public long Second
+            {
+                get { return second; }
+            }
+            private readonly long second;
 
             public TwoLongs(long first, long second)
             {
@@ -196,7 +205,7 @@ namespace Lucene.Net.Util.Fst
             {
                 TwoLongs output = (TwoLongs)_output;
                 long v = prefix.Value;
-                return new TwoLongs(output.first + v, output.second + v);
+                return new TwoLongs(output.First + v, output.Second + v);
             }
         }
 
@@ -211,8 +220,8 @@ namespace Lucene.Net.Util.Fst
             else
             {
                 TwoLongs output = (TwoLongs)_output;
-                @out.WriteVLong((output.first << 1) | 1);
-                @out.WriteVLong(output.second);
+                @out.WriteVLong((output.First << 1) | 1);
+                @out.WriteVLong(output.Second);
             }
         }
 

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/81158d88/src/Lucene.Net.Tests.Misc/Index/TestIndexSplitter.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests.Misc/Index/TestIndexSplitter.cs b/src/Lucene.Net.Tests.Misc/Index/TestIndexSplitter.cs
index 368c294..6d3d8b3 100644
--- a/src/Lucene.Net.Tests.Misc/Index/TestIndexSplitter.cs
+++ b/src/Lucene.Net.Tests.Misc/Index/TestIndexSplitter.cs
@@ -72,7 +72,7 @@ namespace Lucene.Net.Index
             iw.Dispose();
             // we should have 2 segments now
             IndexSplitter @is = new IndexSplitter(dir);
-            string splitSegName = @is.infos.Info(1).Info.Name;
+            string splitSegName = @is.Infos.Info(1).Info.Name;
             @is.Split(destDir, new string[] { splitSegName });
             Store.Directory fsDirDest = NewFSDirectory(destDir);
             DirectoryReader r = DirectoryReader.Open(fsDirDest);

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/81158d88/src/Lucene.Net.Tests.Misc/Util/Fst/TestFSTsMisc.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests.Misc/Util/Fst/TestFSTsMisc.cs b/src/Lucene.Net.Tests.Misc/Util/Fst/TestFSTsMisc.cs
index a75beaf..41752e0 100644
--- a/src/Lucene.Net.Tests.Misc/Util/Fst/TestFSTsMisc.cs
+++ b/src/Lucene.Net.Tests.Misc/Util/Fst/TestFSTsMisc.cs
@@ -157,13 +157,13 @@ namespace Lucene.Net.Util.Fst
                 {
                     UpToTwoPositiveIntOutputs.TwoLongs twoLongs1 = output1 as UpToTwoPositiveIntOutputs.TwoLongs;
                     long[] list2 = (output2 as IEnumerable<long>).ToArray();
-                    return (new long[] { twoLongs1.first, twoLongs1.second }).SequenceEqual(list2);
+                    return (new long[] { twoLongs1.First, twoLongs1.Second }).SequenceEqual(list2);
                 }
                 else if (output2 is UpToTwoPositiveIntOutputs.TwoLongs && output1
is IEnumerable<long>)
                 {
                     long[] list1 = (output1 as IEnumerable<long>).ToArray();
                     UpToTwoPositiveIntOutputs.TwoLongs twoLongs2 = output2 as UpToTwoPositiveIntOutputs.TwoLongs;
-                    return (new long[] { twoLongs2.first, twoLongs2.second }).SequenceEqual(list1);
+                    return (new long[] { twoLongs2.First, twoLongs2.Second }).SequenceEqual(list1);
                 }
 
                 return output1.Equals(output2);


Mime
View raw message