Changeset: e4b8e3ac1cd8 for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=e4b8e3ac1cd8 Modified Files: MonetDB5/src/modules/kernel/aggr_be_avg.mx MonetDB5/src/modules/kernel/aggr_be_count.mx MonetDB5/src/modules/kernel/aggr_be_minmax.mx MonetDB5/src/modules/kernel/aggr_be_prod.mx MonetDB5/src/modules/kernel/aggr_be_sum.mx MonetDB5/src/modules/kernel/aggr_bge_avg.mx MonetDB5/src/modules/kernel/aggr_bge_count.mx MonetDB5/src/modules/kernel/aggr_bge_minmax.mx MonetDB5/src/modules/kernel/aggr_bge_prod.mx MonetDB5/src/modules/kernel/aggr_bge_sum.mx MonetDB5/src/modules/kernel/aggr_ri.mx Branch: Jun2010 Log Message:
improved & "stream-lined" result initialization: - head of result is view of head of group extend - least-effort GDK2-aware result tail initialization diffs (truncated from 365 to 300 lines): diff -r 647c99679171 -r e4b8e3ac1cd8 MonetDB5/src/modules/kernel/aggr_be_avg.mx --- a/MonetDB5/src/modules/kernel/aggr_be_avg.mx Wed Jun 30 12:43:24 2010 +0200 +++ b/MonetDB5/src/modules/kernel/aggr_be_avg.mx Wed Jun 30 12:43:25 2010 +0200 @@ -178,8 +178,8 @@ int cmdaggrx3_a...@1(BAT **ret, BAT *b, BAT *e) { - BAT *bn = BATnew(e->htype, TYPE_dbl, BATcount(e)); - BATiter bni = bat_iterator(bn), bi = bat_iterator(b); + BAT *bn = BATnew(TYPE_void, TYPE_dbl, BATcount(e)); + BATiter bni, bi = bat_iterator(b); BUN off; BUN *cnt = NULL; BUN slots; @@ -194,12 +194,13 @@ GDKerror("cmdaggrx3_a...@1(): BATnew() failed"); return GDK_FAIL; } - off = BUNfirst(bn); ALGODEBUG THRprintf(GDKout, "#cmdaggrx3_a...@1[@2](b=%s,e=%s);\n", BATgetId(b),BATgetId(e)); /* init: set all sums & counts to zero and calculate min/max oid */ @:init_result(dbl)@ + bni = bat_iterator(bn); + off = BUNfirst(bn); range = max - min + 1; /* scan b, calculate sums & counts, derive averages */ diff -r 647c99679171 -r e4b8e3ac1cd8 MonetDB5/src/modules/kernel/aggr_be_count.mx --- a/MonetDB5/src/modules/kernel/aggr_be_count.mx Wed Jun 30 12:43:24 2010 +0200 +++ b/MonetDB5/src/modules/kernel/aggr_be_count.mx Wed Jun 30 12:43:25 2010 +0200 @@ -195,8 +195,7 @@ return GDK_SUCCEED; } - bn = BATnew(e->htype, TYPE_wrd, BATcount(e)); - bni = bat_iterator(bn); + bn = BATnew(TYPE_void, TYPE_wrd, BATcount(e)); if( bn == NULL) { GDKerror("CMDaggrX3_count(): BATnew() failed"); return GDK_FAIL; @@ -204,6 +203,7 @@ /* init: set all counts to zero and calculate min/max oid */ @:init_result(wrd)@ + bni = bat_iterator(bn); range = max - min + 1; if (!BAThdense(b)) diff -r 647c99679171 -r e4b8e3ac1cd8 MonetDB5/src/modules/kernel/aggr_be_minmax.mx --- a/MonetDB5/src/modules/kernel/aggr_be_minmax.mx Wed Jun 30 12:43:24 2010 +0200 +++ b/MonetDB5/src/modules/kernel/aggr_be_minmax.mx Wed Jun 30 12:43:25 2010 +0200 @@ -227,8 +227,8 @@ static int aggr...@1_@3...@4_@5(BAT **ret, BAT *b, BAT *e) { - BAT *bn = BATnew(e->htype, BATttype(b), BATcount(e)); - BATiter bni = bat_iterator(bn), bi = bat_iterator(b); + BAT *bn = BATnew(TYPE_void, BATttype(b), BATcount(e)); + BATiter bni, bi = bat_iterator(b); int (*cmp)(ptr,ptr); ptr nil; BUN off; @@ -247,16 +247,17 @@ GDKerror("aggr...@1_@3...@4_@5(): BATnew() failed"); return GDK_FAIL; } - cmp = BATatoms[bn->ttype].atomCmp; - nil = ATOMnilptr(bn->ttype); - off = BUNfirst(bn); - *ret = NULL; ALGODEBUG THRprintf(GDKout, "#aggr...@1_@3...@4_@5...@2,@6](b=%s,e=%s);\n", BATgetId(b),BATgetId(e)); /* init: prepare the result bat; * trick: by using "tail-type" void, we only write the head column, here */ @:init_result(void)@ + bni = bat_iterator(bn); + cmp = BATatoms[bn->ttype].atomCmp; + nil = ATOMnilptr(bn->ttype); + off = BUNfirst(bn); + *ret = NULL; range = max - min + 1; /* scan b and replace totals by the extreme value (just pointers to vals in b) */ diff -r 647c99679171 -r e4b8e3ac1cd8 MonetDB5/src/modules/kernel/aggr_be_prod.mx --- a/MonetDB5/src/modules/kernel/aggr_be_prod.mx Wed Jun 30 12:43:24 2010 +0200 +++ b/MonetDB5/src/modules/kernel/aggr_be_prod.mx Wed Jun 30 12:43:25 2010 +0200 @@ -178,8 +178,8 @@ int cmdaggrx3_pr...@1_@3(BAT **ret, BAT *b, BAT *e) { - BAT *bn = BATnew(e->htype, ty...@3, BATcount(e)); - BATiter bni = bat_iterator(bn), bi = bat_iterator(b); + BAT *bn = BATnew(TYPE_void, ty...@3, BATcount(e)); + BATiter bni, bi = bat_iterator(b); @3 zero = (@3) 1, *prods = NULL; bit *hit = NULL; BUN slots, off; @@ -193,11 +193,12 @@ GDKerror("cmdaggrx3_pr...@1_@3(): BATnew() failed"); return GDK_FAIL; } - off = BUNfirst(bn); ALGODEBUG THRprintf(GDKout, "#cmdaggrx3_pr...@1_@3...@2](b=%s,e=%s);\n", BATgetId(b), BATgetId(e)); /* init: set all prods to zero and calculate min/max oid */ @:init_result(@3)@ + bni = bat_iterator(bn); + off = BUNfirst(bn); range = max - min + 1; /* scan b, and calculate prods */ diff -r 647c99679171 -r e4b8e3ac1cd8 MonetDB5/src/modules/kernel/aggr_be_sum.mx --- a/MonetDB5/src/modules/kernel/aggr_be_sum.mx Wed Jun 30 12:43:24 2010 +0200 +++ b/MonetDB5/src/modules/kernel/aggr_be_sum.mx Wed Jun 30 12:43:25 2010 +0200 @@ -176,8 +176,8 @@ int cmdaggrx3_s...@1_@3(BAT **ret, BAT *b, BAT *e) { - BAT *bn = BATnew(e->htype, ty...@3, BATcount(e)); - BATiter bni = bat_iterator(bn), bi = bat_iterator(b); + BAT *bn = BATnew(TYPE_void, ty...@3, BATcount(e)); + BATiter bni, bi = bat_iterator(b); @3 zero = (@3) 0, *sums = NULL; bit *hit = NULL; BUN slots, off; @@ -191,11 +191,12 @@ GDKerror("cmdaggrx3_s...@1_@3(): BATnew() failed"); return GDK_FAIL; } - off = BUNfirst(bn); ALGODEBUG THRprintf(GDKout, "#cmdaggrx3_s...@1_@3...@2](b=%s,e=%s);\n", BATgetId(b), BATgetId(e)); /* init: set all sums to zero and calculate min/max oid */ @:init_result(@3)@ + bni = bat_iterator(bn); + off = BUNfirst(bn); range = max - min + 1; /* scan b, and calculate sums */ diff -r 647c99679171 -r e4b8e3ac1cd8 MonetDB5/src/modules/kernel/aggr_bge_avg.mx --- a/MonetDB5/src/modules/kernel/aggr_bge_avg.mx Wed Jun 30 12:43:24 2010 +0200 +++ b/MonetDB5/src/modules/kernel/aggr_bge_avg.mx Wed Jun 30 12:43:25 2010 +0200 @@ -234,16 +234,16 @@ return rtrn; } - bn = BATnew(e->htype, TYPE_dbl, BATcount(e)); + bn = BATnew(TYPE_void, TYPE_dbl, BATcount(e)); if( bn == NULL) { GDKerror("cmdaggrx3_av...@1(): BATnew() failed"); return GDK_FAIL; } - bni = bat_iterator(bn); - off = BUNfirst(bn); /* init: set all sums & counts to zero and calculate min/max oid */ @:init_result(dbl)@ + bni = bat_iterator(bn); + off = BUNfirst(bn); range = max - min + 1; /* scan b & g, calculate sums & counts, derive averages */ diff -r 647c99679171 -r e4b8e3ac1cd8 MonetDB5/src/modules/kernel/aggr_bge_count.mx --- a/MonetDB5/src/modules/kernel/aggr_bge_count.mx Wed Jun 30 12:43:24 2010 +0200 +++ b/MonetDB5/src/modules/kernel/aggr_bge_count.mx Wed Jun 30 12:43:25 2010 +0200 @@ -230,8 +230,7 @@ *ret = bn; return GDK_SUCCEED; } - bn = BATnew(e->htype, TYPE_wrd, BATcount(e)); - bni = bat_iterator(bn); + bn = BATnew(TYPE_void, TYPE_wrd, BATcount(e)); if( bn == NULL) { GDKerror("CMDaggrX3_count3(): BATnew() failed"); return GDK_FAIL; @@ -239,6 +238,7 @@ /* init: set all counts to zero and calculate min/max oid */ @:init_result(wrd)@ + bni = bat_iterator(bn); bn->T->nonil = 1; range = max - min + 1; diff -r 647c99679171 -r e4b8e3ac1cd8 MonetDB5/src/modules/kernel/aggr_bge_minmax.mx --- a/MonetDB5/src/modules/kernel/aggr_bge_minmax.mx Wed Jun 30 12:43:24 2010 +0200 +++ b/MonetDB5/src/modules/kernel/aggr_bge_minmax.mx Wed Jun 30 12:43:25 2010 +0200 @@ -313,19 +313,19 @@ return rtrn; } - bn = BATnew(e->htype, BATttype(b), BATcount(e)); + bn = BATnew(TYPE_void, BATttype(b), BATcount(e)); if( bn == NULL) { GDKerror("aggr...@13_@3...@4_@5(): BATnew() failed"); return GDK_FAIL; } + + /* init: prepare the result bat; + * trick: by using "tail-type" void, we only write the head column, here */ + @:init_result(void)@ bni = bat_iterator(bn); cmp = BATatoms[bn->ttype].atomCmp; nil = ATOMnilptr(bn->ttype); off = BUNfirst(bn); - - /* init: prepare the result bat; - * trick: by using "tail-type" void, we only write the head column, here */ - @:init_result(void)@ range = max - min + 1; /* scan b & g and replace totals by the extreme value (just pointers to vals in b) */ diff -r 647c99679171 -r e4b8e3ac1cd8 MonetDB5/src/modules/kernel/aggr_bge_prod.mx --- a/MonetDB5/src/modules/kernel/aggr_bge_prod.mx Wed Jun 30 12:43:24 2010 +0200 +++ b/MonetDB5/src/modules/kernel/aggr_bge_prod.mx Wed Jun 30 12:43:25 2010 +0200 @@ -262,17 +262,17 @@ return rtrn; } - bn = BATnew(e->htype, ty...@2, BATcount(e)); + bn = BATnew(TYPE_void, ty...@2, BATcount(e)); if( bn == NULL) { GDKerror("cmdaggrx3_pro...@1_@2(): BATnew() failed"); return GDK_FAIL; } + + /* init: set all prods to zero and calculate min/max oid */ + @:init_result(@2)@ bni = bat_iterator(bn); off = BUNfirst(bn); *ret = bn; - - /* init: set all prods to zero and calculate min/max oid */ - @:init_result(@2)@ range = max - min + 1; /* scan b & g, and calculate prods */ diff -r 647c99679171 -r e4b8e3ac1cd8 MonetDB5/src/modules/kernel/aggr_bge_sum.mx --- a/MonetDB5/src/modules/kernel/aggr_bge_sum.mx Wed Jun 30 12:43:24 2010 +0200 +++ b/MonetDB5/src/modules/kernel/aggr_bge_sum.mx Wed Jun 30 12:43:25 2010 +0200 @@ -258,18 +258,17 @@ return rtrn; } - bn = BATnew(e->htype, ty...@2, BATcount(e)); + bn = BATnew(TYPE_void, ty...@2, BATcount(e)); if( bn == NULL) { GDKerror("cmdaggrx3_su...@1_@2(): BATnew() failed"); return GDK_FAIL; } - bni = bat_iterator(bn); - off = BUNfirst(bn); - - *ret = bn; /* init: set all sums to zero and calculate min/max oid */ @:init_result(@2)@ + bni = bat_iterator(bn); + off = BUNfirst(bn); + *ret = bn; range = max - min + 1; /* scan b & g, and calculate sums */ diff -r 647c99679171 -r e4b8e3ac1cd8 MonetDB5/src/modules/kernel/aggr_ri.mx --- a/MonetDB5/src/modules/kernel/aggr_ri.mx Wed Jun 30 12:43:24 2010 +0200 +++ b/MonetDB5/src/modules/kernel/aggr_ri.mx Wed Jun 30 12:43:25 2010 +0200 @@ -27,55 +27,52 @@ */ @= init_result { - REGISTER BUN _p = BUNlast(bn); REGISTER BUN _cnt = BATcount(e); - BATiter ei = bat_iterator(e); + BAT *bm = 0; - bn->tsorted = bn->hsorted = 0; + bn->tsorted = 0; bn->T->nonil = 0; min = max = (oid) 0; - ALIGNsetH(bn, e); + if (_cnt) { + if (BAThdense(e)) { + min = e->hseqbase; + max = min + _cnt - 1; + } else + if (BAThordered(e)) { + min = *(oid*) Hloc(e, BUNfirst(e)); + max = *(oid*) Hloc(e, BUNlast(e) - 1); + } else { + BUN _i = 0; + oid *eh = (oid*)Hloc(e,BUNfirst(e)); + min = max = eh[0]; + BATaccessBegin(e,USE_HEAD,MMAP_SEQUENTIAL); + for (_i = 0; _i < _cnt; _i++) { + if (eh[_i] < min) + min = eh[_i]; + else + if (eh[_i] > max) _______________________________________________ Checkin-list mailing list Checkin-list@monetdb.org http://mail.monetdb.org/mailman/listinfo/checkin-list