You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucenenet.apache.org by ni...@apache.org on 2022/11/09 17:58:59 UTC

[lucenenet] branch master updated (e27faab50 -> c460883f2)

This is an automated email from the ASF dual-hosted git repository.

nightowl888 pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/lucenenet.git


    from e27faab50 BREAKING: Lucene.Net.Analysis.Kuromoji.Token: Renamed IsKnown() > IsKnown, IsUnknown() > IsUnknown, IsUser() > IsUser.
     new 6e341886d Use null propagation
     new c460883f2 Remove unused using statements

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 src/Lucene.Net/Analysis/TokenStreamToAutomaton.cs  |   3 +-
 .../Codecs/MappingMultiDocsAndPositionsEnum.cs     |   3 +-
 src/Lucene.Net/Codecs/MappingMultiDocsEnum.cs      |   3 +-
 src/Lucene.Net/Codecs/TermsConsumer.cs             |   1 -
 src/Lucene.Net/Index/CheckIndex.cs                 | 202 ++++++++-------------
 src/Lucene.Net/Store/BaseDirectory.cs              |   5 +-
 src/Lucene.Net/Store/BufferedChecksumIndexInput.cs |   1 -
 src/Lucene.Net/Store/ByteBufferIndexInput.cs       |   5 +-
 src/Lucene.Net/Store/RAMFile.cs                    |   5 +-
 src/Lucene.Net/Util/CollectionUtil.cs              |   3 +-
 src/Lucene.Net/Util/IOUtils.cs                     |  30 +--
 11 files changed, 91 insertions(+), 170 deletions(-)


[lucenenet] 02/02: Remove unused using statements

Posted by ni...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

nightowl888 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/lucenenet.git

commit c460883f247eacd5b995e3fc859a53d4b12f1eee
Author: Jason Nelson <ja...@carbonmade.com>
AuthorDate: Tue Nov 8 10:58:49 2022 -0800

    Remove unused using statements
---
 src/Lucene.Net/Analysis/TokenStreamToAutomaton.cs         | 3 +--
 src/Lucene.Net/Codecs/MappingMultiDocsAndPositionsEnum.cs | 3 +--
 src/Lucene.Net/Codecs/MappingMultiDocsEnum.cs             | 3 +--
 src/Lucene.Net/Codecs/TermsConsumer.cs                    | 1 -
 src/Lucene.Net/Store/BufferedChecksumIndexInput.cs        | 1 -
 src/Lucene.Net/Util/CollectionUtil.cs                     | 3 +--
 6 files changed, 4 insertions(+), 10 deletions(-)

diff --git a/src/Lucene.Net/Analysis/TokenStreamToAutomaton.cs b/src/Lucene.Net/Analysis/TokenStreamToAutomaton.cs
index 65317e78a..9664c42d9 100644
--- a/src/Lucene.Net/Analysis/TokenStreamToAutomaton.cs
+++ b/src/Lucene.Net/Analysis/TokenStreamToAutomaton.cs
@@ -1,9 +1,8 @@
-using J2N;
+using J2N;
 using Lucene.Net.Analysis.TokenAttributes;
 using Lucene.Net.Diagnostics;
 using Lucene.Net.Util;
 using System;
-using System.Diagnostics;
 
 namespace Lucene.Net.Analysis
 {
diff --git a/src/Lucene.Net/Codecs/MappingMultiDocsAndPositionsEnum.cs b/src/Lucene.Net/Codecs/MappingMultiDocsAndPositionsEnum.cs
index 724dc990c..88145390d 100644
--- a/src/Lucene.Net/Codecs/MappingMultiDocsAndPositionsEnum.cs
+++ b/src/Lucene.Net/Codecs/MappingMultiDocsAndPositionsEnum.cs
@@ -1,5 +1,4 @@
-using Lucene.Net.Support;
-using System;
+using Lucene.Net.Support;
 using System.Diagnostics.CodeAnalysis;
 using System.Runtime.CompilerServices;
 
diff --git a/src/Lucene.Net/Codecs/MappingMultiDocsEnum.cs b/src/Lucene.Net/Codecs/MappingMultiDocsEnum.cs
index 4e21abd25..4bec6b857 100644
--- a/src/Lucene.Net/Codecs/MappingMultiDocsEnum.cs
+++ b/src/Lucene.Net/Codecs/MappingMultiDocsEnum.cs
@@ -1,6 +1,5 @@
-using Lucene.Net.Diagnostics;
+using Lucene.Net.Diagnostics;
 using Lucene.Net.Support;
-using System;
 using System.Diagnostics.CodeAnalysis;
 using System.Runtime.CompilerServices;
 
diff --git a/src/Lucene.Net/Codecs/TermsConsumer.cs b/src/Lucene.Net/Codecs/TermsConsumer.cs
index 8d3791d1d..35f6a09df 100644
--- a/src/Lucene.Net/Codecs/TermsConsumer.cs
+++ b/src/Lucene.Net/Codecs/TermsConsumer.cs
@@ -1,7 +1,6 @@
 using Lucene.Net.Diagnostics;
 using Lucene.Net.Index;
 using System.Collections.Generic;
-using System.Diagnostics;
 using System.Runtime.CompilerServices;
 
 namespace Lucene.Net.Codecs
diff --git a/src/Lucene.Net/Store/BufferedChecksumIndexInput.cs b/src/Lucene.Net/Store/BufferedChecksumIndexInput.cs
index da0178a99..13e86088d 100644
--- a/src/Lucene.Net/Store/BufferedChecksumIndexInput.cs
+++ b/src/Lucene.Net/Store/BufferedChecksumIndexInput.cs
@@ -1,5 +1,4 @@
 using Lucene.Net.Support;
-using System;
 
 namespace Lucene.Net.Store
 {
diff --git a/src/Lucene.Net/Util/CollectionUtil.cs b/src/Lucene.Net/Util/CollectionUtil.cs
index 50d64fc97..71c548096 100644
--- a/src/Lucene.Net/Util/CollectionUtil.cs
+++ b/src/Lucene.Net/Util/CollectionUtil.cs
@@ -1,5 +1,4 @@
-using J2N.Collections.Generic.Extensions;
-using System;
+using J2N.Collections.Generic.Extensions;
 using System.Collections.Generic;
 using System.Runtime.CompilerServices;
 


[lucenenet] 01/02: Use null propagation

Posted by ni...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

nightowl888 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/lucenenet.git

commit 6e341886d2a2e40315525f0997ee4b456bc8f4bd
Author: Jason Nelson <ja...@carbonmade.com>
AuthorDate: Tue Nov 8 10:50:30 2022 -0800

    Use null propagation
---
 src/Lucene.Net/Index/CheckIndex.cs           | 202 +++++++++++----------------
 src/Lucene.Net/Store/BaseDirectory.cs        |   5 +-
 src/Lucene.Net/Store/ByteBufferIndexInput.cs |   5 +-
 src/Lucene.Net/Store/RAMFile.cs              |   5 +-
 src/Lucene.Net/Util/IOUtils.cs               |  30 +---
 5 files changed, 87 insertions(+), 160 deletions(-)

diff --git a/src/Lucene.Net/Index/CheckIndex.cs b/src/Lucene.Net/Index/CheckIndex.cs
index cf84648d8..4c358d29b 100644
--- a/src/Lucene.Net/Index/CheckIndex.cs
+++ b/src/Lucene.Net/Index/CheckIndex.cs
@@ -473,10 +473,7 @@ namespace Lucene.Net.Index
 
         private static void Msg(TextWriter @out, string msg)
         {
-            if (@out != null)
-            {
-                @out.WriteLine(msg);
-            }
+            @out?.WriteLine(msg);
         }
 
         /// <summary>
@@ -522,14 +519,13 @@ namespace Lucene.Net.Index
             {
                 Msg(infoStream, "ERROR: could not read any segments file in directory");
                 result.MissingSegments = true;
-                if (infoStream != null)
-                {
-                    // LUCENENET NOTE: Some tests rely on the error type being in
-                    // the message. We can't get the error type with StackTrace, we
-                    // need ToString() for that.
-                    infoStream.WriteLine(t.ToString());
-                    //infoStream.WriteLine(t.StackTrace);
-                }
+                
+                // LUCENENET NOTE: Some tests rely on the error type being in
+                // the message. We can't get the error type with StackTrace, we
+                // need ToString() for that.
+                infoStream?.WriteLine(t.ToString());
+                //infoStream.WriteLine(t.StackTrace);
+                
                 return result;
             }
 
@@ -571,14 +567,13 @@ namespace Lucene.Net.Index
             catch (Exception t) when (t.IsThrowable())
             {
                 Msg(infoStream, "ERROR: could not open segments file in directory");
-                if (infoStream != null)
-                {
-                    // LUCENENET NOTE: Some tests rely on the error type being in
-                    // the message. We can't get the error type with StackTrace, we
-                    // need ToString() for that.
-                    infoStream.WriteLine(t.ToString());
-                    //infoStream.WriteLine(t.StackTrace);
-                }
+                
+                // LUCENENET NOTE: Some tests rely on the error type being in
+                // the message. We can't get the error type with StackTrace, we
+                // need ToString() for that.
+                infoStream?.WriteLine(t.ToString());
+                //infoStream.WriteLine(t.StackTrace);
+                
                 result.CantOpenSegments = true;
                 return result;
             }
@@ -590,23 +585,19 @@ namespace Lucene.Net.Index
             catch (Exception t) when (t.IsThrowable())
             {
                 Msg(infoStream, "ERROR: could not read segment file version in directory");
-                if (infoStream != null)
-                {
-                    // LUCENENET NOTE: Some tests rely on the error type being in
-                    // the message. We can't get the error type with StackTrace, we
-                    // need ToString() for that.
-                    infoStream.WriteLine(t.ToString());
-                    //infoStream.WriteLine(t.StackTrace);
-                }
+                
+                // LUCENENET NOTE: Some tests rely on the error type being in
+                // the message. We can't get the error type with StackTrace, we
+                // need ToString() for that.
+                infoStream?.WriteLine(t.ToString());
+                //infoStream.WriteLine(t.StackTrace);
+                
                 result.MissingSegmentVersion = true;
                 return result;
             }
             finally
             {
-                if (input != null)
-                {
-                    input.Dispose();
-                }
+                input?.Dispose();
             }
 
             string sFormat = "";
@@ -745,26 +736,21 @@ namespace Lucene.Net.Index
                         segInfoStat.HasDeletions = true;
                         segInfoStat.DeletionsGen = info.DelGen;
                     }
-                    if (infoStream != null)
-                    {
-                        infoStream.Write("    test: open reader.........");
-                    }
+
+                    infoStream?.Write("    test: open reader.........");
+
                     reader = new SegmentReader(info, DirectoryReader.DEFAULT_TERMS_INDEX_DIVISOR, IOContext.DEFAULT);
                     Msg(infoStream, "OK");
 
                     segInfoStat.OpenReaderPassed = true;
 
-                    if (infoStream != null)
-                    {
-                        infoStream.Write("    test: check integrity.....");
-                    }
+                    infoStream?.Write("    test: check integrity.....");
+                    
                     reader.CheckIntegrity();
                     Msg(infoStream, "OK");
 
-                    if (infoStream != null)
-                    {
-                        infoStream.Write("    test: check live docs.....");
-                    }
+                    infoStream?.Write("    test: check live docs.....");
+                    
                     int numDocs = reader.NumDocs;
                     toLoseDocCount = numDocs;
                     if (reader.HasDeletions)
@@ -831,10 +817,8 @@ namespace Lucene.Net.Index
                     }
 
                     // Test getFieldInfos()
-                    if (infoStream != null)
-                    {
-                        infoStream.Write("    test: fields..............");
-                    }
+                    infoStream?.Write("    test: fields..............");
+                    
                     FieldInfos fieldInfos = reader.FieldInfos;
                     Msg(infoStream, "OK [" + fieldInfos.Count + " fields]");
                     segInfoStat.NumFields = fieldInfos.Count;
@@ -884,13 +868,12 @@ namespace Lucene.Net.Index
                     string comment;
                     comment = "fixIndex() would remove reference to this segment";
                     Msg(infoStream, "    WARNING: " + comment + "; full exception:");
-                    if (infoStream != null)
-                    {
-                        // LUCENENET NOTE: Some tests rely on the error type being in
-                        // the message. We can't get the error type with StackTrace, we
-                        // need ToString() for that.
-                        infoStream.WriteLine(t.ToString());
-                    }
+
+                    // LUCENENET NOTE: Some tests rely on the error type being in
+                    // the message. We can't get the error type with StackTrace, we
+                    // need ToString() for that.
+                    infoStream?.WriteLine(t.ToString());
+                    
                     Msg(infoStream, "");
                     result.TotLoseDocCount += toLoseDocCount;
                     result.NumBadSegments++;
@@ -898,10 +881,7 @@ namespace Lucene.Net.Index
                 }
                 finally
                 {
-                    if (reader != null)
-                    {
-                        reader.Dispose();
-                    }
+                    reader?.Dispose();
                 }
 
                 // Keeper
@@ -944,10 +924,8 @@ namespace Lucene.Net.Index
             try
             {
                 // Test Field Norms
-                if (infoStream != null)
-                {
-                    infoStream.Write("    test: field norms.........");
-                }
+                infoStream?.Write("    test: field norms.........");
+
                 foreach (FieldInfo info in reader.FieldInfos)
                 {
                     if (info.HasNorms)
@@ -976,14 +954,12 @@ namespace Lucene.Net.Index
             {
                 Msg(infoStream, "ERROR [" + e.Message + "]");
                 status.Error = e;
-                if (infoStream != null)
-                {
-                    // LUCENENET NOTE: Some tests rely on the error type being in
-                    // the message. We can't get the error type with StackTrace, we
-                    // need ToString() for that.
-                    infoStream.WriteLine(e.ToString());
-                    //infoStream.WriteLine(e.StackTrace);
-                }
+             
+                // LUCENENET NOTE: Some tests rely on the error type being in
+                // the message. We can't get the error type with StackTrace, we
+                // need ToString() for that.
+                infoStream?.WriteLine(e.ToString());
+                //infoStream.WriteLine(e.StackTrace);      
             }
 
             return status;
@@ -1668,20 +1644,14 @@ namespace Lucene.Net.Index
 
             try
             {
-                if (infoStream != null)
-                {
-                    infoStream.Write("    test: terms, freq, prox...");
-                }
-
+                infoStream?.Write("    test: terms, freq, prox...");
+                
                 Fields fields = reader.Fields;
                 FieldInfos fieldInfos = reader.FieldInfos;
                 status = CheckFields(fields, liveDocs, maxDoc, fieldInfos, true, false, infoStream, verbose);
                 if (liveDocs != null)
                 {
-                    if (infoStream != null)
-                    {
-                        infoStream.Write("    test (ignoring deletes): terms, freq, prox...");
-                    }
+                    infoStream?.Write("    test (ignoring deletes): terms, freq, prox...");
                     CheckFields(fields, null, maxDoc, fieldInfos, true, false, infoStream, verbose);
                 }
             }
@@ -1690,14 +1660,12 @@ namespace Lucene.Net.Index
                 Msg(infoStream, "ERROR: " + e);
                 status = new Status.TermIndexStatus();
                 status.Error = e;
-                if (infoStream != null)
-                {
-                    // LUCENENET NOTE: Some tests rely on the error type being in
-                    // the message. We can't get the error type with StackTrace, we
-                    // need ToString() for that.
-                    infoStream.WriteLine(e.ToString());
-                    //infoStream.WriteLine(e.StackTrace);
-                }
+                
+                // LUCENENET NOTE: Some tests rely on the error type being in
+                // the message. We can't get the error type with StackTrace, we
+                // need ToString() for that.
+                infoStream?.WriteLine(e.ToString());
+                //infoStream.WriteLine(e.StackTrace);                
             }
 
             return status;
@@ -1714,10 +1682,7 @@ namespace Lucene.Net.Index
 
             try
             {
-                if (infoStream != null)
-                {
-                    infoStream.Write("    test: stored fields.......");
-                }
+                infoStream?.Write("    test: stored fields.......");
 
                 // Scan stored fields for all documents
                 IBits liveDocs = reader.LiveDocs;
@@ -1745,14 +1710,12 @@ namespace Lucene.Net.Index
             {
                 Msg(infoStream, "ERROR [" + e.Message + "]");
                 status.Error = e;
-                if (infoStream != null)
-                {
-                    // LUCENENET NOTE: Some tests rely on the error type being in
-                    // the message. We can't get the error type with StackTrace, we
-                    // need ToString() for that.
-                    infoStream.WriteLine(e.ToString());
-                    //infoStream.WriteLine(e.StackTrace);
-                }
+               
+                // LUCENENET NOTE: Some tests rely on the error type being in
+                // the message. We can't get the error type with StackTrace, we
+                // need ToString() for that.
+                infoStream?.WriteLine(e.ToString());
+                //infoStream.WriteLine(e.StackTrace);                
             }
 
             return status;
@@ -1768,10 +1731,8 @@ namespace Lucene.Net.Index
             Status.DocValuesStatus status = new Status.DocValuesStatus();
             try
             {
-                if (infoStream != null)
-                {
-                    infoStream.Write("    test: docvalues...........");
-                }
+                infoStream?.Write("    test: docvalues...........");
+                
                 foreach (FieldInfo fieldInfo in reader.FieldInfos)
                 {
                     if (fieldInfo.HasDocValues)
@@ -1794,14 +1755,12 @@ namespace Lucene.Net.Index
             {
                 Msg(infoStream, "ERROR [" + e.Message + "]");
                 status.Error = e;
-                if (infoStream != null)
-                {
-                    // LUCENENET NOTE: Some tests rely on the error type being in
-                    // the message. We can't get the error type with StackTrace, we
-                    // need ToString() for that.
-                    infoStream.WriteLine(e.ToString());
-                    //infoStream.WriteLine(e.StackTrace);
-                }
+                
+                // LUCENENET NOTE: Some tests rely on the error type being in
+                // the message. We can't get the error type with StackTrace, we
+                // need ToString() for that.
+                infoStream?.WriteLine(e.ToString());
+                //infoStream.WriteLine(e.StackTrace);                
             }
             return status;
         }
@@ -2069,10 +2028,7 @@ namespace Lucene.Net.Index
 
             try
             {
-                if (infoStream != null)
-                {
-                    infoStream.Write("    test: term vectors........");
-                }
+                infoStream?.Write("    test: term vectors........");
 
                 DocsEnum docs = null;
                 DocsAndPositionsEnum postings = null;
@@ -2322,14 +2278,12 @@ namespace Lucene.Net.Index
             {
                 Msg(infoStream, "ERROR [" + e.Message + "]");
                 status.Error = e;
-                if (infoStream != null)
-                {
-                    // LUCENENET NOTE: Some tests rely on the error type being in
-                    // the message. We can't get the error type with StackTrace, we
-                    // need ToString() for that.
-                    infoStream.WriteLine(e.ToString());
-                    //infoStream.WriteLine(e.StackTrace);
-                }
+               
+                // LUCENENET NOTE: Some tests rely on the error type being in
+                // the message. We can't get the error type with StackTrace, we
+                // need ToString() for that.
+                infoStream?.WriteLine(e.ToString());
+                //infoStream.WriteLine(e.StackTrace);
             }
 
             return status;
diff --git a/src/Lucene.Net/Store/BaseDirectory.cs b/src/Lucene.Net/Store/BaseDirectory.cs
index 94974784d..fe9745850 100644
--- a/src/Lucene.Net/Store/BaseDirectory.cs
+++ b/src/Lucene.Net/Store/BaseDirectory.cs
@@ -58,10 +58,7 @@ namespace Lucene.Net.Store
 
         public override void ClearLock(string name)
         {
-            if (m_lockFactory != null)
-            {
-                m_lockFactory.ClearLock(name);
-            }
+            m_lockFactory?.ClearLock(name);
         }
 
         public override void SetLockFactory(LockFactory lockFactory)
diff --git a/src/Lucene.Net/Store/ByteBufferIndexInput.cs b/src/Lucene.Net/Store/ByteBufferIndexInput.cs
index b2b8a0ff1..1346b833a 100644
--- a/src/Lucene.Net/Store/ByteBufferIndexInput.cs
+++ b/src/Lucene.Net/Store/ByteBufferIndexInput.cs
@@ -389,10 +389,7 @@ namespace Lucene.Net.Store
                     // make local copy, then un-set early
                     ByteBuffer[] bufs = buffers;
                     UnsetBuffers();
-                    if (clones != null)
-                    {
-                        clones.Remove(this);
-                    }
+                    clones?.Remove(this);
 
                     if (isClone)
                     {
diff --git a/src/Lucene.Net/Store/RAMFile.cs b/src/Lucene.Net/Store/RAMFile.cs
index 2937ca9dc..11b512df6 100644
--- a/src/Lucene.Net/Store/RAMFile.cs
+++ b/src/Lucene.Net/Store/RAMFile.cs
@@ -90,10 +90,7 @@ namespace Lucene.Net.Store
                 UninterruptableMonitor.Exit(this);
             }
 
-            if (directory != null)
-            {
-                directory.m_sizeInBytes.AddAndGet(size);
-            }
+            directory?.m_sizeInBytes.AddAndGet(size);
             return buffer;
         }
 
diff --git a/src/Lucene.Net/Util/IOUtils.cs b/src/Lucene.Net/Util/IOUtils.cs
index 71bcd740b..a90110860 100644
--- a/src/Lucene.Net/Util/IOUtils.cs
+++ b/src/Lucene.Net/Util/IOUtils.cs
@@ -175,10 +175,7 @@ namespace Lucene.Net.Util
             {
                 try
                 {
-                    if (@object != null)
-                    {
-                        @object.Dispose();
-                    }
+                    @object?.Dispose();
                 }
                 catch (Exception t) when (t.IsThrowable())
                 {
@@ -212,10 +209,7 @@ namespace Lucene.Net.Util
             {
                 try
                 {
-                    if (@object != null)
-                    {
-                        @object.Dispose();
-                    }
+                    @object?.Dispose();
                 }
                 catch (Exception t) when (t.IsThrowable())
                 {
@@ -255,10 +249,7 @@ namespace Lucene.Net.Util
             {
                 try
                 {
-                    if (@object != null)
-                    {
-                        @object.Dispose();
-                    }
+                    @object?.Dispose();
                 }
                 catch (Exception t) when (t.IsThrowable())
                 {
@@ -285,10 +276,7 @@ namespace Lucene.Net.Util
             {
                 try
                 {
-                    if (@object != null)
-                    {
-                        @object.Dispose();
-                    }
+                    @object?.Dispose();
                 }
                 catch (Exception t) when (t.IsThrowable())
                 {
@@ -316,10 +304,7 @@ namespace Lucene.Net.Util
             {
                 try
                 {
-                    if (o != null)
-                    {
-                        o.Dispose();
-                    }
+                    o?.Dispose();
                 }
                 catch (Exception t) when (t.IsThrowable())
                 {
@@ -338,10 +323,7 @@ namespace Lucene.Net.Util
             {
                 try
                 {
-                    if (@object != null)
-                    {
-                        @object.Dispose();
-                    }
+                    @object?.Dispose();
                 }
                 catch (Exception t) when (t.IsThrowable())
                 {