Changeset: 2e6787314706 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/2e6787314706
Modified Files:
gdk/gdk.h
gdk/gdk_align.c
gdk/gdk_bat.c
gdk/gdk_group.c
gdk/gdk_hash.c
gdk/gdk_join.c
gdk/gdk_unique.c
monetdb5/mal/mal_profiler.c
Branch: default
Log Message:
Removed properties GDK_HASH_BUCKETS and GDK_NUNIQUE.
They're not really needed since we have the unique_est property.
diffs (195 lines):
diff --git a/gdk/gdk.h b/gdk/gdk.h
--- a/gdk/gdk.h
+++ b/gdk/gdk.h
@@ -2216,8 +2216,7 @@ gdk_export void VIEWbounds(BAT *b, BAT *
* levels.
*/
enum prop_t {
- GDK_HASH_BUCKETS = 3, /* last used hash bucket size (oid) */
- GDK_NUNIQUE, /* number of unique values (oid) */
+ CURRENTLY_NO_PROPERTIES_DEFINED,
};
gdk_export ValPtr BATgetprop(BAT *b, enum prop_t idx);
diff --git a/gdk/gdk_align.c b/gdk/gdk_align.c
--- a/gdk/gdk_align.c
+++ b/gdk/gdk_align.c
@@ -254,7 +254,6 @@ BATmaterialize(BAT *b)
b->theap = tail;
b->tbaseoff = 0;
b->theap->dirty = true;
- BATsetprop_nolock(b, GDK_NUNIQUE, TYPE_oid, &(oid){is_oid_nil(t) ? 1 :
b->batCount});
b->tunique_est = is_oid_nil(t) ? 1.0 : (double) b->batCount;
MT_lock_unset(&b->theaplock);
b->ttype = TYPE_oid;
diff --git a/gdk/gdk_bat.c b/gdk/gdk_bat.c
--- a/gdk/gdk_bat.c
+++ b/gdk/gdk_bat.c
@@ -667,10 +667,9 @@ BATfree(BAT *b)
GDKfree(b->tident);
b->tident = BATstring_t;
MT_rwlock_rdlock(&b->thashlock);
- BUN nunique = BUN_NONE, nbucket = BUN_NONE;
+ BUN nunique = BUN_NONE;
if (b->thash && b->thash != (Hash *) 1) {
nunique = b->thash->nunique;
- nbucket = b->thash->nbucket;
}
MT_rwlock_rdunlock(&b->thashlock);
HASHfree(b);
@@ -678,9 +677,7 @@ BATfree(BAT *b)
OIDXfree(b);
MT_lock_set(&b->theaplock);
if (nunique != BUN_NONE) {
- BATsetprop_nolock(b, GDK_NUNIQUE, TYPE_oid, &(oid){nunique});
b->tunique_est = (double) nunique;
- BATsetprop_nolock(b, GDK_HASH_BUCKETS, TYPE_oid,
&(oid){nbucket});
}
if (b->theap) {
assert(ATOMIC_GET(&b->theap->refs) == 1);
diff --git a/gdk/gdk_group.c b/gdk/gdk_group.c
--- a/gdk/gdk_group.c
+++ b/gdk/gdk_group.c
@@ -622,7 +622,6 @@ BATgroup_internal(BAT **groups, BAT **ex
BUN lo = 0;
struct canditer ci;
oid maxgrp = oid_nil; /* maximum value of g BAT (if subgrouping) */
- const ValRecord *prop;
lng t0 = 0;
const char *algomsg = "";
bool locked = false;
@@ -799,8 +798,8 @@ BATgroup_internal(BAT **groups, BAT **ex
MT_rwlock_rdunlock(&b->thashlock);
if (maxgrps == BUN_NONE) {
MT_lock_set(&b->theaplock);
- if ((prop = BATgetprop_nolock(b, GDK_NUNIQUE)) != NULL)
- maxgrps = prop->val.oval;
+ if (b->tunique_est != 0)
+ maxgrps = (BUN) b->tunique_est;
else
maxgrps = cnt / 10;
MT_lock_unset(&b->theaplock);
diff --git a/gdk/gdk_hash.c b/gdk/gdk_hash.c
--- a/gdk/gdk_hash.c
+++ b/gdk/gdk_hash.c
@@ -737,7 +737,6 @@ BAThash_impl(BAT *restrict b, struct can
Hash *h = NULL;
const char *nme = GDKinmemory(b->theap->farmid) ? ":memory:" :
BBP_physical(b->batCacheid);
BATiter bi = bat_iterator(b);
- const ValRecord *prop;
bool hascand = ci->tpe != cand_dense || ci->ncand != bi.count;
lng timeoffset = 0;
@@ -807,15 +806,6 @@ BAThash_impl(BAT *restrict b, struct can
/* if key, or if small, don't bother dynamically
* adjusting the hash mask */
mask = HASHmask(ci->ncand);
- } else if (!hascand && (prop = BATgetprop_try(b, GDK_NUNIQUE)) != NULL)
{
- assert(prop->vtype == TYPE_oid);
- mask = prop->val.oval * 8 / 7;
- } else if (!hascand && (prop = BATgetprop_try(b, GDK_HASH_BUCKETS)) !=
NULL) {
- assert(prop->vtype == TYPE_oid);
- mask = prop->val.oval;
- maxmask = HASHmask(ci->ncand);
- if (mask > maxmask)
- mask = maxmask;
} else if (!hascand && b->tunique_est != 0) {
mask = (BUN) (b->tunique_est * 1.15); /* about 8/7 */
} else {
@@ -980,15 +970,6 @@ BAThash_impl(BAT *restrict b, struct can
break;
}
bat_iterator_end(&bi);
- if (!hascand) {
- /* don't keep these properties while we have a hash
- * structure: they get added again when the hash is
- * freed */
- MT_lock_set(&b->theaplock);
- BATrmprop_nolock(b, GDK_HASH_BUCKETS);
- BATrmprop_nolock(b, GDK_NUNIQUE);
- MT_lock_unset(&b->theaplock);
- }
h->heapbckt.parentid = b->batCacheid;
h->heaplink.parentid = b->batCacheid;
/* if the number of unique values is equal to the bat count,
diff --git a/gdk/gdk_join.c b/gdk/gdk_join.c
--- a/gdk/gdk_join.c
+++ b/gdk/gdk_join.c
@@ -3308,15 +3308,12 @@ joincost(BAT *r, struct canditer *lci, s
MT_rwlock_rdunlock(&b->thashlock);
}
if (!rhash) {
- const ValRecord *prop = BATgetprop(r, GDK_NUNIQUE);
- if (prop) {
- /* we know number of unique values, assume some
- * collisions */
- rcost *= 1.1 * ((double) BATcount(r) /
prop->val.oval);
- } else {
- /* guess number of unique value and work with
that */
- rcost *= 1.1 * ((double) cnt / guess_uniques(r,
&(struct canditer){.tpe=cand_dense, .ncand=BATcount(r)}));
- }
+ double unique_est;
+ if ((unique_est = r->tunique_est) == 0)
+ unique_est = guess_uniques(r, &(struct
canditer){.tpe=cand_dense, .ncand=BATcount(r)});
+ /* we have an estimate of the number of unique
+ * values, assume some collisions */
+ rcost *= 1.1 * ((double) cnt / unique_est);
#ifdef PERSISTENTHASH
/* only count the cost of creating the hash for
* non-persistent bats */
@@ -3339,15 +3336,12 @@ joincost(BAT *r, struct canditer *lci, s
if (rhash && !prhash) {
rccost = (double) cnt / nheads;
} else {
- ValPtr prop = BATgetprop(r, GDK_NUNIQUE);
- if (prop) {
- /* we know number of unique values, assume some
- * chains */
- rccost = 1.1 * ((double) cnt / prop->val.oval);
- } else {
- /* guess number of unique value and work with
that */
- rccost = 1.1 * ((double) cnt / guess_uniques(r,
rci));
- }
+ double unique_est;
+ if ((unique_est = r->tunique_est) == 0)
+ unique_est = guess_uniques(r, rci);
+ /* we have an estimate of the number of unique
+ * values, assume some chains */
+ rccost = 1.1 * ((double) cnt / unique_est);
}
rccost *= lci->ncand;
rccost += rci->ncand * 2.0; /* cost of building the hash */
diff --git a/gdk/gdk_unique.c b/gdk/gdk_unique.c
--- a/gdk/gdk_unique.c
+++ b/gdk/gdk_unique.c
@@ -39,7 +39,6 @@ BATunique(BAT *b, BAT *s)
BATiter bi;
int (*cmp)(const void *, const void *);
struct canditer ci;
- const ValRecord *prop;
const char *algomsg = "";
lng t0 = 0;
@@ -90,9 +89,7 @@ BATunique(BAT *b, BAT *s)
MT_rwlock_rdunlock(&b->thashlock);
if (initsize == BUN_NONE) {
MT_lock_set(&b->theaplock);
- if ((prop = BATgetprop_nolock(b, GDK_NUNIQUE)) != NULL)
- initsize = prop->val.oval;
- else if (b->tunique_est != 0)
+ if (b->tunique_est != 0)
initsize = (BUN) b->tunique_est;
MT_lock_unset(&b->theaplock);
}
diff --git a/monetdb5/mal/mal_profiler.c b/monetdb5/mal/mal_profiler.c
--- a/monetdb5/mal/mal_profiler.c
+++ b/monetdb5/mal/mal_profiler.c
@@ -388,8 +388,6 @@ prepareProfilerEvent(Client cntxt, MalBl
BBPunfix(d->batCacheid);
goto cleanup_and_exit;
}
- keepprop(GDK_HASH_BUCKETS,"hbuckets");
- keepprop(GDK_NUNIQUE,"nunique");
cv =
VALformat(&stk->stk[getArg(pci,j)]);
c = strchr(cv, '>');
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list