Changeset: 03c658221c6a for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/03c658221c6a
Modified Files:
gdk/gdk_logger.c
Branch: group-commit
Log Message:
Merge with default branch.
diffs (truncated from 963 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,8 +725,7 @@ 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:1, /* varsized/void (true) or fixedsized (false) */
- key:1, /* no duplicate values present */
+ 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 */
sorted:1, /* column is sorted in ascending order */
@@ -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;
@@ -169,9 +168,8 @@ VIEWcreate(oid seq, BAT *b)
*/
gdk_return
-BATmaterialize(BAT *b)
+BATmaterialize(BAT *b, BUN cap)
{
- BUN cnt;
Heap *tail;
Heap *h, *vh = NULL;
BUN p, q;
@@ -179,17 +177,18 @@ BATmaterialize(BAT *b)
BATcheck(b, GDK_FAIL);
assert(!isVIEW(b));
+ if (cap == BUN_NONE || cap < BATcapacity(b))
+ cap = BATcapacity(b);
if (b->ttype != TYPE_void) {
- /* no voids */
- return GDK_SUCCEED;
+ /* no voids; just call BATextend to make sure of capacity */
+ return BATextend(b, cap);
}
- cnt = BATcapacity(b);
if ((tail = GDKmalloc(sizeof(Heap))) == NULL)
return GDK_FAIL;
p = 0;
q = BATcount(b);
- assert(cnt >= q - p);
+ assert(cap >= q - p);
TRC_DEBUG(ALGO, "BATmaterialize(" ALGOBATFMT ")\n", ALGOBATPAR(b));
/* cleanup possible ACC's */
@@ -203,7 +202,7 @@ BATmaterialize(BAT *b)
.dirty = true,
};
settailname(tail, BBP_physical(b->batCacheid), TYPE_oid, 0);
- if (HEAPalloc(tail, cnt, sizeof(oid), 0) != GDK_SUCCEED) {
+ if (HEAPalloc(tail, cap, sizeof(oid), 0) != GDK_SUCCEED) {
GDKfree(tail);
return GDK_FAIL;
}
@@ -266,6 +265,7 @@ BATmaterialize(BAT *b)
BATsetdims(b, 0);
b->batDirtydesc = true;
BATsetcount(b, b->batCount);
+ BATsetcapacity(b, cap);
MT_lock_unset(&b->theaplock);
HEAPdecref(h, false);
if (vh)
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 {
@@ -1027,7 +1029,9 @@ BUNappendmulti(BAT *b, const void *value
return GDK_FAIL;
}
+ MT_lock_set(&b->theaplock);
ALIGNapp(b, force, GDK_FAIL);
+ MT_lock_unset(&b->theaplock);
if (b->ttype == TYPE_void && BATtdense(b)) {
const oid *ovals = values;
@@ -1046,8 +1050,7 @@ BUNappendmulti(BAT *b, const void *value
return GDK_SUCCEED;
} else {
/* we need to materialize b; allocate enough capacity */
- b->batCapacity = BATcount(b) + count;
- if (BATmaterialize(b) != GDK_SUCCEED)
+ if (BATmaterialize(b, BATcount(b) + count) !=
GDK_SUCCEED)
return GDK_FAIL;
}
}
@@ -1179,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];
@@ -1294,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
@@ -1336,7 +1339,7 @@ BUNdelete(BAT *b, oid o)
/* replace to-be-delete BUN with last BUN; materialize
* void column before doing so */
if (b->ttype == TYPE_void &&
- BATmaterialize(b) != GDK_SUCCEED)
+ BATmaterialize(b, BUN_NONE) != GDK_SUCCEED)
return GDK_FAIL;
if (ATOMstorage(b->ttype) == TYPE_msk) {
msk mval = mskGetVal(b, BATcount(b) - 1);
@@ -1401,20 +1404,21 @@ BUNdelete(BAT *b, oid o)
static gdk_return
BUNinplacemulti(BAT *b, const oid *positions, const void *values, BUN count,
bool force, bool autoincr)
{
- BUN last = BATcount(b) - 1;
- BATiter bi = bat_iterator_nolock(b);
int tt;
BUN prv, nxt;
const void *val;
+ MT_lock_set(&b->theaplock);
+ BUN last = BATcount(b) - 1;
+ BATiter bi = bat_iterator_nolock(b);
/* zap alignment info */
if (!force && (b->batRestricted != BAT_WRITE || b->batSharecnt > 0)) {
+ MT_lock_unset(&b->theaplock);
GDKerror("access denied to %s, aborting.\n",
BATgetId(b));
return GDK_FAIL;
}
TRC_DEBUG(ALGO, ALGOBATFMT " replacing " BUNFMT " values\n",
ALGOBATPAR(b), count);
- MT_lock_set(&b->theaplock);
if (b->ttype == TYPE_void) {
PROPdestroy(b);
b->tminpos = BUN_NONE;
@@ -1427,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) &&
@@ -1436,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);
}
@@ -1518,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);
@@ -1685,7 +1687,7 @@ BUNreplacemulti(BAT *b, const oid *posit
{
BATcheck(b, GDK_FAIL);
- if (b->ttype == TYPE_void && BATmaterialize(b) != GDK_SUCCEED)
+ if (b->ttype == TYPE_void && BATmaterialize(b, BUN_NONE) != GDK_SUCCEED)
return GDK_FAIL;
return BUNinplacemulti(b, positions, values, count, force, false);
@@ -1698,7 +1700,7 @@ BUNreplacemultiincr(BAT *b, oid position
{
BATcheck(b, GDK_FAIL);
- if (b->ttype == TYPE_void && BATmaterialize(b) != GDK_SUCCEED)
+ if (b->ttype == TYPE_void && BATmaterialize(b, BUN_NONE) != GDK_SUCCEED)
return GDK_FAIL;
return BUNinplacemulti(b, &position, values, count, force, true);
@@ -1707,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
@@ -1722,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);
}
/*
@@ -2575,14 +2577,14 @@ BATassertProps(BAT *b)
assert(strcmp(b->tvheap->filename, filename) == 0);
}
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]