Github user cestella commented on a diff in the pull request:

    https://github.com/apache/metron/pull/650#discussion_r130879867
  
    --- Diff: 
metron-stellar/stellar-common/src/main/java/org/apache/metron/stellar/dsl/functions/MathFunctions.java
 ---
    @@ -19,45 +19,179 @@
      */
     package org.apache.metron.stellar.dsl.functions;
     
    +import org.apache.metron.stellar.common.utils.math.MathOperations;
    +import org.apache.metron.stellar.common.utils.math.StellarMathFunction;
     import org.apache.metron.stellar.dsl.Context;
     import org.apache.metron.stellar.dsl.ParseException;
     import org.apache.metron.stellar.dsl.Stellar;
     import org.apache.metron.stellar.dsl.StellarFunction;
     
     import java.util.List;
    +import java.util.function.Function;
     
     public class MathFunctions {
     
    +
       @Stellar(name="ABS"
               ,description="Returns the absolute value of a number."
               ,params = {
                     "number - The number to take the absolute value of"
                         }
               , returns="The absolute value of the number passed in."
               )
    -  public static class Abs implements StellarFunction {
    +  public static class Abs extends StellarMathFunction{
    +
    +
    +    public Abs() {
    +      super(MathOperations.ABS);
    +    }
    +  }
    +
    +  @Stellar(name="LOG10"
    +          ,description="Returns the log (base 10) of a number."
    +          ,params = {
    +                "number - The number to take the log (base 10) value of"
    +                    }
    +          , returns="The log (base 10) of the number passed in."
    +          )
    +  public static class Log10 extends StellarMathFunction {
    +   public Log10() {
    +      super(MathOperations.LOG10);
    +    }
    +
    +  }
    +
    +  @Stellar(name="LOG2"
    +          ,description="Returns the log (base 2) of a number."
    +          ,params = {
    +                "number - The number to take the log (base 2) value of"
    +                    }
    +          , returns="The log (base 2) of the number passed in."
    +          )
    +  public static class Log2 extends StellarMathFunction {
    +   public Log2() {
    +      super(MathOperations.LOG2);
    +    }
     
    -    @Override
    -    public Object apply(List<Object> args, Context context) throws 
ParseException {
    -      if(args.size() < 1) {
    -        return Double.NaN;
    -      }
    -      Number n = (Number)args.get(0);
    -      if(n == null) {
    -        return Double.NaN;
    -      }
    -      return Math.abs(n.doubleValue());
    +  }
    +
    +  @Stellar(name="LN"
    +          ,description="Returns the natural log of a number."
    +          ,params = {
    +                "number - The number to take the natural log value of"
    +                    }
    +          , returns="The natural log of the number passed in."
    +          )
    +  public static class Ln extends StellarMathFunction {
    +   public Ln() {
    +      super(MathOperations.LN);
         }
     
    -    @Override
    -    public void initialize(Context context) {
    +  }
     
    +  @Stellar(name="SQRT"
    +          ,description="Returns the square root of a number."
    +          ,params = {
    +                "number - The number to take the square root of"
    +                    }
    +          , returns="The square root of the number passed in."
    +          )
    +  public static class Sqrt extends StellarMathFunction {
    +   public Sqrt() {
    +      super(MathOperations.SQRT);
         }
     
    -    @Override
    -    public boolean isInitialized() {
    -      return true;
    +  }
    +
    +  @Stellar(name="CEIL"
    +          ,description="Returns the ceiling of a number."
    +          ,params = {
    +                "number - The number to take the ceiling of"
    +                    }
    +          , returns="The ceiling of the number passed in."
    +          )
    +  public static class Ceil extends StellarMathFunction {
    +   public Ceil() {
    +      super(MathOperations.CEIL);
         }
    +
       }
     
    +  @Stellar(name="FLOOR"
    +          ,description="Returns the floor of a number."
    +          ,params = {
    +                "number - The number to take the floor of"
    +                    }
    +          , returns="The floor of the number passed in."
    +          )
    +  public static class Floor extends StellarMathFunction {
    +   public Floor() {
    +      super(MathOperations.FLOOR);
    +    }
    +  }
    +
    +  @Stellar(name="SIN"
    +          ,description="Returns the sin of a number."
    +          ,params = {
    +                "number - The number to take the sin of"
    +                    }
    +          , returns="The sin of the number passed in."
    +          )
    +  public static class Sin extends StellarMathFunction {
    +   public Sin() {
    +      super(MathOperations.SIN);
    +    }
    +  }
    +
    +  @Stellar(name="COS"
    +          ,description="Returns the cos of a number."
    +          ,params = {
    +                "number - The number to take the cos of"
    +                    }
    +          , returns="The cos of the number passed in."
    +          )
    +  public static class Cos extends StellarMathFunction {
    +   public Cos() {
    +      super(MathOperations.COS);
    +    }
    +  }
    +
    +  @Stellar(name="TAN"
    +          ,description="Returns the tan of a number."
    +          ,params = {
    +                "number - The number to take the tan of"
    +                    }
    +          , returns="The tan of the number passed in."
    +          )
    +  public static class Tan extends StellarMathFunction {
    +   public Tan() {
    +      super(MathOperations.TAN);
    +    }
    +  }
    +
    +  @Stellar(name="EXP"
    +          ,description="Returns Euler's number raised to the power of the 
argument"
    +          ,params = {
    +                "number - The power to which e is raised."
    +                    }
    +          , returns="Euler's number raised to the power of the argument."
    +          )
    +  public static class Exp extends StellarMathFunction {
    +   public Exp() {
    +      super(MathOperations.EXP);
    +    }
    +  }
    +
    +  @Stellar(name="ROUND"
    +          ,description="Rounds a number to the nearest integer"
    --- End diff --
    
    Yeah, I documented it in the most recent commit.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to