Changeset: 86430d121e1d for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=86430d121e1d
Modified Files:
        monetdb5/modules/mal/xid.c
Branch: xid
Log Message:

prepare to abandon compression as soon as compressed size exceeds original size


diffs (75 lines):

diff --git a/monetdb5/modules/mal/xid.c b/monetdb5/modules/mal/xid.c
--- a/monetdb5/modules/mal/xid.c
+++ b/monetdb5/modules/mal/xid.c
@@ -25,6 +25,12 @@
 #include "xid.h"
 #include "mal_exception.h"
 
+/* "stringigy" (quote) macro */
+#define STR(x) #x
+
+/* maximal compressed size relative to original size */
+#define MAX_COMPRESSED_SIZE (org_size)
+
 #define XIDPOINT    0
 #define XIDSETINC   1
 #define XIDSETDEC   2
@@ -56,11 +62,11 @@ typedef union XIDCOLUMN{
 #define XID_IDX_BASE 3
 
 static str
-XIDencode(BUN *rtrn, XIDcolumn col, oid *p, oid *q, oid min)
+XIDencode(BUN *rtrn, XIDcolumn col, oid *p, oid *q, oid min, BUN org_size)
 {
        oid o;
        xid v, prev = 0, vmin = XID_VAL_MAX, vmax = 0;
-       BUN i=XID_IDX_BASE, scnt=0;
+       BUN i=XID_IDX_BASE, scnt=0, max_size = MAX_COMPRESSED_SIZE + 
XID_IDX_BASE;
        //xid point=0, range=0,set=0;
 
        o = *(oid*) p++;
@@ -224,6 +230,11 @@ XIDencode(BUN *rtrn, XIDcolumn col, oid 
                default:
                        throw(MAL, "xid.compress", "unknown col.x.tag in 
XIDencode()");
                }
+               if (i > max_size) {
+                       /* abandon if compressed size gets larger than 
MAX_COMPRESSED_SIZE % */
+                       *rtrn = BUN_NONE;
+                       return MAL_SUCCEED;
+               }
        }
        //mnstr_printf(GDKout,"stats point " XIDFMT " range " XIDFMT " set " 
XIDFMT "\n",point,range,set);
        *rtrn = i - XID_IDX_BASE;
@@ -242,9 +253,15 @@ XIDcompressCol( Client cntxt, InstrPtr p
                col = (XIDcolumn) cn->heap.base;
 
                clk = GDKusec();
-               msg = XIDencode(&i,col,p,q,min);
+               msg = XIDencode(&i,col,p,q,min,cnt);
                if (msg != MAL_SUCCEED)
                        return msg;
+               if (i == BUN_NONE) {
+                       /* compressed size > MAX_COMPRESSED_SIZE => abandon */
+                       mnstr_printf(cntxt->fdout,"#xid, %d, %s compress, " 
BUNFMT ", > " STR(MAX_COMPRESSED_SIZE) " => abandoned  clk " LLFMT " usec\n",
+                               getArg(pci,0), s, cnt, GDKusec()-clk);
+                       return MAL_SUCCEED;
+               }
                col[XID_IDX_ORIG].count = (xid)cnt; /* keep original size */
                col[XID_IDX_COMP].count = (xid)(i+1); /* keep compression size 
*/
                col[XID_IDX_SHIF].count = (xid)min; /* keep oid range shift */
@@ -413,13 +430,11 @@ XIDcompress(Client cntxt, MalBlkPtr mb, 
                /* keep original count in case we inherit uncompressed head or 
tail */
                BATsetcount(bn, cnt);
                bn->batDirty = 1;
-               assert(skip_h || bn->H->heap.xidcompressed || htx == TYPE_void);
-               assert(skip_t || bn->T->heap.xidcompressed || ttx == TYPE_void);
-               if (skip_h) {
+               if (skip_h || (htx == TYPE_oid && !bn->H->heap.xidcompressed)) {
                        /* inherit original uncompressed head as view */
                        bn = inheritCOL( bn, bn->H, b, b->H, VIEWhparent(b) );
                }
-               if (skip_t) {
+               if (skip_t || (ttx == TYPE_oid && !bn->T->heap.xidcompressed)) {
                        /* inherit original uncompressed tail as view */
                        bn = inheritCOL( bn, bn->T, b, b->T, VIEWtparent(b) );
                }
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list

Reply via email to