Changeset: 40d25d09c586 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/40d25d09c586
Modified Files:
gdk/gdk.h
gdk/gdk_bat.c
gdk/gdk_bbp.c
gdk/gdk_heap.c
gdk/gdk_select.c
monetdb5/modules/kernel/bat5.c
sql/backends/monet5/sql.c
sql/storage/bat/bat_storage.c
Branch: strheapvacuum
Log Message:
merge with default
diffs (truncated from 1879 to 300 lines):
diff --git a/common/stream/fwf.c b/common/stream/fwf.c
--- a/common/stream/fwf.c
+++ b/common/stream/fwf.c
@@ -149,21 +149,18 @@ stream_fwf_create(stream *restrict s, si
}
fsd->in_buf = malloc(fsd->line_len);
if (fsd->in_buf == NULL) {
- close_stream(fsd->s);
free(fsd);
mnstr_set_open_error(STREAM_FWF_NAME, errno, NULL);
return NULL;
}
fsd->out_buf = malloc(fsd->line_len * 3);
if (fsd->out_buf == NULL) {
- close_stream(fsd->s);
free(fsd->in_buf);
free(fsd);
mnstr_set_open_error(STREAM_FWF_NAME, errno, NULL);
return NULL;
}
if ((ns = create_stream(STREAM_FWF_NAME)) == NULL) {
- close_stream(fsd->s);
free(fsd->in_buf);
free(fsd->out_buf);
free(fsd);
diff --git a/gdk/gdk.h b/gdk/gdk.h
--- a/gdk/gdk.h
+++ b/gdk/gdk.h
@@ -535,14 +535,14 @@ typedef enum {
/* Heap storage modes */
typedef enum {
- STORE_MEM = 0, /* load into GDKmalloced memory */
- STORE_MMAP = 1, /* mmap() into virtual memory */
- STORE_PRIV = 2, /* BAT copy of copy-on-write mmap */
- STORE_CMEM = 3, /* load into malloc (not GDKmalloc) memory*/
- STORE_NOWN = 4, /* memory not owned by the BAT */
- STORE_MMAPABS = 5, /* mmap() into virtual memory from an
+ STORE_INVALID = 0, /* invalid value, used to indicate error */
+ STORE_MEM, /* load into GDKmalloced memory */
+ STORE_MMAP, /* mmap() into virtual memory */
+ STORE_PRIV, /* BAT copy of copy-on-write mmap */
+ STORE_CMEM, /* load into malloc (not GDKmalloc) memory*/
+ STORE_NOWN, /* memory not owned by the BAT */
+ STORE_MMAPABS, /* mmap() into virtual memory from an
* absolute path (not part of dbfarm) */
- STORE_INVALID /* invalid value, used to indicate error */
} storage_t;
typedef struct {
@@ -860,9 +860,6 @@ mskGetVal(BAT *b, BUN p)
* HEAPcopy (Heap *dst,*src);
* @item int
* @tab
- * HEAPdelete (Heap *dst, str o, str ext);
- * @item int
- * @tab
* HEAPwarm (Heap *h);
* @end multitable
*
@@ -2147,9 +2144,8 @@ gdk_export void VIEWbounds(BAT *b, BAT *
* correct for the reversed view.
*/
#define isVIEW(x) \
- (assert((x)->batCacheid > 0), \
- (((x)->theap && (x)->theap->parentid != (x)->batCacheid) || \
- ((x)->tvheap && (x)->tvheap->parentid != (x)->batCacheid)))
+ (((x)->theap && (x)->theap->parentid != (x)->batCacheid) || \
+ ((x)->tvheap && (x)->tvheap->parentid != (x)->batCacheid))
#define VIEWtparent(x) ((x)->theap == NULL || (x)->theap->parentid ==
(x)->batCacheid ? 0 : (x)->theap->parentid)
#define VIEWvtparent(x) ((x)->tvheap == NULL || (x)->tvheap->parentid
== (x)->batCacheid ? 0 : (x)->tvheap->parentid)
diff --git a/gdk/gdk_align.c b/gdk/gdk_align.c
--- a/gdk/gdk_align.c
+++ b/gdk/gdk_align.c
@@ -91,7 +91,7 @@ VIEWcreate(oid seq, BAT *b)
return BATdense(seq, b->tseqbase, b->batCount);
}
- bn = BATcreatedesc(seq, b->ttype, false, TRANSIENT);
+ bn = BATcreatedesc(seq, b->ttype, false, TRANSIENT, 0);
if (bn == NULL)
return NULL;
assert(bn->theap == NULL);
@@ -178,7 +178,6 @@ BATmaterialize(BAT *b)
cnt = BATcapacity(b);
if ((tail = GDKmalloc(sizeof(Heap))) == NULL)
return GDK_FAIL;
- *tail = *b->theap;
p = 0;
q = BUNlast(b);
assert(cnt >= q - p);
@@ -194,8 +193,7 @@ BATmaterialize(BAT *b)
.parentid = b->batCacheid,
.dirty = true,
};
- strconcat_len(tail->filename, sizeof(tail->filename),
- BBP_physical(b->batCacheid), ".tail", NULL);
+ settailname(tail, BBP_physical(b->batCacheid), TYPE_oid, 0);
if (HEAPalloc(tail, cnt, sizeof(oid), 0) != GDK_SUCCEED) {
GDKfree(tail);
return GDK_FAIL;
@@ -279,7 +277,6 @@ VIEWunlink(BAT *b)
BAT *tpb = NULL;
BAT *vtpb = NULL;
- assert(b->batCacheid > 0);
if (tp)
tpb = BBP_cache(tp);
if (tp && !vtp)
diff --git a/gdk/gdk_bat.c b/gdk/gdk_bat.c
--- a/gdk/gdk_bat.c
+++ b/gdk/gdk_bat.c
@@ -62,7 +62,7 @@ BATinit_idents(BAT *bn)
}
BAT *
-BATcreatedesc(oid hseq, int tt, bool heapnames, role_t role)
+BATcreatedesc(oid hseq, int tt, bool heapnames, role_t role, uint16_t width)
{
BAT *bn;
@@ -96,6 +96,7 @@ BATcreatedesc(oid hseq, int tt, bool hea
.batRole = role,
.batTransient = true,
+ .batRestricted = BAT_WRITE,
};
if (heapnames && (bn->theap = GDKmalloc(sizeof(Heap))) == NULL) {
GDKfree(bn);
@@ -114,8 +115,6 @@ BATcreatedesc(oid hseq, int tt, bool hea
* fill in heap names, so HEAPallocs can resort to disk for
* very large writes.
*/
- assert(bn->batCacheid > 0);
-
if (heapnames) {
assert(bn->theap != NULL);
*bn->theap = (Heap) {
@@ -124,8 +123,7 @@ BATcreatedesc(oid hseq, int tt, bool hea
};
const char *nme = BBP_physical(bn->batCacheid);
- strconcat_len(bn->theap->filename, sizeof(bn->theap->filename),
- nme, ".tail", NULL);
+ settailname(bn->theap, nme, tt, width);
if (ATOMneedheap(tt)) {
if ((bn->tvheap = GDKmalloc(sizeof(Heap))) == NULL) {
@@ -184,20 +182,21 @@ BATsetdims(BAT *b)
const char *
gettailname(const BAT *b)
{
- if (b->ttype != TYPE_str)
- return "tail";
- switch (b->twidth) {
- case 1:
- return "tail1";
- case 2:
- return "tail2";
+ if (b->ttype == TYPE_str) {
+ switch (b->twidth) {
+ case 1:
+ return "tail1";
+ case 2:
+ return "tail2";
#if SIZEOF_VAR_T == 8
- case 4:
- return "tail4";
+ case 4:
+ return "tail4";
#endif
- default:
- return "tail";
+ default:
+ break;
+ }
}
+ return "tail";
}
void
@@ -265,7 +264,7 @@ COLnew_intern(oid hseq, int tt, BUN cap,
if (cap > BUN_MAX)
cap = BUN_MAX;
- bn = BATcreatedesc(hseq, tt, true, role);
+ bn = BATcreatedesc(hseq, tt, true, role, width);
if (bn == NULL)
return NULL;
@@ -275,8 +274,12 @@ COLnew_intern(oid hseq, int tt, BUN cap,
if (ATOMstorage(tt) == TYPE_msk)
cap /= 8; /* 8 values per byte */
else if (tt == TYPE_str) {
- if (width != 0)
+ if (width != 0) {
+ /* power of two and not too large */
+ assert((width & (width - 1)) == 0);
+ assert(width <= sizeof(var_t));
bn->twidth = width;
+ }
settailname(bn->theap, BBP_physical(bn->batCacheid), tt,
bn->twidth);
}
@@ -662,7 +665,6 @@ BATfree(BAT *b)
return;
/* deallocate all memory for a bat */
- assert(b->batCacheid > 0);
if (b->tident && !default_ident(b->tident))
GDKfree(b->tident);
b->tident = BATstring_t;
@@ -1636,10 +1638,10 @@ BUNinplacemulti(BAT *b, const oid *posit
MT_lock_set(&b->theaplock);
b->tminpos = minpos;
b->tmaxpos = maxpos;
- MT_lock_unset(&b->theaplock);
b->theap->dirty = true;
if (b->tvheap)
b->tvheap->dirty = true;
+ MT_lock_unset(&b->theaplock);
return GDK_SUCCEED;
}
@@ -1900,7 +1902,6 @@ gdk_return
BATkey(BAT *b, bool flag)
{
BATcheck(b, GDK_FAIL);
- assert(b->batCacheid > 0);
if (b->ttype == TYPE_void) {
if (BATtdense(b) && !flag) {
GDKerror("dense column must be unique.\n");
@@ -1941,7 +1942,6 @@ BAThseqbase(BAT *b, oid o)
if (b != NULL) {
assert(o <= GDK_oid_max); /* i.e., not oid_nil */
assert(o + BATcount(b) <= GDK_oid_max);
- assert(b->batCacheid > 0);
if (b->hseqbase != o) {
b->batDirtydesc = true;
b->hseqbase = o;
@@ -1956,7 +1956,6 @@ BATtseqbase(BAT *b, oid o)
if (b == NULL)
return;
assert(is_oid_nil(o) || o + BATcount(b) <= GDK_oid_max);
- assert(b->batCacheid > 0);
if (b->tseqbase != o) {
b->batDirtydesc = true;
}
@@ -2180,8 +2179,7 @@ HEAPchangeaccess(Heap *hp, int dstmode,
if (dstmode == BAT_WRITE) {
if (hp->storage != STORE_PRIV)
hp->dirty = true; /* exception c does not make it
dirty */
-// return STORE_PRIV; /* 4=>6,5=>7,c=>6 persistent BAT_WRITE
needs STORE_PRIV */
- return STORE_MMAP;
+ return STORE_PRIV; /* 4=>6,5=>7,c=>6 persistent BAT_WRITE
needs STORE_PRIV */
}
if (hp->storage == STORE_MMAP) { /* 6=>4 */
hp->dirty = true;
@@ -2209,8 +2207,7 @@ HEAPcommitpersistence(Heap *hp, bool wri
if (hp->newstorage == STORE_MMAP)
hp->dirty = true; /* 2=>6 */
-// return STORE_PRIV; /* 1=>5,2=>6,3=>7,a=>c,b=>6 states */
- return STORE_MMAP;
+ return STORE_PRIV; /* 1=>5,2=>6,3=>7,a=>c,b=>6 states */
}
@@ -2459,6 +2456,7 @@ BATassertProps(BAT *b)
int (*cmpf)(const void *, const void *);
int cmp;
const void *prev = NULL, *valp, *nilp;
+ char filename[sizeof(b->theap->filename)];
/* do the complete check within a lock */
MT_lock_set(&b->theaplock);
@@ -2502,6 +2500,22 @@ BATassertProps(BAT *b)
} else
assert(b->theap->size >> b->tshift >= b->batCapacity);
}
+ strconcat_len(filename, sizeof(filename),
+ BBP_physical(b->theap->parentid),
+ b->ttype == TYPE_str ? b->twidth == 1 ? ".tail1" :
b->twidth == 2 ? ".tail2" :
+#if SIZEOF_VAR_T == 8
+ b->twidth == 4 ? ".tail4" :
+#endif
+ ".tail" : ".tail",
+ NULL);
+ assert(strcmp(b->theap->filename, filename) == 0);
+ if (b->tvheap) {
+ strconcat_len(filename, sizeof(filename),
+ BBP_physical(b->tvheap->parentid),
+ ".theap",
+ NULL);
+ assert(strcmp(b->tvheap->filename, filename) == 0);
+ }
/* void and str imply varsized */
if (b->ttype == TYPE_void ||
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list