Uploaded image for project: 'Solr'
  1. Solr
  2. SOLR-10356

Add Streaming Evaluators for basic math functions

    Details

    • Type: Improvement
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Security Level: Public (Default Security Level. Issues are Public)
    • Labels:
      None
    1. SOLR-10356.patch
      115 kB
      Dennis Gove
    2. SOLR-10356.patch
      109 kB
      Dennis Gove
    3. SOLR-10356.patch
      86 kB
      Dennis Gove
    4. SOLR-10356.patch
      23 kB
      Dennis Gove

      Activity

      Hide
      dpgove Dennis Gove added a comment -
      pow(a,b) // a^b
      mod(a,b) // a % b
      ceil(a) // Math.ceil(a)
      floor(a) // Math.floor(a)
      
      Show
      dpgove Dennis Gove added a comment - pow(a,b) // a^b mod(a,b) // a % b ceil(a) // Math .ceil(a) floor(a) // Math .floor(a)
      Hide
      dpgove Dennis Gove added a comment -

      I'm going to keep this open for a week or so and if anyone has other basic math evaluators you'd like to see added please just let me know and I'll include them here.

      Show
      dpgove Dennis Gove added a comment - I'm going to keep this open for a week or so and if anyone has other basic math evaluators you'd like to see added please just let me know and I'll include them here.
      Hide
      vish741 Vish Persaud added a comment -

      Is this intended for streaming expressions? How about abs(a), coalesce(a,b), round(a), round(a,b), sqrt(a).

      Show
      vish741 Vish Persaud added a comment - Is this intended for streaming expressions? How about abs(a), coalesce(a,b), round(a), round(a,b), sqrt(a).
      Hide
      dpgove Dennis Gove added a comment -

      Yeah, intended for streaming expressions. So far we have the following

      abs(a) // |a|
      add(a,b,...,z) // a + b + ... + z
      div(a,b) // a/b
      mult(a,b,...,z) // a * b * ... * z
      sub(a,b,...,z) // a - b - ... - z
      log(a) // natural log
      pow(a,b) // a^b
      mod(a,b) // a % b
      ceil(a) // ceiling of a
      floor(a) // floor of a
      

      I'll add these ones

      coalesce(a,b,...,z) // this won't actually be specific to math, we can coalesce on any value type
      round(a)
      sqrt(a)
      cbrt(a) // cubed root
      sin(a) // sine of a
      sinh(a) // hyperbolic sine of a
      asin(a) // arc sine of a
      cos(a) // cosine of a
      cosh(a) // hyperbolic cosine of a
      acos(a) // arc cosine of a
      tan(a) // tangent of a
      tanh(a) // hyperbolic tangent of a
      atan(a) // arc tangent of a
      

      What were you thinking for round(a,b)?

      Show
      dpgove Dennis Gove added a comment - Yeah, intended for streaming expressions. So far we have the following abs(a) // |a| add(a,b,...,z) // a + b + ... + z div(a,b) // a/b mult(a,b,...,z) // a * b * ... * z sub(a,b,...,z) // a - b - ... - z log(a) // natural log pow(a,b) // a^b mod(a,b) // a % b ceil(a) // ceiling of a floor(a) // floor of a I'll add these ones coalesce(a,b,...,z) // this won't actually be specific to math, we can coalesce on any value type round(a) sqrt(a) cbrt(a) // cubed root sin(a) // sine of a sinh(a) // hyperbolic sine of a asin(a) // arc sine of a cos(a) // cosine of a cosh(a) // hyperbolic cosine of a acos(a) // arc cosine of a tan(a) // tangent of a tanh(a) // hyperbolic tangent of a atan(a) // arc tangent of a What were you thinking for round(a,b)?
      Hide
      vish741 Vish Persaud added a comment -

      In round(a,b), 'a' is the value to round and 'b' is the desired number of decimal places, i.e.:

      round(4.17) = 4
      round(4.17,0) = 4
      round(4.17,1) = 4.2
      round(4.17,9) = 4.17

      round(a) is same as java.lang.Math.round(a), but I'm unclear if there's a sufficiently performant implementation for round(a,b). After a quick search, it looks like there are implementations involving Math.round with additional multiplication & division, and some involving DecimalFormat, NumberFormat, or BigDecimal. So not sure if round(a,b) is worthwhile.

      Show
      vish741 Vish Persaud added a comment - In round(a,b), 'a' is the value to round and 'b' is the desired number of decimal places, i.e.: round(4.17) = 4 round(4.17,0) = 4 round(4.17,1) = 4.2 round(4.17,9) = 4.17 round(a) is same as java.lang.Math.round(a), but I'm unclear if there's a sufficiently performant implementation for round(a,b). After a quick search, it looks like there are implementations involving Math.round with additional multiplication & division, and some involving DecimalFormat, NumberFormat, or BigDecimal. So not sure if round(a,b) is worthwhile.
      Hide
      dpgove Dennis Gove added a comment -

      I haven't confirmed, but I think BigDecimal can accomplish this by setting the scale

      a.setScale(b, RoundingMode.HALF_UP)
      
      Show
      dpgove Dennis Gove added a comment - I haven't confirmed, but I think BigDecimal can accomplish this by setting the scale a.setScale(b, RoundingMode.HALF_UP)
      Hide
      vish741 Vish Persaud added a comment -

      I think the scale will control placement of the decimal (10^1, 10^2, 10^-1, etc), as opposed to rounding. Seems like rounding while retaining one or more decimal places would need to be handled by setting precision in BigDecimal. In any case, not sure how performant that is, compared to say basic rounding to integers via Math.round().

      Show
      vish741 Vish Persaud added a comment - I think the scale will control placement of the decimal (10^1, 10^2, 10^-1, etc), as opposed to rounding. Seems like rounding while retaining one or more decimal places would need to be handled by setting precision in BigDecimal. In any case, not sure how performant that is, compared to say basic rounding to integers via Math.round().
      Hide
      dpgove Dennis Gove added a comment -

      Adds

      +      .withFunctionName("pow", PowerEvaluator.class)
      +      .withFunctionName("mod", ModuloEvaluator.class)
      +      .withFunctionName("ceil", CeilingEvaluator.class)
      +      .withFunctionName("floor", FloorEvaluator.class)
      +      .withFunctionName("sin", SineEvaluator.class)
      +      .withFunctionName("asin", ArcSineEvaluator.class)
      +      .withFunctionName("sinh", HyperbolicSineEvaluator.class)
      +      .withFunctionName("cos", CosineEvaluator.class)
      +      .withFunctionName("acos", ArcCosineEvaluator.class)
      +      .withFunctionName("cosh", HyperbolicCosineEvaluator.class)
      +      .withFunctionName("tan", TangentEvaluator.class)
      +      .withFunctionName("atan", ArcTangentEvaluator.class)
      +      .withFunctionName("tanh", HyperbolicTangentEvaluator.class)
      
      Show
      dpgove Dennis Gove added a comment - Adds + .withFunctionName( "pow" , PowerEvaluator.class) + .withFunctionName( "mod" , ModuloEvaluator.class) + .withFunctionName( "ceil" , CeilingEvaluator.class) + .withFunctionName( "floor" , FloorEvaluator.class) + .withFunctionName( "sin" , SineEvaluator.class) + .withFunctionName( "asin" , ArcSineEvaluator.class) + .withFunctionName( "sinh" , HyperbolicSineEvaluator.class) + .withFunctionName( "cos" , CosineEvaluator.class) + .withFunctionName( "acos" , ArcCosineEvaluator.class) + .withFunctionName( "cosh" , HyperbolicCosineEvaluator.class) + .withFunctionName( "tan" , TangentEvaluator.class) + .withFunctionName( "atan" , ArcTangentEvaluator.class) + .withFunctionName( "tanh" , HyperbolicTangentEvaluator.class)
      Hide
      dpgove Dennis Gove added a comment -

      Includes everything discussed so far (except round(a,b)), including tests.

      Show
      dpgove Dennis Gove added a comment - Includes everything discussed so far (except round(a,b)), including tests.
      Hide
      dpgove Dennis Gove added a comment -

      Includes some refactoring required due to an addition of StreamContext into the evaluators.

      Show
      dpgove Dennis Gove added a comment - Includes some refactoring required due to an addition of StreamContext into the evaluators.
      Hide
      jira-bot ASF subversion and git services added a comment -

      Commit 674ce4e89393efe3147629e76f053c9901c182dc in lucene-solr's branch refs/heads/master from Dennis Gove
      [ https://git-wip-us.apache.org/repos/asf?p=lucene-solr.git;h=674ce4e ]

      SOLR-10356: Adds basic math streaming evaluators

      Show
      jira-bot ASF subversion and git services added a comment - Commit 674ce4e89393efe3147629e76f053c9901c182dc in lucene-solr's branch refs/heads/master from Dennis Gove [ https://git-wip-us.apache.org/repos/asf?p=lucene-solr.git;h=674ce4e ] SOLR-10356 : Adds basic math streaming evaluators
      Hide
      jira-bot ASF subversion and git services added a comment -

      Commit 6ce02bc693d4ef67872e9c536155c5308227d6e9 in lucene-solr's branch refs/heads/branch_6x from Dennis Gove
      [ https://git-wip-us.apache.org/repos/asf?p=lucene-solr.git;h=6ce02bc ]

      SOLR-10356: Adds basic math streaming evaluators

      Show
      jira-bot ASF subversion and git services added a comment - Commit 6ce02bc693d4ef67872e9c536155c5308227d6e9 in lucene-solr's branch refs/heads/branch_6x from Dennis Gove [ https://git-wip-us.apache.org/repos/asf?p=lucene-solr.git;h=6ce02bc ] SOLR-10356 : Adds basic math streaming evaluators
      Hide
      erickerickson Erick Erickson added a comment -

      Can this be closed?

      Show
      erickerickson Erick Erickson added a comment - Can this be closed?

        People

        • Assignee:
          dpgove Dennis Gove
          Reporter:
          dpgove Dennis Gove
        • Votes:
          1 Vote for this issue
          Watchers:
          4 Start watching this issue

          Dates

          • Created:
            Updated:

            Development