summaryrefslogtreecommitdiffstats
path: root/container-search/src/test/java/com/yahoo/search/dispatch/searchcluster/SearchClusterTest.java
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2020-04-15 10:15:25 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2020-04-15 10:16:09 +0000
commit712ad877d53849772f29b6962a5cb261131e3668 (patch)
tree3fe727339d5f94a9a0295865db983282402b255b /container-search/src/test/java/com/yahoo/search/dispatch/searchcluster/SearchClusterTest.java
parent1ee3a5aa8d674b1456b684c583a96092be91a344 (diff)
Introduce top-k-probability and use it to fetch correct proper amount of hits from each partition
Diffstat (limited to 'container-search/src/test/java/com/yahoo/search/dispatch/searchcluster/SearchClusterTest.java')
-rw-r--r--container-search/src/test/java/com/yahoo/search/dispatch/searchcluster/SearchClusterTest.java12
1 files changed, 12 insertions, 0 deletions
diff --git a/container-search/src/test/java/com/yahoo/search/dispatch/searchcluster/SearchClusterTest.java b/container-search/src/test/java/com/yahoo/search/dispatch/searchcluster/SearchClusterTest.java
index ad281aeda7d..840edd3a419 100644
--- a/container-search/src/test/java/com/yahoo/search/dispatch/searchcluster/SearchClusterTest.java
+++ b/container-search/src/test/java/com/yahoo/search/dispatch/searchcluster/SearchClusterTest.java
@@ -27,6 +27,7 @@ import static org.junit.Assert.assertTrue;
* @author baldersheim
*/
public class SearchClusterTest {
+ private static final double EPSILON = 0.00000000001;
static class State implements AutoCloseable{
@@ -334,4 +335,15 @@ public class SearchClusterTest {
assertEquals(3, node.getLastReceivedPongId());
}
+ @Test
+ public void requireHitsAreEstimatedAccordingToPartitionsAndProbability() {
+ SearchCluster.TopKEstimator estimator = new SearchCluster.TopKEstimator(30, 0.999);
+ assertEquals(91.97368471911312, estimator.estimateExactK(200, 3), EPSILON);
+ assertEquals(92, estimator.estimateK(200, 3));
+ assertEquals(37.96328109101396, estimator.estimateExactK(200, 10), EPSILON);
+ assertEquals(38, estimator.estimateK(200, 10));
+ assertEquals(23.815737601023095, estimator.estimateExactK(200, 20), EPSILON);
+ assertEquals(24, estimator.estimateK(200, 20));
+ }
+
}