Changeset: b86d5ff215e3 for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=b86d5ff215e3 Modified Files: monetdb5/modules/kernel/algebra.c monetdb5/modules/mal/tokenizer.c sql/backends/monet5/sql_statistics.c Branch: Oct2014 Log Message:
Use subunique instead of group to get count of distinct values. diffs (69 lines): diff --git a/monetdb5/modules/kernel/algebra.c b/monetdb5/modules/kernel/algebra.c --- a/monetdb5/modules/kernel/algebra.c +++ b/monetdb5/modules/kernel/algebra.c @@ -333,16 +333,15 @@ ALGgroupby(int *res, int *gids, int *cnt str ALGcard(lng *result, int *bid) { - BAT *b, *gn, *en; + BAT *b, *en; if ((b = BATdescriptor(*bid)) == NULL) { throw(MAL, "algebra.card", RUNTIME_OBJECT_MISSING); } - if (BATgroup(&gn, &en, NULL, b, NULL, NULL, NULL) != GDK_SUCCEED) { + if ((en = BATsubunique(b, NULL)) == NULL) { throw(MAL, "algebra.card", GDK_EXCEPTION); } *result = BATcount(en); - BBPunfix(gn->batCacheid); BBPunfix(en->batCacheid); BBPreleaseref(b->batCacheid); return MAL_SUCCEED; diff --git a/monetdb5/modules/mal/tokenizer.c b/monetdb5/modules/mal/tokenizer.c --- a/monetdb5/modules/mal/tokenizer.c +++ b/monetdb5/modules/mal/tokenizer.c @@ -627,7 +627,7 @@ TKNZRgetCount(int *r) str TKNZRgetCardinality(int *r) { - BAT *b, *gn, *en; + BAT *b, *en; int i; wrd cnt; @@ -638,12 +638,11 @@ TKNZRgetCardinality(int *r) throw(MAL, "tokenizer.getCardinality", MAL_MALLOC_FAIL); BATseqbase(b, 0); for (i = 0; i < tokenDepth; i++) { - if (BATgroup(&gn, &en, NULL, tokenBAT[i].val, NULL, NULL, NULL) != GDK_SUCCEED) { + if ((en = BATsubunique(tokenBAT[i].val, NULL)) == NULL) { BBPreclaim(b); throw(MAL, "tokenizer.getCardinality", GDK_EXCEPTION); } cnt = (wrd) BATcount(en); - BBPunfix(gn->batCacheid); BBPunfix(en->batCacheid); BUNappend(b, &cnt, FALSE); } 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 @@ -115,15 +115,13 @@ sql_analyze(Client cntxt, MalBlkPtr mb, if (bn->tkey) uniq = sz; else { - BAT *gn, *en; + BAT *en; if (bsample) br = BATproject(bsample, bn); else br = bn; - /* BATgroup checks BATproject result */ - if (BATgroup(&gn, &en, NULL, br, NULL, NULL, NULL) == GDK_SUCCEED) { + if (br && (en = BATsubunique(br, NULL)) != NULL) { uniq = BATcount(en); - BBPunfix(gn->batCacheid); BBPunfix(en->batCacheid); } else uniq = 0; _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list