Changeset: b0e91698dd84 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/b0e91698dd84
Modified Files:
gdk/gdk_bbp.c
gdk/gdk_private.h
gdk/gdk_storage.c
Branch: Jan2022
Log Message:
Make more use of the bat iterator.
diffs (158 lines):
diff --git a/gdk/gdk_bbp.c b/gdk/gdk_bbp.c
--- a/gdk/gdk_bbp.c
+++ b/gdk/gdk_bbp.c
@@ -1812,8 +1812,9 @@ BBPexit(void)
* reclaimed as well.
*/
static inline int
-heap_entry(FILE *fp, BAT *b, BUN size, BATiter *bi)
+heap_entry(FILE *fp, BATiter *bi, BUN size)
{
+ BAT *b = bi->b;
size_t free = bi->hfree;
if (size < BUN_NONE) {
if ((bi->type >= 0 && ATOMstorage(bi->type) == TYPE_msk))
@@ -1825,7 +1826,7 @@ heap_entry(FILE *fp, BAT *b, BUN size, B
}
if ((GDKdebug & TAILCHKMASK) && free > 0) {
- char *fname = GDKfilepath(0, BATDIR,
BBP_physical(b->batCacheid), gettailname(b));
+ char *fname = GDKfilepath(0, BATDIR,
BBP_physical(b->batCacheid), gettailnamebi(bi));
if (fname != NULL) {
struct stat stb;
if (stat(fname, &stb) == -1) {
@@ -1864,18 +1865,18 @@ heap_entry(FILE *fp, BAT *b, BUN size, B
}
static inline int
-vheap_entry(FILE *fp, Heap *h, BUN size, BATiter *bi)
+vheap_entry(FILE *fp, BATiter *bi, BUN size)
{
(void) size;
- if (h == NULL)
+ if (bi->vh == NULL)
return 0;
if ((GDKdebug & TAILCHKMASK) && size > 0) {
- char *fname = GDKfilepath(0, BATDIR, BBP_physical(h->parentid),
"theap");
+ char *fname = GDKfilepath(0, BATDIR,
BBP_physical(bi->vh->parentid), "theap");
if (fname != NULL) {
struct stat stb;
if (stat(fname, &stb) == -1) {
assert(0);
- TRC_WARNING(GDK, "file %s not found (expected
size %zu)\n", fname, h->free);
+ TRC_WARNING(GDK, "file %s not found (expected
size %zu)\n", fname, bi->vhfree);
} else if ((size_t) stb.st_size < bi->vhfree) {
/* no assert since this can actually happen */
TRC_WARNING(GDK, "file %s too small (expected
%zu, actual %zu)\n", fname, bi->vhfree, (size_t) stb.st_size);
@@ -1883,7 +1884,7 @@ vheap_entry(FILE *fp, Heap *h, BUN size,
GDKfree(fname);
}
}
- return fprintf(fp, " %zu %zu %d", bi->vhfree, h->size, 0);
+ return fprintf(fp, " %zu %zu %d", bi->vhfree, bi->vh->size, 0);
}
static gdk_return
@@ -1892,16 +1893,16 @@ new_bbpentry(FILE *fp, bat i, BUN size,
#ifndef NDEBUG
assert(i > 0);
assert(i < (bat) ATOMIC_GET(&BBPsize));
- assert(BBP_desc(i));
- assert(BBP_desc(i)->batCacheid == i);
- assert(BBP_desc(i)->batRole == PERSISTENT);
- assert(0 <= BBP_desc(i)->theap->farmid && BBP_desc(i)->theap->farmid <
MAXFARMS);
- assert(BBPfarms[BBP_desc(i)->theap->farmid].roles & (1U << PERSISTENT));
- if (BBP_desc(i)->tvheap) {
- assert(0 <= BBP_desc(i)->tvheap->farmid &&
BBP_desc(i)->tvheap->farmid < MAXFARMS);
- assert(BBPfarms[BBP_desc(i)->tvheap->farmid].roles & (1U <<
PERSISTENT));
+ assert(bi->b);
+ assert(bi->b->batCacheid == i);
+ assert(bi->b->batRole == PERSISTENT);
+ assert(0 <= bi->h->farmid && bi->h->farmid < MAXFARMS);
+ assert(BBPfarms[bi->h->farmid].roles & (1U << PERSISTENT));
+ if (bi->vh) {
+ assert(0 <= bi->vh->farmid && bi->vh->farmid < MAXFARMS);
+ assert(BBPfarms[bi->vh->farmid].roles & (1U << PERSISTENT));
}
- assert(size <= BBP_desc(i)->batCount || size == BUN_NONE);
+ assert(size <= bi->count || size == BUN_NONE);
#endif
if (size > bi->count)
@@ -1912,12 +1913,12 @@ new_bbpentry(FILE *fp, bat i, BUN size,
BBP_status(i) & BBPPERSISTENT,
BBP_logical(i),
BBP_physical(i),
- BBP_desc(i)->batRestricted << 1,
+ bi->b->batRestricted << 1,
size,
- BBP_desc(i)->batCapacity,
- BBP_desc(i)->hseqbase) < 0 ||
- heap_entry(fp, BBP_desc(i), size, bi) < 0 ||
- vheap_entry(fp, BBP_desc(i)->tvheap, size, bi) < 0 ||
+ bi->b->batCapacity,
+ bi->b->hseqbase) < 0 ||
+ heap_entry(fp, bi, size) < 0 ||
+ vheap_entry(fp, bi, size) < 0 ||
(BBP_options(i) && fprintf(fp, " %s", BBP_options(i)) < 0) ||
fprintf(fp, "\n") < 0) {
GDKsyserror("new_bbpentry: Writing BBP.dir entry failed\n");
diff --git a/gdk/gdk_private.h b/gdk/gdk_private.h
--- a/gdk/gdk_private.h
+++ b/gdk/gdk_private.h
@@ -280,6 +280,26 @@ void VIEWdestroy(BAT *b)
BAT *virtualize(BAT *bn)
__attribute__((__visibility__("hidden")));
+static inline const char *
+gettailnamebi(const BATiter *bi)
+{
+ if (bi->type == TYPE_str) {
+ switch (bi->width) {
+ case 1:
+ return "tail1";
+ case 2:
+ return "tail2";
+#if SIZEOF_VAR_T == 8
+ case 4:
+ return "tail4";
+#endif
+ default:
+ break;
+ }
+ }
+ return "tail";
+}
+
static inline bool
imprintable(int tpe)
{
diff --git a/gdk/gdk_storage.c b/gdk/gdk_storage.c
--- a/gdk/gdk_storage.c
+++ b/gdk/gdk_storage.c
@@ -763,25 +763,6 @@ BATmsync(BAT *b)
#endif /* DISABLE_MSYNC */
}
-static inline const char *
-gettailnamebi(const BATiter *bi)
-{
- if (bi->type != TYPE_str)
- return "tail";
- switch (bi->width) {
- case 1:
- return "tail1";
- case 2:
- return "tail2";
-#if SIZEOF_VAR_T == 8
- case 4:
- return "tail4";
-#endif
- default:
- return "tail";
- }
-}
-
gdk_return
BATsave_locked(BAT *b, BATiter *bi, BUN size)
{
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]