Changeset: 1ba3e1f76aba for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=1ba3e1f76aba Modified Files: monetdb5/modules/mal/Tests/mosaic_mix_joins.mal monetdb5/modules/mal/Tests/mosaic_mix_joins.stable.out monetdb5/modules/mal/Tests/mosaic_none_joins.mal monetdb5/modules/mal/Tests/mosaic_none_joins.stable.out monetdb5/modules/mal/Tests/mosaic_rle_joins.mal monetdb5/modules/mal/Tests/mosaic_rle_joins.stable.out monetdb5/modules/mal/mosaic.c monetdb5/modules/mal/mosaic_none.c monetdb5/modules/mal/mosaic_rle.c Branch: mosaic Log Message:
Type expansion to cover the other built-in types. diffs (truncated from 564 to 300 lines): diff --git a/monetdb5/modules/mal/Tests/mosaic_mix_joins.mal b/monetdb5/modules/mal/Tests/mosaic_mix_joins.mal --- a/monetdb5/modules/mal/Tests/mosaic_mix_joins.mal +++ b/monetdb5/modules/mal/Tests/mosaic_mix_joins.mal @@ -40,6 +40,7 @@ io.print(xs); d:= bat.new(:oid,:int); bat.append(d,9); bat.append(d,11); +bat.append(d,nil:int); (jl,jr):= algebra.join(b,d); io.print(jl,jr); diff --git a/monetdb5/modules/mal/Tests/mosaic_mix_joins.stable.out b/monetdb5/modules/mal/Tests/mosaic_mix_joins.stable.out --- a/monetdb5/modules/mal/Tests/mosaic_mix_joins.stable.out +++ b/monetdb5/modules/mal/Tests/mosaic_mix_joins.stable.out @@ -54,6 +54,7 @@ function user.main():void; d := bat.new(:oid,:int); bat.append(d,9); bat.append(d,11); + bat.append(d,nil:int); (jl,jr) := algebra.join(b,d); io.print(jl,jr); (ml,mr) := mosaic.join(x,d); diff --git a/monetdb5/modules/mal/Tests/mosaic_none_joins.mal b/monetdb5/modules/mal/Tests/mosaic_none_joins.mal --- a/monetdb5/modules/mal/Tests/mosaic_none_joins.mal +++ b/monetdb5/modules/mal/Tests/mosaic_none_joins.mal @@ -24,6 +24,7 @@ io.print(xs); d:= bat.new(:oid,:int); bat.append(d,9); bat.append(d,11); +bat.append(d,nil:int); (jl,jr):= algebra.join(b,d); io.print(jl,jr); diff --git a/monetdb5/modules/mal/Tests/mosaic_none_joins.stable.out b/monetdb5/modules/mal/Tests/mosaic_none_joins.stable.out --- a/monetdb5/modules/mal/Tests/mosaic_none_joins.stable.out +++ b/monetdb5/modules/mal/Tests/mosaic_none_joins.stable.out @@ -39,6 +39,7 @@ function user.main():void; d := bat.new(:oid,:int); bat.append(d,9); bat.append(d,11); + bat.append(d,nil:int); (jl,jr) := algebra.join(b,d); io.print(jl,jr); (ml,mr) := mosaic.join(x,d); diff --git a/monetdb5/modules/mal/Tests/mosaic_rle_joins.mal b/monetdb5/modules/mal/Tests/mosaic_rle_joins.mal --- a/monetdb5/modules/mal/Tests/mosaic_rle_joins.mal +++ b/monetdb5/modules/mal/Tests/mosaic_rle_joins.mal @@ -25,6 +25,7 @@ io.print(xs); d:= bat.new(:oid,:int); bat.append(d,9); bat.append(d,11); +bat.append(d,nil:int); (jl,jr):= algebra.join(b,d); io.print(jl,jr); diff --git a/monetdb5/modules/mal/Tests/mosaic_rle_joins.stable.out b/monetdb5/modules/mal/Tests/mosaic_rle_joins.stable.out --- a/monetdb5/modules/mal/Tests/mosaic_rle_joins.stable.out +++ b/monetdb5/modules/mal/Tests/mosaic_rle_joins.stable.out @@ -41,6 +41,7 @@ function user.main():void; d := bat.new(:oid,:int); bat.append(d,9); bat.append(d,11); + bat.append(d,nil:int); (jl,jr) := algebra.join(b,d); io.print(jl,jr); (ml,mr) := mosaic.join(x,d); diff --git a/monetdb5/modules/mal/mosaic.c b/monetdb5/modules/mal/mosaic.c --- a/monetdb5/modules/mal/mosaic.c +++ b/monetdb5/modules/mal/mosaic.c @@ -113,6 +113,7 @@ typedef struct MOSINDEX{ float nextafterf(float x, float y); #endif +#define PREVVALUEbit(x) ((x) - 1) #define PREVVALUEbte(x) ((x) - 1) #define PREVVALUEsht(x) ((x) - 1) #define PREVVALUEint(x) ((x) - 1) @@ -121,6 +122,7 @@ float nextafterf(float x, float y); #define PREVVALUEflt(x) nextafterf((x), -GDK_flt_max) #define PREVVALUEdbl(x) nextafter((x), -GDK_dbl_max) +#define NEXTVALUEbit(x) ((x) + 1) #define NEXTVALUEbte(x) ((x) + 1) #define NEXTVALUEsht(x) ((x) + 1) #define NEXTVALUEint(x) ((x) + 1) @@ -746,7 +748,7 @@ str MOSleftfetchjoin(Client cntxt, MalBl { int *ret, *lid =0, *rid=0; BAT *bl = NULL, *br = NULL, *bn; - BUN cnt, first; + BUN cnt, first=0; oid *ol =0, o = 0; str msg= MAL_SUCCEED; MOStask task; @@ -841,7 +843,7 @@ MOSjoin(Client cntxt, MalBlkPtr mb, MalS { int *ret,*lid,*rid; BAT *bl = NULL, *br = NULL, *bln = NULL, *brn= NULL; - BUN cnt = 0, first; + BUN cnt = 0, first= 0; int swapped = 0; str msg = MAL_SUCCEED; MOStask task; @@ -903,12 +905,12 @@ MOSjoin(Client cntxt, MalBlkPtr mb, MalS switch(task->blk->tag){ case MOSAIC_RLE: MOSjoin_rle(cntxt, task, first, first + task->blk->cnt); - first += task->blk->cnt; + first += (BUN) task->blk->cnt; MOSskip_rle(task); break; case MOSAIC_NONE: MOSjoin_none(cntxt, task, first, first + task->blk->cnt); - first += task->blk->cnt; + first += (BUN) task->blk->cnt; MOSskip_none(task); break; default: diff --git a/monetdb5/modules/mal/mosaic_none.c b/monetdb5/modules/mal/mosaic_none.c --- a/monetdb5/modules/mal/mosaic_none.c +++ b/monetdb5/modules/mal/mosaic_none.c @@ -145,7 +145,69 @@ if ( task->cl && task->n){\ }\ } else if (task->cl) continue; -#define MOSselect_none(TPE)/* TBD */ +#define subselect_none(TPE) {\ + TPE *val= (TPE*) (((char*) task->blk) + MosaicBlkSize);\ + if( !*anti){\ + if( *(TPE*) low == TPE##_nil && *(TPE*) hgh == TPE##_nil){\ + for( ; first < last; first++, val++){\ + MOSskipit();\ + *o++ = (oid) first;\ + }\ + } else\ + if( *(TPE*) low == TPE##_nil ){\ + for( ; first < last; first++, val++){\ + MOSskipit();\ + cmp = ((*hi && *(TPE*)val <= * (TPE*)hgh ) || (!*hi && *(TPE*)val < *(TPE*)hgh ));\ + if (cmp )\ + *o++ = (oid) first;\ + }\ + } else\ + if( *(TPE*) hgh == TPE##_nil ){\ + for( ; first < last; first++, val++){\ + MOSskipit();\ + cmp = ((*li && *(TPE*)val >= * (TPE*)low ) || (!*li && *(TPE*)val > *(TPE*)low ));\ + if (cmp )\ + *o++ = (oid) first;\ + }\ + } else{\ + for( ; first < last; first++, val++){\ + MOSskipit();\ + cmp = ((*hi && *(TPE*)val <= * (TPE*)hgh ) || (!*hi && *(TPE*)val < *(TPE*)hgh )) &&\ + ((*li && *(TPE*)val >= * (TPE*)low ) || (!*li && *(TPE*)val > *(TPE*)low ));\ + if (cmp )\ + *o++ = (oid) first;\ + }\ + }\ + } else {\ + if( *(TPE*) low == TPE##_nil && *(TPE*) hgh == TPE##_nil){\ + /* nothing is matching */\ + } else\ + if( *(TPE*) low == TPE##_nil ){\ + for( ; first < last; first++, val++){\ + MOSskipit();\ + cmp = ((*hi && *(TPE*)val <= * (TPE*)hgh ) || (!*hi && *(TPE*)val < *(TPE*)hgh ));\ + if ( !cmp )\ + *o++ = (oid) first;\ + }\ + } else\ + if( *(TPE*) hgh == TPE##_nil ){\ + for( ; first < last; first++, val++){\ + MOSskipit();\ + cmp = ((*li && *(TPE*)val >= * (TPE*)low ) || (!*li && *(TPE*)val > *(TPE*)low ));\ + if ( !cmp )\ + *o++ = (oid) first;\ + }\ + } else{\ + for( ; first < last; first++, val++){\ + MOSskipit();\ + cmp = ((*hi && *(TPE*)val <= * (TPE*)hgh ) || (!*hi && *(TPE*)val < *(TPE*)hgh )) &&\ + ((*li && *(TPE*)val >= * (TPE*)low ) || (!*li && *(TPE*)val > *(TPE*)low ));\ + if ( !cmp )\ + *o++ = (oid) first;\ + }\ + }\ + }\ + } static str MOSsubselect_none(Client cntxt, MOStask task, lng first, lng last, void *low, void *hgh, bit *li, bit *hi, bit *anti) @@ -163,13 +225,13 @@ MOSsubselect_none(Client cntxt, MOStask last = task->blk->cnt; o = task->lb; - switch(task->type){ - case TYPE_bit: MOSselect_none(bit); break; - case TYPE_bte: MOSselect_none(bte); break; - case TYPE_sht: MOSselect_none(sht); break; - case TYPE_lng: MOSselect_none(lng); break; - case TYPE_flt: MOSselect_none(flt); break; - case TYPE_dbl: MOSselect_none(dbl); break; + switch(ATOMstorage(task->type)){ + case TYPE_bit: subselect_none(bit); break; + case TYPE_bte: subselect_none(bte); break; + case TYPE_sht: subselect_none(sht); break; + case TYPE_lng: subselect_none(lng); break; + case TYPE_flt: subselect_none(flt); break; + case TYPE_dbl: subselect_none(dbl); break; case TYPE_int: // Expanded MOSselect_none for debugging { int *val= (int*) (((char*) task->blk) + MosaicBlkSize); @@ -245,6 +307,45 @@ MOSsubselect_none(Client cntxt, MOStask return MAL_SUCCEED; } +#define thetasubselect_none(TPE)\ +{ TPE low,hgh, *v;\ + low= hgh = TPE##_nil;\ + if ( strcmp(oper,"<") == 0){\ + hgh= *(TPE*) val;\ + hgh = PREVVALUE##TPE(hgh);\ + } else\ + if ( strcmp(oper,"<=") == 0){\ + hgh= *(TPE*) val;\ + } else\ + if ( strcmp(oper,">") == 0){\ + low = *(TPE*) val;\ + low = NEXTVALUE##TPE(low);\ + } else\ + if ( strcmp(oper,">=") == 0){\ + low = *(TPE*) val;\ + } else\ + if ( strcmp(oper,"!=") == 0){\ + hgh= low= *(TPE*) val;\ + anti++;\ + } else\ + if ( strcmp(oper,"==") == 0){\ + hgh= low= *(TPE*) val;\ + } \ + v = (TPE*) (((char*)task->blk) + MosaicBlkSize);\ + for( ; first < last; first++, v++){\ + if( (low == TPE##_nil || * v >= low) && (* v <= hgh || hgh == TPE##_nil) ){\ + if ( !anti) {\ + MOSskipit();\ + *o++ = (oid) first;\ + }\ + } else\ + if( anti){\ + MOSskipit();\ + *o++ = (oid) first;\ + }\ + }\ +} + static str MOSthetasubselect_none(Client cntxt, MOStask task, lng first, lng last, void *val, str oper) { @@ -256,7 +357,13 @@ MOSthetasubselect_none(Client cntxt, MO last = task->blk->cnt; o = task->lb; - switch(task->type){ + switch(ATOMstorage(task->type)){ + case TYPE_bit: thetasubselect_none(bit); break; + case TYPE_bte: thetasubselect_none(bte); break; + case TYPE_sht: thetasubselect_none(sht); break; + case TYPE_lng: thetasubselect_none(lng); break; + case TYPE_flt: thetasubselect_none(flt); break; + case TYPE_dbl: thetasubselect_none(dbl); break; case TYPE_int: { int low,hgh, *v; low= hgh = int_nil; @@ -301,12 +408,30 @@ MOSthetasubselect_none(Client cntxt, MO return MAL_SUCCEED; } +#define leftfetchjoin_none(TPE)\ +{ TPE *val, *v;\ + v= (TPE*) task->src;\ + val = (TPE*) (((char*) task->hdr) + MosaicBlkSize);\ + for(; first < last; first++, val++){\ + MOSskipit();\ + *v++ = *val;\ + task->n--;\ + }\ + task->src = (char*) v;\ +} + static str MOSleftfetchjoin_none(Client cntxt, MOStask task, BUN first, BUN last) { (void) cntxt; - switch(task->type){ + switch(ATOMstorage(task->type)){ + case TYPE_bit: leftfetchjoin_none(bit); break; + case TYPE_bte: leftfetchjoin_none(bte); break; + case TYPE_sht: leftfetchjoin_none(sht); break; _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list