metron-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mmiklav...@apache.org
Subject incubator-metron git commit: METRON-441: Aggregator function "MIN" does not work for threat triage (cestella via mmiklavc) closes apache/incubator-metron#309
Date Fri, 21 Oct 2016 15:12:37 GMT
Repository: incubator-metron
Updated Branches:
  refs/heads/master 4bfb09c49 -> 4de80b35e


METRON-441: Aggregator function "MIN" does not work for threat triage (cestella via mmiklavc)
closes apache/incubator-metron#309


Project: http://git-wip-us.apache.org/repos/asf/incubator-metron/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-metron/commit/4de80b35
Tree: http://git-wip-us.apache.org/repos/asf/incubator-metron/tree/4de80b35
Diff: http://git-wip-us.apache.org/repos/asf/incubator-metron/diff/4de80b35

Branch: refs/heads/master
Commit: 4de80b35efe220142c3d5f4ad8793690ac77f6d6
Parents: 4bfb09c
Author: cestella <cestella@gmail.com>
Authored: Fri Oct 21 11:11:08 2016 -0400
Committer: Michael Miklavcic <michael.miklavcic@gmail.com>
Committed: Fri Oct 21 11:11:08 2016 -0400

----------------------------------------------------------------------
 .../java/org/apache/metron/common/aggregator/Aggregators.java   | 2 +-
 .../src/test/java/org/apache/metron/common/AggregatorsTest.java | 5 +++++
 2 files changed, 6 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-metron/blob/4de80b35/metron-platform/metron-common/src/main/java/org/apache/metron/common/aggregator/Aggregators.java
----------------------------------------------------------------------
diff --git a/metron-platform/metron-common/src/main/java/org/apache/metron/common/aggregator/Aggregators.java
b/metron-platform/metron-common/src/main/java/org/apache/metron/common/aggregator/Aggregators.java
index 57e3ae2..79094d7 100644
--- a/metron-platform/metron-common/src/main/java/org/apache/metron/common/aggregator/Aggregators.java
+++ b/metron-platform/metron-common/src/main/java/org/apache/metron/common/aggregator/Aggregators.java
@@ -27,7 +27,7 @@ import java.util.function.Predicate;
 
 public enum Aggregators implements Aggregator {
    MAX( (numbers, config) -> accumulate(0d, (x,y) -> Math.max(x.doubleValue(),y.doubleValue()),
numbers, config))
-  ,MIN( (numbers, config) -> accumulate(0d, (x,y) -> Math.min(x.doubleValue(),y.doubleValue()),
numbers, config))
+  ,MIN( (numbers, config) -> accumulate(Double.MAX_VALUE, (x,y) -> Math.min(x.doubleValue(),y.doubleValue()),
numbers, config))
   ,SUM( (numbers, config) -> accumulate(0d, (x,y) -> x.doubleValue() + y.doubleValue(),
numbers, config))
   ,MEAN( (numbers, config) -> scale(SUM.aggregate(numbers, config), numbers, n -> true))
   ,POSITIVE_MEAN( (numbers, config) -> positiveMean(numbers, config))

http://git-wip-us.apache.org/repos/asf/incubator-metron/blob/4de80b35/metron-platform/metron-common/src/test/java/org/apache/metron/common/AggregatorsTest.java
----------------------------------------------------------------------
diff --git a/metron-platform/metron-common/src/test/java/org/apache/metron/common/AggregatorsTest.java
b/metron-platform/metron-common/src/test/java/org/apache/metron/common/AggregatorsTest.java
index ab3eb1d..fd999c8 100644
--- a/metron-platform/metron-common/src/test/java/org/apache/metron/common/AggregatorsTest.java
+++ b/metron-platform/metron-common/src/test/java/org/apache/metron/common/AggregatorsTest.java
@@ -42,6 +42,11 @@ public class AggregatorsTest {
   }
 
   @Test
+  public void testMinAllPositive() {
+    Assert.assertEquals(1, Aggregators.MIN.aggregate(ImmutableList.of(1, 5, 7), ImmutableMap.of(Aggregators.NEGATIVE_VALUES_TRUMP_CONF,
"false")), 1e-7);
+  }
+
+  @Test
   public void testMean() {
     Assert.assertEquals(Double.NEGATIVE_INFINITY, Aggregators.MEAN.aggregate(ImmutableList.of(1,
5, -1, 7, 0), new HashMap<>()), 1e-7);
     Assert.assertEquals(12.0/5.0, Aggregators.MEAN.aggregate(ImmutableList.of(1, 5, -1, 7,
0), ImmutableMap.of(Aggregators.NEGATIVE_VALUES_TRUMP_CONF, "false")), 1e-7);


Mime
View raw message