Hi Saneth,

Were you able to do this? If so what is the query you used.

seshika



On Thu, Oct 16, 2014 at 5:30 PM, Aiyadurai Rajeevan <[email protected]>
wrote:

> Hi Saneth,
>
> If i'm not mistaken we can achieve this using a custom transform. Since
> you have a separate table which holds all the books, You simply check using
> some java code and send the result as an output stream.
>
> Then your query would something like below,
>
> from userboughtbooks#window.time(10 min)
>
> select userboughtbooks.book_id as boughtBooks
>
> insert into IntermediateOutputStream
>
>
> from IntermediateOutputStream#transform.custom:AvailableBook(boughtBooks)
>
> select availableBook
>
> insert into RecommendationsOutputDataStream
>
>
> where AvailableBook would be your custom transform written in Java.
>
>
>
> Thanks & Regards,
> S.A.Rajeevan
> Software Engineer WSO2 Inc
> E-Mail: [email protected] | Mobile : +94776411636
>
> On Thu, Oct 16, 2014 at 12:52 PM, Seshika Fernando <[email protected]>
> wrote:
>
>> Hi Saneth,
>>
>> The reason for this is because, when you put a != , the join happens as
>> follows.
>> [image: Inline image 2]
>>
>>
>> This is why you get book1 and book2 once and book3, and book4 twice, in
>> your RecommendationsOutputStream. You may have to use a count operator from
>> the RecommendationsOutputStream to determine which books have not been
>> bought.
>>
>> Seshika
>>
>>
>>
>> On Thu, Oct 16, 2014 at 12:29 PM, Rajeev Sampath <[email protected]>
>> wrote:
>>
>>> Hi,
>>>
>>> On Thu, Oct 16, 2014 at 12:07 PM, Saneth Dharmakeerthi <[email protected]
>>> > wrote:
>>>
>>>> Hi,
>>>>
>>>> I am writing a Siddhi query to get the un-purchased books from an
>>>>  event table that has all  the books and a stream that contains  the
>>>> already bought books.
>>>>
>>>> my quarry is like  this;
>>>>
>>>> *userboughtbooks: *Stream that contains  the already bought books
>>>> *bookGroupTable: *Table that has all  the books
>>>> *RecommendationsOutputDataStream: *Out  put stream that contains  all
>>>> un-purchased books.
>>>>
>>>> from userboughtbooks#window.time(10 min) join bookGroupTable
>>>> on  bookGroupTable.book_id  != userboughtbooks.book_id
>>>> select bookGroupTable.book_id
>>>> insert into RecommendationsOutputDataStream
>>>>
>>>> 1. when  userboughtbooks has one element it gives the correct result.
>>>>
>>>> userboughtbooks: book1
>>>> bookGroupTable: book1, book2, book3, book4
>>>> RecommendationsOutputDataStream: book2, book3, book4
>>>>
>>>> 2. but  userboughtbooks has more than one element  gives the out put
>>>> like follows
>>>>
>>>> userboughtbooks: book1, book2
>>>> bookGroupTable: book1, book2, book3, book4
>>>> RecommendationsOutputDataStream: book1,book2,book3,book3,book4,book4
>>>>
>>>> I think behaviour of [2] , because of joining with  more than one
>>>> element.
>>>>
>>>> Is there a recommended way to accomplish this task?
>>>>
>>>>
>>>>
>>> As a workaround to solve this, you can add another query to check
>>> whether each output of recommendations stream exists in the table and then
>>> output only the non existing ones.
>>>
>>> eg:
>>>
>>> from RecommendationsOutputDataStream [not ((book_id ==
>>> bookGroupTable.book_id ) in bookGroupTable)]
>>> select *
>>> insert into filteredRecommendationsStream;
>>>
>>>
>>> Thanks
>>> Rajeev
>>>
>>>
>>>
>>>>
>>>> Thanks and Best Regards,
>>>>
>>>> Saneth Dharmakeerthi
>>>> Senior Software Engineer
>>>> WSO2, Inc.
>>>> Mobile: +94772325511
>>>>
>>>> _______________________________________________
>>>> Dev mailing list
>>>> [email protected]
>>>> http://wso2.org/cgi-bin/mailman/listinfo/dev
>>>>
>>>>
>>>
>>>
>>> --
>>> Rajeev Sampath
>>> Senior Software Engineer
>>> WSO2, Inc.; http://www.wso2.com.
>>>
>>> Mobile:
>>> * +94716265766 <%2B94716265766>*
>>>
>>> _______________________________________________
>>> Dev mailing list
>>> [email protected]
>>> http://wso2.org/cgi-bin/mailman/listinfo/dev
>>>
>>>
>>
>> _______________________________________________
>> Dev mailing list
>> [email protected]
>> http://wso2.org/cgi-bin/mailman/listinfo/dev
>>
>>
>
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to