Changeset: f619cf62c92d for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/f619cf62c92d
Modified Files:
gdk/gdk.h
gdk/gdk_align.c
gdk/gdk_bat.c
gdk/gdk_batop.c
gdk/gdk_bbp.c
gdk/gdk_hash.c
gdk/gdk_heap.c
sql/backends/monet5/sql.c
sql/backends/monet5/sql_result.c
tools/monetdbe/monetdbe.c
Branch: default
Log Message:
Merge with Jul2021 branch.
diffs (truncated from 812 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 {
@@ -2148,9 +2148,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
@@ -278,7 +278,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
@@ -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) {
@@ -662,7 +661,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;
@@ -1900,7 +1898,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 +1938,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 +1952,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 +2175,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 +2203,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 */
}
diff --git a/gdk/gdk_batop.c b/gdk/gdk_batop.c
--- a/gdk/gdk_batop.c
+++ b/gdk/gdk_batop.c
@@ -21,7 +21,6 @@
gdk_return
unshare_varsized_heap(BAT *b)
{
- assert(b->batCacheid > 0);
if (ATOMvarsized(b->ttype) &&
b->tvheap->parentid != b->batCacheid) {
Heap *h = GDKzalloc(sizeof(Heap));
@@ -647,7 +646,6 @@ BATappend2(BAT *b, BAT *n, BAT *s, bool
if (b == NULL || n == NULL || BATcount(n) == 0) {
return GDK_SUCCEED;
}
- assert(b->batCacheid > 0);
assert(b->theap->parentid == b->batCacheid);
TRC_DEBUG_IF(ALGO) {
diff --git a/gdk/gdk_bbp.c b/gdk/gdk_bbp.c
--- a/gdk/gdk_bbp.c
+++ b/gdk/gdk_bbp.c
@@ -502,8 +502,8 @@ heapinit(BAT *b, const char *buf,
b->theap->size = (size_t) size;
b->theap->base = NULL;
settailname(b->theap, filename, t, width);
- b->theap->storage = (storage_t) storage;
- b->theap->newstorage = (storage_t) storage;
+ b->theap->storage = STORE_INVALID;
+ b->theap->newstorage = STORE_INVALID;
b->theap->farmid = BBPselectfarm(PERSISTENT, b->ttype, offheap);
b->theap->dirty = false;
b->theap->parentid = b->batCacheid;
@@ -546,9 +546,9 @@ vheapinit(BAT *b, const char *buf, bat b
.free = (size_t) free,
.size = (size_t) size,
.base = NULL,
- .storage = (storage_t) storage,
+ .storage = STORE_INVALID,
.cleanhash = true,
- .newstorage = (storage_t) storage,
+ .newstorage = STORE_INVALID,
.dirty = false,
.parentid = bid,
.farmid = BBPselectfarm(PERSISTENT, b->ttype, varheap),
@@ -1670,7 +1670,7 @@ heap_entry(FILE *fp, BAT *b, BUN size)
b->tseqbase,
free,
b->theap->size,
- (int) b->theap->newstorage,
+ 0,
b->tminpos < b->hseqbase + size ? (uint64_t) b->tminpos
: (uint64_t) oid_nil,
b->tmaxpos < b->hseqbase + size ? (uint64_t) b->tmaxpos
: (uint64_t) oid_nil);
}
@@ -1680,8 +1680,7 @@ vheap_entry(FILE *fp, Heap *h)
{
if (h == NULL)
return 0;
- return fprintf(fp, " %zu %zu %d",
- h->free, h->size, (int) h->newstorage);
+ return fprintf(fp, " %zu %zu %d", h->free, h->size, 0);
}
static gdk_return
@@ -2276,7 +2275,6 @@ BBPcacheit(BAT *bn, bool lock)
if (bn->tvheap)
bn->tvheap->parentid = i;
}
- assert(bn->batCacheid > 0);
if (lock)
MT_lock_set(&GDKswapLock(i));
diff --git a/gdk/gdk_hash.c b/gdk/gdk_hash.c
--- a/gdk/gdk_hash.c
+++ b/gdk/gdk_hash.c
@@ -474,6 +474,10 @@ BATcheckhash(BAT *b)
strconcat_len(h->heapbckt.filename,
sizeof(h->heapbckt.filename),
nme, ".thashb", NULL);
+ h->heaplink.storage = STORE_INVALID;
+ h->heaplink.newstorage = STORE_INVALID;
+ h->heapbckt.storage = STORE_INVALID;
+ h->heapbckt.newstorage = STORE_INVALID;
/* check whether a persisted hash can be found
*/
if ((fd = GDKfdlocate(h->heapbckt.farmid, nme,
"rb+", "thashb")) >= 0) {
@@ -993,7 +997,6 @@ BAThash_impl(BAT *restrict b, struct can
gdk_return
BAThash(BAT *b)
{
- assert(b->batCacheid > 0);
if (ATOMstorage(b->ttype) == TYPE_msk) {
GDKerror("No hash on msk type bats\n");
return GDK_FAIL;
diff --git a/gdk/gdk_heap.c b/gdk/gdk_heap.c
--- a/gdk/gdk_heap.c
+++ b/gdk/gdk_heap.c
@@ -292,7 +292,12 @@ HEAPextend(Heap *h, size_t size, bool ma
}
fd = GDKfdlocate(h->farmid, nme, "wb", ext);
if (fd >= 0) {
+ gdk_return rc = GDKextendf(fd, size, nme);
close(fd);
+ if (rc != GDK_SUCCEED) {
+ failure = "h->storage == STORE_MEM &&
can_map && fd >= 0 && GDKextendf() != GDK_SUCCEED";
+ goto failed;
+ }
h->storage = h->newstorage == STORE_MMAP &&
existing && !mayshare ? STORE_PRIV : h->newstorage;
/* make sure we really MMAP */
if (must_mmap && h->newstorage == STORE_MEM)
@@ -746,7 +751,8 @@ HEAPload_intern(Heap *h, const char *nme
char *srcpath, *dstpath, *tmp;
int t0;
- h->storage = h->newstorage = h->size < GDK_mmap_minsize_persistent ?
STORE_MEM : STORE_MMAP;
+ if (h->storage == STORE_INVALID || h->newstorage == STORE_INVALID)
+ h->storage = h->newstorage = h->size < (h->farmid == 0 ?
GDK_mmap_minsize_persistent : GDK_mmap_minsize_transient) ? STORE_MEM :
STORE_MMAP;
minsize = (h->size + GDK_mmap_pagesize - 1) & ~(GDK_mmap_pagesize - 1);
if (h->storage != STORE_MEM && minsize != h->size)
diff --git a/gdk/gdk_imprints.c b/gdk/gdk_imprints.c
--- a/gdk/gdk_imprints.c
+++ b/gdk/gdk_imprints.c
@@ -321,6 +321,7 @@ BATcheckimprints(BAT *b)
strconcat_len(imprints->imprints.filename,
sizeof(imprints->imprints.filename),
nme, ".timprints", NULL);
+ imprints->imprints.storage =
imprints->imprints.newstorage = STORE_INVALID;
/* check whether a persisted imprints index
* can be found */
if ((fd =
GDKfdlocate(imprints->imprints.farmid, nme, "rb", "timprints")) >= 0) {
@@ -774,7 +775,6 @@ IMPSfree(BAT *b)
Imprints *imprints;
if (b && b->timprints) {
- assert(b->batCacheid > 0);
MT_lock_set(&b->batIdxLock);
imprints = b->timprints;
if (imprints != NULL && imprints != (Imprints *) 1) {
diff --git a/gdk/gdk_orderidx.c b/gdk/gdk_orderidx.c
--- a/gdk/gdk_orderidx.c
+++ b/gdk/gdk_orderidx.c
@@ -76,7 +76,6 @@ BATcheckorderidx(BAT *b)
if (b == NULL)
return false;
- assert(b->batCacheid > 0);
/* we don't need the lock just to read the value b->torderidx */
if (b->torderidx == (Heap *) 1) {
/* but when we want to change it, we need the lock */
@@ -93,6 +92,7 @@ BATcheckorderidx(BAT *b)
strconcat_len(hp->filename,
sizeof(hp->filename),
nme, ".torderidx", NULL);
+ hp->storage = hp->newstorage = STORE_INVALID;
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list