Changeset: 3daf1bbb01ae for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/3daf1bbb01ae
Modified Files:
gdk/gdk.h
gdk/gdk_batop.c
Branch: persistent_sketches
Log Message:
Add lock protections and some unreachable statements.
diffs (58 lines):
diff --git a/gdk/gdk.h b/gdk/gdk.h
--- a/gdk/gdk.h
+++ b/gdk/gdk.h
@@ -1680,7 +1680,7 @@ typedef struct BAT {
Heap *theap; /* space for the column. */
BUN tbaseoff; /* offset in heap->base (in whole items) */
Heap *tvheap; /* space for the varsized data. */
- Heap *tstats; /* probabilistic counting sketch */
+ Heap *tstats; /* on dsk tail stats, e.g., counting sketch */
Hash *thash; /* hash table */
#ifdef HAVE_RTREE
RTree *trtree; /* rtree geometric index */
diff --git a/gdk/gdk_batop.c b/gdk/gdk_batop.c
--- a/gdk/gdk_batop.c
+++ b/gdk/gdk_batop.c
@@ -1157,32 +1157,25 @@ BATappend2(BAT *b, BAT *n, BAT *s, bool
}
if (b->tstats) {
+ assert(b->batRole == PERSISTENT);
MT_lock_set(&b->theaplock);
void *sk_b = tstats_sketch(b->tstats);
if (n->tstats) {
- if (BATcount(b) == ci.ncand) { /* b was empty */
- memcpy(b->tstats->base, n->tstats->base,
TSTATS_SZ);
- } else {
- void *sk_n = tstats_sketch(n->tstats);
- if (sketch_merge(sk_b, sk_n) != GDK_SUCCEED)
- goto bailout;
- }
+ void *sk_n = tstats_sketch(n->tstats);
+ if (BATcount(b) == ci.ncand) /* b was empty */
+ memcpy(sk_b, sk_n, SKETCH_SZ);
+ else if (sketch_merge(sk_b, sk_n) != GDK_SUCCEED)
+ MT_UNREACHABLE(); /* sketch_merge cannot fail */
} else {
- assert(b->batRole == PERSISTENT);
uint8_t tmp_sketch[SKETCH_BUCKETS][SKETCH_CLZ_BUCKETS]
= {0};
if (bat_sketch(&ni, &ci, tmp_sketch) != GDK_SUCCEED)
goto bailout;
- if (BATcount(b) == ci.ncand) { /* b was empty */
- int32_t *ver = tstats_version(b->tstats);
- int32_t *age = tstats_age(b->tstats);
- *ver = TSTATS_VERSION;
- *age = -1;
+ if (BATcount(b) == ci.ncand) /* b was empty */
memcpy(sk_b, tmp_sketch, SKETCH_SZ);
- } else {
- if (sketch_merge(sk_b, tmp_sketch) !=
GDK_SUCCEED)
- goto bailout;
- }
+ else if (sketch_merge(sk_b, tmp_sketch) != GDK_SUCCEED)
+ MT_UNREACHABLE(); /* sketch_merge cannot fail */
}
+ b->tstats->dirty = true;
b->tunique_est = sketch_estimate(sk_b);
MT_lock_unset(&b->theaplock);
}
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]