Changeset: 46557a37e44a for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=46557a37e44a Modified Files: monetdb5/modules/mosaic/mosaic.h monetdb5/modules/mosaic/mosaic_calendar.c monetdb5/modules/mosaic/mosaic_delta.c monetdb5/modules/mosaic/mosaic_dictionary.c monetdb5/modules/mosaic/mosaic_frame.c monetdb5/modules/mosaic/mosaic_prefix.c monetdb5/modules/mosaic/mosaic_raw.c monetdb5/modules/mosaic/mosaic_runlength.c Branch: mosaic Log Message:
Do proper checks on possible nil values. diffs (truncated from 446 to 300 lines): diff --git a/monetdb5/modules/mosaic/mosaic.h b/monetdb5/modules/mosaic/mosaic.h --- a/monetdb5/modules/mosaic/mosaic.h +++ b/monetdb5/modules/mosaic/mosaic.h @@ -130,6 +130,9 @@ typedef struct MOSAICBLK{ #define MosaicHdrSize wordaligned(sizeof(struct MOSAICHEADER),sizeof(struct MOSAICBLK)) #define MosaicBlkSize sizeof(MosaicBlkRec) +// helper function to check if a value is equal to the nil value of its type. +// TODO: check if this function can be added to gdk_atoms.h +#define is_nil(TPE, v) (ATOMcmp( TYPE_##TPE , (void*) &(v), (void*) ATOMnilptr(TYPE_##TPE) ) == 0) /* The (de) compression task descriptor */ typedef struct MOSTASK{ diff --git a/monetdb5/modules/mosaic/mosaic_calendar.c b/monetdb5/modules/mosaic/mosaic_calendar.c --- a/monetdb5/modules/mosaic/mosaic_calendar.c +++ b/monetdb5/modules/mosaic/mosaic_calendar.c @@ -358,13 +358,13 @@ MOSdecompress_calendar(Client cntxt, MOS #define select_calendar(TPE,BITS,MASK) {\ base = (BitVector) MOScodevector(task);\ if( !*anti){\ - if( *(TPE*) low == TPE##_nil && *(TPE*) hgh == TPE##_nil){\ + if( is_nil(TPE, *(TPE*) low) && is_nil(TPE, *(TPE*) hgh)){\ for( ; first < last; first++){\ MOSskipit();\ *o++ = (oid) first;\ }\ } else\ - if( *(TPE*) low == TPE##_nil ){\ + if( is_nil(TPE, *(TPE*) low) ){\ for(i=0 ; first < last; first++, i++){\ MOSskipit();\ j= getBitVector(base,i,(int) hdr->bits); \ @@ -373,7 +373,7 @@ MOSdecompress_calendar(Client cntxt, MOS *o++ = (oid) first;\ }\ } else\ - if( *(TPE*) hgh == TPE##_nil ){\ + if( is_nil(TPE, *(TPE*) hgh) ){\ for(i=0; first < last; first++, i++){\ MOSskipit();\ j= getBitVector(base,i,(int) hdr->bits ); \ @@ -392,10 +392,10 @@ MOSdecompress_calendar(Client cntxt, MOS }\ }\ } else {\ - if( *(TPE*) low == TPE##_nil && *(TPE*) hgh == TPE##_nil){\ + if( is_nil(TPE, *(TPE*) low) && is_nil(TPE, *(TPE*) hgh)){\ /* nothing is matching */\ } else\ - if( *(TPE*) low == TPE##_nil ){\ + if( is_nil(TPE, *(TPE*) low) ){\ for(i=0 ; first < last; first++, i++){\ MOSskipit();\ j= getBitVector(base,i,(int) hdr->bits ); \ @@ -404,7 +404,7 @@ MOSdecompress_calendar(Client cntxt, MOS *o++ = (oid) first;\ }\ } else\ - if( *(TPE*) hgh == TPE##_nil ){\ + if( is_nil(TPE, *(TPE*) hgh) ){\ for(i=0 ; first < last; first++, i++){\ MOSskipit();\ j= getBitVector(base,i,(int) hdr->bits); \ @@ -486,8 +486,8 @@ MOSselect_calendar(Client cntxt, MOStas for( ; first < last; first++){\ MOSskipit();\ j= getBitVector(base,first,(int) hdr->bits ); \ - if( (low == TPE##_nil || (task->hdr->dict.val##TPE[(j>>MASKBITS) & task->hdr->mask] | (j & MASKDAY)) >= low) && \ - ((task->hdr->dict.val##TPE[(j>>MASKBITS) & task->hdr->mask] | (j & MASKDAY)) <= hgh || hgh == TPE##_nil) ){\ + if( (is_nil(TPE, low) || (task->hdr->dict.val##TPE[(j>>MASKBITS) & task->hdr->mask] | (j & MASKDAY)) >= low) && \ + ((task->hdr->dict.val##TPE[(j>>MASKBITS) & task->hdr->mask] | (j & MASKDAY)) <= hgh || is_nil(TPE, hgh)) ){\ if ( !anti) {\ *o++ = (oid) first;\ }\ diff --git a/monetdb5/modules/mosaic/mosaic_delta.c b/monetdb5/modules/mosaic/mosaic_delta.c --- a/monetdb5/modules/mosaic/mosaic_delta.c +++ b/monetdb5/modules/mosaic/mosaic_delta.c @@ -267,13 +267,13 @@ MOSdecompress_delta(Client cntxt, MOStas TPE val= * (TPE*) (((char*) task->blk) + MosaicBlkSize);\ task->dst = MOScodevector(task) + sizeof(TYPE);\ if( !*anti){\ - if( *(TPE*) low == TPE##_nil && *(TPE*) hgh == TPE##_nil){\ + if( is_nil(TPE, *(TPE*) low) && is_nil(TPE, *(TPE*) hgh) ){\ for( ; first < last; first++){\ MOSskipit();\ *o++ = (oid) first;\ }\ } else\ - if( *(TPE*) low == TPE##_nil ){\ + if( is_nil(TPE, *(TPE*) low) ){\ for( ; first < last; first++, val+= *(bte*)task->dst, task->dst++){\ MOSskipit();\ cmp = ((*hi && val <= * (TPE*)hgh ) || (!*hi && val < *(TPE*)hgh ));\ @@ -281,7 +281,7 @@ MOSdecompress_delta(Client cntxt, MOStas *o++ = (oid) first;\ }\ } else\ - if( *(TPE*) hgh == TPE##_nil ){\ + if( is_nil(TPE, *(TPE*) hgh) ){\ for( ; first < last; first++, val+= *(bte*)task->dst, task->dst++){\ MOSskipit();\ cmp = ((*li && val >= * (TPE*)low ) || (!*li && val > *(TPE*)low ));\ @@ -298,10 +298,10 @@ MOSdecompress_delta(Client cntxt, MOStas }\ }\ } else {\ - if( *(TPE*) low == TPE##_nil && *(TPE*) hgh == TPE##_nil){\ + if( is_nil(TPE, *(TPE*) low) && is_nil(TPE, *(TPE*) hgh)){\ /* nothing is matching */\ } else\ - if( *(TPE*) low == TPE##_nil ){\ + if( is_nil(TPE, *(TPE*) low) ){\ for( ; first < last; first++, val+= *(bte*)task->dst, task->dst++){\ MOSskipit();\ cmp = ((*hi && val <= * (TPE*)hgh ) || (!*hi && val < *(TPE*)hgh ));\ @@ -309,7 +309,7 @@ MOSdecompress_delta(Client cntxt, MOStas *o++ = (oid) first;\ }\ } else\ - if( *(TPE*) hgh == TPE##_nil ){\ + if( is_nil(TPE, *(TPE*) hgh) ){\ for( ; first < last; first++, val+= *(bte*)task->dst, task->dst++){\ MOSskipit();\ cmp = ((*li && val >= * (TPE*)low ) || (!*li && val > *(TPE*)low ));\ @@ -532,7 +532,7 @@ MOSselect_delta(Client cntxt, MOStask t v= *(TPE*) (((char*) task->blk) + MosaicBlkSize);\ task->dst = MOScodevector(task) + sizeof(int);\ for( ; first < last; first++, v+= *(bte*)task->dst, task->dst++){\ - if( (low == TPE##_nil || v >= low) && (v <= hgh || hgh == TPE##_nil) ){\ + if( (is_nil(TPE, low) || v >= low) && (v <= hgh || is_nil(TPE, hgh)) ){\ if ( !anti) {\ MOSskipit();\ *o++ = (oid) first;\ diff --git a/monetdb5/modules/mosaic/mosaic_dictionary.c b/monetdb5/modules/mosaic/mosaic_dictionary.c --- a/monetdb5/modules/mosaic/mosaic_dictionary.c +++ b/monetdb5/modules/mosaic/mosaic_dictionary.c @@ -500,13 +500,13 @@ MOSdecompress_dictionary(Client cntxt, M #define select_dictionary(TPE) {\ base = (BitVector) MOScodevector(task);\ if( !*anti){\ - if( *(TPE*) low == TPE##_nil && *(TPE*) hgh == TPE##_nil){\ + if( is_nil(TPE, *(TPE*) low) && is_nil(TPE, *(TPE*) hgh)){\ for( ; first < last; first++){\ MOSskipit();\ *o++ = (oid) first;\ }\ } else\ - if( *(TPE*) low == TPE##_nil ){\ + if( is_nil(TPE, *(TPE*) low) ){\ for(i=0 ; first < last; first++, i++){\ MOSskipit();\ j= getBitVector(base,i,(int) hdr->bits); \ @@ -515,7 +515,7 @@ MOSdecompress_dictionary(Client cntxt, M *o++ = (oid) first;\ }\ } else\ - if( *(TPE*) hgh == TPE##_nil ){\ + if( is_nil(TPE, *(TPE*) hgh) ){\ for(i=0; first < last; first++, i++){\ MOSskipit();\ j= getBitVector(base,i,(int) hdr->bits); \ @@ -534,10 +534,10 @@ MOSdecompress_dictionary(Client cntxt, M }\ }\ } else {\ - if( *(TPE*) low == TPE##_nil && *(TPE*) hgh == TPE##_nil){\ + if( is_nil(TPE, *(TPE*) low) && is_nil(TPE, *(TPE*) hgh)){\ /* nothing is matching */\ } else\ - if( *(TPE*) low == TPE##_nil ){\ + if( is_nil(TPE, *(TPE*) low) ){\ for(i=0 ; first < last; first++, i++){\ MOSskipit();\ j= getBitVector(base,i,(int) hdr->bits); \ @@ -546,7 +546,7 @@ MOSdecompress_dictionary(Client cntxt, M *o++ = (oid) first;\ }\ } else\ - if( *(TPE*) hgh == TPE##_nil ){\ + if( is_nil(TPE, *(TPE*) hgh) ){\ for(i=0 ; first < last; first++, i++){\ MOSskipit();\ j= getBitVector(base,i,(int) hdr->bits); \ @@ -644,7 +644,7 @@ MOSselect_dictionary(Client cntxt, MOSt for( ; first < last; first++){\ MOSskipit();\ j= getBitVector(base,first,(int) hdr->bits); \ - if( (low == TPE##_nil || task->hdr->dict.val##TPE[j] >= low) && (task->hdr->dict.val##TPE[j] <= hgh || hgh == TPE##_nil) ){\ + if( (is_nil(TPE, low) || task->hdr->dict.val##TPE[j] >= low) && (task->hdr->dict.val##TPE[j] <= hgh || is_nil(TPE, hgh)) ){\ if ( !anti) {\ *o++ = (oid) first;\ }\ diff --git a/monetdb5/modules/mosaic/mosaic_frame.c b/monetdb5/modules/mosaic/mosaic_frame.c --- a/monetdb5/modules/mosaic/mosaic_frame.c +++ b/monetdb5/modules/mosaic/mosaic_frame.c @@ -374,13 +374,13 @@ MOSdecompress_frame(Client cntxt, MOStas TPE frame = *(TPE*)MOScodevector(task);\ base = (BitVector) (((char*) task->blk) + 2 * MosaicBlkSize);\ if( !*anti){\ - if( *(TPE*) low == TPE##_nil && *(TPE*) hgh == TPE##_nil){\ + if( is_nil(TPE, *(TPE*) low) && is_nil(TPE, *(TPE*) hgh)){\ for( ; first < last; first++){\ MOSskipit();\ *o++ = (oid) first;\ }\ } else\ - if( *(TPE*) low == TPE##_nil ){\ + if( is_nil(TPE, *(TPE*) low) ){\ for(i=0 ; first < last; first++, i++){\ MOSskipit();\ framedecompress(i); \ @@ -389,7 +389,7 @@ MOSdecompress_frame(Client cntxt, MOStas *o++ = (oid) first;\ }\ } else\ - if( *(TPE*) hgh == TPE##_nil ){\ + if( is_nil(TPE, *(TPE*) hgh) ){\ for(i=0; first < last; first++, i++){\ MOSskipit();\ framedecompress(i); \ @@ -408,10 +408,10 @@ MOSdecompress_frame(Client cntxt, MOStas }\ }\ } else {\ - if( *(TPE*) low == TPE##_nil && *(TPE*) hgh == TPE##_nil){\ + if( is_nil(TPE, *(TPE*) low) && is_nil(TPE, *(TPE*) hgh)){\ /* nothing is matching */\ } else\ - if( *(TPE*) low == TPE##_nil ){\ + if( is_nil(TPE, *(TPE*) low) ){\ for(i=0 ; first < last; first++, i++){\ MOSskipit();\ framedecompress(i); \ @@ -420,7 +420,7 @@ MOSdecompress_frame(Client cntxt, MOStas *o++ = (oid) first;\ }\ } else\ - if( *(TPE*) hgh == TPE##_nil ){\ + if( is_nil(TPE, *(TPE*) hgh) ){\ for(i=0 ; first < last; first++, i++){\ MOSskipit();\ framedecompress(i); \ @@ -508,7 +508,7 @@ MOSselect_frame(Client cntxt, MOStask t for( ; first < last; first++){\ MOSskipit();\ framedecompress(first); \ - if( (low == TPE##_nil || frame + task->hdr->frame.val##TPE[j] >= low) && (frame + task->hdr->frame.val##TPE[j] <= hgh || hgh == TPE##_nil) ){\ + if( (is_nil(TPE, low) || frame + task->hdr->frame.val##TPE[j] >= low) && (frame + task->hdr->frame.val##TPE[j] <= hgh || is_nil(TPE, hgh)) ){\ if ( !anti) {\ *o++ = (oid) first;\ }\ diff --git a/monetdb5/modules/mosaic/mosaic_prefix.c b/monetdb5/modules/mosaic/mosaic_prefix.c --- a/monetdb5/modules/mosaic/mosaic_prefix.c +++ b/monetdb5/modules/mosaic/mosaic_prefix.c @@ -759,13 +759,13 @@ MOSdecompress_prefix(Client cntxt, MOSta bits = (int) (val & (~mask));\ val = val & mask;\ if( !*anti){\ - if( *(TPE*) low == TPE##_nil && *(TPE*) hgh == TPE##_nil){\ + if( is_nil(TPE, *(TPE*) low) && is_nil(TPE, *(TPE*) hgh)){\ for( ; first < last; first++){\ MOSskipit();\ *o++ = (oid) first;\ }\ } else\ - if( *(TPE*) low == TPE##_nil ){\ + if( is_nil(TPE, *(TPE*) low) ){\ for( ; first < last; first++,i++){\ MOSskipit();\ v = val | decompress(base,i,bits);\ @@ -775,7 +775,7 @@ MOSdecompress_prefix(Client cntxt, MOSta *o++ = (oid) first;\ }\ } else\ - if( *(TPE*) hgh == TPE##_nil ){\ + if( is_nil(TPE, *(TPE*) hgh) ){\ for( ; first < last; first++,i++){\ MOSskipit();\ v = val | decompress(base,i,bits);\ @@ -796,10 +796,10 @@ MOSdecompress_prefix(Client cntxt, MOSta }\ }\ } else {\ - if( *(TPE*) low == TPE##_nil && *(TPE*) hgh == TPE##_nil){\ + if( is_nil(TPE, *(TPE*) low) && is_nil(TPE, *(TPE*) hgh)){\ /* nothing is matching */\ } else\ - if( *(TPE*) low == TPE##_nil ){\ + if( is_nil(TPE, *(TPE*) low) ){\ for( ; first < last; first++,i++){\ MOSskipit();\ v = val | decompress(base,i,bits);\ @@ -809,7 +809,7 @@ MOSdecompress_prefix(Client cntxt, MOSta *o++ = (oid) first;\ }\ } else\ - if( *(TPE*) hgh == TPE##_nil ){\ + if( is_nil(TPE, *(TPE*) hgh) ){\ for( ; first < last; first++, val++,i++){\ MOSskipit();\ _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list