Changeset: b7a3329950a3 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=b7a3329950a3
Modified Files:
        monetdb5/modules/mal/mosaic.h
        monetdb5/modules/mal/mosaic_frame.c
        monetdb5/modules/mal/mosaic_hdr.c
Branch: mosaic
Log Message:

Protect against bit-field overflow


diffs (55 lines):

diff --git a/monetdb5/modules/mal/mosaic.h b/monetdb5/modules/mal/mosaic.h
--- a/monetdb5/modules/mal/mosaic.h
+++ b/monetdb5/modules/mal/mosaic.h
@@ -93,15 +93,17 @@ typedef struct MOSAICHEADER{
 } * MosaicHdr;
 
 // bit stuffed header block, currently 4 bytes wide
+#define MOSAICMAXCNT (1<<23)
+
 typedef struct{
        unsigned int tag:8, cnt:24;
 } *MosaicBlk;
 
 #define MOSgetTag(Blk) (Blk->tag)
 #define MOSsetTag(Blk,Tag)  (Blk)->tag = Tag
-#define MOSsetCnt(Blk,I) (assert(I < (1<<23)), (Blk)->cnt = (unsigned int)(I))
+#define MOSsetCnt(Blk,I) (assert(I < MOSAICMAXCNT), (Blk)->cnt = (unsigned 
int)(I))
 #define MOSgetCnt(Blk) (BUN)((Blk)->cnt)
-#define MOSincCnt(Blk,I) (assert((Blk)->cnt +I < (1<<23)), (Blk)->cnt+= 
(unsigned int)(I))
+#define MOSincCnt(Blk,I) (assert((Blk)->cnt +I < MOSAICMAXCNT), (Blk)->cnt+= 
(unsigned int)(I))
 
 /* Memory word alignement is type and platform dependent.
  * We use an encoding that fits the column type requirements
diff --git a/monetdb5/modules/mal/mosaic_frame.c 
b/monetdb5/modules/mal/mosaic_frame.c
--- a/monetdb5/modules/mal/mosaic_frame.c
+++ b/monetdb5/modules/mal/mosaic_frame.c
@@ -19,7 +19,14 @@
 
 /*
  * (c)2014 author Martin Kersten
- * Use the dictionary space to administer deltas wrt frame of reference value
+ * Dictionary frame of reference compression
+ * A chunk is beheaded by a reference value F from the column. The elements V 
in the
+ * chunk are replaced by an index into a global dictionary of V-F offsets.
+ *
+ * The dictionary is limited to 256 entries and all indices are one byte.
+ * The maximal achievable compression ratio is 8 (for longs)
+ *
+ * This scheme is particularly geared at evolving time series.
  */
 
 #include "monetdb_config.h"
diff --git a/monetdb5/modules/mal/mosaic_hdr.c 
b/monetdb5/modules/mal/mosaic_hdr.c
--- a/monetdb5/modules/mal/mosaic_hdr.c
+++ b/monetdb5/modules/mal/mosaic_hdr.c
@@ -123,7 +123,8 @@ MOSinitializeScan(Client cntxt, MOStask 
 */
 BUN 
 MOSlimit(void) {
+       if( MOSblocklimit > MOSAICMAXCNT)
+               MOSblocklimit = MOSAICMAXCNT;
        return MOSblocklimit;
-       //return (BUN) ~(0377<<MOSshift);
 }
 /* allow for experiementation using different block sizes */
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to