Changeset: dc251b317e2f for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=dc251b317e2f
Modified Files:
gdk/gdk_sample.c
monetdb5/modules/kernel/microbenchmark.c
monetdb5/modules/mal/sample.c
monetdb5/modules/mal/sample.h
Branch: stratified_sampling
Log Message:
remove wrd, BUNfirst and BATnew
diffs (109 lines):
diff --git a/gdk/gdk_sample.c b/gdk/gdk_sample.c
--- a/gdk/gdk_sample.c
+++ b/gdk/gdk_sample.c
@@ -186,7 +186,7 @@ static BAT *
} else {
/* do weighted sampling */
- cdf_ptr = (dbl*) Tloc(cdf, BUNfirst(cdf));
+ cdf_ptr = (dbl*) Tloc(cdf, 0);
if (!antiset)
cdf_max = cdf_ptr[cnt-1];
else
@@ -199,8 +199,7 @@ static BAT *
do {
random = mtwist_drand(mt_rng)*cdf_max;
- /* generate a new random OID in
[minoid, maxoid[
- * that is including minoid, excluding
maxoid*/
+ /* generate a new random OID with
minoid <= OID < maxoid */
/* note that cdf has already been
adjusted for antiset case */
candoid = (oid) ( minoid + (oid)
SORTfndfirst(cdf, &random) );
/* if that candidate OID was already
@@ -260,14 +259,16 @@ BATweightedsample(BAT *b, BUN n, BAT *w)
antiset = n > cnt / 2;
- cdf = BATnew(TYPE_void, TYPE_dbl, cnt, TRANSIENT);
+ cdf = COLnew(0, TYPE_dbl, cnt, TRANSIENT);
BATsetcount(cdf, cnt);
/* calculate cumilative distribution function */
- w_ptr = (dbl*) Tloc(w, BUNfirst(w));//TODO support different types w
- cdf_ptr = (dbl*) Tloc(cdf, BUNfirst(cdf));
+ w_ptr = (dbl*) Tloc(w, 0);//TODO support different types w
+ cdf_ptr = (dbl*) Tloc(cdf, 0);
cdf_ptr[0] = (dbl)w_ptr[0];
+
+ /* remove NULL values */
for (i = 1; i < cnt; i++) {
if((dbl)w_ptr[i] == dbl_nil) {//TODO fix NULL-test if w can
have different types
cdf_ptr[i] = cdf_ptr[i-1];
@@ -302,7 +303,7 @@ BATweightedsample(BAT *b, BUN n, BAT *w)
BATweightedbitbat(BUN cnt, BUN n, BAT *w)
{
BAT* res;
- res = BATnew(TYPE_void, TYPE_dbl, cnt, TRANSIENT);
+ res = COLnew(0, TYPE_dbl, cnt, TRANSIENT);
BATsetcount(res, cnt);
//Need to adjust _BATsample so it will return a bit BAT with bools
denoting if element is selected
diff --git a/monetdb5/modules/kernel/microbenchmark.c
b/monetdb5/modules/kernel/microbenchmark.c
--- a/monetdb5/modules/kernel/microbenchmark.c
+++ b/monetdb5/modules/kernel/microbenchmark.c
@@ -374,7 +374,6 @@ MBMmix(bat *bn, bat *batid)
throw(MAL, "microbenchmark.mix", RUNTIME_OBJECT_MISSING);
n = BATcount(b);
- firstbun = BUNfirst(b);
mt_rng = mtwist_new();
diff --git a/monetdb5/modules/mal/sample.c b/monetdb5/modules/mal/sample.c
--- a/monetdb5/modules/mal/sample.c
+++ b/monetdb5/modules/mal/sample.c
@@ -106,7 +106,7 @@ SAMPLEuniform_dbl(bat *r, bat *b, dbl *p
}
str
-SAMPLEweighted(bat *r, bat *b, wrd *s, bat *w) {
+SAMPLEweighted(bat *r, bat *b, lng *s, bat *w) {
BAT *br, *bb, *bw;
if ((bw = BATdescriptor(*w)) == NULL ) {
@@ -128,7 +128,7 @@ str
SAMPLEweighted_dbl(bat *r, bat *b, dbl *p, bat *w) {
BAT *bb;
double pr = *p;
- wrd s;
+ lng s;
if ( pr < 0.0 || pr > 1.0 ) {
throw(MAL, "sample.subweighted", ILLEGAL_ARGUMENT
@@ -140,7 +140,7 @@ SAMPLEweighted_dbl(bat *r, bat *b, dbl *
if ((bb = BATdescriptor(*b)) == NULL) {
throw(MAL, "sample.subweighted", INTERNAL_BAT_ACCESS);
}
- s = (wrd) (pr*(double)BATcount(bb));
+ s = (lng) (pr*(double)BATcount(bb));
BBPunfix(bb->batCacheid);
return SAMPLEweighted(r, b, &s, w);
}
diff --git a/monetdb5/modules/mal/sample.h b/monetdb5/modules/mal/sample.h
--- a/monetdb5/modules/mal/sample.h
+++ b/monetdb5/modules/mal/sample.h
@@ -23,10 +23,10 @@ SAMPLEuniform(bat *r, bat *b, lng *s);
mal_export str
SAMPLEuniform_dbl(bat *r, bat *b, dbl *p);
-sample_export str
-SAMPLEweighted(bat *r, bat *b, wrd *s, bat *w);
+mal_export str
+SAMPLEweighted(bat *r, bat *b, lng *s, bat *w);
-sample_export str
+mal_export str
SAMPLEweighted_dbl(bat *r, bat *b, dbl *p, bat *w);
#endif
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list