This message was forwarded from [email protected].  The MonetDB
mailing lists have moved to monetdb.org.  Please subscribe to
[email protected], and unsubscribe from this list.
See: http://mail.monetdb.org/mailman/listinfo/developers-list

Send developers-list mailing list submissions to
        [email protected]

To subscribe or unsubscribe via the World Wide Web, visit
        http://mail.monetdb.org/mailman/listinfo/developers-list
or, via email, send a message with subject or body 'help' to
        [email protected]

You can reach the person managing the list at
        [email protected]

When replying, please edit your Subject line so it is more specific
than "Re: Contents of developers-list digest..."


Today's Topics:

   1. Re: MonetDB: default - use new sub sample function (cleans up
      some m... (Sjoerd Mullender)


----------------------------------------------------------------------

Message: 1
Date: Thu, 06 Dec 2012 11:09:08 +0100
From: Sjoerd Mullender <[email protected]>
To: [email protected]
Subject: Re: MonetDB: default - use new sub sample function (cleans up
        some m...
Message-ID: <[email protected]>
Content-Type: text/plain; charset=UTF-8

Why the mix of ptr/BUN/wrd in SAMPLEsubuniform?
The function is only called from MAL for a command whose last parameter
is declared as s:wrd, so SAMPLEsubuniform can be declared as having a
last argument as wrd *s and the cast inside then becomes correct too:
(BUN) *s.
Remember, wrd and BUN are not *necessarily* the same size.

On 2012-12-06 10:25, Niels Nes wrote:
> Changeset: 7c832c8b1a70 for MonetDB
> URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=7c832c8b1a70
> Modified Files:
>       monetdb5/modules/kernel/algebra.mx
>       monetdb5/modules/mal/sample.c
>       monetdb5/modules/mal/sample.h
>       monetdb5/modules/mal/sample.mal
>       sql/backends/monet5/rel_bin.c
>       sql/backends/monet5/sql_gencode.c
> Branch: default
> Log Message:
> 
> use new sub sample function (cleans up some more reverses and marks)
> 
> 
> diffs (112 lines):
> 
> diff --git a/monetdb5/modules/kernel/algebra.mx 
> b/monetdb5/modules/kernel/algebra.mx
> --- a/monetdb5/modules/kernel/algebra.mx
> +++ b/monetdb5/modules/kernel/algebra.mx
> @@ -282,6 +282,11 @@ comment "Selects all elements that have 
>  command sample ( b:bat[:oid,:any_2], num:int ) :bat[:oid,:any_2] 
>  address ALGsample
>  comment "Produce a random selection of size 'num' from the input BAT.";
> +
> +command subsample(b:bat[:oid,:any_1], num:int ) :bat[:oid,:oid] 
> +address ALGsubsample
> +comment "Return the oids of a random selection of size 'num' from the input 
> BAT.";
> +
>  # @+ BAT copying
>  command copy( b:bat[:any_1,:any_2]) :bat[:any_1,:any_2] 
>  address ALGcopy
> @@ -1076,6 +1081,7 @@ algebra_export str ALG@1(int *result, in
>  @:ALGbinaryExport(tdifference)@
>  @:ALGbinaryExport(tdiff)@
>  @:ALGbinaryintExport(sample)@
> +@:ALGbinaryintExport(subsample)@
>  
>  algebra_export str ALGtunique(int *result, int *bid);
>  algebra_export str ALGtsort(int *result, int *bid);
> @@ -2765,6 +2771,11 @@ ALGsample(bat *result, bat *bid, int *pa
>       return ALGbinaryint(result, bid, param, BATsample, "algebra.sample");
>  }
>  
> +str
> +ALGsubsample(bat *result, bat *bid, int *param)
> +{
> +     return ALGbinaryint(result, bid, param, BATsample_, 
> "algebra.subsample");
> +}
>  
>  /* add items missing in the kernel */
>  str
> 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
> @@ -96,6 +96,23 @@ SAMPLEuniform(bat *r, bat *b, ptr s) {
>  }
>  
>  sample_export str
> +SAMPLEsubuniform(bat *r, bat *b, ptr s) {
> +     BAT *br, *bb;
> +
> +     if ((bb = BATdescriptor(*b)) == NULL) {
> +             throw(MAL, "sample.subuniform", INTERNAL_BAT_ACCESS);
> +     }
> +     br = BATsample_(bb,*(BUN *)s);
> +     if (br == NULL)
> +             throw(MAL, "sample.subuniform", OPERATION_FAILED);
> +
> +     BBPunfix(bb->batCacheid);
> +     BBPkeepref(*r = br->batCacheid);
> +     return MAL_SUCCEED;
> +
> +}
> +
> +sample_export str
>  SAMPLEuniform_dbl(bat *r, bat *b, ptr p) {
>       BAT *bb;
>       double pr = *(double *)p;
> 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
> @@ -42,6 +42,9 @@ sample_export str
>  SAMPLEuniform(bat *r, bat *b, ptr s);
>  
>  sample_export str
> +SAMPLEsubuniform(bat *r, bat *b, ptr s);
> +
> +sample_export str
>  SAMPLEuniform_dbl(bat *r, bat *b, ptr p);
>  
>  #endif
> diff --git a/monetdb5/modules/mal/sample.mal b/monetdb5/modules/mal/sample.mal
> --- a/monetdb5/modules/mal/sample.mal
> +++ b/monetdb5/modules/mal/sample.mal
> @@ -27,6 +27,10 @@ command uniform(b:bat[:oid,:any],s:wrd):
>  address SAMPLEuniform
>  comment "Returns a uniform sample of size s"
>  
> +command subuniform(b:bat[:oid,:any],s:wrd):bat[:oid,:oid]
> +address SAMPLEsubuniform
> +comment "Returns the oids of a uniform sample of size s"
> +
>  command uniform(b:bat[:oid,:any],p:dbl):bat[:oid,:any]
>  address SAMPLEuniform_dbl
>  comment "Returns a uniform sample of size = (p x count(b)), where 0 <= p <= 
> 1.0"
> diff --git a/sql/backends/monet5/rel_bin.c b/sql/backends/monet5/rel_bin.c
> --- a/sql/backends/monet5/rel_bin.c
> +++ b/sql/backends/monet5/rel_bin.c
> @@ -2677,7 +2677,6 @@ rel2bin_sample( mvc *sql, sql_rel *rel, 
>               sc = column(sql->sa, sc);
>               sample = stmt_sample(sql->sa, stmt_alias(sql->sa, sc, tname, 
> cname),s);
>  
> -             sample = stmt_reverse(sql->sa, stmt_mark_tail(sql->sa, sample, 
> 0));
>               for ( ; n; n = n->next) {
>                       stmt *sc = n->data;
>                       char *cname = column_name(sql->sa, sc);
> diff --git a/sql/backends/monet5/sql_gencode.c 
> b/sql/backends/monet5/sql_gencode.c
> --- a/sql/backends/monet5/sql_gencode.c
> +++ b/sql/backends/monet5/sql_gencode.c
> @@ -983,7 +983,7 @@ _dumpstmt(backend *sql, MalBlkPtr mb, st
>               case st_sample:{
>                       int l = _dumpstmt(sql, mb, s->op1);
>                       int r = _dumpstmt(sql, mb, s->op2);
> -                     q = newStmt(mb, "sample", "uniform");
> +                     q = newStmt(mb, "sample", "subuniform");
>                       q = pushArgument(mb, q, l);
>                       q = pushArgument(mb, q, r);
>                       s->nr = getDestVar(q);
> _______________________________________________
> checkin-list mailing list
> [email protected]
> http://mail.monetdb.org/mailman/listinfo/checkin-list
> 


-- 
Sjoerd Mullender


------------------------------

_______________________________________________
developers-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/developers-list


End of developers-list Digest, Vol 4, Issue 5
*********************************************

------------------------------------------------------------------------------
LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial
Remotely access PCs and mobile devices and provide instant support
Improve your efficiency, and focus on delivering more value-add services
Discover what IT Professionals Know. Rescue delivers
http://p.sf.net/sfu/logmein_12329d2d
_______________________________________________
Monetdb-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-developers

Reply via email to