From efae8aff51348681717514d79e68664370b843dd Mon Sep 17 00:00:00 2001 From: gnosygnu Date: Mon, 24 Apr 2017 21:23:00 -0400 Subject: [PATCH] Search: Include pages with scores of 10,000 or less --- 400_xowa/src/gplx/dbs/percentiles/Percentile_rng.java | 9 ++++++++- .../src/gplx/dbs/percentiles/Percentile_select_base.java | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/400_xowa/src/gplx/dbs/percentiles/Percentile_rng.java b/400_xowa/src/gplx/dbs/percentiles/Percentile_rng.java index 6473288c2..2b8c1a1fc 100644 --- a/400_xowa/src/gplx/dbs/percentiles/Percentile_rng.java +++ b/400_xowa/src/gplx/dbs/percentiles/Percentile_rng.java @@ -74,7 +74,14 @@ public class Percentile_rng { private void Rng_len_(boolean first) { score_end = score_bgn + (first ? 1 : 0); // + 1 to include rows with scores at max; EX: > 999,998 AND < 1,000,001 score_bgn = score_end - score_len; - if (score_bgn < 0) score_bgn = 0; // make sure score is not negative + + // note that score_bgn will be first to go negative; EX: (2,000 : 12,000) -> (-8,000 : 2,000) -> (0 : 2,000) -> search still run for 0 - 2000; DATE:2017-04-24 + if (score_bgn < 0) + score_bgn = 0; + + // note that score_end will go to 0 only at end of lookup; EX: (0 : 2,000) -> (-10,000 : -8,000) -> (0 : 0) -> search will not be run; DATE:2017-04-24 + if (score_end < 0) + score_end = 0; } @gplx.Internal protected static int Calc_score_unit(int total_needed, long total_max, int score_max) {// TEST: int rv = (int)Math_.Ceil(Math_.Div_safe_as_double(total_needed, Math_.Div_safe_as_double(total_max, score_max))); // EX: 100 needed / (16 M / 1 M) -> 7 units to fill 100 diff --git a/400_xowa/src/gplx/dbs/percentiles/Percentile_select_base.java b/400_xowa/src/gplx/dbs/percentiles/Percentile_select_base.java index 28139ae4e..707129844 100644 --- a/400_xowa/src/gplx/dbs/percentiles/Percentile_select_base.java +++ b/400_xowa/src/gplx/dbs/percentiles/Percentile_select_base.java @@ -35,7 +35,7 @@ public abstract class Percentile_select_base { // SELECT * FROM x ORDER BY y LIM rdr = Rdr__term(rdr); Rng__update(rdr_found); boolean found_enough = Found_enough(); - boolean none_left = rng.Score_bgn() == 0; + boolean none_left = rng.Score_end() == 0; // search is done when score_end == 0; note that this is set in Percentile_rng; DATE:2017-04-24 Rdr__done(found_enough, none_left); if (found_enough || none_left) break;