Changeset: 68aa1effbbe0 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/68aa1effbbe0
Modified Files:
gdk/gdk.h
sql/storage/bat/bat_storage.c
Branch: Jul2021
Log Message:
bat_iterator is for read-only access only.
diffs (51 lines):
diff --git a/gdk/gdk.h b/gdk/gdk.h
--- a/gdk/gdk.h
+++ b/gdk/gdk.h
@@ -888,6 +888,8 @@ gdk_export void HEAPincref(Heap *h);
* accesses, it is better to use the iterator, even without the BUNt*
* macros, since the theaplock is only held very briefly.
*
+ * Note, bat_iterator must only be used for read-only access.
+ *
* If BATs are to be modified, higher level code must assure that no
* other thread is going to modify the same BAT at the same time. A
* to-be-modified BAT should not use bat_iterator. It can use
diff --git a/sql/storage/bat/bat_storage.c b/sql/storage/bat/bat_storage.c
--- a/sql/storage/bat/bat_storage.c
+++ b/sql/storage/bat/bat_storage.c
@@ -320,9 +320,6 @@ segments2cs(sql_trans *tr, segments *seg
return LOG_ERR;
}
- if (nr > BATcount(b))
- BATsetcount(b, nr);
-
/* disable all properties here */
b->tsorted = false;
b->trevsorted = false;
@@ -334,13 +331,12 @@ segments2cs(sql_trans *tr, segments *seg
b->tnokey[1] = 0;
uint32_t *restrict dst;
- BATiter bi = bat_iterator(b);
for (; s ; s=s->next) {
if (s->ts == tr->tid && s->end != s->start) {
b->batDirtydesc = true;
size_t lnr = s->end-s->start;
size_t pos = s->start;
- dst = ((uint32_t*)bi.base) + (s->start/32);
+ dst = (uint32_t *) Tloc(b, 0) + (s->start/32);
uint32_t cur = 0;
if (s->deleted) {
size_t used = pos&31, end = 32;
@@ -385,7 +381,9 @@ segments2cs(sql_trans *tr, segments *seg
}
}
}
- bat_iterator_end(&bi);
+ if (nr > BATcount(b))
+ BATsetcount(b, nr);
+
bat_destroy(b);
return LOG_OK;
}
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list