Changeset: 24c897fc5700 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/24c897fc5700
Modified Files:
gdk/gdk.h
gdk/gdk_aggr.c
gdk/gdk_bat.c
gdk/gdk_batop.c
monetdb5/modules/atoms/batxml.c
monetdb5/modules/mal/manifold.c
sql/backends/monet5/sql.c
Branch: Jul2021
Log Message:
A little cleanup.
diffs (217 lines):
diff --git a/gdk/gdk.h b/gdk/gdk.h
--- a/gdk/gdk.h
+++ b/gdk/gdk.h
@@ -1079,7 +1079,6 @@ gdk_export BUN BUNfnd(BAT *b, const void
(BUN) (*(const oid*)(v) - (b)->tseqbase))
#define BATttype(b) (BATtdense(b) ? TYPE_oid : (b)->ttype)
-#define Tbase(b) ((b)->tvheap->base)
#define Tsize(b) ((b)->twidth)
@@ -1410,8 +1409,8 @@ BATsettrivprop(BAT *b)
int c;
if (b->tvarsized)
c = ATOMcmp(b->ttype,
- Tbase(b) + VarHeapVal(Tloc(b, 0), 0,
b->twidth),
- Tbase(b) + VarHeapVal(Tloc(b, 0), 1,
b->twidth));
+ b->tvheap->base + VarHeapVal(Tloc(b, 0), 0,
b->twidth),
+ b->tvheap->base + VarHeapVal(Tloc(b, 0), 1,
b->twidth));
else
c = ATOMcmp(b->ttype, Tloc(b, 0), Tloc(b, 1));
b->tsorted = c <= 0;
diff --git a/gdk/gdk_aggr.c b/gdk/gdk_aggr.c
--- a/gdk/gdk_aggr.c
+++ b/gdk/gdk_aggr.c
@@ -910,7 +910,7 @@ BATgroupsum(BAT *b, BAT *g, BAT *e, BAT
}
if ((e == NULL ||
- (BATcount(e) == BATcount(b) && e->hseqbase == b->hseqbase)) &&
+ (BATcount(e) == ncand && e->hseqbase == ci.hseq)) &&
(BATtdense(g) || (g->tkey && g->tnonil))) {
/* trivial: singleton groups, so all results are equal
* to the inputs (but possibly a different type) */
@@ -1586,7 +1586,7 @@ BATgroupprod(BAT *b, BAT *g, BAT *e, BAT
}
if ((e == NULL ||
- (BATcount(e) == BATcount(b) && e->hseqbase == b->hseqbase)) &&
+ (BATcount(e) == ncand && e->hseqbase == ci.hseq)) &&
(BATtdense(g) || (g->tkey && g->tnonil))) {
/* trivial: singleton groups, so all results are equal
* to the inputs (but possibly a different type) */
@@ -4583,7 +4583,7 @@ dogroupstdev(BAT **avgb, BAT *b, BAT *g,
}
if ((e == NULL ||
- (BATcount(e) == BATcount(b) && e->hseqbase == b->hseqbase)) &&
+ (BATcount(e) == ncand && e->hseqbase == ci.hseq)) &&
(BATtdense(g) || (g->tkey && g->tnonil)) &&
(issample || b->tnonil)) {
/* trivial: singleton groups, so all results are equal
diff --git a/gdk/gdk_bat.c b/gdk/gdk_bat.c
--- a/gdk/gdk_bat.c
+++ b/gdk/gdk_bat.c
@@ -174,7 +174,7 @@ void
BATsetdims(BAT *b)
{
b->twidth = b->ttype == TYPE_str ? 1 : ATOMsize(b->ttype);
- b->tshift = ATOMelmshift(Tsize(b));
+ b->tshift = ATOMelmshift(b->twidth);
assert_shift_width(b->tshift, b->twidth);
b->tvarsized = b->ttype == TYPE_void || BATatoms[b->ttype].atomPut !=
NULL;
}
@@ -602,6 +602,7 @@ BATclear(BAT *b, bool force)
PROPdestroy(b);
/* we must dispose of all inserted atoms */
+ MT_lock_set(&b->theaplock);
if (force && BATatoms[b->ttype].atomDel == NULL) {
assert(b->tvheap == NULL || b->tvheap->parentid ==
b->batCacheid);
/* no stable elements: we do a quick heap clean */
@@ -621,12 +622,10 @@ BATclear(BAT *b, bool force)
if (ATOMheap(b->ttype, th, 0) != GDK_SUCCEED)
return GDK_FAIL;
ATOMIC_INIT(&th->refs, 1);
- MT_lock_set(&b->theaplock);
th->parentid = b->tvheap->parentid;
th->dirty = true;
HEAPdecref(b->tvheap, false);
b->tvheap = th;
- MT_lock_unset(&b->theaplock);
}
} else {
/* do heap-delete of all inserted atoms */
@@ -635,15 +634,14 @@ BATclear(BAT *b, bool force)
/* TYPE_str has no del method, so we shouldn't get here */
assert(tatmdel == NULL || b->twidth == sizeof(var_t));
if (tatmdel) {
- MT_lock_set(&b->theaplock);
BATiter bi = bat_iterator_nolock(b);
for (p = b->batInserted, q = BUNlast(b); p < q; p++)
(*tatmdel)(b->tvheap, (var_t*) BUNtloc(bi,p));
b->tvheap->dirty = true;
- MT_lock_unset(&b->theaplock);
}
}
+ MT_lock_unset(&b->theaplock);
if (force)
b->batInserted = 0;
diff --git a/gdk/gdk_batop.c b/gdk/gdk_batop.c
--- a/gdk/gdk_batop.c
+++ b/gdk/gdk_batop.c
@@ -409,7 +409,7 @@ insert_string_bat(BAT *b, BAT *n, struct
b->theap->dirty = true;
/* maintain hash */
for (r = oldcnt, cnt = BATcount(b); b->thash && r < cnt; r++) {
- HASHappend(b, r, Tbase(b) + VarHeapVal(Tloc(b, 0), r,
b->twidth));
+ HASHappend(b, r, b->tvheap->base + VarHeapVal(Tloc(b, 0), r,
b->twidth));
}
return GDK_SUCCEED;
}
diff --git a/monetdb5/modules/atoms/batxml.c b/monetdb5/modules/atoms/batxml.c
--- a/monetdb5/modules/atoms/batxml.c
+++ b/monetdb5/modules/atoms/batxml.c
@@ -515,7 +515,7 @@ BATXMLoptions(bat *ret, const char * con
if (strNil(t)) {
if (bunfastappVAR(bn, buf) != GDK_SUCCEED)
- goto bunins_failed;
+ goto bunins_failed1;
} else {
if (strlen(t) > size - 2 * len - 6) {
char *tmp;
@@ -523,13 +523,13 @@ BATXMLoptions(bat *ret, const char * con
tmp = (char *) GDKrealloc(val, size +
strlen(t));
if (tmp == NULL) {
err = SQLSTATE(HY013) MAL_MALLOC_FAIL;
- goto bunins_failed;
+ goto bunins_failed1;
}
val = tmp;
}
snprintf(val + len + 2, size - len, "%s</%s>", t,
*name);
if (bunfastappVAR(bn, val) != GDK_SUCCEED)
- goto bunins_failed;
+ goto bunins_failed1;
}
}
bat_iterator_end(&bi);
@@ -537,8 +537,9 @@ BATXMLoptions(bat *ret, const char * con
GDKfree(buf);
finalizeResult(ret, bn, b);
return MAL_SUCCEED;
+bunins_failed1:
+ bat_iterator_end(&bi);
bunins_failed:
- bat_iterator_end(&bi);
BBPunfix(b->batCacheid);
BBPunfix(bn->batCacheid);
if (buf != NULL)
@@ -1300,7 +1301,7 @@ BATxmlaggr(BAT **bnp, BAT *b, BAT *g, BA
BBPreclaim(bn);
bn = NULL;
err = GDK_EXCEPTION;
- goto out;
+ goto out1;
}
if (freeg)
BBPunfix(g->batCacheid);
@@ -1418,8 +1419,9 @@ BATxmlaggr(BAT **bnp, BAT *b, BAT *g, BA
bn->trevsorted = BATcount(bn) <= 1;
bn->tkey = BATcount(bn) <= 1;
+ out1:
+ bat_iterator_end(&bi);
out:
- bat_iterator_end(&bi);
if (t2)
BBPunfix(t2->batCacheid);
if (freeb && b)
diff --git a/monetdb5/modules/mal/manifold.c b/monetdb5/modules/mal/manifold.c
--- a/monetdb5/modules/mal/manifold.c
+++ b/monetdb5/modules/mal/manifold.c
@@ -299,10 +299,7 @@ MANIFOLDevaluate(Client cntxt, MalBlkPtr
goto wrapup;
}
mut.lvar = i;
- if (ATOMstorage(tpe) == TYPE_str)
- mat[i].size = Tsize(mat[i].b);
- else
- mat[i].size = ATOMsize(tpe);
+ mat[i].size = mat[i].bi.width;
mat[i].cnt = cnt;
if ( mat[i].b->ttype == TYPE_void){
o = mat[i].b->tseqbase;
diff --git a/sql/backends/monet5/sql.c b/sql/backends/monet5/sql.c
--- a/sql/backends/monet5/sql.c
+++ b/sql/backends/monet5/sql.c
@@ -968,10 +968,8 @@ mvc_bat_next_get_value(Client cntxt, Mal
if (!BATcount(it))
goto bailout; /* Success case */
- if (b)
- bi = bat_iterator(b);
- if (c)
- ci = bat_iterator(c);
+ bi = bat_iterator(b);
+ ci = bat_iterator(c);
BATloop(it, p, q) {
str nsname, nseqname;
@@ -1015,10 +1013,8 @@ mvc_bat_next_get_value(Client cntxt, Mal
}
}
bailout1:
- if (b)
- bat_iterator_end(&bi);
- if (c)
- bat_iterator_end(&ci);
+ bat_iterator_end(&bi);
+ bat_iterator_end(&ci);
bailout:
if (sb)
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list