Changeset: 51c9e661c8ca for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=51c9e661c8ca Modified Files: gdk/gdk.h gdk/gdk_batop.c gdk/gdk_select.c gdk/gdk_unique.c monetdb5/modules/mal/manifold.c monetdb5/modules/mal/pcre.c Branch: default Log Message:
Introduce new macro bunfastapp to insert value in tail (if head is void).
diffs (184 lines):
diff --git a/gdk/gdk.h b/gdk/gdk.h
--- a/gdk/gdk.h
+++ b/gdk/gdk.h
@@ -1338,7 +1338,26 @@ gdk_export bte ATOMelmshift(int sz);
bunfastins_nocheck(b, _p, h, t, Hsize(b), Tsize(b)); \
} while (0)
-#define bunfastins_check(b, p, h, t) bunfastins(b, h, t)
+#define bunfastapp_nocheck(b, p, t, ts) \
+ do { \
+ tfastins_nocheck(b, p, t, ts); \
+ (b)->batCount++; \
+ } while (0)
+
+#define bunfastapp(b, t) \
+ do { \
+ register BUN _p = BUNlast(b); \
+ assert((b)->htype == TYPE_void); \
+ if (_p == BUN_MAX || BATcount(b) == BUN_MAX) { \
+ GDKerror("bunfastapp: too many elements to accomodate
(INT_MAX)\n"); \
+ goto bunins_failed; \
+ } \
+ if (_p + 1 > BATcapacity(b)) { \
+ if (BATextend((b), BATgrows(b)) == NULL) \
+ goto bunins_failed; \
+ } \
+ bunfastapp_nocheck(b, _p, t, Tsize(b)); \
+ } while (0)
gdk_export int GDKupgradevarheap(COLrec *c, var_t v, int copyall, int
mayshare);
gdk_export BAT *BUNfastins(BAT *b, const void *left, const void *right);
diff --git a/gdk/gdk_batop.c b/gdk/gdk_batop.c
--- a/gdk/gdk_batop.c
+++ b/gdk/gdk_batop.c
@@ -843,7 +843,7 @@ BATslice(BAT *b, BUN l, BUN h)
BATsetcount(bn, h - l);
} else if (BAThdense(b) && b->ttype) {
for (; p < q; p++) {
- bunfastins(bn, NULL, BUNtail(bi, p));
+ bunfastapp(bn, BUNtail(bi, p));
}
} else if (b->htype != b->ttype || b->htype != TYPE_void) {
for (; p < q; p++) {
diff --git a/gdk/gdk_select.c b/gdk/gdk_select.c
--- a/gdk/gdk_select.c
+++ b/gdk/gdk_select.c
@@ -82,10 +82,10 @@ BATslice2(BAT *b, BUN l1, BUN h1, BUN l2
if (bn == NULL)
return bn;
for (p = (BUN) l1, q = (BUN) h1; p < q; p++) {
- bunfastins(bn, NULL, BUNhead(bi, p));
+ bunfastapp(bn, BUNhead(bi, p));
}
for (p = (BUN) l2, q = (BUN) h2; p < q; p++) {
- bunfastins(bn, NULL, BUNhead(bi, p));
+ bunfastapp(bn, BUNhead(bi, p));
}
BATseqbase(bn, 0);
bn->tsorted = BAThordered(b);
diff --git a/gdk/gdk_unique.c b/gdk/gdk_unique.c
--- a/gdk/gdk_unique.c
+++ b/gdk/gdk_unique.c
@@ -129,7 +129,7 @@ BATsubunique(BAT *b, BAT *s)
v = VALUE(i);
if (prev == NULL || (*cmp)(v, prev) != 0) {
o = i + b->hseqbase;
- bunfastins(bn, NULL, &o);
+ bunfastapp(bn, &o);
}
prev = v;
}
@@ -156,7 +156,7 @@ BATsubunique(BAT *b, BAT *s)
if (!(seen[val >> 4] & (1 << (val & 0xF)))) {
seen[val >> 4] |= 1 << (val & 0xF);
o = i + b->hseqbase;
- bunfastins(bn, NULL, &o);
+ bunfastapp(bn, &o);
}
}
GDKfree(seen);
@@ -184,7 +184,7 @@ BATsubunique(BAT *b, BAT *s)
if (!(seen[val >> 4] & (1 << (val & 0xF)))) {
seen[val >> 4] |= 1 << (val & 0xF);
o = i + b->hseqbase;
- bunfastins(bn, NULL, &o);
+ bunfastapp(bn, &o);
}
}
GDKfree(seen);
@@ -221,7 +221,7 @@ BATsubunique(BAT *b, BAT *s)
}
if (hb == HASHnil(hs)) {
o = i + b->hseqbase;
- bunfastins(bn, NULL, &o);
+ bunfastapp(bn, &o);
}
}
} else {
@@ -273,7 +273,7 @@ BATsubunique(BAT *b, BAT *s)
if (hb == HASHnil(hs)) {
o = i + b->hseqbase;
p = i + BUNfirst(b);
- bunfastins(bn, NULL, &o);
+ bunfastapp(bn, &o);
/* enter into hash table */
HASHputlink(hs, p, HASHget(hs, prb));
HASHput(hs, prb, p);
diff --git a/monetdb5/modules/mal/manifold.c b/monetdb5/modules/mal/manifold.c
--- a/monetdb5/modules/mal/manifold.c
+++ b/monetdb5/modules/mal/manifold.c
@@ -96,7 +96,7 @@ case TYPE_str: \
msg = (*mut->pci->fcn)(&y, __VA_ARGS__); \
if (msg) \
break; \
- bunfastins(mut->args[0].b, (void*) 0, (void*) y); \
+ bunfastapp(mut->args[0].b, (void*) y); \
for( i = mut->fvar; i<= mut->lvar; i++) { \
if( ATOMstorage(mut->args[i].type) != TYPE_str){\
args[i] += mut->args[i].size; \
diff --git a/monetdb5/modules/mal/pcre.c b/monetdb5/modules/mal/pcre.c
--- a/monetdb5/modules/mal/pcre.c
+++ b/monetdb5/modules/mal/pcre.c
@@ -362,37 +362,37 @@ pcre_compile_wrap(pcre **res, const char
/* these two defines are copies from gdk_select.c */
/* scan select loop with candidates */
-#define candscanloop(TEST)
\
- do {
\
- ALGODEBUG fprintf(stderr,
\
+#define candscanloop(TEST)
\
+ do {
\
+ ALGODEBUG fprintf(stderr,
\
"#BATsubselect(b=%s#"BUNFMT",s=%s,anti=%d): "
\
"scanselect %s\n", BATgetId(b), BATcount(b),
\
- s ? BATgetId(s) : "NULL", anti, #TEST);
\
- while (p < q) {
\
- o = *candlist++;
\
- r = (BUN) (o - off);
\
- v = BUNtail(bi, r);
\
- if (TEST)
\
- bunfastins(bn, NULL, &o);
\
- p++;
\
- }
\
+ s ? BATgetId(s) : "NULL", anti, #TEST);
\
+ while (p < q) {
\
+ o = *candlist++;
\
+ r = (BUN) (o - off);
\
+ v = BUNtail(bi, r);
\
+ if (TEST)
\
+ bunfastapp(bn, &o);
\
+ p++;
\
+ }
\
} while (0)
/* scan select loop without candidates */
-#define scanloop(TEST)
\
- do {
\
- ALGODEBUG fprintf(stderr,
\
+#define scanloop(TEST)
\
+ do {
\
+ ALGODEBUG fprintf(stderr,
\
"#BATsubselect(b=%s#"BUNFMT",s=%s,anti=%d): "
\
"scanselect %s\n", BATgetId(b), BATcount(b),
\
- s ? BATgetId(s) : "NULL", anti, #TEST);
\
- while (p < q) {
\
- v = BUNtail(bi, p-off);
\
- if (TEST) {
\
- o = (oid) p;
\
- bunfastins(bn, NULL, &o);
\
- }
\
- p++;
\
- }
\
+ s ? BATgetId(s) : "NULL", anti, #TEST);
\
+ while (p < q) {
\
+ v = BUNtail(bi, p-off);
\
+ if (TEST) {
\
+ o = (oid) p;
\
+ bunfastapp(bn, &o);
\
+ }
\
+ p++;
\
+ }
\
} while (0)
static str
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list
