Changeset: e6609a13d383 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=e6609a13d383
Modified Files:
gdk/gdk_firstn.c
Branch: Oct2014
Log Message:
Check for candidate lists that don't refer to any elements of input.
diffs (79 lines):
diff --git a/gdk/gdk_firstn.c b/gdk/gdk_firstn.c
--- a/gdk/gdk_firstn.c
+++ b/gdk/gdk_firstn.c
@@ -286,6 +286,17 @@ BATfirstn_unique_with_groups(BAT *b, BAT
if (cand && n > (BUN) (candend - cand))
n = (BUN) (candend - cand);
+ if (n == 0) {
+ /* candidate list might refer only to values outside
+ * of the bat and hence be effectively empty */
+ bn = BATnew(TYPE_void, TYPE_void, 0, TRANSIENT);
+ if (bn == NULL)
+ return NULL;
+ BATseqbase(bn, 0);
+ BATseqbase(BATmirror(bn), 0);
+ return bn;
+ }
+
bn = BATnew(TYPE_void, TYPE_oid, n, TRANSIENT);
if (bn == NULL)
return NULL;
@@ -460,6 +471,28 @@ BATfirstn_grouped(BAT **topn, BAT **gids
if (cand && n > (BUN) (candend - cand))
n = (BUN) (candend - cand);
+ if (n == 0) {
+ /* candidate list might refer only to values outside
+ * of the bat and hence be effectively empty */
+ bn = BATnew(TYPE_void, TYPE_void, 0, TRANSIENT);
+ if (bn == NULL)
+ return GDK_FAIL;
+ BATseqbase(bn, 0);
+ BATseqbase(BATmirror(bn), 0);
+ if (gids) {
+ gn = BATnew(TYPE_void, TYPE_void, 0, TRANSIENT);
+ if (gn == NULL) {
+ BBPreclaim(bn);
+ return GDK_FAIL;
+ }
+ BATseqbase(gn, 0);
+ BATseqbase(BATmirror(gn), 0);
+ *gids = gn;
+ }
+ *topn = bn;
+ return GDK_SUCCEED;
+ }
+
top = 0;
cmp = BATatoms[b->ttype].atomCmp;
/* if base type has same comparison function as type itself, we
@@ -735,6 +768,28 @@ BATfirstn_grouped_with_groups(BAT **topn
if (cand && n > (BUN) (candend - cand))
n = (BUN) (candend - cand);
+ if (n == 0) {
+ /* candidate list might refer only to values outside
+ * of the bat and hence be effectively empty */
+ bn = BATnew(TYPE_void, TYPE_void, 0, TRANSIENT);
+ if (bn == NULL)
+ return GDK_FAIL;
+ BATseqbase(bn, 0);
+ BATseqbase(BATmirror(bn), 0);
+ if (gids) {
+ gn = BATnew(TYPE_void, TYPE_void, 0, TRANSIENT);
+ if (gn == NULL) {
+ BBPreclaim(bn);
+ return GDK_FAIL;
+ }
+ BATseqbase(gn, 0);
+ BATseqbase(BATmirror(gn), 0);
+ *gids = gn;
+ }
+ *topn = bn;
+ return GDK_SUCCEED;
+ }
+
top = 0;
cmp = BATatoms[b->ttype].atomCmp;
/* if base type has same comparison function as type itself, we
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list