Changeset: cd44b921c2b6 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/cd44b921c2b6
Branch: ppbench
Log Message:
merge with pp_hashjoin
diffs (121 lines):
diff --git a/gdk/gdk.h b/gdk/gdk.h
--- a/gdk/gdk.h
+++ b/gdk/gdk.h
@@ -1434,7 +1434,7 @@ gdk_export void STRMPdestroy(BAT *b);
gdk_export bool BAThasstrimps(BAT *b);
gdk_export gdk_return BATsetstrimps(BAT *b);
-gdk_export void sketch_populate(BAT* n, BATiter *ni, struct canditer *nci,
uint8_t cnting_sketch[BUCKETS][CLZ_BUCKETS]);
+gdk_export int sketch_populate(BAT* n, BATiter *ni, struct canditer *nci,
uint8_t cnting_sketch[BUCKETS][CLZ_BUCKETS]);
/* gdk_export void sketch_merge(BAT* b, BAT* n); */
gdk_export double sketch_estimate(uint8_t cnt_sketch[BUCKETS][CLZ_BUCKETS]);
gdk_export double bat_guess_uniques(BAT *b, BATiter *bi, struct canditer *bci);
diff --git a/gdk/gdk_sketch.c b/gdk/gdk_sketch.c
--- a/gdk/gdk_sketch.c
+++ b/gdk/gdk_sketch.c
@@ -79,7 +79,7 @@ sketch_estimate(uint8_t cnt_sketch[BUCKE
return alpha * (double)BUCKETS * BUCKETS / z;
}
-void
+int
sketch_populate(BAT* b, BATiter *bi, struct canditer *bci,
uint8_t cnting_sketch[BUCKETS][CLZ_BUCKETS])
{
@@ -121,7 +121,9 @@ sketch_populate(BAT* b, BATiter *bi, str
hash = XXH64(ptr, strlen(ptr), HLLSEED);
break;
default:
- return;
+ /* TRC_ERROR(ACCELERATOR, "Type not supported for
counting sketches." */
+ /* "Aborting count distinct estimation."); */
+ return -1;
}
bucket = hash & BITS_MASK;
hash |= BITS_MASK;
@@ -132,11 +134,16 @@ sketch_populate(BAT* b, BATiter *bi, str
} else {
uint8_t k = cnting_sketch[bucket][clz] - 128;
uint64_t rng;
- if (getentropy(&rng, sizeof(rng)) == 0 &&
- (rng & ((1ULL << k) - 1)) == 0)
+ if (getentropy(&rng, sizeof(rng)) != 0) {
+ /* TRC_ERROR(ACCELERATOR, "Failed to generate
sketch seed." */
+ /* "Aborting count distinct
estimation."); */
+ return -1;
+ }
+ if ((rng & ((1ULL << k) - 1)) == 0)
cnting_sketch[bucket][clz]++;
}
}
+ return 0;
}
/* void */
@@ -155,14 +162,15 @@ double
bat_guess_uniques(BAT *b, BATiter *bi, struct canditer *bci)
{
uint8_t cnting_sketch[BUCKETS][CLZ_BUCKETS] = {0};
+ double unique_guess = 0;
BATiter nbi = bi ? *bi : bat_iterator(b);
struct canditer nbci;
if (bci == NULL)
canditer_init(&nbci, b, NULL);
- sketch_populate(b, &nbi, &nbci, cnting_sketch);
- double unique_guess = sketch_estimate(cnting_sketch);
+ if (sketch_populate(b, &nbi, &nbci, cnting_sketch) == 0)
+ unique_guess = sketch_estimate(cnting_sketch);
if (bi == NULL)
bat_iterator_end(&nbi);
diff --git a/monetdb5/modules/mal/pipeline.c b/monetdb5/modules/mal/pipeline.c
--- a/monetdb5/modules/mal/pipeline.c
+++ b/monetdb5/modules/mal/pipeline.c
@@ -522,9 +522,22 @@ PPclaim(Client cntxt, MalBlkPtr mb, MalS
BAT *b = BATdescriptor(rb);
if (b) {
+ bool sync = false;
+ Pipeline *p = MT_thread_getdata();
+ int nr = -1;
+ if (p) {
+ nr = p->seqnr;
+ if (nr >= 0) {
+ bool done = 0;
+ pipeline_get_token(p, 7, nr, &done);
+ sync = true;
+ }
+ }
struct pipeline_resultset *rs = (struct
pipeline_resultset*)b->pl_io;
*res = ATOMIC_ADD(&rs->claimed, cnt);
BBPreclaim(b);
+ if (sync)
+ pipeline_pass_token(p, 7, nr);
}
return MAL_SUCCEED;
}
diff --git a/sql/backends/monet5/sql_statistics.c
b/sql/backends/monet5/sql_statistics.c
--- a/sql/backends/monet5/sql_statistics.c
+++ b/sql/backends/monet5/sql_statistics.c
@@ -205,6 +205,9 @@ sql_analyze(Client cntxt, MalBlkPtr mb,
/* Guess number of uniques if not
entirely unique */
/* unique_est =
(double)BATguess_uniques(b, NULL); */
unique_est =
(double)bat_guess_uniques(b, NULL, NULL);
+ MT_lock_set(&b->theaplock);
+ b->tunique_est = unique_est;
+ MT_lock_unset(&b->theaplock);
/* Collect min and max values */
mn = BATmin(b, NULL);
@@ -213,7 +216,8 @@ sql_analyze(Client cntxt, MalBlkPtr mb,
GDKfree(mx);
BBPunfix(b->batCacheid);
- store->storage_api.set_stats_col(tr, c,
&unique_est, NULL, NULL);
+ /* if (unique_est > 0) */
+ /*
store->storage_api.set_stats_col(tr, c, &unique_est, NULL, NULL); */
}
}
}
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]