Changeset: 6b5dde41eb6b for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=6b5dde41eb6b
Modified Files:
        sql/backends/monet5/sql.c
        sql/storage/bat/bat_storage.c
        sql/storage/bat/bat_table.c
Branch: unlock
Log Message:

small steps towards using msk for deleted rows


diffs (158 lines):

diff --git a/sql/backends/monet5/sql.c b/sql/backends/monet5/sql.c
--- a/sql/backends/monet5/sql.c
+++ b/sql/backends/monet5/sql.c
@@ -2244,9 +2244,8 @@ SQLtid(Client cntxt, MalBlkPtr mb, MalSt
                        BBPunfix(uv->batCacheid);
                        d = nd;
                }
-               bit *deleted = (bit*)Tloc(d, 0);
                for(BUN p = sb; p < sb+nr; p++) {
-                       if (deleted[p]) {
+                       if (mskGetVal(d,p)) {
                                oid id = p;
                                if (BUNappend(del_ids, &id, false) != 
GDK_SUCCEED) {
                                        BBPreclaim(del_ids);
diff --git a/sql/storage/bat/bat_storage.c b/sql/storage/bat/bat_storage.c
--- a/sql/storage/bat/bat_storage.c
+++ b/sql/storage/bat/bat_storage.c
@@ -174,32 +174,33 @@ count_deletes(storage *d)
 {
        /* needs to be optimized */
        BAT *b = temp_descriptor(d->cs.bid);
-       bit t = TRUE;
-       BAT *s = BATselect(b, NULL, &t, NULL, true, false, false);
-       size_t cnt = 0;
-
-       bat_destroy(b);
-       if (d->cs.ucnt) {
-               BAT *ui, *uv, *cminu;
+       lng cnt = 0;
 
-               if (cs_real_update_bats(&d->cs, &ui, &uv) == LOG_ERR)
+       if (d->cs.ucnt) {
+               if (BATsum(&cnt, TYPE_lng, b, NULL, true, false, false) != 
GDK_SUCCEED) {
+                       bat_destroy(b);
                        return 0;
-               cminu = BATdiff(s, ui, NULL, NULL, false, false, BUN_NONE);
-               BBPunfix(s->batCacheid);
-               BBPunfix(ui->batCacheid);
-               if (!cminu) {
-                       BBPunfix(uv->batCacheid);
+               }
+       } else {
+               BAT *ui, *uv, *c;
+
+               if (cs_real_update_bats(&d->cs, &ui, &uv) == LOG_ERR) {
+                       bat_destroy(b);
                        return 0;
                }
-               cnt = BATcount(cminu);
-               BBPunfix(cminu->batCacheid);
-               s = BATselect(uv, NULL, &t, NULL, true, false, false);
+               c = COLcopy(b, b->ttype, true, TRANSIENT);
+               bat_destroy(b);
+               if (BATreplace(c, ui, uv, true) != GDK_SUCCEED) {
+                       BBPunfix(c->batCacheid);
+                       return 0;
+               }
+               BBPunfix(ui->batCacheid);
                BBPunfix(uv->batCacheid);
-               if (!s)
+               if (BATsum(&cnt, TYPE_lng, c, NULL, true, false, false) != 
GDK_SUCCEED) {
+                       BBPunfix(c->batCacheid);
                        return 0;
+               }
        }
-       cnt += BATcount(s);
-       bat_destroy(s);
        return cnt;
 }
 
@@ -329,7 +330,7 @@ bind_del(sql_trans *tr, sql_table *t, in
                t->base.rtime = t->s->base.rtime = tr->stime;
        storage *s = t->data;
        if (access == RD_UPD_ID || access == RD_UPD_VAL) {
-               return cs_bind_ubat( &s->cs, access, TYPE_bit);
+               return cs_bind_ubat( &s->cs, access, TYPE_msk);
        } else {
                return cs_bind_bat( &s->cs, access, s->end);
        }
@@ -740,7 +741,7 @@ dup_dbat(storage *obat, storage *bat, in
                MT_lock_unset(&segs_lock);
                assert(bat->end <= bat->segs->end);
        }
-       return dup_cs(&obat->cs, &bat->cs, TYPE_bit, is_new, temp);
+       return dup_cs(&obat->cs, &bat->cs, TYPE_msk, is_new, temp);
 }
 
 static int
@@ -808,8 +809,8 @@ static int
 delta_delete_bat( storage *bat, BAT *i, int is_new)
 {
        /* update ids */
-       bit T = TRUE;
-       BAT *t = BATconstant(i->hseqbase, TYPE_bit, &T, BATcount(i), TRANSIENT);
+       msk T = TRUE;
+       BAT *t = BATconstant(i->hseqbase, TYPE_msk, &T, BATcount(i), TRANSIENT);
        int ok = LOG_OK;
 
        if (t) {
@@ -823,7 +824,7 @@ static int
 delta_delete_val( storage *bat, oid rid, int is_new)
 {
        /* update pos */
-       bit T = TRUE;
+       msk T = TRUE;
        return cs_update_val(&bat->cs, rid, &T, is_new);
 }
 
@@ -973,7 +974,7 @@ claim_tab(sql_trans *tr, sql_table *t, s
 
        assert(isNew(t) || isTempTable(t) || s->cs.cleared || BATcount(b) == 
slot);
 
-       bit deleted = FALSE;
+       msk deleted = FALSE;
        lng i;
 
        /* general case, write deleted in the central bat (ie others don't see 
these values) and
@@ -1291,7 +1292,7 @@ log_create_idx(sql_trans *tr, sql_idx *n
 static int
 load_storage(storage *bat, sqlid id)
 {
-       int ok = load_cs(&bat->cs, TYPE_bit, id);
+       int ok = load_cs(&bat->cs, TYPE_msk, id);
 
        if (ok == LOG_OK) {
                bat->segs = 
new_segments(BATcount(quick_descriptor(bat->cs.bid)));
@@ -1325,7 +1326,7 @@ create_del(sql_trans *tr, sql_table *t)
                bat->segs = new_segments(0);
                bat->end = 0;
 
-               b = bat_new(TYPE_bit, t->sz, PERSISTENT);
+               b = bat_new(TYPE_msk, t->sz, PERSISTENT);
                if(b != NULL) {
                        bat_set_access(b, BAT_READ);
                        bat->cs.bid = temp_create(b);
diff --git a/sql/storage/bat/bat_table.c b/sql/storage/bat/bat_table.c
--- a/sql/storage/bat/bat_table.c
+++ b/sql/storage/bat/bat_table.c
@@ -36,7 +36,7 @@ static BAT *
                                BAT *uv = store_funcs.bind_del(tr, t, 
RD_UPD_VAL);
 
                                BBPunfix(d->batCacheid);
-                               if (!nd || !ui || !uv || BATreplace(nd, ui, uv, 
true) != GDK_SUCCEED) {
+                       if (!nd || !ui || !uv || BATreplace(nd, ui, uv, true) 
!= GDK_SUCCEED) {
                                        if (nd) BBPunfix(nd->batCacheid);
                                        if (ui) BBPunfix(ui->batCacheid);
                                        if (uv) BBPunfix(uv->batCacheid);
@@ -47,9 +47,8 @@ static BAT *
                                BBPunfix(uv->batCacheid);
                                d = nd;
                        }
-                       bit *deleted = (bit*)Tloc(d, 0);
                        for(BUN p = 0; p < nr; p++) {
-                               if (deleted[p]) {
+                               if (mskGetVal(d, p)) {
                                        oid id = p;
                                        if (BUNappend(del_ids, &id, false) != 
GDK_SUCCEED) {
                                                BBPreclaim(del_ids);
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to