Hi All,

Today, we had a discussion about the things we've done so far and the
improvements needed in the current implementation. And pointed out the
followings,

1. The current implementation of the function definition doesn't have a
return type, so, the return type is going to be added in the following
manner,

define function concat[Scala] *return String* {
var a = data(0).asInstanceOf[String]
var b = data(1).asInstanceOf[String]
a + b
}

2. The test case implemented need not to be in the same FunctionTestCase
class, so, new test class for the script function is to be added.
3. The test should not be implemented only for the happy path of the
scenario, but, failure scenarios too to check if the right exceptions are
being thrown while working with failure cases.
4. functionID has to be changed to functionId to get it to be tally with
the current siddhi convention.

So, the above changes are going to be added to the current implementation.

Appreciate your thoughts!!!

Thanks,
-Ayash

On Fri, Dec 5, 2014 at 3:34 PM, Ayash <ayashkan...@wso2.com> wrote:
>
> Hi All,
>
> As discussed with Suho and Srinath today, the scripting support is going
> to be in following manner,
>
> 1. The user can just write only set of statements without writing
> functions.
>    For example, if the user needs to concatenate strings defining a siddhi
> function call concat, he can define the function like below,
>
> define function concat[JavaScript] {
>   var a = data[0];
>   var b = data[1];
>   rerurn a + b;
> };
>
> and he/she can call it in siddhi like below,
>
> from cseEventStream
> select *concat( *a, b *) *as c
> insert into some_other;
>
> 2. Internally, Siddhi construct a function like below, for the above
> example, Siddhi constructs a function like below which the external user
> cannot see,
>
> function concat(Data) {
>   var a = data[0].toString();
>   var b = data[1].toString();
>   return a + b;
> }
>
> For the Scala also, user is having the same ability, below is the
> suggested Siddhi script for scala,
>
> define function concat[Scala] {
>   var a = data(0).asInstanceOf[String]
>   var b = data(1).asInstanceOf[String]
>   a + b
> }
>
> and call it in siddhi exactly like we did it above JavaScript example.
> Siddhi internally construct the below function,
>
> data: Array[Any] => {
>   var a = data(0).asInstanceOf[String]
>   var b = data(1).asInstanceOf[String]
>   a + b
> }
>
> Appreciate your thoughts!!!!
>
> Thanks,
> -Ayash
>
> On Mon, Dec 1, 2014 at 5:17 PM, Sriskandarajah Suhothayan <s...@wso2.com>
> wrote:
>
>> +1 looks good
>>
>> Suho
>>
>> On Mon, Dec 1, 2014 at 4:57 PM, Ayash <ayashkan...@wso2.com> wrote:
>>
>>> Hi All,
>>>
>>> The implementation, $subject is adding some scripting support for
>>> Siddhi. It is as follows,
>>>
>>> 1. Scripting languages are going to be JavaScript and Scala.
>>> 2. New language feature is to be introduced like below,
>>>       Define script[Language]{//script implementation goes here}
>>> 3. Siddhi user can choose the scripting language mentioning it like
>>> below in Siddhi,
>>>       Define script[JavaScript] {//JavaScript implementation goes here}
>>>       or
>>>       Define script[Scala]{//Scala implementation goes here}
>>> 4. The functions or methods defined are to be available to the user to
>>> call it like Siddhi inbuilt function.
>>>
>>> For example, let's just define and call a Scala-method in Siddhi like
>>> below,
>>>
>>> define script[Scala] {
>>>     Def *getSymbol*(id: String): String = id
>>> }
>>> define stream cseEventStream (symbol string, price float, volume string)
>>> from cseEventStream
>>> select *getSymbol*(symbol), convert(volume,long)/1000 as vol,
>>> sum(convert(volume,long)) as sumVolume
>>> group by symbol
>>> insert into StockQuote;
>>>
>>> Appreciate your thoughts!!!
>>>
>>> Thanks,
>>> -Ayash
>>>
>>>
>>> --
>>> Ayashkantha Ramasinghe
>>> Software Engineer WSO2, Inc.
>>> email: ayashkan...@wso2.com <sanj...@wso2.com>;
>>> TP: +94 77 7 487 669
>>>
>>
>>
>>
>> --
>>
>> *S. Suhothayan*
>> Technical Lead & Team Lead of WSO2 Complex Event Processor
>>  *WSO2 Inc. *http://wso2.com
>> * <http://wso2.com/>*
>> lean . enterprise . middleware
>>
>>
>> *cell: (+94) 779 756 757 <%28%2B94%29%20779%20756%20757> | blog:
>> http://suhothayan.blogspot.com/ <http://suhothayan.blogspot.com/>twitter:
>> http://twitter.com/suhothayan <http://twitter.com/suhothayan> | linked-in:
>> http://lk.linkedin.com/in/suhothayan <http://lk.linkedin.com/in/suhothayan>*
>>
>
>
>
> --
> Ayashkantha Ramasinghe
> Software Engineer WSO2, Inc.
> email: ayashkan...@wso2.com <sanj...@wso2.com>;
> TP: +94 77 7 487 669
>


-- 
Ayashkantha Ramasinghe
Software Engineer WSO2, Inc.
email: ayashkan...@wso2.com <sanj...@wso2.com>;
TP: +94 77 7 487 669
_______________________________________________
Architecture mailing list
Architecture@wso2.org
https://mail.wso2.org/cgi-bin/mailman/listinfo/architecture

Reply via email to