You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucenenet.apache.org by GitBox <gi...@apache.org> on 2021/12/10 11:42:51 UTC

[GitHub] [lucenenet] NightOwl888 opened a new pull request #570: BREAKING: Fix for Numeric Type Boxing/Unboxing (fixes #428, fixes #429)

NightOwl888 opened a new pull request #570:
URL: https://github.com/apache/lucenenet/pull/570


   Fixes #428, Fixes #429.
   
   This reverts `FieldComparer` to be closer to the Java implementation, which uses reference type wrappers for numeric value types so it is not so expensive to unbox them when placed in an `object[]` array.
   
   Note that the tests were all converted to use the fastest syntax to unbox the number:
   
   ```c#
   int value = (J2N.Numerics.Int32)objectWrapped; // Implicit conversion to System.Int32
   int value2 = ((J2N.Numerics.Number)objectWrapped2).ToInt32(); // Explicit conversion from unknown reference numeric type to Int32
   ```
   Although slower, using `Convert` methods are less verbose and more consistent:
   
   ```c#
   int value = Convert.ToInt32(objectWrapped); // objectWrapped2 is J2N.Numerics.Int32
   int value2 = Convert.ToInt32(objectWrapped2); // objectWrapped2 is unknown subclass of J2N.Numerics.Number
   ```
   
   There are also several other updates:
   
   - J2N parsers and formatters are used to convert to/from strings (these patch the broken floating point round tripping back to .NET Framework and change the default format to always include at least one place after the decimal point)
   - NumericRangeQuery<T> was also modified to eliminate boxing that was introduced by using `Convert.ToXXX` methods on generic value types.
   - Use `HasValue`/`Value` on nullable value types to reduce casting
   - Use `Nullable.Equals()` for comparing generic numeric types for equality
   - `Lucene.Net.Queries.ObjectVal` returns a `J2N.Numerics.Number`-derived type rather than a value type cast to `object`
   - **BREAKING:** `Lucene.Net.Search.FieldCache.IParser::TermsEnum()` Renamed method to `GetTermsEnum()` to match other APIs


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@lucenenet.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [lucenenet] NightOwl888 merged pull request #570: BREAKING: Fix for Numeric Type Boxing/Unboxing (fixes #428, fixes #429)

Posted by GitBox <gi...@apache.org>.
NightOwl888 merged pull request #570:
URL: https://github.com/apache/lucenenet/pull/570


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@lucenenet.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [lucenenet] NightOwl888 merged pull request #570: BREAKING: Fix for Numeric Type Boxing/Unboxing (fixes #428, fixes #429)

Posted by GitBox <gi...@apache.org>.
NightOwl888 merged pull request #570:
URL: https://github.com/apache/lucenenet/pull/570


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@lucenenet.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org