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

Modified Files:
        bpm_storage.mx bpm_table.mx 
Log Message:
we can now support select count(*) from bla; on bpm storage.

(bpm storage can be enabled by setting sql_debug=16)
Adding parts is done by 

call inc_parts('sys','lineitem');



Index: bpm_storage.mx
===================================================================
RCS file: /cvsroot/monetdb/sql/src/storage/bpm/bpm_storage.mx,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- bpm_storage.mx      11 Nov 2007 22:31:45 -0000      1.3
+++ bpm_storage.mx      12 Nov 2007 20:11:04 -0000      1.4
@@ -57,7 +57,7 @@
 /* initialize bat storage call back functions interface */
 extern int bpm_storage_init( store_functions *sf );
 
-extern void bpm_add_partition(sql_bpm *p);
+extern int bpm_add_partition(sql_bpm *p);
 
 #endif /*BPMSTORAGE_H */
 
@@ -109,9 +109,16 @@
        }
        p -> parts[nr].cnt = BATcount(b);
        if (p->type == bpm_hrange) {
-               p -> parts[nr].hlow = p -> parts[nr].hhgh = -1;
-               if (nr)
+               p->parts[nr].hlow = 0;
+               p->parts[nr].hhgh = -1;
+               if (nr) {
+                       /* this should be fixed by the update_part code which
+                          should remove empty partitions */
+                       if (p->parts[nr-1].hhgh == (oid)-1)
+                               p->parts[nr-1].hhgh = p->parts[nr-1].hlow;
+                       
                        p->parts[nr].hlow = p->parts[nr-1].hhgh;
+               }
                BATseqbase(b, p->parts[nr].hlow);
                if (BATcount(b)) {
                        BATiter bi = bat_iterator(b);
@@ -124,12 +131,19 @@
        return nr;
 }
 
-void
+int
 bpm_add_partition(sql_bpm *p)
 {
-       BAT *b = BATnew(TYPE_void, p->ttpe, 0);
-       extend_part(p, b, 0);
-       bat_destroy(b);
+       /* do not add a partition if the current part is empty */
+       if (p->parts[p->nr-1].cnt > 0) {
+               BAT *b = bat_new(TYPE_void, p->ttpe, 0);
+               
+               extend_part(p, b, 0);
+               bat_destroy(b);
+               return 1;
+       }
+       /* error */
+       return 0;
 }
 
 static sql_bpm *
@@ -459,6 +473,7 @@
        } else {
                BATappend(b, i, TRUE);
        }
+       p->parts[p->nr-1].cnt += BATcount(i);
        bat_destroy(b);
 }
 
@@ -469,6 +484,7 @@
        BAT *b = temp_descriptor(p->parts[p->ins].bid);
 
        BUNappend(b, i, TRUE);
+       p->parts[p->nr-1].cnt++;
        bat_destroy(b);
 }
 
@@ -553,7 +569,7 @@
        if (p->nr > 1) {
                int i;
 
-               b = BATnew(TYPE_void, TYPE_oid, 0);
+               b = bat_new(TYPE_void, TYPE_oid, 0);
                for (i=0; i<p->nr; i++) {
                        BAT *d = temp_descriptor(p->parts[i].bid);
                        BATappend(b, d, TRUE);
@@ -597,10 +613,11 @@
                pp->parts[pp->nr-1].name = name;
                pp->parts[pp->nr-1].uname = uname;
                bat_destroy(b);
+               assert(pp->parts[pp->nr-1].hlow != (oid)-1);
        }
        *cnt = o;
        pp->ins = pp->nr;
-       b = BATnew(TYPE_void, ttpe, sz);
+       b = bat_new(TYPE_void, ttpe, sz);
        extend_part(pp, b, 0);
        bat_destroy(b);
        bat_destroy(parts);
@@ -831,7 +848,7 @@
                        if (op->parts[i].ubid) {
                                p->parts[i].ubid = temp_copy(op->parts[i].ubid, 
0);
                        } else {
-                               BAT *U = BATnew(TYPE_oid, b->ttype, 0);
+                               BAT *U = bat_new(TYPE_oid, b->ttype, 0);
                                p->parts[i].ubid = temp_create(U);
                                op->parts[i].ubid = temp_copy(p->parts[i].ubid, 
0);
                                bat_destroy(U);
@@ -856,7 +873,7 @@
                                if (op->parts[i].ubid) {
                                        p->parts[i].ubid = 
temp_copy(op->parts[i].ubid, 0);
                                } else {
-                                       BAT *U = BATnew(TYPE_oid, b->ttype, 0);
+                                       BAT *U = bat_new(TYPE_oid, b->ttype, 0);
                                        p->parts[i].ubid = temp_create(U);
                                        op->parts[i].ubid = 
temp_copy(p->parts[i].ubid, 0);
                                        bat_destroy(U);
@@ -1115,7 +1132,9 @@
                                bat_clear(ins);
                        }
                        bat_clear(pi);
+                       op->parts[op->ins-1].cnt =
                        op->parts[op->ins-1].hhgh = op->parts[op->ins].hlow =
+                       cp->parts[cp->ins-1].cnt =
                        cp->parts[cp->ins-1].hhgh = cp->parts[cp->ins].hlow = 
                                BATcount(cur);
                        BATseqbase(ins, op->parts[op->ins].hlow);
@@ -1202,7 +1221,7 @@
                        bpm_new_part(op->pid, op->name);
 
                        /* add old parts to the partition table */
-                       for (i=0; i<op->nr; i++) {
+                       for (i=0; i<op->ins; i++) {
                                Part p = op->parts+i;
 
                                BUNappend(part_pid,&op->pid,TRUE);

Index: bpm_table.mx
===================================================================
RCS file: /cvsroot/monetdb/sql/src/storage/bpm/bpm_table.mx,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- bpm_table.mx        10 Nov 2007 21:47:30 -0000      1.2
+++ bpm_table.mx        12 Nov 2007 20:11:05 -0000      1.3
@@ -88,15 +88,20 @@
                t = BATsemijoin(u,s); bat_destroy(u); u = t;
        }
        assert(b->ttype == i->ttype);
-       r = BATkunion(b,i); bat_destroy(b); bat_destroy(i); b = r;
-       r = BATkdiff(b,u); bat_destroy(b); b = r;
-       assert(b->ttype == u->ttype);
-       r = BATkunion(b,u); bat_destroy(b); bat_destroy(u); b = r;
-       if (d) {
+       if (BATcount(i)) {
+               r = BATkunion(b,i); bat_destroy(b); b = r;
+       }
+       bat_destroy(i); 
+       if (BATcount(u)) {
+               r = BATkdiff(b,u); bat_destroy(b); b = r;
+               assert(b->ttype == u->ttype);
+               r = BATkunion(b,u); bat_destroy(b); b = r;
+       }
+       bat_destroy(u); 
+       if (d && BATcount(d)) {
                r = BATkdiff(b,BATmirror(d)); bat_destroy(b); b = r;
        }
-       assert(r->T->hash == NULL);
-       return r;
+       return b;
 }
 
 static ssize_t


-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Monetdb-sql-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-sql-checkins

Reply via email to