Changeset: 41e20127de41 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=41e20127de41
Modified Files:
        monetdb5/modules/mal/tablet.c
Branch: headless
Log Message:

Move it out of the way
Most is not needed anymore and would require a redesign


diffs (truncated from 544 to 300 lines):

diff --git a/monetdb5/modules/mal/tablet.c b/monetdb5/modules/mal/tablet.c
--- a/monetdb5/modules/mal/tablet.c
+++ b/monetdb5/modules/mal/tablet.c
@@ -592,18 +592,8 @@
        return MAL_SUCCEED;
 }
 
-static ptr
-bun_head(COL *b, BUN nr)
-{
-       COLiter bi = col_iterator(b);
-       register BUN _i = BUNfirst(b);
-
-       return (ptr) BUNhead(bi, _i + nr);
-}
-
-
 static COL *
-void_bat_create(int adt, BUN nr)
+void_bat_create(int adt, oid nr)
 {
        COL *b = COLnew(adt, 32);
 
@@ -611,7 +601,7 @@
        if (b == NULL)
                return b;
        COLsetaccess(b, COL_APPEND);
-       if (nr > (BUN) REMAP_PAGE_MAXSIZE)
+       if (nr > (oid) REMAP_PAGE_MAXSIZE)
                COLmmap(b, STORE_MMAP, STORE_MMAP, 0); 
        if (nr > 32 && adt)
                b = COLextend(b, nr);
@@ -755,10 +745,10 @@
        as->output= NULL;
        /* assert(as->nr_attrs == nr_attrs); *//* i.e. it fits */
        for (p = 0; p < nr_attrs; p++) {
-               fmt[p].name = (char *) bun_head(names, p);
-               fmt[p].sep = sep_dup((char *) bun_head(seps, p));
+               fmt[p].name = COLgetString(names,p);
+               fmt[p].sep = sep_dup(COLgetString(seps, p));
                fmt[p].seplen = (int) strlen(fmt[p].sep);
-               fmt[p].type = (char *) bun_head(types, p);
+               fmt[p].type = (char *) COLgetString(types, p);
                fmt[p].adt = ATOMindex(fmt[p].type);
                if (fmt[p].adt <= 0) {
                        GDKerror("create_loadformat: %s has unknown type %s 
(using str instead).\n", fmt[p].name, fmt[p].name);
@@ -785,13 +775,14 @@
        return as->nr_attrs;
 }
 
-static BUN
+static oid
 create_dumpformat(Tablet * as, COL *names, COL *seps, COL *bats)
 {
        oid p;
        oid nr_attrs = COLcount(bats);
        Column *fmt = as->format = (Column *) GDKmalloc(sizeof(Column) * 
(nr_attrs + 1));
 
+       assert(0); /* we can not allow for COL of COLs anymore */
        if (fmt == NULL)
                return 0;
        as->offset = 0;
@@ -803,14 +794,14 @@
        as->output = NULL;
        /* assert(as->nr_attrs == nr_attrs); *//* i.e. it fits */
        for (p = 0; p < nr_attrs; p++) {
-               COL *b = COLdescriptor(*(bat *) bun_head(bats, p));
+               COL *b = NULL;
 
                if (!b)
                        return BUN_NONE;
                fmt[p].name = NULL;
                if (names)
-                       fmt[p].name = (char *) bun_head(names, p);
-               fmt[p].sep = sep_dup((char *) bun_head(seps, p));
+                       fmt[p].name = (char *) COLgetString(names, p);
+               fmt[p].sep = sep_dup((char *) COLgetString(seps, p));
                fmt[p].seplen = (int) strlen(fmt[p].sep);
                fmt[p].type = ATOMname(COLtype(b));
                fmt[p].adt = COLtype(b);
@@ -851,7 +842,7 @@
        GDKfree(fmt);
 }
 
-BUN
+oid
 TABLETassign_COLs(Tablet * as, COL *bats)
 {
        Column *fmt = as->format;
@@ -859,7 +850,7 @@
        oid i;
 
        for (i = 0; i < as->nr_attrs; i++) {
-               COL *b = COLdescriptor(*(bat *) bun_head(bats, i));
+               COL *b = COLdescriptor(*(bat *) COLgetString(bats, i));
 
                fmt[i].c[0] = (b);
                fmt[i].ci[0] = col_iterator(b);
@@ -891,7 +882,7 @@
                b = fmt[i].c[0];
                if (b == NULL)
                        continue;
-               offset = BUNfirst(b) + as->offset;
+               offset = as->offset;
 
                if (COLcount(b) != cnt || !COLdense(b) )
                        return oid_nil;
@@ -902,7 +893,7 @@
 }
 
 int
-TABLETcreate_bats(Tablet * as, BUN est)
+TABLETcreate_bats(Tablet * as, oid est)
 {
        Column *fmt = as->format;
        oid i;
@@ -919,7 +910,7 @@
                fmt[i].c[0] = void_bat_create(fmt[i].adt, est);
                fmt[i].ci[0] = col_iterator(fmt[i].c[0]);
                if (!fmt[i].c[0]) {
-                       GDKerror("TABLETcreate_bats: Failed to create bat of 
size " BUNFMT "\n", as->nr);
+                       GDKerror("TABLETcreate_bats: Failed to create bat of 
size " OIDFMT "\n", as->nr);
                        return -1;
                }
        }
@@ -953,7 +944,7 @@
 
                if (cnt != COLcount(fmt[i].c[0])) {
                        if ( as->error == 0) /* a new error */
-                               GDKerror("Error: column %d  count " BUNFMT " 
differs from " BUNFMT "\n",i,COLcount(fmt[i].c[0]),cnt);
+                               GDKerror("Error: column %d  count " OIDFMT " 
differs from " OIDFMT "\n",i,COLcount(fmt[i].c[0]),cnt);
                        CBPreleaseref(bats);
                        return NULL;
                }
@@ -1015,7 +1006,7 @@
                /* string needs the quotes included */
                s = find_quote(s, quote);
                if (!s) {
-                       snprintf(buf,BUFSIZ, "quote '%c' expected but not found 
in \"%s\" from line " BUNFMT "\n", quote, s, COLcount(fmt->c[0]));
+                       snprintf(buf,BUFSIZ, "quote '%c' expected but not found 
in \"%s\" from line " OIDFMT "\n", quote, s, COLcount(fmt->c[0]));
                        *err= GDKstrdup(buf);
                        return -1;
                }
@@ -1058,7 +1049,7 @@
                val = (s!=e)?GDKstrdup(s):GDKstrdup("");
                *e = bak;
 
-               snprintf(buf,BUFSIZ, "value '%s' while parsing '%s' from line " 
BUNFMT " field %d not inserted, expecting type %s\n", val, s, 
COLcount(fmt->c[0]), c, fmt->type);
+               snprintf(buf,BUFSIZ, "value '%s' while parsing '%s' from line " 
OIDFMT " field %d not inserted, expecting type %s\n", val, s, 
COLcount(fmt->c[0]), c, fmt->type);
                *err= GDKstrdup(buf);
                GDKfree(val);
                return -1;
@@ -1070,7 +1061,7 @@
                bunfastins(fmt->c[0], adt);
        return 0;
 bunins_failed:
-       snprintf(buf,BUFSIZ, "while parsing '%s' from line " BUNFMT " field %d 
not inserted\n", s, COLcount(fmt->c[0]), c);
+       snprintf(buf,BUFSIZ, "while parsing '%s' from line " OIDFMT " field %d 
not inserted\n", s, COLcount(fmt->c[0]), c);
        *err= GDKstrdup(buf);
        return -1;
 }
@@ -1098,11 +1089,11 @@
 }
 
 inline int
-insert_line(Tablet * as, char *line, BUN col1, BUN col2 )
+insert_line(Tablet * as, char *line, oid col1, oid col2 )
 {
        Column *fmt = as->format;
        char *s, *e = 0, quote=0, seperator = 0;
-       BUN i;
+       oid i;
        char errmsg[BUFSIZ];
 
        for (i = 0; i < as->nr_attrs ; i++) {
@@ -1122,7 +1113,7 @@
                        line = tablet_skip_string(line, quote);
                        if (!line) {
                                snprintf(errmsg,BUFSIZ, "End of string (%c) 
missing "
-                                       "in %s at line " BUNFMT "\n", quote, s, 
COLcount(fmt->c[0]));
+                                       "in %s at line " OIDFMT "\n", quote, s, 
COLcount(fmt->c[0]));
                                as->error = GDKstrdup(errmsg);
                                if (!as->tryall)
                                        return -1;
@@ -1163,7 +1154,7 @@
                                BUNappend(as->complaints, as->error, TRUE);
                        }
                } else {
-                       snprintf(errmsg,BUFSIZ, "missing separator '%s' line " 
BUNFMT " field " BUNFMT "\n", 
+                       snprintf(errmsg,BUFSIZ, "missing separator '%s' line " 
OIDFMT " field " OIDFMT "\n", 
                                fmt->sep, COLcount(fmt->c[0]), i);
                        as->error = GDKstrdup(errmsg);
                        if (!as->tryall)
@@ -1189,9 +1180,9 @@
 }
 
 static inline int
-dump_line(char **buf, int *len, Column * fmt, stream *fd, BUN nr_attrs, BUN id)
+dump_line(char **buf, int *len, Column * fmt, stream *fd, oid nr_attrs, oid id)
 {
-       BUN i;
+       oid i;
 
        for (i = 0; i < nr_attrs; i++) {
                Column *f;
@@ -1200,7 +1191,7 @@
 
                f = fmt + i;
                if (f->c[0]) {
-                       p = (char *) bun_head(f->c[0], id);
+                       p = (char *) COLgetString(f->c[0], id);
 
                        if (!p || ATOMcmp(f->adt, ATOMnilptr(f->adt), p) ==0) {
                                l = (int) strlen(f->nullstr);
@@ -1219,9 +1210,9 @@
 }
 
 static inline int
-output_line(char **buf, int *len, Column * fmt, stream *fd, BUN nr_attrs, ptr 
id)
+output_line(char **buf, int *len, Column * fmt, stream *fd, oid nr_attrs, ptr 
id)
 {
-       BUN i;
+       oid i;
 
        for (i = 0; i < nr_attrs; i++) {
                if (fmt[i].c[0] == NULL)
@@ -1259,9 +1250,9 @@
 }
 
 static inline int
-output_line_dense(char **buf, int *len, Column * fmt, stream *fd, BUN nr_attrs)
+output_line_dense(char **buf, int *len, Column * fmt, stream *fd, oid nr_attrs)
 {
-       BUN i;
+       oid i;
 
        for (i = 0; i < nr_attrs; i++) {
                Column *f = fmt + i;
@@ -1287,15 +1278,15 @@
 }
 
 static inline int
-output_line_lookup(char **buf, int *len, Column * fmt, stream *fd, BUN 
nr_attrs, BUN id)
+output_line_lookup(char **buf, int *len, Column * fmt, stream *fd, oid 
nr_attrs, oid id)
 {
-       BUN i;
+       oid i;
 
        for (i = 0; i < nr_attrs; i++) {
                Column *f = fmt + i;
 
                if (f->c[0]) {
-                       char *p = BUNhead(f->ci[0], id + BUNfirst(f->c[0]));
+                       str p = COLgetString(f->c[0], id );
 
                        if (!p || ATOMcmp(f->adt, ATOMnilptr(f->adt), p) ==0) {
                                size_t l = strlen(f->nullstr);
@@ -1375,15 +1366,15 @@
  * The rawmode() indicator acts as the internal switch.
 */
 
-static BUN
-TABLETload_bulk(Tablet * as, bstream *b, stream *out, BUN col1, BUN col2, int 
start, lng limit)
+static oid
+TABLETload_bulk(Tablet * as, bstream *b, stream *out, oid col1, oid col2, int 
start, lng limit)
 {
        int res = 0, done = 0;
-       BUN i = 0;
+       oid i = 0;
        char *sep = as->format[as->nr_attrs - 1].sep;
        int seplen = as->format[as->nr_attrs - 1].seplen;
-       BUN offset = as->offset;
-       BUN nr = offset + as->nr;
+       oid offset = as->offset;
+       oid nr = offset + as->nr;
        int started = !start;
 
 #ifdef _DEBUG_TABLET_
@@ -1397,7 +1388,7 @@
                        if (nr != BUN_NONE && i < nr) {
                                res = 1; 
                                if (b->len > b->pos) {
-                                       GDKerror("TABLETload_bulk: read error 
(after loading " BUNFMT " records)\n", COLcount(as->format[0].c[0]));
+                                       GDKerror("TABLETload_bulk: read error 
(after loading " OIDFMT " records)\n", COLcount(as->format[0].c[0]));
                                        res = -1;
                                }
                        }
@@ -1445,7 +1436,7 @@
                                                                
GDKerror(as->error);
                                                                as->error=0;
                                                                
GDKerror("TABLETload_bulk: read error "
-                                                                               
"(after loading " BUNFMT " records)\n",
+                                                                               
"(after loading " OIDFMT " records)\n",
                                                                                
COLcount(as->format[0].c[0]));
                                                        res = -1;
                                                }
@@ -1470,7 +1461,7 @@
                        started = 1;
 #ifdef _DEBUG_TABLET_
                        if ((i % 100000) == 0)
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list

Reply via email to