Changeset: 4d61fcc1dc92 for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=4d61fcc1dc92 Modified Files: monetdb5/modules/mal/xid.c Branch: xid Log Message:
Encode oid-rebasing When the oid to be stored does not fit, then simply switch to a new base. This should deal with the case that fragmented oid sequences can not be compressed. diffs (82 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 @@ -37,6 +37,7 @@ #define XIDRANGEINC 3 #define XIDRANGEDEC 4 #define XIDRANGEEQ 5 +#define XIDBASE 6 /* must be <= XID_TAG_MAX */ typedef oid xid; @@ -70,7 +71,13 @@ XIDencode(BUN *rtrn, XIDcolumn col, oid //xid point=0, range=0,set=0; o = *(oid*) p++; - assert(o >= min); + //assert(o >= min); + //assert(o <= XID_VAL_MAX); + if ( o - min >= XID_VAL_MAX) { + col[i].x.tag = XIDBASE; + min= col[++i].count = o; + i++; + } o -= min; assert(o <= XID_VAL_MAX); v = (xid) o; @@ -80,7 +87,29 @@ XIDencode(BUN *rtrn, XIDcolumn col, oid for ( ; p<q ; p++) { o = *(oid*) p; - assert(o >= min); + //assert(o >= min); + if ( o - min >= XID_VAL_MAX) { + switch( col[i].x.tag){ + case XIDRANGEEQ: + case XIDRANGEINC: + case XIDRANGEDEC: + case XIDPOINT: + i++; + break; + case XIDSETINC: + case XIDSETDEC: + if (scnt == 1) { /* simplify decoding */ + col[i].x.tag = XIDPOINT; + col[i].x.val = prev; + scnt =0; + } + /* finish the current*/ + i++; + } + col[i].x.tag = XIDBASE; + min = col[i + 1].count = o; + i += 2; + } o -= min; assert(o <= XID_VAL_MAX); v = (xid) o; @@ -227,6 +256,13 @@ XIDencode(BUN *rtrn, XIDcolumn col, oid //mnstr_printf(GDKout,"xidpoint " BUNFMT " " XIDFMT "\n",i,v); } break; + case XIDBASE : + /* skip it and start a new point encoding */ + i += 2; + col[i].x.tag = XIDPOINT; + col[i].x.val = v; + //mnstr_printf(GDKout,"xidpoint " BUNFMT " " XIDFMT "\n",i,v); + break; default: throw(MAL, "xid.compress", "unknown col.x.tag in XIDencode()"); } @@ -517,6 +553,10 @@ XIDdecode(BUN *rtrn, XIDcolumn col, oid throw(MAL, "xid.decompress", "XIDPOINT: result BAT capacity exceeded in XIDdecode()"); *o++ = v + min; break; + case XIDBASE: + o++; + min = *o++; + break; default: throw(MAL, "xid.decompress", "unknown col.x.tag in XIDdecode()"); } _______________________________________________ Checkin-list mailing list Checkin-list@monetdb.org http://mail.monetdb.org/mailman/listinfo/checkin-list