@Test public void testTrendingScore() { TrendingScore trendingScore = new TrendingScore(); TreeMap<String, KeyTopper> hourly = new TreeMap<>(); KeyTopper kt1 = new KeyTopper().init().setLossy(true); kt1.increment("foo", 1, 10); kt1.increment("bar", 1, 10); KeyTopper kt2 = new KeyTopper().init().setLossy(true); kt2.increment("foo", 1, 10); kt2.increment("bar", 2, 10); KeyTopper kt3 = new KeyTopper().init().setLossy(true); kt3.increment("foo", 1, 10); kt3.increment("bar", 1, 10); kt3.increment("foobar", 2, 10); KeyTopper kt4 = new KeyTopper().init().setLossy(true); kt4.increment("foo", 1, 10); kt4.increment("bar", 2, 10); kt3.increment("foobar", 4, 10); hourly.put("20120901", kt1); hourly.put("20120902", kt2); hourly.put("20120903", kt3); hourly.put("20120904", kt4); TreeMap<String, KeyTopper> monthly = new TreeMap<>(); KeyTopper kt5 = new KeyTopper().init().setLossy(true); kt5.increment("some", 1, 10); kt5.increment("more", 2, 10); KeyTopper kt6 = new KeyTopper().init().setLossy(true); kt6.increment("foo", 1, 10); kt6.increment("more", 2, 10); kt6.increment("urls", 4, 10); monthly.put("201209", kt5); monthly.put("201210", kt6); List<UrlTreeObject.TreeValue> values = trendingScore.getTrends(hourly, monthly, null); assertEquals(values.toString(), "[foobar:30.0, urls:12.0, foo:8.0, bar:7.235, more:6.0, some:3.0]"); }
public TrendingScore() { }
TrendingScore implements Codable { public TrendingScore() { } }
TrendingScore implements Codable { public TrendingScore() { } TrendingScore();  TrendingScore(double alpha, int minResults); }
TrendingScore implements Codable { public TrendingScore() { } TrendingScore();  TrendingScore(double alpha, int minResults); List<UrlTreeObject.TreeValue> getTrends(TreeMap<String, KeyTopper> hourlyTrends, TreeMap<String, KeyTopper> dailyTrends, TreeMap<String, KeyTopper> monthlyTrends); double ema(double prevValue, double currValue); static List<UrlTreeObject.TreeValue> sortByValue(URLTree tree); }
TrendingScore implements Codable { public TrendingScore() { } TrendingScore();  TrendingScore(double alpha, int minResults); List<UrlTreeObject.TreeValue> getTrends(TreeMap<String, KeyTopper> hourlyTrends, TreeMap<String, KeyTopper> dailyTrends, TreeMap<String, KeyTopper> monthlyTrends); double ema(double prevValue, double currValue); static List<UrlTreeObject.TreeValue> sortByValue(URLTree tree);  }