Changeset: 24df055e29af for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/24df055e29af
Modified Files:
gdk/gdk.h
gdk/gdk_batop.c
sql/backends/monet5/sql_rank.c
Branch: Mar2025
Log Message:
Propagate unique estimate a bit better.
diffs (63 lines):
diff --git a/gdk/gdk.h b/gdk/gdk.h
--- a/gdk/gdk.h
+++ b/gdk/gdk.h
@@ -1518,11 +1518,13 @@ BATsettrivprop(BAT *b)
b->tnil = !b->tnonil;
b->trevsorted = true;
b->tkey = b->batCount <= 1;
+ b->tunique_est = b->batCount == 0 ? 0.0 : 1.0;
} else {
b->tnonil = true;
b->tnil = false;
b->tkey = true;
b->trevsorted = b->batCount <= 1;
+ b->tunique_est = (double) b->batCount;
}
b->tsorted = true;
} else if (b->batCount <= 1) {
@@ -1591,11 +1593,15 @@ BATsettrivprop(BAT *b)
b->tnokey[0] = 0;
b->tnokey[1] = !b->tkey;
b->tunique_est = (double) (1 + b->tkey);
- } else if (!ATOMlinear(b->ttype)) {
- b->tsorted = false;
- b->trevsorted = false;
- b->tminpos = BUN_NONE;
- b->tmaxpos = BUN_NONE;
+ } else {
+ if (!ATOMlinear(b->ttype)) {
+ b->tsorted = false;
+ b->trevsorted = false;
+ b->tminpos = BUN_NONE;
+ b->tmaxpos = BUN_NONE;
+ }
+ if (b->tkey)
+ b->tunique_est = (double) b->batCount;
}
}
diff --git a/gdk/gdk_batop.c b/gdk/gdk_batop.c
--- a/gdk/gdk_batop.c
+++ b/gdk/gdk_batop.c
@@ -788,7 +788,9 @@ BATappend2(BAT *b, BAT *n, BAT *s, bool
b->tminpos = BUN_NONE;
}
}
- if (ci.ncand > BATcount(b) / gdk_unique_estimate_keep_fraction) {
+ if (BATcount(b) == 0 && ci.ncand == ni.count)
+ b->tunique_est = ni.unique_est;
+ else if (ci.ncand > BATcount(b) / gdk_unique_estimate_keep_fraction) {
b->tunique_est = 0;
}
MT_lock_unset(&b->theaplock);
diff --git a/sql/backends/monet5/sql_rank.c b/sql/backends/monet5/sql_rank.c
--- a/sql/backends/monet5/sql_rank.c
+++ b/sql/backends/monet5/sql_rank.c
@@ -237,6 +237,7 @@ SQLrow_number(Client cntxt, MalBlkPtr mb
int icnt = (int) cnt;
for (j = 1; j <= icnt; j++, rp++)
*rp = j;
+ r->tunique_est = (double) cnt;
}
BATsetcount(r, cnt);
r->tnonil = true;
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]