Changeset: 97fcc171ba0e for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/97fcc171ba0e Modified Files: gdk/gdk.h gdk/gdk_align.c gdk/gdk_bat.c gdk/gdk_batop.c gdk/gdk_bbp.c gdk/gdk_calc.c gdk/gdk_calc_convert.c gdk/gdk_join.c gdk/gdk_project.c gdk/gdk_select.c gdk/gdk_unique.c monetdb5/mal/mal_debugger.c monetdb5/modules/kernel/bat5.c monetdb5/modules/mal/pcre.c monetdb5/modules/mal/remote.c sql/backends/monet5/sql_result.c sql/storage/bat/bat_table.c Branch: default Log Message:
Removed the tvarsized property. It's almost completely equivalent to tvheap not being NULL (just watch out for TYPE_void). diffs (truncated from 652 to 300 lines): diff --git a/gdk/gdk.h b/gdk/gdk.h --- a/gdk/gdk.h +++ b/gdk/gdk.h @@ -692,7 +692,6 @@ gdk_export bool VALisnil(const ValRecord * bool tkey; // tail values are unique * bool tnonil; // tail has no nils * bool tsorted; // are tail values currently ordered? - * bool tvarsized; // for speed: tail type is varsized? * // Tail storage * int tloc; // byte-offset in BUN for tail elements * Heap *theap; // heap for varsized tail values @@ -726,7 +725,6 @@ typedef struct { uint16_t width; /* byte-width of the atom array */ int8_t type; /* type id. */ uint8_t shift; /* log2 of bun width */ - bool varsized; /* varsized/void (true) or fixedsized (false) */ bool key:1, /* no duplicate values present */ nonil:1, /* there are no nils in the column */ nil:1, /* there is a nil in the column */ @@ -820,7 +818,6 @@ typedef struct BAT { /* macros to hide complexity of the BAT structure */ #define ttype T.type #define tkey T.key -#define tvarsized T.varsized #define tseqbase T.seq #define tsorted T.sorted #define trevsorted T.revsorted @@ -1228,8 +1225,8 @@ typedef var_t stridx_t; #define BUNtmsk(bi,p) Tmsk(&(bi), (p)) #define BUNtloc(bi,p) (assert((bi).type != TYPE_msk), ((void *) ((char *) (bi).base + ((p) << (bi).shift)))) #define BUNtpos(bi,p) Tpos(&(bi),p) -#define BUNtvar(bi,p) (assert((bi).type && (bi).b->tvarsized), (void *) ((bi).vh->base+BUNtvaroff(bi,p))) -#define BUNtail(bi,p) ((bi).type?(bi).b->tvarsized?BUNtvar(bi,p):(bi).type==TYPE_msk?BUNtmsk(bi,p):BUNtloc(bi,p):BUNtpos(bi,p)) +#define BUNtvar(bi,p) (assert((bi).type && (bi).vh), (void *) ((bi).vh->base+BUNtvaroff(bi,p))) +#define BUNtail(bi,p) ((bi).type?(bi).vh?BUNtvar(bi,p):(bi).type==TYPE_msk?BUNtmsk(bi,p):BUNtloc(bi,p):BUNtpos(bi,p)) #define BATcount(b) ((b)->batCount) @@ -1472,7 +1469,7 @@ BATsettrivprop(BAT *b) } } else if (b->batCount == 2 && ATOMlinear(b->ttype)) { int c; - if (b->tvarsized) + if (b->tvheap) c = ATOMcmp(b->ttype, b->tvheap->base + VarHeapVal(Tloc(b, 0), 0, b->twidth), b->tvheap->base + VarHeapVal(Tloc(b, 0), 1, b->twidth)); @@ -1734,7 +1731,7 @@ tfastins_nocheck(BAT *b, BUN p, const vo ; } else if (ATOMstorage(b->ttype) == TYPE_msk) { mskSetVal(b, p, * (msk *) v); - } else if (b->tvarsized) { + } else if (b->tvheap) { return tfastins_nocheckVAR(b, p, v); } else { return tfastins_nocheckFIX(b, p, v); diff --git a/gdk/gdk_align.c b/gdk/gdk_align.c --- a/gdk/gdk_align.c +++ b/gdk/gdk_align.c @@ -106,7 +106,6 @@ VIEWcreate(oid seq, BAT *b) * accelerator data. We need copies because in case of a mark, * we are going to override a column with a void. */ bn->tkey = b->tkey; - bn->tvarsized = b->tvarsized; bn->tseqbase = b->tseqbase; bn->tsorted = b->tsorted; bn->trevsorted = b->trevsorted; @@ -178,9 +177,8 @@ BATmaterialize(BAT *b, BUN cap) BATcheck(b, GDK_FAIL); assert(!isVIEW(b)); - if (cap == BUN_NONE) + if (cap == BUN_NONE || cap < BATcapacity(b)) cap = BATcapacity(b); - assert(cap >= BATcapacity(b)); if (b->ttype != TYPE_void) { /* no voids; just call BATextend to make sure of capacity */ return BATextend(b, cap); diff --git a/gdk/gdk_bat.c b/gdk/gdk_bat.c --- a/gdk/gdk_bat.c +++ b/gdk/gdk_bat.c @@ -176,7 +176,6 @@ BATsetdims(BAT *b, uint16_t width) b->twidth = b->ttype == TYPE_str ? width > 0 ? width : 1 : ATOMsize(b->ttype); b->tshift = ATOMelmshift(b->twidth); assert_shift_width(b->tshift, b->twidth); - b->tvarsized = b->ttype == TYPE_void || BATatoms[b->ttype].atomPut != NULL; } const char * @@ -820,7 +819,10 @@ COLcopy(BAT *b, int tt, bool writable, r } if (tt != bn->ttype) { bn->ttype = tt; - bn->tvarsized = ATOMvarsized(tt); + if (bn->tvheap && !ATOMvarsized(tt)) { + HEAPdecref(bn->tvheap, false); + bn->tvheap = NULL; + } bn->tseqbase = ATOMtype(tt) == TYPE_oid ? bi.tseq : oid_nil; } } else { @@ -1180,7 +1182,7 @@ BUNappendmulti(BAT *b, const void *value minvalp = BUNtail(bi, bi.minpos); if (bi.maxpos != BUN_NONE) maxvalp = BUNtail(bi, bi.maxpos); - if (b->tvarsized) { + if (b->tvheap) { const void *vbase = b->tvheap->base; for (BUN i = 0; i < count; i++) { t = ((void **) values)[i]; @@ -1295,7 +1297,7 @@ BUNappendmulti(BAT *b, const void *value gdk_return BUNappend(BAT *b, const void *t, bool force) { - return BUNappendmulti(b, b->ttype && b->tvarsized ? (const void *) &t : (const void *) t, 1, force); + return BUNappendmulti(b, b->ttype && b->tvheap ? (const void *) &t : (const void *) t, 1, force); } gdk_return @@ -1429,7 +1431,7 @@ BUNinplacemulti(BAT *b, const oid *posit MT_rwlock_wrlock(&b->thashlock); for (BUN i = 0; i < count; i++) { BUN p = autoincr ? positions[0] - b->hseqbase + i : positions[i] - b->hseqbase; - const void *t = b->ttype && b->tvarsized ? + const void *t = b->ttype && b->tvheap ? ((const void **) values)[i] : (const void *) ((const char *) values + (i << b->tshift)); const bool isnil = ATOMlinear(b->ttype) && @@ -1438,18 +1440,16 @@ BUNinplacemulti(BAT *b, const oid *posit /* retrieve old value, but if this comes from the * logger, we need to deal with offsets that point * outside of the valid vheap */ - if (b->tvarsized) { - if (b->ttype) { - size_t off = BUNtvaroff(bi, p); - if (off < bi.vhfree) - val = bi.vh->base + off; - else - val = NULL; /* bad offset */ - } else { - val = BUNtpos(bi, p); - } + if (b->ttype == TYPE_void) { + val = BUNtpos(bi, p); } else if (bi.type == TYPE_msk) { val = BUNtmsk(bi, p); + } else if (b->tvheap) { + size_t off = BUNtvaroff(bi, p); + if (off < bi.vhfree) + val = bi.vh->base + off; + else + val = NULL; /* bad offset */ } else { val = BUNtloc(bi, p); } @@ -1520,7 +1520,7 @@ BUNinplacemulti(BAT *b, const oid *posit IMPSdestroy(b); STRMPdestroy(b); - if (b->tvarsized && b->ttype) { + if (b->tvheap && b->ttype) { var_t _d; ptr _ptr; _ptr = BUNtloc(bi, p); @@ -1709,7 +1709,7 @@ BUNreplacemultiincr(BAT *b, oid position gdk_return BUNreplace(BAT *b, oid id, const void *t, bool force) { - return BUNreplacemulti(b, &id, b->ttype && b->tvarsized ? (const void *) &t : t, 1, force); + return BUNreplacemulti(b, &id, b->ttype && b->tvheap ? (const void *) &t : t, 1, force); } /* very much like BUNreplace, but this doesn't make any changes if the @@ -1724,7 +1724,7 @@ void_inplace(BAT *b, oid id, const void } if (b->ttype == TYPE_void) return GDK_SUCCEED; - return BUNinplacemulti(b, &id, b->ttype && b->tvarsized ? (const void *) &val : (const void *) val, 1, force, false); + return BUNinplacemulti(b, &id, b->ttype && b->tvheap ? (const void *) &val : (const void *) val, 1, force, false); } /* @@ -2577,14 +2577,14 @@ BATassertProps(BAT *b) assert(strcmp(b->tvheap->filename, filename) == 0); } - /* void and str imply varsized */ - if (b->ttype == TYPE_void || - ATOMstorage(b->ttype) == TYPE_str) - assert(b->tvarsized); + /* void, str and blob imply varsized */ + if (ATOMstorage(b->ttype) == TYPE_str || + ATOMstorage(b->ttype) == TYPE_blob) + assert(b->tvheap != NULL); /* other "known" types are not varsized */ if (ATOMstorage(b->ttype) > TYPE_void && ATOMstorage(b->ttype) < TYPE_str) - assert(!b->tvarsized); + assert(b->tvheap == NULL); /* shift and width have a particular relationship */ if (ATOMstorage(b->ttype) == TYPE_str) assert(b->twidth >= 1 && b->twidth <= ATOMsize(b->ttype)); diff --git a/gdk/gdk_batop.c b/gdk/gdk_batop.c --- a/gdk/gdk_batop.c +++ b/gdk/gdk_batop.c @@ -1138,7 +1138,7 @@ BATappend_or_update(BAT *b, BAT *p, cons bool anynil = false; bool locked = false; - if (b->tvarsized) { + if (b->tvheap) { for (BUN i = 0; i < ni.count; i++) { oid updid; if (positions) { @@ -1759,15 +1759,14 @@ BATslice(BAT *b, BUN l, BUN h) if (bn == NULL) goto doreturn; - if (bn->ttype == TYPE_void || - (!bn->tvarsized && - BATatoms[bn->ttype].atomPut == NULL && - BATatoms[bn->ttype].atomFix == NULL)) { - if (bn->ttype) { - memcpy(Tloc(bn, 0), (const char *) bi.base + (p << bi.shift), - (q - p) << bn->tshift); - bn->theap->dirty = true; - } + if (bn->ttype == TYPE_void) { + BATsetcount(bn, h - l); + } else if (bn->tvheap == NULL && + BATatoms[bn->ttype].atomFix == NULL) { + assert(BATatoms[bn->ttype].atomPut == NULL); + memcpy(Tloc(bn, 0), (const char *) bi.base + (p << bi.shift), + (q - p) << bn->tshift); + bn->theap->dirty = true; BATsetcount(bn, h - l); } else { for (; p < q; p++) { @@ -2989,7 +2988,7 @@ BATcount_no_nil(BAT *b, BAT *s) cmp = ATOMcompare(t); if (nil == NULL) { cnt = ci.ncand; - } else if (b->tvarsized) { + } else if (b->tvheap) { base = b->tvheap->base; CAND_LOOP(&ci) cnt += (*cmp)(nil, base + ((const var_t *) p)[canditer_next(&ci) - hseq]) != 0; diff --git a/gdk/gdk_bbp.c b/gdk/gdk_bbp.c --- a/gdk/gdk_bbp.c +++ b/gdk/gdk_bbp.c @@ -396,6 +396,59 @@ static gdk_return BBPrecover_subdir(void static bool BBPdiskscan(const char *, size_t); static int +vheapinit(BAT *b, const char *buf, bat bid, unsigned bbpversion, const char *filename, int lineno) +{ + int n = 0; + uint64_t free, size; + uint16_t storage; + + (void) bbpversion; /* could be used to implement compatibility */ + + size = 0; /* for GDKLIBRARY_HSIZE case */ + storage = STORE_INVALID; /* for GDKLIBRARY_HSIZE case */ + if (bbpversion <= GDKLIBRARY_HSIZE ? + sscanf(buf, + " %" SCNu64 " %" SCNu64 " %" SCNu16 + "%n", + &free, &size, &storage, &n) < 3 : + sscanf(buf, + " %" SCNu64 + "%n", + &free, &n) < 1) { + TRC_CRITICAL(GDK, "invalid format for BBP.dir on line %d", lineno); + return -1; + } + b->tvheap = GDKmalloc(sizeof(Heap)); + if (b->tvheap == NULL) { + TRC_CRITICAL(GDK, "cannot allocate memory for heap."); + return -1; + } + if (b->ttype >= 0 && + ATOMstorage(b->ttype) == TYPE_str && + free < GDK_STRHASHTABLE * sizeof(stridx_t) + BATTINY * GDK_VARALIGN) + size = GDK_STRHASHTABLE * sizeof(stridx_t) + BATTINY * GDK_VARALIGN; + else if (free < 512) + size = 512; + else + size = free; + *b->tvheap = (Heap) { + .free = (size_t) free, + .size = (size_t) size, + .base = NULL, + .storage = STORE_INVALID, + .cleanhash = true, + .newstorage = STORE_INVALID, + .dirty = false, + .parentid = bid, + .farmid = BBPselectfarm(PERSISTENT, b->ttype, varheap), + }; _______________________________________________ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org