[ 
https://issues.apache.org/jira/browse/CASSANDRA-7395?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14056683#comment-14056683
 ] 

Robert Stupp commented on CASSANDRA-7395:
-----------------------------------------

I have to revert myself - it's not BCEL, it's 
[javassist|http://www.csg.ci.i.u-tokyo.ac.jp/~chiba/javassist/] (available 
under APL2, MPL1.1, LGPL2.1 licenses). Sorry for the confusion.
javassist does not write to the file system - it generates the byte code in the 
JVM without javac or tools.jar and has support for class hot-swapping. It's 
been in use since '98 and still maintained. I've used it often to build code 
"on demand" to optimize "interpreted" code paths with byte code. I've built a 
quick demo available at https://bitbucket.org/snazy/udf-javassist-demo - just 
execute 'mvn test' - one test ("single") builds a class, adds one method and 
instantiates a new object from it (0/1ms per class) - the other test ("bundle") 
builds a new class with 27 methods (5..10ms per class). One drawback with 
javassist - it has no source code level support for boxing/unboxing support.

But ok - let's start with {{CREATE FUNCTION double foobar(value text) AS 
foo.bar.Baz.foobar;}} which simply does a 
{{Class.forName(...).getMethod(...)}}. A little tool might help to create the 
{{CREATE BUNDLE/FUNCTION}} CQL statements. Then add javassist, Nashorn or 
whatever. Maybe Nashorn is fast enough to fulfil most usecases (Nashorn has 
compiled script support).

Regarding the "deterministic" keyword. It's possible to define 
non-deterministic functions as "deterministic" in Oracle for example and use it 
in a functional index (which does not work, of course). The keyword's just 
there to prevent accidental use of non-deterministic functions. This may likely 
occur if multiple (different) people work on a database project for a long time 
(months, years). If people declare a non-deterministic function as 
deterministic, then it's obviously their stupid failure.

> Support for pure user-defined functions (UDF)
> ---------------------------------------------
>
>                 Key: CASSANDRA-7395
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-7395
>             Project: Cassandra
>          Issue Type: New Feature
>          Components: API, Core
>            Reporter: Jonathan Ellis
>              Labels: cql
>             Fix For: 3.0
>
>         Attachments: 7395-v2.diff, 7395.diff
>
>
> We have some tickets for various aspects of UDF (CASSANDRA-4914, 
> CASSANDRA-5970, CASSANDRA-4998) but they all suffer from various degrees of 
> ocean-boiling.
> Let's start with something simple: allowing pure user-defined functions in 
> the SELECT clause of a CQL query.  That's it.
> By "pure" I mean, must depend only on the input parameters.  No side effects. 
>  No exposure to C* internals.  Column values in, result out.  
> http://en.wikipedia.org/wiki/Pure_function



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Reply via email to