Changeset: 5adb14259cdc for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=5adb14259cdc
Modified Files:
        monetdb5/modules/mal/mat.c
        monetdb5/modules/mal/mkey.c
        monetdb5/modules/mal/pcrelib.c
        monetdb5/modules/mal/profiler.c
        monetdb5/modules/mal/tablet.c
        monetdb5/modules/mal/tokenizer.c
        monetdb5/modules/mal/zorder.c
Branch: headless
Log Message:

BATnew -> COLnew
And further preparations for the new GDK.


diffs (truncated from 1216 to 300 lines):

diff --git a/monetdb5/modules/mal/mat.c b/monetdb5/modules/mal/mat.c
--- a/monetdb5/modules/mal/mat.c
+++ b/monetdb5/modules/mal/mat.c
@@ -21,7 +21,7 @@
  * Multiple association tables
  * A MAT is a convenient way to deal represent horizontal fragmented
  * tables. It combines the definitions of several, type compatible
- * BATs under a single name. 
+ * columns under a single name. 
  * It is produced by the mitosis optimizer and the operations
  * are the target of the mergetable optimizer.
  * 
@@ -41,10 +41,10 @@
 #include "group.h"
 
 /*
- * The pack is an ordinary multi BAT insert. Oid synchronistion
+ * The pack is an ordinary multi columne insert. Oid synchronistion
  * between pieces should be ensured by the code generators.
  * The pack operation could be quite expensive, because it
- * may create a really large BAT.
+ * may create a really large columne.
  * The slice over a mat helps to avoid constructing intermediates
  * that are subsequently reduced.
 */
@@ -52,8 +52,8 @@
 MATpackInternal(MalStkPtr stk, InstrPtr p)
 {
        int i, *ret = (int*) getArgReference(stk,p,0);
-       BAT *b, *bn;
-       BUN cap = 0;
+       COL *b, *bn;
+       oid cap = 0;
        int ht = TYPE_any;
 
        for (i = 1; i < p->argc; i++) {
@@ -69,7 +69,7 @@
                cap += BATcount(b);
        }
 
-       bn = BATnew(TYPE_void, ht, cap);
+       bn = COLnew(ht, cap);
        if (bn == NULL)
                throw(MAL, "mat.pack", MAL_MALLOC_FAIL);
        /* must set seqbase or else BATins will not materialize column */
@@ -93,13 +93,13 @@
 MATpack2Internal(MalStkPtr stk, InstrPtr p)
 {
        int i,*ret;
-       BAT *b, *bn;
-       BUN cap=0;
+       COL *b, *bn;
+       oid cap=0;
 
        b= BATdescriptor(stk->stk[getArg(p,1)].val.ival);
        if( b == NULL)
                throw(MAL, "mat.pack", RUNTIME_OBJECT_MISSING);
-       bn = BATcopy(b, b->htype, b->ttype, TRUE);
+       bn = BATcopy(b, COLtype(b), TRUE);
        BBPunfix(b->batCacheid);
        if( bn == NULL)
                throw(MAL, "mat.pack", MAL_MALLOC_FAIL);
@@ -131,20 +131,20 @@
 MATpackSliceInternal(MalBlkPtr mb, MalStkPtr stk, InstrPtr p)
 {
        int i, i1 = p->argc, i2 = -1, *ret = (int*) getArgReference(stk,p,0);
-       BAT *b, *bn;
-       BUN cap = 0, fst, lst, cnt, c;
+       COL *b, *bn;
+       oid cap = 0, fst, lst, cnt, c;
        int ht = TYPE_any;
 
        assert(p->argc > 3);
        switch getArgType(mb,p,1) {
        case TYPE_wrd:
-               fst = (BUN) *(wrd*) getArgReference(stk,p,1);
+               fst = (oid) *(wrd*) getArgReference(stk,p,1);
                break;
        case TYPE_lng:
-               fst = (BUN) *(lng*) getArgReference(stk,p,1);
+               fst = (oid) *(lng*) getArgReference(stk,p,1);
                break;
        case TYPE_int:
-               fst = (BUN) *(int*) getArgReference(stk,p,1);
+               fst = (oid) *(int*) getArgReference(stk,p,1);
                break;
        default:
                throw(MAL, "mat.packSlice", "wrong type for lower bound");
@@ -225,7 +225,7 @@
                cap -= fst;
        cnt = MIN(cnt, cap);
 
-       bn = BATnew(TYPE_void, ht, cnt);
+       bn = COLnew(ht, cnt);
        if (bn == NULL)
                throw(MAL, "mat.packSlice", MAL_MALLOC_FAIL);
        /* must set seqbase or else BATins will not materialize column */
@@ -286,12 +286,12 @@
 {
        BAT *res;
        int i;
-       BUN j, cnt = BATcount(map);
+       oid j, cnt = BATcount(map);
        BATiter *bats_i;
-       BUN *batsT;
+       oid *batsT;
        bte *mapT;
 
-       res = BATnew(TYPE_void, bats[0]->ttype, cnt);
+       res = COLnew(bats[0]->ttype, cnt);
        BATseqbase(res, map->hseqbase);
        mapT = (bte*)Tloc(map, 0);
        batsT = (BUN*)GDKmalloc(sizeof(BUN) * len);
@@ -306,34 +306,97 @@
        return res;
 }
 
-@= project
 static BAT *
-MATproject_@1( BAT *map, BAT **bats, int len )
+MATproject_bte( BAT *map, BAT **bats, int len )
 {
-       BAT *res;
+       COL *res;
        int i;
-       BUN j, cnt = BATcount(map);
-       @1 *resT, **batsT;
+       oid j, cnt = BATcount(map);
+       bte *resT, **batsT;
        bte *mapT;
 
-       res = BATnew(TYPE_void, bats[0]->ttype, cnt);
+       res = COLnew(bats[0]->ttype, cnt);
        BATseqbase(res, map->hseqbase);
-       resT = (@1*)Tloc(res, 0);
+       resT = (bte*)Tloc(res, 0);
        mapT = (bte*)Tloc(map, 0);
-       batsT = (@1**)GDKmalloc(sizeof(@1*) * len);
+       batsT = (bte**)GDKmalloc(sizeof(bte*) * len);
        for (i=0; i<len; i++)
-               batsT[i] = (@1*)Tloc(bats[i], 0);
+               batsT[i] = (bte*)Tloc(bats[i], 0);
        for (j=0; j<cnt; j++)
                resT[j] = *batsT[mapT[j]]++;
        BATsetcount(res, j);
        GDKfree(batsT);
        return res;
 }
-@c
-@:project(bte)@
-@:project(sht)@
-@:project(int)@
-@:project(lng)@
+
+static BAT *
+MATproject_sht( BAT *map, BAT **bats, int len )
+{
+       COL *res;
+       int i;
+       oid j, cnt = BATcount(map);
+       sht *resT, **batsT;
+       bte *mapT;
+
+       res = COLnew(bats[0]->ttype, cnt);
+       BATseqbase(res, map->hseqbase);
+       resT = (sht*)Tloc(res, 0);
+       mapT = (bte*)Tloc(map, 0);
+       batsT = (sht**)GDKmalloc(sizeof(sht*) * len);
+       for (i=0; i<len; i++)
+               batsT[i] = (sht*)Tloc(bats[i], 0);
+       for (j=0; j<cnt; j++)
+               resT[j] = *batsT[mapT[j]]++;
+       BATsetcount(res, j);
+       GDKfree(batsT);
+       return res;
+}
+
+static BAT *
+MATproject_int( BAT *map, BAT **bats, int len )
+{
+       COL *res;
+       int i;
+       oid j, cnt = BATcount(map);
+       int *resT, **batsT;
+       bte *mapT;
+
+       res = COLnew(bats[0]->ttype, cnt);
+       BATseqbase(res, map->hseqbase);
+       resT = (int*)Tloc(res, 0);
+       mapT = (bte*)Tloc(map, 0);
+       batsT = (int**)GDKmalloc(sizeof(int*) * len);
+       for (i=0; i<len; i++)
+               batsT[i] = (int*)Tloc(bats[i], 0);
+       for (j=0; j<cnt; j++)
+               resT[j] = *batsT[mapT[j]]++;
+       BATsetcount(res, j);
+       GDKfree(batsT);
+       return res;
+}
+
+static BAT *
+MATproject_lng( BAT *map, BAT **bats, int len )
+{
+       COL *res;
+       int i;
+       oid j, cnt = BATcount(map);
+       lng *resT, **batsT;
+       bte *mapT;
+
+       res = COLnew(bats[0]->ttype, cnt);
+       BATseqbase(res, map->hseqbase);
+       resT = (lng*)Tloc(res, 0);
+       mapT = (bte*)Tloc(map, 0);
+       batsT = (lng**)GDKmalloc(sizeof(lng*) * len);
+       for (i=0; i<len; i++)
+               batsT[i] = (lng*)Tloc(bats[i], 0);
+       for (j=0; j<cnt; j++)
+               resT[j] = *batsT[mapT[j]]++;
+       BATsetcount(res, j);
+       GDKfree(batsT);
+       return res;
+}
 
 static int
 MATnonil( BAT **bats, int len)
diff --git a/monetdb5/modules/mal/mkey.c b/monetdb5/modules/mal/mkey.c
--- a/monetdb5/modules/mal/mkey.c
+++ b/monetdb5/modules/mal/mkey.c
@@ -20,7 +20,7 @@
 /* Author(s) Peter Boncz, Stefan Manegold, Niels Nes
  * The Problem
  * When creating a join, we want to make a unique key of the attributes on both
- * sides and then join these keys. Consider the following BATs.
+ * sides and then join these keys. Consider the following columns.
  * 
  * @verbatim
  * orders                  customer                link
@@ -226,14 +226,14 @@
 }
 
 static str
-voidbathash(BAT **res, BAT *b )
+voidbathash(COL **res, BAT *b )
 {
-       BAT *dst;
-       BUN (*hash)(ptr v); 
+       COL *dst;
+       oid (*hash)(ptr v); 
        wrd *r, *f;
        BATiter bi, dsti;
 
-       dst = BATnew(TYPE_void, TYPE_wrd, BATcount(b));
+       dst = COLnew(TYPE_wrd, BATcount(b));
        if (!dst) 
                throw(SQL, "bathash", "can not create bat");
        BATseqbase(dst, b->hseqbase);
@@ -300,11 +300,10 @@
 MKEYbathash(bat *res, bat *bid )
 {
        str msg;
-       BAT *b, *dst = 0;
+       COL *b, *dst = 0;
 
-       if( (b = BATdescriptor(*bid)) == NULL ){
+       if( (b = BATdescriptor(*bid)) == NULL )
                throw(SQL, "bathash", "Cannot access descriptor");
-       }
        assert(BAThrestricted(b));
 
        msg = voidbathash(&dst, b);
@@ -360,9 +359,9 @@
 }
 
 static str
-CMDbulk_rotate_xor_hash(BAT **res, BAT *bn, int *rotate, BAT *b)
+CMDbulk_rotate_xor_hash(COL **res, COL *bn, int *rotate, COL *b)
 {
-       BAT* br = NULL;
+       COL *br = NULL;
        BATiter bi = bat_iterator(b);
        wrd *src = (wrd *) Tloc(bn, BUNfirst(bn));
        wrd *dst = NULL;
@@ -389,7 +388,7 @@
        }
        
        BATaccessBegin(b, USE_TAIL, MMAP_SEQUENTIAL);
-       br = BATnew(TYPE_void, TYPE_wrd, BATcount(bn));
+       br = COLnew(TYPE_wrd, BATcount(bn));
        if (br == NULL) {
 #ifdef _DEBUG_MKEY_
                mnstr_printf(GDKout,"CMDbulk_rotate_xor_hash: fail to allocate 
result BAT[void,wrd] of "SZFMT" tuples.\n", BATcount(bn));
@@ -447,7 +446,7 @@
                        src++;
                }
        } else if (tpe == TYPE_str) {   /* TYPE_str */
-               BUN p, q;
+               oid p, q;
 
                if (b->T->vheap->hashash) {
                        BATloop(b, p, q) {
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list

Reply via email to