Changeset: b0fbb79ec064 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=b0fbb79ec064
Modified Files:
clients/Tests/exports.stable.out
gdk/gdk.h
gdk/gdk_align.c
gdk/gdk_bat.c
gdk/gdk_batop.c
gdk/gdk_delta.c
gdk/gdk_imprints.c
gdk/gdk_logger.c
gdk/gdk_sample.c
gdk/gdk_select.c
gdk/gdk_storage.c
gdk/gdk_utils.c
monetdb5/mal/mal_profiler.c
monetdb5/modules/atoms/batxml.c
monetdb5/modules/atoms/json.c
monetdb5/modules/atoms/mtime.c
monetdb5/modules/kernel/algebra.c
monetdb5/modules/kernel/batmmath.c
monetdb5/modules/kernel/batstr.c
monetdb5/modules/kernel/microbenchmark.c
monetdb5/modules/mal/manifold.c
monetdb5/modules/mal/manual.c
monetdb5/modules/mal/pcre.c
monetdb5/modules/mal/querylog.c
monetdb5/modules/mal/remote.c
monetdb5/modules/mal/sysmon.c
monetdb5/modules/mal/tablet.c
monetdb5/modules/mal/tokenizer.c
monetdb5/modules/mal/txtsim.c
monetdb5/modules/mal/zorder.c
monetdb5/optimizer/opt_statistics.c
sql/backends/monet5/LSST/lsst.c
sql/backends/monet5/UDF/udf.c
sql/backends/monet5/generator/generator.c
sql/backends/monet5/sql_cast_impl_down_from_int.h
sql/backends/monet5/sql_cast_impl_up_to_flt.h
sql/backends/monet5/sql_cast_impl_up_to_int.h
sql/backends/monet5/vaults/netcdf/netcdf.c
sql/storage/bat/bat_storage.c
sql/storage/bat/bat_table.c
sql/storage/bat/bat_utils.c
Branch: default
Log Message:
We can avoid setting properties on the head column most of the time.
The head properties are correctly maintained by BATsetcount and
BAThseqbase (called in any order) and also by BUNappend (which also
maintains tail properties) so we don't have to set the head properties
(and some tail properties) in most places.
Also added some asserts.
diffs (truncated from 1237 to 300 lines):
diff --git a/clients/Tests/exports.stable.out b/clients/Tests/exports.stable.out
--- a/clients/Tests/exports.stable.out
+++ b/clients/Tests/exports.stable.out
@@ -6,6 +6,7 @@ stdout of test 'exports` in directory 'c
# 21:40:57 >
# gdk
+void ALIGNsetH(BAT *b1, BAT *b2);
void ALIGNsetT(BAT *b1, BAT *b2);
int ALIGNsynced(BAT *b1, BAT *b2);
int ATOMallocate(const char *nme);
diff --git a/gdk/gdk.h b/gdk/gdk.h
--- a/gdk/gdk.h
+++ b/gdk/gdk.h
@@ -2781,9 +2781,9 @@ gdk_export BAT *VIEWcreate_(oid seq, BAT
gdk_export void VIEWbounds(BAT *b, BAT *view, BUN l, BUN h);
/* low level functions */
+gdk_export void ALIGNsetH(BAT *b1, BAT *b2);
gdk_export void ALIGNsetT(BAT *b1, BAT *b2);
-#define ALIGNsetH(x,y) ALIGNsetT(BATmirror(x),BATmirror(y))
#define ALIGNins(x,y,f,e) do {if (!(f))
VIEWchk(x,y,BAT_READ,e);(x)->halign=(x)->talign=0; } while (0)
#define ALIGNdel(x,y,f,e) do {if (!(f))
VIEWchk(x,y,BAT_READ|BAT_APPEND,e);(x)->halign=(x)->talign=0; } while (0)
#define ALIGNinp(x,y,f,e) do {if (!(f))
VIEWchk(x,y,BAT_READ|BAT_APPEND,e);(x)->talign=0; } while (0)
diff --git a/gdk/gdk_align.c b/gdk/gdk_align.c
--- a/gdk/gdk_align.c
+++ b/gdk/gdk_align.c
@@ -86,6 +86,32 @@ ALIGNcommit(BAT *b)
}
void
+ALIGNsetH(BAT *b1, BAT *b2)
+{
+ if (b1 == NULL || b2 == NULL)
+ return;
+
+ assert(b1->htype == TYPE_void);
+ assert(b2->htype == TYPE_void);
+
+ if (b2->halign == 0) {
+ b2->halign = OIDnew(1);
+ b2->batDirtydesc = TRUE;
+ }
+ /* b2 is either dense or has a void(nil) tail */
+ BAThseqbase(b1, b2->hseqbase);
+ b1->halign = b2->halign;
+ b1->batDirtydesc = TRUE;
+
+ assert(b1->hkey & 1);
+ assert(b2->hkey & 1);
+ assert(b1->hsorted);
+ assert(b2->hsorted);
+ assert(b1->hrevsorted == (BATcount(b1) <= 1));
+ assert(b2->hrevsorted == (BATcount(b2) <= 1));
+}
+
+void
ALIGNsetT(BAT *b1, BAT *b2)
{
ssize_t diff;
@@ -487,7 +513,6 @@ VIEWreset(BAT *b)
b->batDirty = 1;
/* reset BOUND2KEY */
- b->hkey = BAThkey(v);
b->tkey = BATtkey(v);
/* make the BAT empty and insert all again */
diff --git a/gdk/gdk_bat.c b/gdk/gdk_bat.c
--- a/gdk/gdk_bat.c
+++ b/gdk/gdk_bat.c
@@ -320,7 +320,6 @@ BATattach(int tt, const char *heapfile,
return NULL;
}
GDKfree(path);
- BATkey(bn, TRUE);
BATsetcapacity(bn, cap);
BATsetcount(bn, cap);
/*
@@ -685,13 +684,6 @@ COLcopy(BAT *b, int tt, int writable, in
bn = VIEWcreate(b->hseqbase, b);
if (bn == NULL)
return NULL;
- if (bn->htype != TYPE_void) {
- /* legacy BAT, transform to "headless" */
- assert(bn->H != bn->T);
- bn->htype = TYPE_void;
- bn->hvarsized = ATOMvarsized(TYPE_void);
- bn->hseqbase = b->hseqbase;
- }
if (tt != bn->ttype) {
assert(bn->H != bn->T);
bn->ttype = tt;
@@ -845,9 +837,6 @@ COLcopy(BAT *b, int tt, int writable, in
bn->T->nokey[0] = bn->T->nokey[1] = 0;
}
if (BATcount(bn) <= 1) {
- bn->hsorted = ATOMlinear(b->htype);
- bn->hrevsorted = ATOMlinear(b->htype);
- bn->hkey = 1;
bn->tsorted = ATOMlinear(b->ttype);
bn->trevsorted = ATOMlinear(b->ttype);
bn->tkey = 1;
@@ -1137,7 +1126,6 @@ gdk_return
BUNinplace(BAT *b, BUN p, const void *t, bit force)
{
BUN last = BUNlast(b) - 1;
- BAT *bm = BBP_cache(-b->batCacheid);
BATiter bi = bat_iterator(b);
int tt;
BUN prv, nxt;
@@ -1182,7 +1170,7 @@ BUNinplace(BAT *b, BUN p, const void *t,
b->T->nodense = nxt;
} else if (prv == BUN_NONE &&
nxt == BUN_NONE) {
- bm->hseqbase = b->tseqbase = * (oid *) t;
+ b->tseqbase = * (oid *) t;
}
}
} else if (b->T->nosorted >= p)
@@ -1200,7 +1188,7 @@ BUNinplace(BAT *b, BUN p, const void *t,
} else if (b->T->norevsorted >= p)
b->T->norevsorted = 0;
if (((b->ttype != TYPE_void) & b->tkey & !(b->tkey & BOUND2BTRUE)) &&
b->batCount > 1) {
- BATkey(bm, FALSE);
+ BATkey(BATmirror(b), FALSE);
}
if (b->T->nonil)
b->T->nonil = t && atom_CMP(t, ATOMnilptr(b->ttype), b->ttype)
!= 0;
@@ -1370,29 +1358,30 @@ BATsetcapacity(BAT *b, BUN cnt)
void
BATsetcount(BAT *b, BUN cnt)
{
+ /* head column is always VOID, and some head properties never change */
+ assert(b->htype == TYPE_void);
+ assert(b->hseqbase != oid_nil);
+ assert(b->hsorted);
+ assert(b->hkey & 1);
+ assert(!b->H->nil);
+ assert(b->H->nonil);
+ assert(b->H->heap.free == 0);
+
b->batCount = cnt;
b->batDirtydesc = TRUE;
- b->H->heap.free = headsize(b, BUNfirst(b) + cnt);
b->T->heap.free = tailsize(b, BUNfirst(b) + cnt);
- if (b->H->type == TYPE_void && b->T->type == TYPE_void)
+ if (b->T->type == TYPE_void)
b->batCapacity = cnt;
if (cnt <= 1) {
- b->hsorted = b->hrevsorted = ATOMlinear(b->htype) != 0;
+ b->hrevsorted = 1;
+ b->H->norevsorted = 0;
b->tsorted = b->trevsorted = ATOMlinear(b->ttype) != 0;
- b->H->nosorted = b->H->norevsorted = 0;
b->T->nosorted = b->T->norevsorted = 0;
+ } else {
+ b->hrevsorted = 0;
+ b->H->norevsorted = BUNfirst(b) + 1;
}
/* if the BAT was made smaller, we need to zap some values */
- if (b->H->nosorted >= BUNlast(b))
- b->H->nosorted = 0;
- if (b->H->norevsorted >= BUNlast(b))
- b->H->norevsorted = 0;
- if (b->H->nodense >= BUNlast(b))
- b->H->nodense = 0;
- if (b->H->nokey[0] >= BUNlast(b) || b->H->nokey[1] >= BUNlast(b)) {
- b->H->nokey[0] = 0;
- b->H->nokey[1] = 0;
- }
if (b->T->nosorted >= BUNlast(b))
b->T->nosorted = 0;
if (b->T->norevsorted >= BUNlast(b))
@@ -1403,20 +1392,6 @@ BATsetcount(BAT *b, BUN cnt)
b->T->nokey[0] = 0;
b->T->nokey[1] = 0;
}
- if (b->htype == TYPE_void) {
- b->hsorted = 1;
- if (b->hseqbase == oid_nil) { /* unlikely */
- b->hkey = cnt <= 1;
- b->hrevsorted = 1;
- b->H->nil = 1;
- b->H->nonil = 0;
- } else {
- b->hkey = 1;
- b->hrevsorted = cnt <= 1;
- b->H->nil = 0;
- b->H->nonil = 1;
- }
- }
if (b->ttype == TYPE_void) {
b->tsorted = 1;
if (b->tseqbase == oid_nil) {
@@ -1510,9 +1485,10 @@ BAThseqbase(BAT *b, oid o)
{
if (b == NULL)
return;
- assert(o < oid_nil);
+ assert(o < oid_nil); /* i.e., not oid_nil */
assert(o + BATcount(b) < oid_nil);
assert(b->htype == TYPE_void);
+ assert(b->batCacheid > 0);
if (b->hseqbase != o) {
b->batDirtydesc = TRUE;
b->hseqbase = o;
@@ -1539,6 +1515,7 @@ BATtseqbase(BAT *b, oid o)
return;
assert(o <= oid_nil);
assert(o == oid_nil || o + BATcount(b) < oid_nil);
+ assert(b->batCacheid > 0);
if (ATOMtype(b->ttype) == TYPE_oid) {
if (b->tseqbase != o) {
b->batDirtydesc = TRUE;
@@ -2588,6 +2565,12 @@ BATderiveProps(BAT *b, int expensive)
return;
}
BATderiveTailProps(b, expensive);
- if (b->H != b->T)
- BATderiveTailProps(BATmirror(b), expensive);
+ assert(b->H != b->T);
+ assert(b->htype == TYPE_void);
+ assert(b->hsorted);
+ assert(b->hkey & 1);
+ assert(b->H->nonil);
+ assert(!b->H->nil);
+ if ((b->hrevsorted = BATcount(b) <= 1) != 0)
+ b->H->norevsorted = BUNfirst(b) + 1;
}
diff --git a/gdk/gdk_batop.c b/gdk/gdk_batop.c
--- a/gdk/gdk_batop.c
+++ b/gdk/gdk_batop.c
@@ -525,6 +525,8 @@ BATappend(BAT *b, BAT *n, bit force)
}
}
b->hrevsorted = BATcount(b) <= 1;
+ if (b->hrevsorted)
+ b->H->norevsorted = BUNfirst(b) + 1;
b->T->nonil &= n->T->nonil;
return GDK_SUCCEED;
bunins_failed:
@@ -784,6 +786,7 @@ BATslice(BAT *b, BUN l, BUN h)
} else {
bn->tsorted = b->tsorted;
bn->hrevsorted = 0;
+ bn->H->norevsorted = BUNfirst(bn) + 1;
bn->trevsorted = b->trevsorted;
BATkey(BATmirror(bn), BATtkey(b));
}
diff --git a/gdk/gdk_delta.c b/gdk/gdk_delta.c
--- a/gdk/gdk_delta.c
+++ b/gdk/gdk_delta.c
@@ -118,13 +118,12 @@ BATundo(BAT *b)
if (b == NULL)
return;
DELTADEBUG fprintf(stderr, "#BATundo %s \n", BATgetId(b));
+ assert(b->htype == TYPE_void);
if (b->batDirtyflushed) {
- b->batDirtydesc = b->H->heap.dirty = b->T->heap.dirty = 1;
+ b->batDirtydesc = b->T->heap.dirty = 1;
} else {
b->batDirty = 0;
- b->batDirtydesc = b->H->heap.dirty = b->T->heap.dirty = 0;
- if (b->H->vheap)
- b->H->vheap->dirty = 0;
+ b->batDirtydesc = b->T->heap.dirty = 0;
if (b->T->vheap)
b->T->vheap->dirty = 0;
}
@@ -135,8 +134,6 @@ BATundo(BAT *b)
int (*tunfix) (const void *) = BATatoms[b->ttype].atomUnfix;
void (*tatmdel) (Heap *, var_t *) = BATatoms[b->ttype].atomDel;
- assert(BATatoms[b->htype].atomUnfix == NULL);
- assert(BATatoms[b->htype].atomDel == NULL);
assert(b->H->hash == NULL);
if (tunfix || tatmdel || b->T->hash) {
HASHdestroy(b);
@@ -152,19 +149,14 @@ BATundo(BAT *b)
}
}
}
- b->H->heap.free = headsize(b, b->batInserted);
b->T->heap.free = tailsize(b, b->batInserted);
bunfirst = b->batDeleted;
bunlast = b->batFirst;
if (bunlast > b->batDeleted) {
/* elements are 'inserted' => zap properties */
- b->hsorted = 0;
- b->hrevsorted = 0;
b->tsorted = 0;
b->trevsorted = 0;
- if (b->hkey)
- BATkey(b, FALSE);
if (b->tkey)
BATkey(BATmirror(b), FALSE);
HASHdestroy(b);
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list