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 aeaf8193b2bea76e307aa5d5cf61a1c152df1db9 Author: Shad Storhaug <[email protected]> AuthorDate: Tue Sep 3 23:58:38 2019 +0700 Added various TODOs, mostly about analyzing APIs to check whether it makes sense to pass CultureInfo --- .../PostingsHighlight/PassageFormatter.cs | 2 +- .../Function/DocValues/DoubleDocValues.cs | 4 ++-- .../Function/DocValues/FloatDocValues.cs | 2 +- .../Function/DocValues/IntDocValues.cs | 4 ++-- .../Function/DocValues/LongDocValues.cs | 4 ++-- src/Lucene.Net.Queries/Function/FunctionValues.cs | 4 ++-- .../Function/ValueSources/ByteFieldSource.cs | 2 +- .../Function/ValueSources/DocFreqValueSource.cs | 4 ++-- .../Function/ValueSources/DoubleConstValueSource.cs | 2 +- .../Function/ValueSources/EnumFieldSource.cs | 20 +++++++------------- .../Function/ValueSources/IntFieldSource.cs | 2 +- .../Function/ValueSources/LinearFloatFunction.cs | 2 +- .../Function/ValueSources/LongFieldSource.cs | 6 +++--- .../Function/ValueSources/ReciprocalFloatFunction.cs | 4 ++-- .../Function/ValueSources/ScaleFloatFunction.cs | 2 +- .../Function/ValueSources/ShortFieldSource.cs | 2 +- .../Classic/QueryParserBase.cs | 2 +- .../Standard/Processors/NumericQueryNodeProcessor.cs | 8 ++++---- .../Processors/NumericRangeQueryNodeProcessor.cs | 8 ++++---- .../Simple/SimpleQueryParser.cs | 2 +- src/Lucene.Net/Index/SegmentInfos.cs | 2 +- 21 files changed, 41 insertions(+), 47 deletions(-) diff --git a/src/Lucene.Net.Highlighter/PostingsHighlight/PassageFormatter.cs b/src/Lucene.Net.Highlighter/PostingsHighlight/PassageFormatter.cs index 80f0e09..88348ed 100644 --- a/src/Lucene.Net.Highlighter/PostingsHighlight/PassageFormatter.cs +++ b/src/Lucene.Net.Highlighter/PostingsHighlight/PassageFormatter.cs @@ -40,7 +40,7 @@ namespace Lucene.Net.Search.PostingsHighlight /// return <see cref="string"/>, the <see cref="object.ToString()"/> method on the <see cref="object"/> /// returned by this method is used to compute the string. /// </returns> - public abstract object Format(Passage[] passages, string content); // LUCENENET TODO: Make return type generic? + public abstract object Format(Passage[] passages, string content); // LUCENENET TODO: API Make return type generic? } } #endif diff --git a/src/Lucene.Net.Queries/Function/DocValues/DoubleDocValues.cs b/src/Lucene.Net.Queries/Function/DocValues/DoubleDocValues.cs index 98e6b67..3d8cc18 100644 --- a/src/Lucene.Net.Queries/Function/DocValues/DoubleDocValues.cs +++ b/src/Lucene.Net.Queries/Function/DocValues/DoubleDocValues.cs @@ -78,7 +78,7 @@ namespace Lucene.Net.Queries.Function.DocValues public override abstract double DoubleVal(int doc); - public override string StrVal(int doc) + public override string StrVal(int doc) // LUCENENET TODO: API - Add overload to include CultureInfo ? { return Convert.ToString(DoubleVal(doc)); } @@ -94,7 +94,7 @@ namespace Lucene.Net.Queries.Function.DocValues } public override ValueSourceScorer GetRangeScorer(IndexReader reader, string lowerVal, string upperVal, - bool includeLower, bool includeUpper) + bool includeLower, bool includeUpper) // LUCENENET TODO: API - Add overload to include CultureInfo ? { double lower, upper; diff --git a/src/Lucene.Net.Queries/Function/DocValues/FloatDocValues.cs b/src/Lucene.Net.Queries/Function/DocValues/FloatDocValues.cs index 91d0b9a..85f562b 100644 --- a/src/Lucene.Net.Queries/Function/DocValues/FloatDocValues.cs +++ b/src/Lucene.Net.Queries/Function/DocValues/FloatDocValues.cs @@ -74,7 +74,7 @@ namespace Lucene.Net.Queries.Function.DocValues return (double)SingleVal(doc); } - public override string StrVal(int doc) + public override string StrVal(int doc) // LUCENENET TODO: API - Add overload to include CultureInfo ? { return Convert.ToString(SingleVal(doc)); } diff --git a/src/Lucene.Net.Queries/Function/DocValues/IntDocValues.cs b/src/Lucene.Net.Queries/Function/DocValues/IntDocValues.cs index 01f66f0..6d16209 100644 --- a/src/Lucene.Net.Queries/Function/DocValues/IntDocValues.cs +++ b/src/Lucene.Net.Queries/Function/DocValues/IntDocValues.cs @@ -75,7 +75,7 @@ namespace Lucene.Net.Queries.Function.DocValues return (double)Int32Val(doc); } - public override string StrVal(int doc) + public override string StrVal(int doc) // LUCENENET TODO: API - Add overload to include CultureInfo ? { return Convert.ToString(Int32Val(doc)); } @@ -90,7 +90,7 @@ namespace Lucene.Net.Queries.Function.DocValues return m_vs.GetDescription() + '=' + StrVal(doc); } - public override ValueSourceScorer GetRangeScorer(IndexReader reader, string lowerVal, string upperVal, bool includeLower, bool includeUpper) + public override ValueSourceScorer GetRangeScorer(IndexReader reader, string lowerVal, string upperVal, bool includeLower, bool includeUpper) // LUCENENET TODO: API - Add overload to include CultureInfo ? { int lower, upper; diff --git a/src/Lucene.Net.Queries/Function/DocValues/LongDocValues.cs b/src/Lucene.Net.Queries/Function/DocValues/LongDocValues.cs index f779a60..7b68cdf 100644 --- a/src/Lucene.Net.Queries/Function/DocValues/LongDocValues.cs +++ b/src/Lucene.Net.Queries/Function/DocValues/LongDocValues.cs @@ -77,7 +77,7 @@ namespace Lucene.Net.Queries.Function.DocValues return Int64Val(doc) != 0; } - public override string StrVal(int doc) + public override string StrVal(int doc) // LUCENENET TODO: API - Add overload to include CultureInfo ? { return Convert.ToString(Int64Val(doc)); } @@ -95,7 +95,7 @@ namespace Lucene.Net.Queries.Function.DocValues /// <summary> /// NOTE: This was externalToLong() in Lucene /// </summary> - protected virtual long ExternalToInt64(string extVal) + protected virtual long ExternalToInt64(string extVal) // LUCENENET TODO: API - Add overload to include CultureInfo ? { return Convert.ToInt64(extVal); } diff --git a/src/Lucene.Net.Queries/Function/FunctionValues.cs b/src/Lucene.Net.Queries/Function/FunctionValues.cs index 9f2e296..76273b5 100644 --- a/src/Lucene.Net.Queries/Function/FunctionValues.cs +++ b/src/Lucene.Net.Queries/Function/FunctionValues.cs @@ -227,7 +227,7 @@ namespace Lucene.Net.Queries.Function } // TODO: should we make a termVal, fills BytesRef[]? - public virtual void StrVal(int doc, string[] vals) + public virtual void StrVal(int doc, string[] vals) // LUCENENET TODO: API - Add overload to include CultureInfo ? { throw new System.NotSupportedException(); } @@ -247,7 +247,7 @@ namespace Lucene.Net.Queries.Function // a setup cost - parsing and normalizing params, and doing a binary search on the StringIndex. // TODO: change "reader" to AtomicReaderContext public virtual ValueSourceScorer GetRangeScorer(IndexReader reader, string lowerVal, string upperVal, - bool includeLower, bool includeUpper) + bool includeLower, bool includeUpper) // LUCENENET TODO: API - Add overload to include CultureInfo ? { float lower; float upper; diff --git a/src/Lucene.Net.Queries/Function/ValueSources/ByteFieldSource.cs b/src/Lucene.Net.Queries/Function/ValueSources/ByteFieldSource.cs index 290c3a9..4a339b6 100644 --- a/src/Lucene.Net.Queries/Function/ValueSources/ByteFieldSource.cs +++ b/src/Lucene.Net.Queries/Function/ValueSources/ByteFieldSource.cs @@ -108,7 +108,7 @@ namespace Lucene.Net.Queries.Function.ValueSources return (double)(sbyte)arr.Get(doc); } - public override string StrVal(int doc) + public override string StrVal(int doc) // LUCENENET TODO: API - Add overload to include CultureInfo ? { return Convert.ToString((sbyte)arr.Get(doc)); } diff --git a/src/Lucene.Net.Queries/Function/ValueSources/DocFreqValueSource.cs b/src/Lucene.Net.Queries/Function/ValueSources/DocFreqValueSource.cs index be51be6..3c5bb0a 100644 --- a/src/Lucene.Net.Queries/Function/ValueSources/DocFreqValueSource.cs +++ b/src/Lucene.Net.Queries/Function/ValueSources/DocFreqValueSource.cs @@ -36,7 +36,7 @@ namespace Lucene.Net.Queries.Function.ValueSources internal readonly string sval; internal readonly ValueSource parent; - internal ConstInt32DocValues(int val, ValueSource parent) + internal ConstInt32DocValues(int val, ValueSource parent) // LUCENENET TODO: API - Add overload to include CultureInfo ? : base(parent) { ival = val; @@ -93,7 +93,7 @@ namespace Lucene.Net.Queries.Function.ValueSources internal readonly string sval; internal readonly ValueSource parent; - internal ConstDoubleDocValues(double val, ValueSource parent) + internal ConstDoubleDocValues(double val, ValueSource parent) // LUCENENET TODO: API - Add overload to include CultureInfo ? : base(parent) { ival = (int)val; diff --git a/src/Lucene.Net.Queries/Function/ValueSources/DoubleConstValueSource.cs b/src/Lucene.Net.Queries/Function/ValueSources/DoubleConstValueSource.cs index 618205d..d27859d 100644 --- a/src/Lucene.Net.Queries/Function/ValueSources/DoubleConstValueSource.cs +++ b/src/Lucene.Net.Queries/Function/ValueSources/DoubleConstValueSource.cs @@ -87,7 +87,7 @@ namespace Lucene.Net.Queries.Function.ValueSources return outerInstance.constant; } - public override string StrVal(int doc) + public override string StrVal(int doc) // LUCENENET TODO: API - Add overload to include CultureInfo ? { return Convert.ToString(outerInstance.constant); } diff --git a/src/Lucene.Net.Queries/Function/ValueSources/EnumFieldSource.cs b/src/Lucene.Net.Queries/Function/ValueSources/EnumFieldSource.cs index b8dfe92..d8a4d65 100644 --- a/src/Lucene.Net.Queries/Function/ValueSources/EnumFieldSource.cs +++ b/src/Lucene.Net.Queries/Function/ValueSources/EnumFieldSource.cs @@ -52,23 +52,17 @@ namespace Lucene.Net.Queries.Function.ValueSources /// <summary> /// NOTE: This was tryParseInt() in Lucene /// </summary> - private static int? TryParseInt32(string valueStr) + private static int? TryParseInt32(string valueStr) // LUCENENET TODO: API - Add overload to include CultureInfo ? { - int? intValue = null; - try - { - intValue = Convert.ToInt32(valueStr); - } - catch (FormatException) - { - } - return intValue; + if (int.TryParse(valueStr, out int intValue)) + return intValue; + return null; } /// <summary> /// NOTE: This was intValueToStringValue() in Lucene /// </summary> - private string Int32ValueToStringValue(int? intVal) + private string Int32ValueToStringValue(int? intVal) // LUCENENET TODO: API - Add overload to include CultureInfo { if (intVal == null) { @@ -87,7 +81,7 @@ namespace Lucene.Net.Queries.Function.ValueSources /// <summary> /// NOTE: This was stringValueToIntValue() in Lucene /// </summary> - private int? StringValueToInt32Value(string stringVal) + private int? StringValueToInt32Value(string stringVal) // LUCENENET TODO: API - Add overload to include CultureInfo { if (stringVal == null) { @@ -199,7 +193,7 @@ namespace Lucene.Net.Queries.Function.ValueSources } - public override ValueSourceScorer GetRangeScorer(IndexReader reader, string lowerVal, string upperVal, bool includeLower, bool includeUpper) + public override ValueSourceScorer GetRangeScorer(IndexReader reader, string lowerVal, string upperVal, bool includeLower, bool includeUpper) // LUCENENET TODO: API - Add overload to include CultureInfo ? { int? lower = outerInstance.StringValueToInt32Value(lowerVal); int? upper = outerInstance.StringValueToInt32Value(upperVal); diff --git a/src/Lucene.Net.Queries/Function/ValueSources/IntFieldSource.cs b/src/Lucene.Net.Queries/Function/ValueSources/IntFieldSource.cs index 7498cda..8eddd02 100644 --- a/src/Lucene.Net.Queries/Function/ValueSources/IntFieldSource.cs +++ b/src/Lucene.Net.Queries/Function/ValueSources/IntFieldSource.cs @@ -106,7 +106,7 @@ namespace Lucene.Net.Queries.Function.ValueSources return (double)arr.Get(doc); } - public override string StrVal(int doc) + public override string StrVal(int doc) // LUCENENET TODO: API - Add overload to include CultureInfo ? { return Convert.ToString(arr.Get(doc)); } diff --git a/src/Lucene.Net.Queries/Function/ValueSources/LinearFloatFunction.cs b/src/Lucene.Net.Queries/Function/ValueSources/LinearFloatFunction.cs index ba7f20b..cc61bec 100644 --- a/src/Lucene.Net.Queries/Function/ValueSources/LinearFloatFunction.cs +++ b/src/Lucene.Net.Queries/Function/ValueSources/LinearFloatFunction.cs @@ -74,7 +74,7 @@ namespace Lucene.Net.Queries.Function.ValueSources { return vals.SingleVal(doc) * outerInstance.m_slope + outerInstance.m_intercept; } - public override string ToString(int doc) + public override string ToString(int doc) // LUCENENET TODO: API - Add overload to include CultureInfo ? { return outerInstance.m_slope + "*float(" + vals.ToString(doc) + ")+" + outerInstance.m_intercept; } diff --git a/src/Lucene.Net.Queries/Function/ValueSources/LongFieldSource.cs b/src/Lucene.Net.Queries/Function/ValueSources/LongFieldSource.cs index 959da29..4d7cbe9 100644 --- a/src/Lucene.Net.Queries/Function/ValueSources/LongFieldSource.cs +++ b/src/Lucene.Net.Queries/Function/ValueSources/LongFieldSource.cs @@ -54,7 +54,7 @@ namespace Lucene.Net.Queries.Function.ValueSources /// <summary> /// NOTE: This was externalToLong() in Lucene /// </summary> - public virtual long ExternalToInt64(string extVal) + public virtual long ExternalToInt64(string extVal) // LUCENENET TODO: API - Add overload to include CultureInfo ? { return Convert.ToInt64(extVal); } @@ -70,7 +70,7 @@ namespace Lucene.Net.Queries.Function.ValueSources /// <summary> /// NOTE: This was longToString() in Lucene /// </summary> - public virtual string Int64ToString(long val) + public virtual string Int64ToString(long val) // LUCENENET TODO: API - Add overload to include CultureInfo ? { return Int64ToObject(val).ToString(); } @@ -115,7 +115,7 @@ namespace Lucene.Net.Queries.Function.ValueSources return valid.Get(doc) ? outerInstance.Int64ToObject(arr.Get(doc)) : null; } - public override string StrVal(int doc) + public override string StrVal(int doc) // LUCENENET TODO: API - Add overload to include CultureInfo ? { return valid.Get(doc) ? outerInstance.Int64ToString(arr.Get(doc)) : null; } diff --git a/src/Lucene.Net.Queries/Function/ValueSources/ReciprocalFloatFunction.cs b/src/Lucene.Net.Queries/Function/ValueSources/ReciprocalFloatFunction.cs index 4f8bae6..6faac50 100644 --- a/src/Lucene.Net.Queries/Function/ValueSources/ReciprocalFloatFunction.cs +++ b/src/Lucene.Net.Queries/Function/ValueSources/ReciprocalFloatFunction.cs @@ -83,7 +83,7 @@ namespace Lucene.Net.Queries.Function.ValueSources { return outerInstance.m_a / (outerInstance.m_m * vals.SingleVal(doc) + outerInstance.m_b); } - public override string ToString(int doc) + public override string ToString(int doc) // LUCENENET TODO: API - Add overload to include CultureInfo ? { return Convert.ToString(outerInstance.m_a) + "/(" + outerInstance.m_m + "*float(" + vals.ToString(doc) + ')' + '+' + outerInstance.m_b + ')'; } @@ -94,7 +94,7 @@ namespace Lucene.Net.Queries.Function.ValueSources m_source.CreateWeight(context, searcher); } - public override string GetDescription() + public override string GetDescription() // LUCENENET TODO: API - Add overload to include CultureInfo ? { return Convert.ToString(m_a) + "/(" + m_m + "*float(" + m_source.GetDescription() + ")" + "+" + m_b + ')'; } diff --git a/src/Lucene.Net.Queries/Function/ValueSources/ScaleFloatFunction.cs b/src/Lucene.Net.Queries/Function/ValueSources/ScaleFloatFunction.cs index 4c798a2..b205e7a 100644 --- a/src/Lucene.Net.Queries/Function/ValueSources/ScaleFloatFunction.cs +++ b/src/Lucene.Net.Queries/Function/ValueSources/ScaleFloatFunction.cs @@ -146,7 +146,7 @@ namespace Lucene.Net.Queries.Function.ValueSources { return (vals.SingleVal(doc) - minSource) * scale + outerInstance.m_min; } - public override string ToString(int doc) + public override string ToString(int doc) // LUCENENET TODO: API - Add overload to include CultureInfo ? { return "scale(" + vals.ToString(doc) + ",toMin=" + outerInstance.m_min + ",toMax=" + outerInstance.m_max + ",fromMin=" + minSource + ",fromMax=" + maxSource + ")"; } diff --git a/src/Lucene.Net.Queries/Function/ValueSources/ShortFieldSource.cs b/src/Lucene.Net.Queries/Function/ValueSources/ShortFieldSource.cs index 04fa3fd..c3636e1 100644 --- a/src/Lucene.Net.Queries/Function/ValueSources/ShortFieldSource.cs +++ b/src/Lucene.Net.Queries/Function/ValueSources/ShortFieldSource.cs @@ -109,7 +109,7 @@ namespace Lucene.Net.Queries.Function.ValueSources return arr.Get(doc); } - public override string StrVal(int doc) + public override string StrVal(int doc) // LUCENENET TODO: API - Add overload to include CultureInfo ? { return Convert.ToString(arr.Get(doc)); } diff --git a/src/Lucene.Net.QueryParser/Classic/QueryParserBase.cs b/src/Lucene.Net.QueryParser/Classic/QueryParserBase.cs index 67e56b8..bcd4fa8 100644 --- a/src/Lucene.Net.QueryParser/Classic/QueryParserBase.cs +++ b/src/Lucene.Net.QueryParser/Classic/QueryParserBase.cs @@ -295,7 +295,7 @@ namespace Lucene.Net.QueryParsers.Classic /// the current thread, QueryParser will utilize it. You can also explicitly set a culture. /// Setting the culture to <c>null</c> will restore the default behavior if you have explicitly set a culture. /// </summary> - public virtual CultureInfo Locale + public virtual CultureInfo Locale // LUCENENET TODO: API - Rename Culture { get { return this.locale == null ? CultureInfo.CurrentCulture : this.locale; } set { this.locale = value; } diff --git a/src/Lucene.Net.QueryParser/Flexible/Standard/Processors/NumericQueryNodeProcessor.cs b/src/Lucene.Net.QueryParser/Flexible/Standard/Processors/NumericQueryNodeProcessor.cs index cb71fac..1179035 100644 --- a/src/Lucene.Net.QueryParser/Flexible/Standard/Processors/NumericQueryNodeProcessor.cs +++ b/src/Lucene.Net.QueryParser/Flexible/Standard/Processors/NumericQueryNodeProcessor.cs @@ -101,16 +101,16 @@ namespace Lucene.Net.QueryParsers.Flexible.Standard.Processors switch (numericConfig.Type) { case NumericType.INT64: - number = Convert.ToInt64(number); + number = Convert.ToInt64(number); // LUCENENET TODO: Find a way to pass culture break; case NumericType.INT32: - number = Convert.ToInt32(number); + number = Convert.ToInt32(number); // LUCENENET TODO: Find a way to pass culture break; case NumericType.DOUBLE: - number = Convert.ToDouble(number); + number = Convert.ToDouble(number); // LUCENENET TODO: Find a way to pass culture break; case NumericType.SINGLE: - number = Convert.ToSingle(number); + number = Convert.ToSingle(number); // LUCENENET TODO: Find a way to pass culture break; } diff --git a/src/Lucene.Net.QueryParser/Flexible/Standard/Processors/NumericRangeQueryNodeProcessor.cs b/src/Lucene.Net.QueryParser/Flexible/Standard/Processors/NumericRangeQueryNodeProcessor.cs index 2061f75..ebd53a8 100644 --- a/src/Lucene.Net.QueryParser/Flexible/Standard/Processors/NumericRangeQueryNodeProcessor.cs +++ b/src/Lucene.Net.QueryParser/Flexible/Standard/Processors/NumericRangeQueryNodeProcessor.cs @@ -113,19 +113,19 @@ namespace Lucene.Net.QueryParsers.Flexible.Standard.Processors switch (numericConfig.Type) { case NumericType.INT64: - if (upperNumber != null) upperNumber = Convert.ToInt64(upperNumber); + if (upperNumber != null) upperNumber = Convert.ToInt64(upperNumber); // LUCENENET TODO: Find a way to pass culture if (lowerNumber != null) lowerNumber = Convert.ToInt64(lowerNumber); break; case NumericType.INT32: - if (upperNumber != null) upperNumber = Convert.ToInt32(upperNumber); + if (upperNumber != null) upperNumber = Convert.ToInt32(upperNumber); // LUCENENET TODO: Find a way to pass culture if (lowerNumber != null) lowerNumber = Convert.ToInt32(lowerNumber); break; case NumericType.DOUBLE: - if (upperNumber != null) upperNumber = Convert.ToDouble(upperNumber); + if (upperNumber != null) upperNumber = Convert.ToDouble(upperNumber); // LUCENENET TODO: Find a way to pass culture if (lowerNumber != null) lowerNumber = Convert.ToDouble(lowerNumber); break; case NumericType.SINGLE: - if (upperNumber != null) upperNumber = Convert.ToSingle(upperNumber); + if (upperNumber != null) upperNumber = Convert.ToSingle(upperNumber); // LUCENENET TODO: Find a way to pass culture if (lowerNumber != null) lowerNumber = Convert.ToSingle(lowerNumber); break; } diff --git a/src/Lucene.Net.QueryParser/Simple/SimpleQueryParser.cs b/src/Lucene.Net.QueryParser/Simple/SimpleQueryParser.cs index 7438bdd..80ea56d 100644 --- a/src/Lucene.Net.QueryParser/Simple/SimpleQueryParser.cs +++ b/src/Lucene.Net.QueryParser/Simple/SimpleQueryParser.cs @@ -569,7 +569,7 @@ namespace Lucene.Net.QueryParsers.Simple } } int fuzziness = 0; - int.TryParse(new string(slopText, 0, slopLength), out fuzziness); + int.TryParse(new string(slopText, 0, slopLength), out fuzziness); // LUCENENET TODO: Find a way to pass culture // negative -> 0 if (fuzziness < 0) { diff --git a/src/Lucene.Net/Index/SegmentInfos.cs b/src/Lucene.Net/Index/SegmentInfos.cs index 455cb09..1eaad2e 100644 --- a/src/Lucene.Net/Index/SegmentInfos.cs +++ b/src/Lucene.Net/Index/SegmentInfos.cs @@ -177,7 +177,7 @@ namespace Lucene.Net.Index /// Returns <see cref="SegmentCommitInfo"/> at the provided /// index. /// </summary> - public SegmentCommitInfo Info(int i) + public SegmentCommitInfo Info(int i) // LUCENENET TODO: API - add indexer for this class { return segments[i]; }
