Changeset: 6fa2c554df88 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/6fa2c554df88 Modified Files: gdk/gdk_cand.c gdk/gdk_cross.c Branch: Sep2022 Log Message:
Implemented special cases for BATsubcross when either BAT count <= 1. Also, canditer_slice (which is now used there) returns a void bat for length 1 slices. diffs (70 lines): diff --git a/gdk/gdk_cand.c b/gdk/gdk_cand.c --- a/gdk/gdk_cand.c +++ b/gdk/gdk_cand.c @@ -1098,6 +1098,8 @@ canditer_slice(const struct canditer *ci return BATdense(0, 0, 0); if (hi > ci->ncand) hi = ci->ncand; + if (hi - lo == 1) + return BATdense(0, canditer_idx(ci, lo), 1); switch (ci->tpe) { case cand_materialized: if (ci->s) { diff --git a/gdk/gdk_cross.c b/gdk/gdk_cross.c --- a/gdk/gdk_cross.c +++ b/gdk/gdk_cross.c @@ -36,6 +36,54 @@ BATsubcross(BAT **r1p, BAT **r2p, BAT *l return GDK_FAIL; } + /* first some special cases */ + if (ci1.ncand == 0 || ci2.ncand == 0) { + if ((bn1 = BATdense(0, 0, 0)) == NULL) + return GDK_FAIL; + if (r2p) { + if ((bn2 = BATdense(0, 0, 0)) == NULL) { + BBPreclaim(bn1); + return GDK_FAIL; + } + *r2p = bn2; + } + *r1p = bn1; + return GDK_SUCCEED; + } + if (ci2.ncand == 1) { + if ((bn1 = canditer_slice(&ci1, 0, ci1.ncand)) == NULL) + return GDK_FAIL; + if (r2p) { + if (ci1.ncand == 1) { + bn2 = canditer_slice(&ci2, 0, ci2.ncand); + } else { + bn2 = BATconstant(0, TYPE_oid, &ci2.seq, ci1.ncand, TRANSIENT); + } + if (bn2 == NULL) { + BBPreclaim(bn1); + return GDK_FAIL; + } + *r2p = bn2; + } + *r1p = bn1; + return GDK_SUCCEED; + } + if (ci1.ncand == 1) { + bn1 = BATconstant(0, TYPE_oid, &ci1.seq, ci2.ncand, TRANSIENT); + if (bn1 == NULL) + return GDK_FAIL; + if (r2p) { + bn2 = canditer_slice(&ci2, 0, ci2.ncand); + if (bn2 == NULL) { + BBPreclaim(bn1); + return GDK_FAIL; + } + *r2p = bn2; + } + *r1p = bn1; + return GDK_SUCCEED; + } + bn1 = COLnew(0, TYPE_oid, ci1.ncand * ci2.ncand, TRANSIENT); if (r2p) bn2 = COLnew(0, TYPE_oid, ci1.ncand * ci2.ncand, TRANSIENT); _______________________________________________ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org