Changeset: 1d74391be3ef for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=1d74391be3ef
Added Files:
gdk/gdk_cand.c
sql/test/BugTracker-2019/Tests/disallow_duplicate_column_aliases.Bug-6723.sql
sql/test/BugTracker-2019/Tests/disallow_duplicate_column_aliases.Bug-6723.stable.err
sql/test/BugTracker-2019/Tests/disallow_duplicate_column_aliases.Bug-6723.stable.out
sql/test/BugTracker-2019/Tests/select_window_function_and_asterisk.Bug-6722.sql
sql/test/BugTracker-2019/Tests/select_window_function_and_asterisk.Bug-6722.stable.err
sql/test/BugTracker-2019/Tests/select_window_function_and_asterisk.Bug-6722.stable.out
Modified Files:
clients/Tests/exports.stable.out
gdk/Makefile.ag
gdk/gdk.h
gdk/gdk_batop.c
gdk/gdk_join.c
gdk/gdk_select.c
gdk/gdk_unique.c
monetdb5/modules/mal/pcre.c
sql/server/rel_optimizer.c
sql/storage/bat/bat_storage.c
sql/test/BugTracker-2008/Tests/auto_coersion_bug.SF-2075157.stable.out
sql/test/BugTracker-2019/Tests/All
sql/test/analytics/Tests/analytics09.stable.out
sql/test/pg_regress/Tests/select_views.stable.out
Branch: context
Log Message:
merged with default
diffs (truncated from 1202 to 300 lines):
diff --git a/clients/Tests/exports.stable.out b/clients/Tests/exports.stable.out
--- a/clients/Tests/exports.stable.out
+++ b/clients/Tests/exports.stable.out
@@ -106,6 +106,7 @@ dbl BATcalcvariance_population(dbl *avgp
dbl BATcalcvariance_sample(dbl *avgp, BAT *b);
BAT *BATcalcxor(BAT *b1, BAT *b2, BAT *s);
BAT *BATcalcxorcst(BAT *b, const ValRecord *v, BAT *s);
+bool BATcandcontains(BAT *s, oid o);
gdk_return BATclear(BAT *b, bool force);
void BATcommit(BAT *b);
BAT *BATconstant(oid hseq, int tt, const void *val, BUN cnt, role_t role);
diff --git a/gdk/Makefile.ag b/gdk/Makefile.ag
--- a/gdk/Makefile.ag
+++ b/gdk/Makefile.ag
@@ -16,7 +16,8 @@ lib_gdk = {
gdk_calc.c gdk_calc.h gdk_calc_compare.h gdk_calc_private.h \
gdk_ssort.c gdk_ssort_impl.h \
gdk_aggr.c \
- gdk.h gdk_cand.h gdk_batop.c \
+ gdk.h gdk_batop.c \
+ gdk_cand.h gdk_cand.c \
gdk_search.c gdk_hash.c gdk_hash.h gdk_tm.c \
gdk_orderidx.c \
gdk_align.c gdk_bbp.c gdk_bbp.h \
diff --git a/gdk/gdk.h b/gdk/gdk.h
--- a/gdk/gdk.h
+++ b/gdk/gdk.h
@@ -2737,6 +2737,7 @@ gdk_export BAT *BATunique(BAT *b, BAT *s
gdk_export BAT *BATmergecand(BAT *a, BAT *b);
gdk_export BAT *BATintersectcand(BAT *a, BAT *b);
gdk_export BAT *BATdiffcand(BAT *a, BAT *b);
+gdk_export bool BATcandcontains(BAT *s, oid o);
gdk_export gdk_return BATfirstn(BAT **topn, BAT **gids, BAT *b, BAT *cands,
BAT *grps, BUN n, bool asc, bool nilslast, bool distinct)
__attribute__((__warn_unused_result__));
diff --git a/gdk/gdk_batop.c b/gdk/gdk_batop.c
--- a/gdk/gdk_batop.c
+++ b/gdk/gdk_batop.c
@@ -2090,345 +2090,3 @@ BATcount_no_nil(BAT *b)
}
return cnt;
}
-
-/* create a new, dense candidate list with values from `first' up to,
- * but not including, `last' */
-static BAT *
-newdensecand(oid first, oid last)
-{
- if (last < first)
- first = last = 0; /* empty range */
- return BATdense(0, first, last - first);
-}
-
-/* merge two candidate lists and produce a new one
- *
- * candidate lists are VOID-headed BATs with an OID tail which is
- * sorted and unique.
- */
-BAT *
-BATmergecand(BAT *a, BAT *b)
-{
- BAT *bn;
- const oid *restrict ap, *restrict bp, *ape, *bpe;
- oid *restrict p, i;
- oid af, al, bf, bl;
- bit ad, bd;
-
- BATcheck(a, "BATmergecand", NULL);
- BATcheck(b, "BATmergecand", NULL);
- assert(ATOMtype(a->ttype) == TYPE_oid);
- assert(ATOMtype(b->ttype) == TYPE_oid);
- assert(BATcount(a) <= 1 || a->tsorted);
- assert(BATcount(b) <= 1 || b->tsorted);
- assert(BATcount(a) <= 1 || a->tkey);
- assert(BATcount(b) <= 1 || b->tkey);
- assert(a->tnonil);
- assert(b->tnonil);
-
- /* we can return a if b is empty (and v.v.) */
- if (BATcount(a) == 0) {
- return COLcopy(b, b->ttype, false, TRANSIENT);
- }
- if (BATcount(b) == 0) {
- return COLcopy(a, a->ttype, false, TRANSIENT);
- }
- /* we can return a if a fully covers b (and v.v) */
- af = BUNtoid(a, 0);
- bf = BUNtoid(b, 0);
- al = BUNtoid(a, BUNlast(a) - 1);
- bl = BUNtoid(b, BUNlast(b) - 1);
- ad = (af + BATcount(a) - 1 == al); /* i.e., dense */
- bd = (bf + BATcount(b) - 1 == bl); /* i.e., dense */
- if (ad && bd) {
- /* both are dense */
- if (af <= bf && bf <= al + 1) {
- /* partial overlap starting with a, or b is
- * smack bang after a */
- return newdensecand(af, al < bl ? bl + 1 : al + 1);
- }
- if (bf <= af && af <= bl + 1) {
- /* partial overlap starting with b, or a is
- * smack bang after b */
- return newdensecand(bf, al < bl ? bl + 1 : al + 1);
- }
- }
- if (ad && af <= bf && al >= bl) {
- return newdensecand(af, al + 1);
- }
- if (bd && bf <= af && bl >= al) {
- return newdensecand(bf, bl + 1);
- }
-
- bn = COLnew(0, TYPE_oid, BATcount(a) + BATcount(b), TRANSIENT);
- if (bn == NULL)
- return NULL;
- p = (oid *) Tloc(bn, 0);
- if (BATtdense(a) && BATtdense(b)) {
- /* both lists are dense */
- if (a->tseqbase > b->tseqbase) {
- BAT *t = a;
-
- a = b;
- b = t;
- }
- /* a->tseqbase <= b->tseqbase */
- for (i = a->tseqbase; i < a->tseqbase + BATcount(a); i++)
- *p++ = i;
- for (i = MAX(b->tseqbase, i);
- i < b->tseqbase + BATcount(b);
- i++)
- *p++ = i;
- } else if (BATtdense(a) || BATtdense(b)) {
- if (BATtdense(b)) {
- BAT *t = a;
-
- a = b;
- b = t;
- }
- /* only a is dense */
- bp = (const oid *) Tloc(b, 0);
- bpe = bp + BATcount(b);
- while (bp < bpe && *bp < a->tseqbase)
- *p++ = *bp++;
- for (i = a->tseqbase; i < a->tseqbase + BATcount(a); i++)
- *p++ = i;
- while (bp < bpe && *bp < i)
- bp++;
- while (bp < bpe)
- *p++ = *bp++;
- } else {
- /* a and b are both not dense */
- ap = (const oid *) Tloc(a, 0);
- ape = ap + BATcount(a);
- bp = (const oid *) Tloc(b, 0);
- bpe = bp + BATcount(b);
- while (ap < ape && bp < bpe) {
- if (*ap < *bp)
- *p++ = *ap++;
- else if (*ap > *bp)
- *p++ = *bp++;
- else {
- *p++ = *ap++;
- bp++;
- }
- }
- while (ap < ape)
- *p++ = *ap++;
- while (bp < bpe)
- *p++ = *bp++;
- }
-
- /* properties */
- BATsetcount(bn, (BUN) (p - (oid *) Tloc(bn, 0)));
- bn->trevsorted = BATcount(bn) <= 1;
- bn->tsorted = true;
- bn->tkey = true;
- bn->tnil = false;
- bn->tnonil = true;
- return virtualize(bn);
-}
-
-/* intersect two candidate lists and produce a new one
- *
- * candidate lists are VOID-headed BATs with an OID tail which is
- * sorted and unique.
- */
-BAT *
-BATintersectcand(BAT *a, BAT *b)
-{
- BAT *bn;
- const oid *restrict ap, *restrict bp, *ape, *bpe;
- oid *restrict p;
- oid af, al, bf, bl;
-
- BATcheck(a, "BATintersectcand", NULL);
- BATcheck(b, "BATintersectcand", NULL);
- assert(ATOMtype(a->ttype) == TYPE_oid);
- assert(ATOMtype(b->ttype) == TYPE_oid);
- assert(a->tsorted);
- assert(b->tsorted);
- assert(a->tkey);
- assert(b->tkey);
- assert(a->tnonil);
- assert(b->tnonil);
-
- if (BATcount(a) == 0 || BATcount(b) == 0) {
- return newdensecand(0, 0);
- }
-
- af = BUNtoid(a, 0);
- bf = BUNtoid(b, 0);
- al = BUNtoid(a, BUNlast(a) - 1);
- bl = BUNtoid(b, BUNlast(b) - 1);
-
- if ((af + BATcount(a) - 1 == al) && (bf + BATcount(b) - 1 == bl)) {
- /* both lists are dense */
- return newdensecand(MAX(af, bf), MIN(al, bl) + 1);
- }
-
- bn = COLnew(0, TYPE_oid, MIN(BATcount(a), BATcount(b)), TRANSIENT);
- if (bn == NULL)
- return NULL;
- p = (oid *) Tloc(bn, 0);
- if (BATtdense(a) || BATtdense(b)) {
- if (BATtdense(b)) {
- BAT *t = a;
-
- a = b;
- b = t;
- }
- /* only a is dense */
- bp = (const oid *) Tloc(b, 0);
- bpe = bp + BATcount(b);
- while (bp < bpe && *bp < a->tseqbase)
- bp++;
- while (bp < bpe && *bp < a->tseqbase + BATcount(a))
- *p++ = *bp++;
- } else {
- /* a and b are both not dense */
- ap = (const oid *) Tloc(a, 0);
- ape = ap + BATcount(a);
- bp = (const oid *) Tloc(b, 0);
- bpe = bp + BATcount(b);
- while (ap < ape && bp < bpe) {
- if (*ap < *bp)
- ap++;
- else if (*ap > *bp)
- bp++;
- else {
- *p++ = *ap++;
- bp++;
- }
- }
- }
-
- /* properties */
- BATsetcount(bn, (BUN) (p - (oid *) Tloc(bn, 0)));
- bn->trevsorted = BATcount(bn) <= 1;
- bn->tsorted = true;
- bn->tkey = true;
- bn->tnil = false;
- bn->tnonil = true;
- return virtualize(bn);
-}
-
-/* calculate the difference of two candidate lists and produce a new one
- */
-BAT *
-BATdiffcand(BAT *a, BAT *b)
-{
- BAT *bn;
- const oid *restrict ap, *restrict bp, *ape, *bpe;
- oid *restrict p;
- oid af, al, bf, bl;
-
- BATcheck(a, "BATdiffcand", NULL);
- BATcheck(b, "BATdiffcand", NULL);
- assert(ATOMtype(a->ttype) == TYPE_oid);
- assert(ATOMtype(b->ttype) == TYPE_oid);
- assert(a->tsorted);
- assert(b->tsorted);
- assert(a->tkey);
- assert(b->tkey);
- assert(a->tnonil);
- assert(b->tnonil);
-
- if (BATcount(a) == 0)
- return newdensecand(0, 0);
- if (BATcount(b) == 0)
- return COLcopy(a, a->ttype, false, TRANSIENT);
-
- af = BUNtoid(a, 0);
- bf = BUNtoid(b, 0);
- al = BUNtoid(a, BUNlast(a) - 1) + 1;
- bl = BUNtoid(b, BUNlast(b) - 1) + 1;
-
- if (bf >= al || bl <= af) {
- /* no overlap, return a */
- return COLcopy(a, a->ttype, false, TRANSIENT);
- }
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list