Update of /cvsroot/monetdb/sql/src/storage/restrict
In directory 
sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv26843/src/storage/restrict

Modified Files:
        restrict_storage.mx restrict_table.mx 
Log Message:
redid most of the bpm storage layer as it needed to be split in snapshot, log
and rollforward


U restrict_table.mx
Index: restrict_table.mx
===================================================================
RCS file: /cvsroot/monetdb/sql/src/storage/restrict/restrict_table.mx,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- restrict_table.mx   15 Jan 2008 10:40:27 -0000      1.1
+++ restrict_table.mx   22 Aug 2008 09:50:32 -0000      1.2
@@ -152,7 +152,6 @@
                store_funcs.append_col(tr, c, val, c->type.type->localtype);
                cnt++;
        }
-       t->cnt ++;
        if (n) {
                fprintf(stderr, "called table_insert(%s) with wrong number of 
args (%d,%d)\n", t->base.name, list_length(t->columns.set), cnt);
                assert(0);

U restrict_storage.mx
Index: restrict_storage.mx
===================================================================
RCS file: /cvsroot/monetdb/sql/src/storage/restrict/restrict_storage.mx,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- restrict_storage.mx 17 Jul 2008 13:29:43 -0000      1.6
+++ restrict_storage.mx 22 Aug 2008 09:50:32 -0000      1.7
@@ -27,6 +27,7 @@
        char *name;     /* name of the main bat */
        int bid;
        int ubid;       /* bat with old updated values (su only) */
+       size_t cnt;             /* number of tuples (excluding the deletes) */
 } sql_bat;
 
 #define bat_set_access(b,access) b->P->restricted = access
@@ -189,6 +190,7 @@
 {
        BAT *b = temp_descriptor(bat->bid);
 
+       bat->cnt += BATcount(i);
        if (BATcount(b) == 0 && !isVIEW(i) && i->htype == TYPE_void && i->ttype 
!= TYPE_void){
                temp_destroy(bat->bid);
                bat->bid = temp_create(i);
@@ -206,6 +208,7 @@
        BAT *b = temp_descriptor(bat->bid);
 
        BUNappend(b, i, TRUE);
+       bat->cnt ++;
        bat_destroy(b);
 }
 
@@ -272,14 +275,28 @@
                delete_val(bat, ib);
 }
 
+static size_t
+count_col(sql_column *col)
+{
+       sql_bat *b = col->data;
+       return b->cnt;
+}
+
+static size_t
+count_idx(sql_idx *idx)
+{
+       sql_bat *b = idx->data;
+       return b->cnt;
+}
+
 static int 
-load_bat( sql_bat *bat, lng *cnt ) 
+load_bat( sql_bat *bat) 
 {
        BAT *b;
 
        b = quick_descriptor(logger_find_bat(restrict_logger, bat->name));
        bat->bid = temp_create(b);
-       *cnt = BATcount(b);
+       bat->cnt = (size_t)BATcount(b);
        return LOG_OK;
 }
 
@@ -313,12 +330,11 @@
 }
 
 static int
-new_persistent_bat(sql_trans *tr, sql_bat *bat, lng *cnt) 
+new_persistent_bat(sql_trans *tr, sql_bat *bat) 
 {
        BAT *b = temp_descriptor(bat->bid);
 
        (void)tr;
-       *cnt = BATcount(b);
        BATcommit(b);
        bat_destroy(b);
        return LOG_OK;
@@ -337,10 +353,10 @@
 
        (void)tr;
        if (c->base.flag == TR_OLD && !isTempTable(c->t)){
-               return load_bat(bat, &c->t->cnt);
+               return load_bat(bat);
        } else if (bat->bid && !isTempTable(c->t)) {
                assert(active_store_type == store_su);
-               return new_persistent_bat( tr, c->data, &c->t->cnt);
+               return new_persistent_bat( tr, c->data);
        } else {
                if (!bat)
                        bat = c->data = ZNEW(sql_bat);
@@ -403,10 +419,10 @@
 
        /* create bats for a loaded idx structure */
        if (ni->base.flag == TR_OLD && !isTempTable(ni->t)){
-               return load_bat( bat, &ni->t->cnt);
+               return load_bat( bat);
        } else if (bat->bid && !isTempTable(ni->t)) { 
                assert(active_store_type == store_su);
-               return new_persistent_bat( tr, ni->data, &ni->t->cnt);
+               return new_persistent_bat( tr, ni->data);
        } else if (!bat->bid) {
                BAT *b = bat_new(TYPE_void, type, ni->t->sz);
                if (!b) 
@@ -450,7 +466,6 @@
                assert(active_store_type == store_su);
                b = temp_descriptor(bat->bid);
                bat->bid = temp_create(b);
-               t->cnt -= BATcount(b);
                bat_destroy(b);
        } else if (!bat->bid) {
                b = bat_new(TYPE_void, TYPE_oid, t->sz);
@@ -498,6 +513,7 @@
        if (!obat)
                return LOG_OK;
        bat->bid = obat->bid;
+       bat->cnt = obat->cnt;
        if (bat->bid)
                temp_dup(bat->bid);
        bat->name = _strdup(obat->name);
@@ -657,6 +673,7 @@
                BATcommit(b);
                bat_destroy(b);
        }
+       bat->cnt = 0;
        return sz;
 }
 
@@ -685,19 +702,18 @@
 }
 
 static int 
-tr_update_bat( sql_trans *tr, sql_bat *obat, sql_bat *cbat, lng *cnt)
+tr_update_bat( sql_trans *tr, sql_bat *obat, sql_bat *cbat)
 {
        int ok = LOG_OK;
        BAT *cb = temp_descriptor(cbat->bid);
 
        (void)tr;
-       (void)obat;
        if (cbat->ubid) {
                temp_destroy(cbat->ubid);
                cbat->ubid = 0;
        }
+       obat->cnt = cbat->cnt;
        BATcommit(cb);
-       *cnt = BATcount(cb);
        bat_destroy(cb);
        return ok;
 }
@@ -707,7 +723,6 @@
 {
        int ok = LOG_OK;
        node *n, *m;
-       lng deleted = 0;
 
        if (ft->cleared) {
                (void)store_funcs.clear_del(tr->parent, tt);
@@ -717,15 +732,14 @@
                        for (n = tt->idxs.set->h; n; n = n->next) 
                                (void)store_funcs.clear_idx(tr->parent, 
n->data);
        }
-       tr_update_bat(tr, tt->data, ft->data, &deleted);
+       tr_update_bat(tr, tt->data, ft->data);
        for (n = ft->columns.set->h, m = tt->columns.set->h; ok == LOG_OK && n 
&& m; n = n->next, m = m->next) {
                sql_column *cc = n->data;
                sql_column *oc = m->data;
 
                if (!cc->base.wtime) 
                        continue;
-               tr_update_bat(tr, oc->data, cc->data, &cc->t->cnt);
-               tt->cnt = cc->t->cnt;
+               tr_update_bat(tr, oc->data, cc->data);
 
                if (cc->base.rtime)
                        oc->base.rtime = tr->stime;
@@ -744,7 +758,7 @@
 
                        if (!ci->base.wtime) 
                                continue;
-                       tr_update_bat(tr, oi->data, ci->data, &ci->t->cnt);
+                       tr_update_bat(tr, oi->data, ci->data);
 
                        if (ci->base.rtime)
                                oi->base.rtime = tr->stime;
@@ -752,7 +766,6 @@
                        ci->base.rtime = ci->base.wtime = 0;
                }
        }
-       tt->cnt -= deleted;
        return ok;
 }
 
@@ -897,6 +910,9 @@
        sf->update_idx = (update_idx_fptr)&update_idx;
        sf->delete_tab = (delete_tab_fptr)&delete_tab;
 
+       sf->count_col = (count_col_fptr)&count_col;
+       sf->count_idx = (count_idx_fptr)&count_idx;
+
        sf->create_col = (create_col_fptr)&create_col;
        sf->create_idx = (create_idx_fptr)&create_idx;
        sf->create_del = (create_del_fptr)&create_del;
@@ -944,6 +960,9 @@
        sf->update_idx = (update_idx_fptr)NULL;
        sf->delete_tab = (delete_tab_fptr)NULL;
 
+       sf->count_col = (count_col_fptr)&count_col;
+       sf->count_idx = (count_idx_fptr)&count_idx;
+
        sf->create_col = (create_col_fptr)&create_col;
        sf->create_idx = (create_idx_fptr)&create_idx;
        sf->create_del = (create_del_fptr)&create_del;


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Monetdb-sql-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-sql-checkins

Reply via email to