[jira] [Commented] (METRON-1038) Stellar should have a better collection of basic math operations

2017-08-03 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/METRON-1038?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16112471#comment-16112471
 ] 

ASF GitHub Bot commented on METRON-1038:


Github user cestella commented on the issue:

https://github.com/apache/metron/pull/650
  
Committed, but I wanted to make a comment about the BiFunction.  Honestly, 
I like the notion of providing candy for 2-arg functions like we did for 
single-arg functions.  I think it'll make it super easy for @simonellistonball 
to add `POWER`.


> Stellar should have a better collection of basic math operations
> 
>
> Key: METRON-1038
> URL: https://issues.apache.org/jira/browse/METRON-1038
> Project: Metron
>  Issue Type: Improvement
>Reporter: Casey Stella
>
> At the moment the math functions are woefully incomplete.  
> We should add at least the ones difficult or impossible to reconstruct using 
> existing stellar primitives/math functions:
> * log10
> * log2
> * ln
> * sqrt
> * ceil
> * floor
> * sin
> * cos
> * tan



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (METRON-1038) Stellar should have a better collection of basic math operations

2017-08-03 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/METRON-1038?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16112467#comment-16112467
 ] 

ASF GitHub Bot commented on METRON-1038:


Github user asfgit closed the pull request at:

https://github.com/apache/metron/pull/650


> Stellar should have a better collection of basic math operations
> 
>
> Key: METRON-1038
> URL: https://issues.apache.org/jira/browse/METRON-1038
> Project: Metron
>  Issue Type: Improvement
>Reporter: Casey Stella
>
> At the moment the math functions are woefully incomplete.  
> We should add at least the ones difficult or impossible to reconstruct using 
> existing stellar primitives/math functions:
> * log10
> * log2
> * ln
> * sqrt
> * ceil
> * floor
> * sin
> * cos
> * tan



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (METRON-1038) Stellar should have a better collection of basic math operations

2017-08-02 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/METRON-1038?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16111350#comment-16111350
 ] 

ASF GitHub Bot commented on METRON-1038:


Github user mattf-horton commented on the issue:

https://github.com/apache/metron/pull/650
  
+1, lgtm.  By the way, my mentions of BiFunction were incorrect because 
MathFunction takes an array of numbers as its (sole) argument.  But glad to see 
you added Min Args as well as Max Args.


> Stellar should have a better collection of basic math operations
> 
>
> Key: METRON-1038
> URL: https://issues.apache.org/jira/browse/METRON-1038
> Project: Metron
>  Issue Type: Improvement
>Reporter: Casey Stella
>
> At the moment the math functions are woefully incomplete.  
> We should add at least the ones difficult or impossible to reconstruct using 
> existing stellar primitives/math functions:
> * log10
> * log2
> * ln
> * sqrt
> * ceil
> * floor
> * sin
> * cos
> * tan



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (METRON-1038) Stellar should have a better collection of basic math operations

2017-08-02 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/METRON-1038?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16110968#comment-16110968
 ] 

ASF GitHub Bot commented on METRON-1038:


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

https://github.com/apache/metron/pull/650#discussion_r130886124
  
--- Diff: metron-stellar/stellar-common/README.md ---
@@ -101,58 +101,69 @@ In the core language functions, we support basic 
functional programming primitiv
 
 ## Stellar Core Functions
 
-|  
  |
-| --   
  |
-| [ `ABS`](../../metron-analytics/metron-statistics#abs)   
  |
-| [ `APPEND_IF_MISSING`](#append_if_missing)   
  |
-| [ `BIN`](../../metron-analytics/metron-statistics#bin)   
  |
-| [ `BLOOM_ADD`](#bloom_add)   
  |
-| [ `BLOOM_EXISTS`](#bloom_exists) 
  |
-| [ `BLOOM_INIT`](#bloom_init) 
  |
-| [ `BLOOM_MERGE`](#bloom_merge)   
  |
-| [ `CHOP`](#chop) 
  |
-| [ `CHOMP`](#chomp)   
  |
-| [ `COUNT_MATCHES`](#count_matches)   
  |
-| [ `DAY_OF_MONTH`](#day_of_month) 
  |
-| [ `DAY_OF_WEEK`](#day_of_week)   
  |
-| [ `DAY_OF_YEAR`](#day_of_year)   
  |
-| [ `DECODE`](#decode) 
  |
-| [ `DOMAIN_REMOVE_SUBDOMAINS`](#domain_remove_subdomains) 
  |
-| [ `DOMAIN_REMOVE_TLD`](#domain_remove_tld)   
  |
-| [ `DOMAIN_TO_TLD`](#domain_to_tld)   
  |
-| [ `ENCODE`](#encode) 
  |
-| [ `ENDS_WITH`](#ends_with)   
  |
-| [ `ENRICHMENT_EXISTS`](#enrichment_exists)   
  |
-| [ `ENRICHMENT_GET`](#enrichment_get) 
  |
-| [ `FILL_LEFT`](#fill_left)   
  |
-| [ `FILL_RIGHT`](#fill_right) 
  |
-| [ `FILTER`](#filter) 
  |
-| [ `FORMAT`](#format) 
  |
-| [ 
`HLLP_CARDINALITY`](../../metron-analytics/metron-statistics#hllp_cardinality)  
 |
-| [ `HLLP_INIT`](../../metron-analytics/metron-statistics#hllp_init)   
  |
-| [ `HLLP_MERGE`](../../metron-analytics/metron-statistics#hllp_merge) 
  |
-| [ `HLLP_OFFER`](../../metron-analytics/metron-statistics#hllp_offer) 
  |
-| [ `GEO_GET`](#geo_get)   
  |
-| [ `GET`](#get)   
  |
-| [ `GET_FIRST`](#get_first)   
  |
-| [ `GET_LAST`](#get_last) 
  |
-| [ `GET_SUPPORTED_ENCODINGS`](#get_supported_encodings)   
|
-| [ `IN_SUBNET`](#in_subnet)   
  |
-| [ `IS_DATE`](#is_date)   
  |
-| [ `IS_ENCODING`](#is_encoding)   
  |
-| [ `IS_DOMAIN`](#is_domain)   
  |
-| [ `IS_EMAIL`](#is_email)

[jira] [Commented] (METRON-1038) Stellar should have a better collection of basic math operations

2017-08-02 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/METRON-1038?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16110951#comment-16110951
 ] 

ASF GitHub Bot commented on METRON-1038:


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

https://github.com/apache/metron/pull/650#discussion_r130883191
  
--- Diff: 
metron-stellar/stellar-common/src/main/java/org/apache/metron/stellar/common/utils/math/MathOperations.java
 ---
@@ -0,0 +1,66 @@
+/*
+ *
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 
implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+package org.apache.metron.stellar.common.utils.math;
+
+import java.util.function.Function;
+
+public enum MathOperations implements Function {
+  ABS(d -> Math.abs(d)),
+  CEIL(d -> Math.ceil(d)),
+  COS(d -> Math.cos(d)),
+  FLOOR(d -> Math.floor(d)),
+  LOG10(d -> Math.log10(d)),
+  LOG2(d -> Math.log(d)/Math.log(2)),
+  LN(d -> Math.log(d)),
+  SIN(d -> Math.sin(d)),
+  SQRT(d -> Math.sqrt(d)),
+  TAN(d -> Math.tan(d)),
+  EXP(d -> Math.exp(d)),
+  ROUND(new MathOperation(d -> {
+Double val = d[0].doubleValue();
+return Double.isNaN(val)?Double.NaN:Math.round(d[0].doubleValue());
+  }, 1)),
+  ;
+
+  private static class SingleOpFunc implements Function {
+Function f;
+public SingleOpFunc(Function f) {
+  this.f = f;
+}
+@Override
+public Number apply(Number[] numbers) {
+  return f.apply(numbers[0].doubleValue());
+}
+  }
--- End diff --

yep, I'll add it here; makes sense.


> Stellar should have a better collection of basic math operations
> 
>
> Key: METRON-1038
> URL: https://issues.apache.org/jira/browse/METRON-1038
> Project: Metron
>  Issue Type: Improvement
>Reporter: Casey Stella
>
> At the moment the math functions are woefully incomplete.  
> We should add at least the ones difficult or impossible to reconstruct using 
> existing stellar primitives/math functions:
> * log10
> * log2
> * ln
> * sqrt
> * ceil
> * floor
> * sin
> * cos
> * tan



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (METRON-1038) Stellar should have a better collection of basic math operations

2017-08-02 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/METRON-1038?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16110948#comment-16110948
 ] 

ASF GitHub Bot commented on METRON-1038:


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

https://github.com/apache/metron/pull/650#discussion_r130883104
  
--- Diff: 
metron-stellar/stellar-common/src/main/java/org/apache/metron/stellar/common/utils/math/StellarMathFunction.java
 ---
@@ -0,0 +1,64 @@
+/*
+ *
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 
implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+package org.apache.metron.stellar.common.utils.math;
+
+import org.apache.metron.stellar.dsl.Context;
+import org.apache.metron.stellar.dsl.ParseException;
+import org.apache.metron.stellar.dsl.StellarFunction;
+
+import java.util.List;
+
+public class StellarMathFunction implements StellarFunction {
+  MathOperation _func;
+  public StellarMathFunction(MathOperations _func) {
+this._func = _func.op;
+  }
+
+  public StellarMathFunction(MathOperation _func) {
+this._func = _func;
+  }
+
+  @Override
+  public Object apply(List args, Context context) throws 
ParseException {
+if(args.size() < _func.getMaxArgs()) {
--- End diff --

Agreed, we need `getMinArgs()`.  This is confusing; good catch.


> Stellar should have a better collection of basic math operations
> 
>
> Key: METRON-1038
> URL: https://issues.apache.org/jira/browse/METRON-1038
> Project: Metron
>  Issue Type: Improvement
>Reporter: Casey Stella
>
> At the moment the math functions are woefully incomplete.  
> We should add at least the ones difficult or impossible to reconstruct using 
> existing stellar primitives/math functions:
> * log10
> * log2
> * ln
> * sqrt
> * ceil
> * floor
> * sin
> * cos
> * tan



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (METRON-1038) Stellar should have a better collection of basic math operations

2017-08-02 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/METRON-1038?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16110932#comment-16110932
 ] 

ASF GitHub Bot commented on METRON-1038:


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

https://github.com/apache/metron/pull/650#discussion_r130880080
  
--- Diff: metron-stellar/stellar-common/README.md ---
@@ -613,6 +684,12 @@ In the core language functions, we support basic 
functional programming primitiv
 * key - Property to get the value for
   * Returns: String
 
+### `TAN`
+  * Description: Returns the `tan` of a number.
--- End diff --

yep :)


> Stellar should have a better collection of basic math operations
> 
>
> Key: METRON-1038
> URL: https://issues.apache.org/jira/browse/METRON-1038
> Project: Metron
>  Issue Type: Improvement
>Reporter: Casey Stella
>
> At the moment the math functions are woefully incomplete.  
> We should add at least the ones difficult or impossible to reconstruct using 
> existing stellar primitives/math functions:
> * log10
> * log2
> * ln
> * sqrt
> * ceil
> * floor
> * sin
> * cos
> * tan



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (METRON-1038) Stellar should have a better collection of basic math operations

2017-08-02 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/METRON-1038?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16110927#comment-16110927
 ] 

ASF GitHub Bot commented on METRON-1038:


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

https://github.com/apache/metron/pull/650#discussion_r130879985
  
--- Diff: metron-stellar/stellar-common/README.md ---
@@ -238,6 +249,18 @@ In the core language functions, we support basic 
functional programming primitiv
 * bloomfilters - A list of bloom filters to merge
   * Returns: Bloom Filter or null if the list is empty
 
+### `CEIL`
+  * Description: Returns the ceiling of a number.
+  * Input:
+* number - The number to take the ceiling of
+  * Returns: The ceiling of the number passed in.
+
+### `COS`
+  * Description: Returns the `cos` of a number.
--- End diff --

yep


> Stellar should have a better collection of basic math operations
> 
>
> Key: METRON-1038
> URL: https://issues.apache.org/jira/browse/METRON-1038
> Project: Metron
>  Issue Type: Improvement
>Reporter: Casey Stella
>
> At the moment the math functions are woefully incomplete.  
> We should add at least the ones difficult or impossible to reconstruct using 
> existing stellar primitives/math functions:
> * log10
> * log2
> * ln
> * sqrt
> * ceil
> * floor
> * sin
> * cos
> * tan



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (METRON-1038) Stellar should have a better collection of basic math operations

2017-08-02 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/METRON-1038?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16110929#comment-16110929
 ] 

ASF GitHub Bot commented on METRON-1038:


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

https://github.com/apache/metron/pull/650#discussion_r130880007
  
--- Diff: metron-stellar/stellar-common/README.md ---
@@ -581,6 +634,24 @@ In the core language functions, we support basic 
functional programming primitiv
 * group - The integer that selects what group to select, starting at 1
   * Returns: The value of the group, or null if not matched or no group at 
index.
 
+### `ROUND`
+  * Description: Rounds a number to the nearest integer
+  * Input:
+* number - The number to round
+  * Returns: The nearest integer.
+
+### `SIN`
+  * Description: Returns the `sin` of a number.
--- End diff --

yep


> Stellar should have a better collection of basic math operations
> 
>
> Key: METRON-1038
> URL: https://issues.apache.org/jira/browse/METRON-1038
> Project: Metron
>  Issue Type: Improvement
>Reporter: Casey Stella
>
> At the moment the math functions are woefully incomplete.  
> We should add at least the ones difficult or impossible to reconstruct using 
> existing stellar primitives/math functions:
> * log10
> * log2
> * ln
> * sqrt
> * ceil
> * floor
> * sin
> * cos
> * tan



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (METRON-1038) Stellar should have a better collection of basic math operations

2017-08-02 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/METRON-1038?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16110922#comment-16110922
 ] 

ASF GitHub Bot commented on METRON-1038:


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 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 = {
+  

[jira] [Commented] (METRON-1038) Stellar should have a better collection of basic math operations

2017-08-02 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/METRON-1038?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16110924#comment-16110924
 ] 

ASF GitHub Bot commented on METRON-1038:


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

https://github.com/apache/metron/pull/650#discussion_r130879927
  
--- Diff: metron-stellar/stellar-common/README.md ---
@@ -110,6 +110,8 @@ In the core language functions, we support basic 
functional programming primitiv
 | [ `BLOOM_EXISTS`](#bloom_exists) 
  |
 | [ `BLOOM_INIT`](#bloom_init) 
  |
 | [ `BLOOM_MERGE`](#bloom_merge)   
  |
+| [ `CEIL`](#ceil) 
  |
+| [ `COS`](#ceil)  
 |
--- End diff --

Thanks, good catch.


> Stellar should have a better collection of basic math operations
> 
>
> Key: METRON-1038
> URL: https://issues.apache.org/jira/browse/METRON-1038
> Project: Metron
>  Issue Type: Improvement
>Reporter: Casey Stella
>
> At the moment the math functions are woefully incomplete.  
> We should add at least the ones difficult or impossible to reconstruct using 
> existing stellar primitives/math functions:
> * log10
> * log2
> * ln
> * sqrt
> * ceil
> * floor
> * sin
> * cos
> * tan



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (METRON-1038) Stellar should have a better collection of basic math operations

2017-07-25 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/METRON-1038?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16100492#comment-16100492
 ] 

ASF GitHub Bot commented on METRON-1038:


Github user mattf-horton commented on a diff in the pull request:

https://github.com/apache/metron/pull/650#discussion_r129375196
  
--- Diff: metron-stellar/stellar-common/README.md ---
@@ -581,6 +634,24 @@ In the core language functions, we support basic 
functional programming primitiv
 * group - The integer that selects what group to select, starting at 1
   * Returns: The value of the group, or null if not matched or no group at 
index.
 
+### `ROUND`
+  * Description: Rounds a number to the nearest integer
+  * Input:
+* number - The number to round
+  * Returns: The nearest integer.
+
+### `SIN`
+  * Description: Returns the `sin` of a number.
+  * Input:
+* number - The number to take the `sin` of
+  * Returns: The `sin` of the number passed in.
+
+### `SQRT`
+  * Description: Returns the `sqrt` of a number.
--- End diff --

Returns the square root of a number.


> Stellar should have a better collection of basic math operations
> 
>
> Key: METRON-1038
> URL: https://issues.apache.org/jira/browse/METRON-1038
> Project: Metron
>  Issue Type: Improvement
>Reporter: Casey Stella
>
> At the moment the math functions are woefully incomplete.  
> We should add at least the ones difficult or impossible to reconstruct using 
> existing stellar primitives/math functions:
> * log10
> * log2
> * ln
> * sqrt
> * ceil
> * floor
> * sin
> * cos
> * tan



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (METRON-1038) Stellar should have a better collection of basic math operations

2017-07-25 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/METRON-1038?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16100488#comment-16100488
 ] 

ASF GitHub Bot commented on METRON-1038:


Github user mattf-horton commented on a diff in the pull request:

https://github.com/apache/metron/pull/650#discussion_r129384031
  
--- Diff: 
metron-stellar/stellar-common/src/main/java/org/apache/metron/stellar/common/utils/math/MathOperation.java
 ---
@@ -0,0 +1,39 @@
+/*
+ *
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 
implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+package org.apache.metron.stellar.common.utils.math;
+
+import java.util.function.Function;
+
+public class MathOperation {
+  private int maxArgs;
+  private Function operation;
+  public MathOperation(Function operation, int maxArgs) {
+this.operation = operation;
+this.maxArgs = maxArgs;
+  }
--- End diff --

If you give equal billing to binary ops in MathOperations.java, as 
requested below, then this also needs an additional constructor with BiFunction 
arg, I think.


> Stellar should have a better collection of basic math operations
> 
>
> Key: METRON-1038
> URL: https://issues.apache.org/jira/browse/METRON-1038
> Project: Metron
>  Issue Type: Improvement
>Reporter: Casey Stella
>
> At the moment the math functions are woefully incomplete.  
> We should add at least the ones difficult or impossible to reconstruct using 
> existing stellar primitives/math functions:
> * log10
> * log2
> * ln
> * sqrt
> * ceil
> * floor
> * sin
> * cos
> * tan



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (METRON-1038) Stellar should have a better collection of basic math operations

2017-07-25 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/METRON-1038?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16100489#comment-16100489
 ] 

ASF GitHub Bot commented on METRON-1038:


Github user mattf-horton commented on a diff in the pull request:

https://github.com/apache/metron/pull/650#discussion_r129379794
  
--- Diff: 
metron-stellar/stellar-common/src/main/java/org/apache/metron/stellar/common/utils/math/StellarMathFunction.java
 ---
@@ -0,0 +1,64 @@
+/*
+ *
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 
implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+package org.apache.metron.stellar.common.utils.math;
+
+import org.apache.metron.stellar.dsl.Context;
+import org.apache.metron.stellar.dsl.ParseException;
+import org.apache.metron.stellar.dsl.StellarFunction;
+
+import java.util.List;
+
+public class StellarMathFunction implements StellarFunction {
+  MathOperation _func;
+  public StellarMathFunction(MathOperations _func) {
+this._func = _func.op;
+  }
+
+  public StellarMathFunction(MathOperation _func) {
+this._func = _func;
+  }
+
+  @Override
+  public Object apply(List args, Context context) throws 
ParseException {
+if(args.size() < _func.getMaxArgs()) {
--- End diff --

If this is the logical use of getMaxArgs() then it should be called 
minRequiredArgs(), shouldn't it?  Or perhaps you need another member for that.


> Stellar should have a better collection of basic math operations
> 
>
> Key: METRON-1038
> URL: https://issues.apache.org/jira/browse/METRON-1038
> Project: Metron
>  Issue Type: Improvement
>Reporter: Casey Stella
>
> At the moment the math functions are woefully incomplete.  
> We should add at least the ones difficult or impossible to reconstruct using 
> existing stellar primitives/math functions:
> * log10
> * log2
> * ln
> * sqrt
> * ceil
> * floor
> * sin
> * cos
> * tan



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (METRON-1038) Stellar should have a better collection of basic math operations

2017-07-25 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/METRON-1038?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16100494#comment-16100494
 ] 

ASF GitHub Bot commented on METRON-1038:


Github user mattf-horton commented on a diff in the pull request:

https://github.com/apache/metron/pull/650#discussion_r129378858
  
--- Diff: 
metron-stellar/stellar-common/src/main/java/org/apache/metron/stellar/common/utils/math/MathOperations.java
 ---
@@ -0,0 +1,66 @@
+/*
+ *
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 
implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+package org.apache.metron.stellar.common.utils.math;
+
+import java.util.function.Function;
+
+public enum MathOperations implements Function {
+  ABS(d -> Math.abs(d)),
+  CEIL(d -> Math.ceil(d)),
+  COS(d -> Math.cos(d)),
+  FLOOR(d -> Math.floor(d)),
+  LOG10(d -> Math.log10(d)),
+  LOG2(d -> Math.log(d)/Math.log(2)),
+  LN(d -> Math.log(d)),
+  SIN(d -> Math.sin(d)),
+  SQRT(d -> Math.sqrt(d)),
+  TAN(d -> Math.tan(d)),
+  EXP(d -> Math.exp(d)),
+  ROUND(new MathOperation(d -> {
+Double val = d[0].doubleValue();
+return Double.isNaN(val)?Double.NaN:Math.round(d[0].doubleValue());
+  }, 1)),
+  ;
+
+  private static class SingleOpFunc implements Function {
+Function f;
+public SingleOpFunc(Function f) {
+  this.f = f;
+}
+@Override
+public Number apply(Number[] numbers) {
+  return f.apply(numbers[0].doubleValue());
+}
+  }
--- End diff --

Wouldn't it make sense to give BinaryOp equal billing?
Or are you going to make @simonellistonball work it out? :-)


> Stellar should have a better collection of basic math operations
> 
>
> Key: METRON-1038
> URL: https://issues.apache.org/jira/browse/METRON-1038
> Project: Metron
>  Issue Type: Improvement
>Reporter: Casey Stella
>
> At the moment the math functions are woefully incomplete.  
> We should add at least the ones difficult or impossible to reconstruct using 
> existing stellar primitives/math functions:
> * log10
> * log2
> * ln
> * sqrt
> * ceil
> * floor
> * sin
> * cos
> * tan



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (METRON-1038) Stellar should have a better collection of basic math operations

2017-07-25 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/METRON-1038?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16100495#comment-16100495
 ] 

ASF GitHub Bot commented on METRON-1038:


Github user mattf-horton commented on a diff in the pull request:

https://github.com/apache/metron/pull/650#discussion_r129380511
  
--- 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 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 = {
+  

[jira] [Commented] (METRON-1038) Stellar should have a better collection of basic math operations

2017-07-25 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/METRON-1038?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16100486#comment-16100486
 ] 

ASF GitHub Bot commented on METRON-1038:


Github user mattf-horton commented on a diff in the pull request:

https://github.com/apache/metron/pull/650#discussion_r129374250
  
--- Diff: metron-stellar/stellar-common/README.md ---
@@ -110,6 +110,8 @@ In the core language functions, we support basic 
functional programming primitiv
 | [ `BLOOM_EXISTS`](#bloom_exists) 
  |
 | [ `BLOOM_INIT`](#bloom_init) 
  |
 | [ `BLOOM_MERGE`](#bloom_merge)   
  |
+| [ `CEIL`](#ceil) 
  |
+| [ `COS`](#ceil)  
 |
--- End diff --

wrong link


> Stellar should have a better collection of basic math operations
> 
>
> Key: METRON-1038
> URL: https://issues.apache.org/jira/browse/METRON-1038
> Project: Metron
>  Issue Type: Improvement
>Reporter: Casey Stella
>
> At the moment the math functions are woefully incomplete.  
> We should add at least the ones difficult or impossible to reconstruct using 
> existing stellar primitives/math functions:
> * log10
> * log2
> * ln
> * sqrt
> * ceil
> * floor
> * sin
> * cos
> * tan



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (METRON-1038) Stellar should have a better collection of basic math operations

2017-07-25 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/METRON-1038?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16100493#comment-16100493
 ] 

ASF GitHub Bot commented on METRON-1038:


Github user mattf-horton commented on a diff in the pull request:

https://github.com/apache/metron/pull/650#discussion_r129379273
  
--- Diff: 
metron-stellar/stellar-common/src/main/java/org/apache/metron/stellar/common/utils/math/MathOperations.java
 ---
@@ -0,0 +1,66 @@
+/*
+ *
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 
implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+package org.apache.metron.stellar.common.utils.math;
+
+import java.util.function.Function;
+
+public enum MathOperations implements Function {
+  ABS(d -> Math.abs(d)),
+  CEIL(d -> Math.ceil(d)),
+  COS(d -> Math.cos(d)),
+  FLOOR(d -> Math.floor(d)),
+  LOG10(d -> Math.log10(d)),
+  LOG2(d -> Math.log(d)/Math.log(2)),
+  LN(d -> Math.log(d)),
+  SIN(d -> Math.sin(d)),
+  SQRT(d -> Math.sqrt(d)),
+  TAN(d -> Math.tan(d)),
+  EXP(d -> Math.exp(d)),
+  ROUND(new MathOperation(d -> {
+Double val = d[0].doubleValue();
+return Double.isNaN(val)?Double.NaN:Math.round(d[0].doubleValue());
+  }, 1)),
+  ;
+
+  private static class SingleOpFunc implements Function {
+Function f;
+public SingleOpFunc(Function f) {
+  this.f = f;
+}
+@Override
+public Number apply(Number[] numbers) {
+  return f.apply(numbers[0].doubleValue());
+}
+  }
+
+  MathOperation op;
+  MathOperations(Function singleArg) {
+op = new MathOperation(new SingleOpFunc(singleArg), 1);
+  }
--- End diff --

same here, MathOperations(BiFunction doublearg)


> Stellar should have a better collection of basic math operations
> 
>
> Key: METRON-1038
> URL: https://issues.apache.org/jira/browse/METRON-1038
> Project: Metron
>  Issue Type: Improvement
>Reporter: Casey Stella
>
> At the moment the math functions are woefully incomplete.  
> We should add at least the ones difficult or impossible to reconstruct using 
> existing stellar primitives/math functions:
> * log10
> * log2
> * ln
> * sqrt
> * ceil
> * floor
> * sin
> * cos
> * tan



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (METRON-1038) Stellar should have a better collection of basic math operations

2017-07-25 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/METRON-1038?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16100490#comment-16100490
 ] 

ASF GitHub Bot commented on METRON-1038:


Github user mattf-horton commented on a diff in the pull request:

https://github.com/apache/metron/pull/650#discussion_r129374680
  
--- Diff: metron-stellar/stellar-common/README.md ---
@@ -238,6 +249,18 @@ In the core language functions, we support basic 
functional programming primitiv
 * bloomfilters - A list of bloom filters to merge
   * Returns: Bloom Filter or null if the list is empty
 
+### `CEIL`
+  * Description: Returns the ceiling of a number.
+  * Input:
+* number - The number to take the ceiling of
+  * Returns: The ceiling of the number passed in.
+
+### `COS`
+  * Description: Returns the `cos` of a number.
--- End diff --

Returns the cosine of a number.


> Stellar should have a better collection of basic math operations
> 
>
> Key: METRON-1038
> URL: https://issues.apache.org/jira/browse/METRON-1038
> Project: Metron
>  Issue Type: Improvement
>Reporter: Casey Stella
>
> At the moment the math functions are woefully incomplete.  
> We should add at least the ones difficult or impossible to reconstruct using 
> existing stellar primitives/math functions:
> * log10
> * log2
> * ln
> * sqrt
> * ceil
> * floor
> * sin
> * cos
> * tan



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (METRON-1038) Stellar should have a better collection of basic math operations

2017-07-25 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/METRON-1038?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16100485#comment-16100485
 ] 

ASF GitHub Bot commented on METRON-1038:


Github user mattf-horton commented on a diff in the pull request:

https://github.com/apache/metron/pull/650#discussion_r129374210
  
--- Diff: metron-stellar/stellar-common/README.md ---
@@ -110,6 +110,8 @@ In the core language functions, we support basic 
functional programming primitiv
 | [ `BLOOM_EXISTS`](#bloom_exists) 
  |
 | [ `BLOOM_INIT`](#bloom_init) 
  |
 | [ `BLOOM_MERGE`](#bloom_merge)   
  |
+| [ `CEIL`](#ceil) 
  |
--- End diff --

If this means CEILING, let's call it that?


> Stellar should have a better collection of basic math operations
> 
>
> Key: METRON-1038
> URL: https://issues.apache.org/jira/browse/METRON-1038
> Project: Metron
>  Issue Type: Improvement
>Reporter: Casey Stella
>
> At the moment the math functions are woefully incomplete.  
> We should add at least the ones difficult or impossible to reconstruct using 
> existing stellar primitives/math functions:
> * log10
> * log2
> * ln
> * sqrt
> * ceil
> * floor
> * sin
> * cos
> * tan



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (METRON-1038) Stellar should have a better collection of basic math operations

2017-07-25 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/METRON-1038?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16100491#comment-16100491
 ] 

ASF GitHub Bot commented on METRON-1038:


Github user mattf-horton commented on a diff in the pull request:

https://github.com/apache/metron/pull/650#discussion_r129375098
  
--- Diff: metron-stellar/stellar-common/README.md ---
@@ -581,6 +634,24 @@ In the core language functions, we support basic 
functional programming primitiv
 * group - The integer that selects what group to select, starting at 1
   * Returns: The value of the group, or null if not matched or no group at 
index.
 
+### `ROUND`
+  * Description: Rounds a number to the nearest integer
+  * Input:
+* number - The number to round
+  * Returns: The nearest integer.
+
+### `SIN`
+  * Description: Returns the `sin` of a number.
--- End diff --

Returns the sine of a number.


> Stellar should have a better collection of basic math operations
> 
>
> Key: METRON-1038
> URL: https://issues.apache.org/jira/browse/METRON-1038
> Project: Metron
>  Issue Type: Improvement
>Reporter: Casey Stella
>
> At the moment the math functions are woefully incomplete.  
> We should add at least the ones difficult or impossible to reconstruct using 
> existing stellar primitives/math functions:
> * log10
> * log2
> * ln
> * sqrt
> * ceil
> * floor
> * sin
> * cos
> * tan



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (METRON-1038) Stellar should have a better collection of basic math operations

2017-07-25 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/METRON-1038?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16099846#comment-16099846
 ] 

ASF GitHub Bot commented on METRON-1038:


Github user cestella commented on the issue:

https://github.com/apache/metron/pull/650
  
Any comments or review here?


> Stellar should have a better collection of basic math operations
> 
>
> Key: METRON-1038
> URL: https://issues.apache.org/jira/browse/METRON-1038
> Project: Metron
>  Issue Type: Improvement
>Reporter: Casey Stella
>
> At the moment the math functions are woefully incomplete.  
> We should add at least the ones difficult or impossible to reconstruct using 
> existing stellar primitives/math functions:
> * log10
> * log2
> * ln
> * sqrt
> * ceil
> * floor
> * sin
> * cos
> * tan



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (METRON-1038) Stellar should have a better collection of basic math operations

2017-07-13 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/METRON-1038?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16085943#comment-16085943
 ] 

ASF GitHub Bot commented on METRON-1038:


Github user cestella commented on the issue:

https://github.com/apache/metron/pull/650
  
Ok, I broke this abstraction out a bit and made it easier to add 
non-single-arg functions (a la POW, which is a separate PR by 
@simonellistonball ).  I also went ahead and added `ROUND` and `EXP`.  I looked 
through the remainder of the math functions and honestly, I didn't see a strong 
reason to include any of the rest of them immediately.  I'd RATHER them come in 
via separate PRs with some justification of use.


> Stellar should have a better collection of basic math operations
> 
>
> Key: METRON-1038
> URL: https://issues.apache.org/jira/browse/METRON-1038
> Project: Metron
>  Issue Type: Improvement
>Reporter: Casey Stella
>
> At the moment the math functions are woefully incomplete.  
> We should add at least the ones difficult or impossible to reconstruct using 
> existing stellar primitives/math functions:
> * log10
> * log2
> * ln
> * sqrt
> * ceil
> * floor
> * sin
> * cos
> * tan



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (METRON-1038) Stellar should have a better collection of basic math operations

2017-07-13 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/METRON-1038?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16085839#comment-16085839
 ] 

ASF GitHub Bot commented on METRON-1038:


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

https://github.com/apache/metron/pull/650#discussion_r127245372
  
--- Diff: 
metron-stellar/stellar-common/src/main/java/org/apache/metron/stellar/dsl/functions/MathFunctions.java
 ---
@@ -25,17 +25,39 @@
 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 {
+  private enum SingleArgMathFunctions implements Function {
+ABS(d -> Math.abs(d)),
+CEIL(d -> Math.ceil(d)),
+COS(d -> Math.cos(d)),
+FLOOR(d -> Math.floor(d)),
+LOG10(d -> Math.log10(d)),
+LOG2(d -> Math.log(d)/Math.log(2)),
+LN(d -> Math.log(d)),
+SIN(d -> Math.sin(d)),
+SQRT(d -> Math.sqrt(d)),
+TAN(d -> Math.tan(d)),
+;
+
--- End diff --

I agree.  I think that in general when we are adapting or exposing a set of 
functionality  from java or from apache-commons  we should state our intent 
explicitly for the record.


> Stellar should have a better collection of basic math operations
> 
>
> Key: METRON-1038
> URL: https://issues.apache.org/jira/browse/METRON-1038
> Project: Metron
>  Issue Type: Improvement
>Reporter: Casey Stella
>
> At the moment the math functions are woefully incomplete.  
> We should add at least the ones difficult or impossible to reconstruct using 
> existing stellar primitives/math functions:
> * log10
> * log2
> * ln
> * sqrt
> * ceil
> * floor
> * sin
> * cos
> * tan



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (METRON-1038) Stellar should have a better collection of basic math operations

2017-07-13 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/METRON-1038?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16085823#comment-16085823
 ] 

ASF GitHub Bot commented on METRON-1038:


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

https://github.com/apache/metron/pull/650#discussion_r127242712
  
--- Diff: 
metron-stellar/stellar-common/src/main/java/org/apache/metron/stellar/dsl/functions/MathFunctions.java
 ---
@@ -25,17 +25,39 @@
 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 {
+  private enum SingleArgMathFunctions implements Function {
+ABS(d -> Math.abs(d)),
+CEIL(d -> Math.ceil(d)),
+COS(d -> Math.cos(d)),
+FLOOR(d -> Math.floor(d)),
+LOG10(d -> Math.log10(d)),
+LOG2(d -> Math.log(d)/Math.log(2)),
+LN(d -> Math.log(d)),
+SIN(d -> Math.sin(d)),
+SQRT(d -> Math.sqrt(d)),
+TAN(d -> Math.tan(d)),
+;
+
--- End diff --

I think they're all applicable, most of the remainder aren't as useful to 
Metron, IMO, but I would be willing to go through and add them if we feel that 
there is a need for completeness.


> Stellar should have a better collection of basic math operations
> 
>
> Key: METRON-1038
> URL: https://issues.apache.org/jira/browse/METRON-1038
> Project: Metron
>  Issue Type: Improvement
>Reporter: Casey Stella
>
> At the moment the math functions are woefully incomplete.  
> We should add at least the ones difficult or impossible to reconstruct using 
> existing stellar primitives/math functions:
> * log10
> * log2
> * ln
> * sqrt
> * ceil
> * floor
> * sin
> * cos
> * tan



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (METRON-1038) Stellar should have a better collection of basic math operations

2017-07-13 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/METRON-1038?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16085819#comment-16085819
 ] 

ASF GitHub Bot commented on METRON-1038:


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

https://github.com/apache/metron/pull/650#discussion_r127242317
  
--- Diff: 
metron-stellar/stellar-common/src/main/java/org/apache/metron/stellar/dsl/functions/MathFunctions.java
 ---
@@ -25,17 +25,39 @@
 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 {
+  private enum SingleArgMathFunctions implements Function {
--- End diff --

I can certainly pull this out if you think it's useful.  I didn't think it 
was super useful outside of a helper enum for this class.


> Stellar should have a better collection of basic math operations
> 
>
> Key: METRON-1038
> URL: https://issues.apache.org/jira/browse/METRON-1038
> Project: Metron
>  Issue Type: Improvement
>Reporter: Casey Stella
>
> At the moment the math functions are woefully incomplete.  
> We should add at least the ones difficult or impossible to reconstruct using 
> existing stellar primitives/math functions:
> * log10
> * log2
> * ln
> * sqrt
> * ceil
> * floor
> * sin
> * cos
> * tan



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (METRON-1038) Stellar should have a better collection of basic math operations

2017-07-13 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/METRON-1038?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16085818#comment-16085818
 ] 

ASF GitHub Bot commented on METRON-1038:


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

https://github.com/apache/metron/pull/650#discussion_r127242100
  
--- Diff: 
metron-stellar/stellar-common/src/main/java/org/apache/metron/stellar/dsl/functions/MathFunctions.java
 ---
@@ -25,17 +25,39 @@
 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 {
+  private enum SingleArgMathFunctions implements Function {
+ABS(d -> Math.abs(d)),
+CEIL(d -> Math.ceil(d)),
+COS(d -> Math.cos(d)),
+FLOOR(d -> Math.floor(d)),
+LOG10(d -> Math.log10(d)),
+LOG2(d -> Math.log(d)/Math.log(2)),
+LN(d -> Math.log(d)),
+SIN(d -> Math.sin(d)),
+SQRT(d -> Math.sqrt(d)),
+TAN(d -> Math.tan(d)),
+;
+
--- End diff --

Honestly, I just added the ones that seem to be the most pressingly missing 
and that we could not recreate using primitives.  Did you have any functions 
that you wanted in there?


> Stellar should have a better collection of basic math operations
> 
>
> Key: METRON-1038
> URL: https://issues.apache.org/jira/browse/METRON-1038
> Project: Metron
>  Issue Type: Improvement
>Reporter: Casey Stella
>
> At the moment the math functions are woefully incomplete.  
> We should add at least the ones difficult or impossible to reconstruct using 
> existing stellar primitives/math functions:
> * log10
> * log2
> * ln
> * sqrt
> * ceil
> * floor
> * sin
> * cos
> * tan



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (METRON-1038) Stellar should have a better collection of basic math operations

2017-07-13 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/METRON-1038?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16085719#comment-16085719
 ] 

ASF GitHub Bot commented on METRON-1038:


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

https://github.com/apache/metron/pull/650#discussion_r127220715
  
--- Diff: 
metron-stellar/stellar-common/src/main/java/org/apache/metron/stellar/dsl/functions/MathFunctions.java
 ---
@@ -25,17 +25,39 @@
 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 {
+  private enum SingleArgMathFunctions implements Function {
--- End diff --

Why have this private? why not have stellar/common/util/math/*



> Stellar should have a better collection of basic math operations
> 
>
> Key: METRON-1038
> URL: https://issues.apache.org/jira/browse/METRON-1038
> Project: Metron
>  Issue Type: Improvement
>Reporter: Casey Stella
>
> At the moment the math functions are woefully incomplete.  
> We should add at least the ones difficult or impossible to reconstruct using 
> existing stellar primitives/math functions:
> * log10
> * log2
> * ln
> * sqrt
> * ceil
> * floor
> * sin
> * cos
> * tan



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (METRON-1038) Stellar should have a better collection of basic math operations

2017-07-13 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/METRON-1038?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16085720#comment-16085720
 ] 

ASF GitHub Bot commented on METRON-1038:


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

https://github.com/apache/metron/pull/650#discussion_r127220966
  
--- Diff: 
metron-stellar/stellar-common/src/main/java/org/apache/metron/stellar/dsl/functions/MathFunctions.java
 ---
@@ -25,17 +25,39 @@
 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 {
+  private enum SingleArgMathFunctions implements Function {
+ABS(d -> Math.abs(d)),
+CEIL(d -> Math.ceil(d)),
+COS(d -> Math.cos(d)),
+FLOOR(d -> Math.floor(d)),
+LOG10(d -> Math.log10(d)),
+LOG2(d -> Math.log(d)/Math.log(2)),
+LN(d -> Math.log(d)),
+SIN(d -> Math.sin(d)),
+SQRT(d -> Math.sqrt(d)),
+TAN(d -> Math.tan(d)),
+;
+
--- End diff --

Is there a reason why only this subset of Math.* is exposed?  What about 
the rest?  Are they not needed, applicable, or left for future work?



> Stellar should have a better collection of basic math operations
> 
>
> Key: METRON-1038
> URL: https://issues.apache.org/jira/browse/METRON-1038
> Project: Metron
>  Issue Type: Improvement
>Reporter: Casey Stella
>
> At the moment the math functions are woefully incomplete.  
> We should add at least the ones difficult or impossible to reconstruct using 
> existing stellar primitives/math functions:
> * log10
> * log2
> * ln
> * sqrt
> * ceil
> * floor
> * sin
> * cos
> * tan



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (METRON-1038) Stellar should have a better collection of basic math operations

2017-07-13 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/METRON-1038?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16085429#comment-16085429
 ] 

ASF GitHub Bot commented on METRON-1038:


GitHub user cestella opened a pull request:

https://github.com/apache/metron/pull/650

METRON-1038: Stellar should have a better collection of basic math 
operations

## Contributor Comments
At the moment the math functions are woefully incomplete. 
We should add at least the ones difficult or impossible to reconstruct 
using existing stellar primitives/math functions:
* log10
* log2
* ln
* sqrt
* ceil
* floor
* sin
* cos
* tan

It should be sufficient to test these out in the Stellar REPL for manual 
evaluation.  I have also refactored and added a more robust suite of unit tests 
for existing basic math functions as well as these new ones.

## Pull Request Checklist

Thank you for submitting a contribution to Apache Metron.  
Please refer to our [Development 
Guidelines](https://cwiki.apache.org/confluence/pages/viewpage.action?pageId=61332235)
 for the complete guide to follow for contributions.  
Please refer also to our [Build Verification 
Guidelines](https://cwiki.apache.org/confluence/display/METRON/Verifying+Builds?show-miniview)
 for complete smoke testing guides.  


In order to streamline the review of the contribution we ask you follow 
these guidelines and ask you to double check the following:

### For all changes:
- [x] Is there a JIRA ticket associated with this PR? If not one needs to 
be created at [Metron 
Jira](https://issues.apache.org/jira/browse/METRON/?selectedTab=com.atlassian.jira.jira-projects-plugin:summary-panel).
 
- [x] Does your PR title start with METRON- where  is the JIRA 
number you are trying to resolve? Pay particular attention to the hyphen "-" 
character.
- [x] Has your PR been rebased against the latest commit within the target 
branch (typically master)?


### For code changes:
- [x] Have you included steps to reproduce the behavior or problem that is 
being changed or addressed?
- [x] Have you included steps or a guide to how the change may be verified 
and tested manually?
- [x] Have you ensured that the full suite of tests and checks have been 
executed in the root metron folder via:
  ```
  mvn -q clean integration-test install && build_utils/verify_licenses.sh 
  ```

- [x] Have you written or updated unit tests and or integration tests to 
verify your changes?
- [x] If adding new dependencies to the code, are these dependencies 
licensed in a way that is compatible for inclusion under [ASF 
2.0](http://www.apache.org/legal/resolved.html#category-a)? 
- [x] Have you verified the basic functionality of the build by building 
and running locally with Vagrant full-dev environment or the equivalent?

### For documentation related changes:
- [x] Have you ensured that format looks appropriate for the output in 
which it is rendered by building and verifying the site-book? If not then run 
the following commands and the verify changes via 
`site-book/target/site/index.html`:

  ```
  cd site-book
  mvn site
  ```

 Note:
Please ensure that once the PR is submitted, you check travis-ci for build 
issues and submit an update to your PR as soon as possible.
It is also recommended that [travis-ci](https://travis-ci.org) is set up 
for your personal repository such that your branches are built there before 
submitting a pull request.



You can merge this pull request into a Git repository by running:

$ git pull https://github.com/cestella/incubator-metron METRON-1038

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/metron/pull/650.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #650


commit 87f1cc99144de3fd6b920c10fbe7e1c1c00d0baf
Author: cstella 
Date:   2017-07-13T09:06:10Z

METRON-1038: Stellar should have a better collection of basic math 
operations

commit ee6c609664f37c7a4fb376431a1bbcd98c08faa2
Author: cstella 
Date:   2017-07-13T09:21:38Z

Updating docs




> Stellar should have a better collection of basic math operations
> 
>
> Key: METRON-1038
> URL: https://issues.apache.org/jira/browse/METRON-1038
> Project: Metron
>  Issue Type: Improvement
>Reporter: Casey Stella
>
> At the moment the math functions are woefully incomplete.  
> We should add at least the ones difficult or impossible to reconstruct using 
> existing stellar primitives/math