Changeset: fe36cbb7226e for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/fe36cbb7226e
Modified Files:
        gdk/gdk.h
        gdk/gdk_unique.c
        monetdb5/modules/mal/txtsim.c
Branch: default
Log Message:

New inline function bunfastappOID.


diffs (112 lines):

diff --git a/gdk/gdk.h b/gdk/gdk.h
--- a/gdk/gdk.h
+++ b/gdk/gdk.h
@@ -1863,6 +1863,25 @@ bunfastapp(BAT *b, const void *v)
        return rc;
 }
 
+__attribute__((__warn_unused_result__))
+static inline gdk_return
+bunfastappOID(BAT *b, oid o)
+{
+       BUN p = b->batCount;
+       if (p >= BATcapacity(b)) {
+               if (p >= BUN_MAX) {
+                       GDKerror("tfastins: too many elements to accommodate (" 
BUNFMT ")\n", BUN_MAX);
+                       return GDK_FAIL;
+               }
+               gdk_return rc = BATextend(b, BATgrows(b));
+               if (rc != GDK_SUCCEED)
+                       return rc;
+       }
+       ((oid *) b->theap->base)[b->batCount++] = o;
+       b->theap->free += sizeof(oid);
+       return GDK_SUCCEED;
+}
+
 #define bunfastappTYPE(TYPE, b, v)                                     \
        (BATcount(b) >= BATcapacity(b) &&                               \
         ((BATcount(b) == BUN_MAX &&                                    \
diff --git a/gdk/gdk_unique.c b/gdk/gdk_unique.c
--- a/gdk/gdk_unique.c
+++ b/gdk/gdk_unique.c
@@ -122,7 +122,7 @@ BATunique(BAT *b, BAT *s)
                        uint32_t m = UINT32_C(1) << (val & 0x1F);
                        if (!(seen[val >> 5] & m)) {
                                seen[val >> 5] |= m;
-                               if (bunfastappTYPE(oid, bn, &o) != GDK_SUCCEED)
+                               if (bunfastappOID(bn, o) != GDK_SUCCEED)
                                        goto bunins_failed;
                                if (bn->batCount == 256) {
                                        /* there cannot be more than
@@ -148,7 +148,7 @@ BATunique(BAT *b, BAT *s)
                        uint32_t m = UINT32_C(1) << (val & 0x1F);
                        if (!(seen[val >> 5] & m)) {
                                seen[val >> 5] |= m;
-                               if (bunfastappTYPE(oid, bn, &o) != GDK_SUCCEED)
+                               if (bunfastappOID(bn, o) != GDK_SUCCEED)
                                        goto bunins_failed;
                                if (bn->batCount == 65536) {
                                        /* there cannot be more than
@@ -166,7 +166,7 @@ BATunique(BAT *b, BAT *s)
                        o = canditer_next(&ci);
                        v = VALUE(o - hseq);
                        if (prev == NULL || (*cmp)(v, prev) != 0) {
-                               if (bunfastappTYPE(oid, bn, &o) != GDK_SUCCEED)
+                               if (bunfastappOID(bn, o) != GDK_SUCCEED)
                                        goto bunins_failed;
                        }
                        prev = v;
@@ -205,7 +205,7 @@ BATunique(BAT *b, BAT *s)
                                }
                        }
                        if (hb == BUN_NONE) {
-                               if (bunfastappTYPE(oid, bn, &o) != GDK_SUCCEED) 
{
+                               if (bunfastappOID(bn, o) != GDK_SUCCEED) {
                                        MT_rwlock_rdunlock(&b->thashlock);
                                        hs = NULL;
                                        goto bunins_failed;
@@ -263,7 +263,7 @@ BATunique(BAT *b, BAT *s)
                        }
                        if (hb == BUN_NONE) {
                                p = o - hseq;
-                               if (bunfastappTYPE(oid, bn, &o) != GDK_SUCCEED)
+                               if (bunfastappOID(bn, o) != GDK_SUCCEED)
                                        goto bunins_failed;
                                /* enter into hash table */
                                HASHputlink(hs, p, HASHget(hs, prb));
diff --git a/monetdb5/modules/mal/txtsim.c b/monetdb5/modules/mal/txtsim.c
--- a/monetdb5/modules/mal/txtsim.c
+++ b/monetdb5/modules/mal/txtsim.c
@@ -824,13 +824,13 @@ maxlevenshteinjoin(BAT **r1, BAT **r2, B
                        /* The match test succeeded */
                        lsi[n].matches++;
                        rsi[rstart].matches++;
-                       if (bunfastappTYPE(oid, r1t, &(lsi[n].o)) != 
GDK_SUCCEED) {
+                       if (bunfastappOID(r1t, lsi[n].o) != GDK_SUCCEED) {
                                reclaim_bats(2, r1t, r2t);
                                msg = createException(MAL, 
"txtsim.maxlevenshteinjoin",
                                                                          
OPERATION_FAILED "Failed bun append");
                                goto exit;
                        }
-                       if (bunfastappTYPE(oid, r2t, &(rsi[rstart].o)) != 
GDK_SUCCEED) {
+                       if (bunfastappOID(r2t, rsi[rstart].o) != GDK_SUCCEED) {
                                reclaim_bats(2, r1t, r2t);
                                msg = createException(MAL, 
"txtsim.maxlevenshteinjoin",
                                                                          
OPERATION_FAILED "Failed bun append");
@@ -1026,13 +1026,13 @@ minjarowinklerjoin(BAT **r1, BAT **r2, B
                        /* The match test succeeded */
                        ssl[n].matches++;
                        ssr[rstart].matches++;
-                       if (bunfastappTYPE(oid, r1t, &(ssl[n].o)) != 
GDK_SUCCEED) {
+                       if (bunfastappOID(r1t, ssl[n].o) != GDK_SUCCEED) {
                                reclaim_bats(2, r1t, r2t);
                                msg = createException(MAL, 
"txtsim.maxlevenshteinjoin",
                                                                          
OPERATION_FAILED "Failed bun append");
                                goto exit;
                        }
-                       if (bunfastappTYPE(oid, r2t, &(ssr[rstart].o)) != 
GDK_SUCCEED) {
+                       if (bunfastappOID(r2t, ssr[rstart].o) != GDK_SUCCEED) {
                                reclaim_bats(2, r1t, r2t);
                                msg = createException(MAL, 
"txtsim.maxlevenshteinjoin",
                                                                          
OPERATION_FAILED "Failed bun append");
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to