uwescience / raco

Compilation and rule-based optimization framework for relational algebra. Raco is the language, optimization, and query translation layer for the Myria project.
Other
72 stars 19 forks source link

Allow user to specify log base #393

Open BrandonHaynes opened 9 years ago

BrandonHaynes commented 9 years ago

I have a while statement that needs to run log_2 n times. If overloading is supported, it would be nice to be able to specify a base for the existing log function. (I guess a log2 function would work as well; I find both options to be more clear than log(n) / log(2)).

dhalperi commented 9 years ago

You know that you can define little inline functions (like Lambda expressions), right?

def logN(a, b): log(a) / log(b);

will let you use logN in your program.

dhalperi commented 9 years ago

But, yes, this is a great suggestion. The place to do this is in the Expression Library: https://github.com/uwescience/raco/blob/master/raco/expression/expressions_library.py#L34

Overloading works (see SafeDiv), but I am not certain what will happen if you add a 2-ary log to the expressions library while leaving the unary log, which is in the language, alone... :) It might just work!

BrandonHaynes commented 9 years ago

Oh nice -- I did not know that the language supported inline functions. Thanks for mentioning that!

domoritz commented 9 years ago

We need docs on that. And how to write stateful apply and UDAs. I'd be happy to write the latter some time next month. Ref https://github.com/uwescience/myria-docs/blob/master/myriaql.markdown

bmyerz commented 9 years ago

@domoritz is there a issue in myria-docs to track that?

domoritz commented 9 years ago

@bmyerz No, oh I mean yes https://github.com/uwescience/myria-docs/issues/9