Thanks Jason/Anil for your guidance!

In that case, going with option2 I will write some generic ResultTransformer to 
group by records by some field.

Thanks,
Dharam

Sent with BlackBerry Work (www.blackberry.com)
________________________________
From: Jason Huynh <[email protected]>
Sent: Feb 26, 2018 22:31
To: [email protected]
Subject: Re: LinkedList with OQL not working

Hi Dharam,

Option 1 is projecting the the name and dependencies.  So it will project the 
entire list of dependencies from the object that matches the criteria.  It will 
not manipulate the underlying field or collection.  That is by design, 
projecting a field will return the exact field.

Nested filtering is occurring (which is why you get 2 results instead of 4), 
but the projection of the field from the object is what you are seeing.

Option 2 is more of what you are looking for but you'd have to group or order 
the results.

On Fri, Feb 23, 2018 at 11:35 PM Thacker, Dharam 
<[email protected]<mailto:[email protected]>> wrote:
Hi Jason,

Yeah you are exactly there.

Correct, I am expecting OBJECTB to be filtered out from the projection. That’s 
where it makes sense when you apply filter into nested collections.

struct(ID:1,linkedList:[Position [secId=OBJECTA]])
struct(ID:3,linkedList:[Position [secId=OBJECTA]])

Currently your output also confines with layout as (Map<ID, 
LinkedList<Position>>)

Thanks,
Dharam

From: Jason Huynh [[email protected]<mailto:[email protected]>]
Sent: Saturday, February 24, 2018 12:13 AM

To: [email protected]<mailto:[email protected]>
Subject: Re: LinkedList with OQL not working

Hi Dharam,

I tried something similar but instead of IS_DEFINED I just used a string 
equality comparison.
I have a top level object and a linkedList in the top level object.  The 
linkedList contains two Position objects with a field named secId. One position 
has a secId of OBJECTA and other OBJECTB.
I created 2 of these top level objects, so the region only has 2 objects.

When running "select p.ID<https://secureweb.jpmchase.net/readonly/http://p.ID>, 
p.linkedList from /region p, p.linkedList empty"  (no filter), I get 4 structs 
returned as expected, the structs are tuples of the from clause.  So all 
combinations of ID and empd.  However we have projected the entire linkedList 
into the result based on our query.
struct(ID:1,linkedList:[Position [secId=OBJECTA], Position [secId=OBJECTB]])
struct(ID:1,linkedList:[Position [secId=OBJECTA], Position [secId=OBJECTB]])
struct(ID:3,linkedList:[Position [secId=OBJECTA], Position [secId=OBJECTB]])
struct(ID:3,linkedList:[Position [secId=OBJECTA], Position [secId=OBJECTB]])

When running with a filter  "select 
p.ID<https://secureweb.jpmchase.net/readonly/http://p.ID>, p.linkedList from 
/region p, p.linkedList empd where empd.secId='OBJECTA'", I receive two rows:
struct(ID:1,linkedList:[Position [secId=OBJECTA], Position [secId=OBJECTB]])
struct(ID:3,linkedList:[Position [secId=OBJECTA], Position [secId=OBJECTB]])

This time we only returned the tuples where empd matched the criteria.  We 
still projected the entire linkedList into the result (as expected).

Is this what you were hoping to be filtered out?  Are you expecting OBJECTB to 
be filtered out from the projection?:
struct(ID:1,linkedList:[Position [secId=OBJECTA]])
struct(ID:3,linkedList:[Position [secId=OBJECTA]])

Sorry if I I have a misunderstanding the expectation/problem.

-Jason



On Fri, Feb 23, 2018 at 5:05 AM Thacker, Dharam 
<[email protected]<mailto:[email protected]>> wrote:
Hello Jason/Team,

Did you get chance to try out option 1 with filter? I double checked today but 
it's not filtering inside LinkedList.

For my region, I have value as json with nested array which is converted to pdx 
instance using JSONFormatter api.

By default JSON array is always converted to LinkedList with JSONFormatter api. 
Not sure why?

I tried with my other regions as well having LinkedList. But it's not getting 
filtered. As they are JSON mapped PDXInstance, it's quite possible that some of 
JSON documents do not have "something" field which I am trying to check using 
IS_DEFINED(empd.something)

Thanks,
Dharam

Sent with BlackBerry Work 
(www.blackberry.com<https://secureweb.jpmchase.net/readonly/http://www.blackberry.com>)
________________________________
From: "Thacker, Dharam" 
<[email protected]<mailto:[email protected]>>
Sent: Feb 22, 2018 08:46
To: [email protected]<mailto:[email protected]>
Subject: RE: LinkedList with OQL not working

Thanks Jason/Anil for the reply!

Jason,
It's exactly the same output I am also getting for option 1 and option 2.

Now with your option 1, if you try to apply filter like I have 
IS_DEFINED(empd.something) it won't get filtered.

In your case your linked list has "ObjectX". Assume that ObjectX is instance of 
java class "Customer" having field as "country". Now as customer object is 
within LinkedList, Option 1 would fail with filter 
(IS_DEFINEE(objectX.country)).

Option2 works but it then changes the layout of output and in real world output 
is sent back as xml/json to business service.

Could you try that as well for Option 1?

Anil,

In both the options, my filter and outcome should be same as per my queries but 
layout is different.

In one case I am directly asking "service.dependencies" and in another case I 
am asking "alias" for "service.dependenies".

But the issue is Option1 does not give right outcome as filter condition is not 
being applied.

In real world, the actual object stored in geode itself is de normalized 
document. In my example "Dependencies grouped by service name"

Now if I again have to write code to group them(Map<Service,LinkedList>) then 
it defeats the purpose of having such prepared de normalized model for 
efficiency.

I hope that makes sense.

Dharam

Sent with BlackBerry Work 
(www.blackberry.com<https://secureweb.jpmchase.net/readonly/http://www.blackberry.com>)
________________________________
From: Jason Huynh <[email protected]<mailto:[email protected]>>
Sent: Feb 22, 2018 00:20
To: [email protected]<mailto:[email protected]>
Subject: Re: LinkedList with OQL not working

Correction, empd not empty, not sure how autocorrect came into play.

On Wed, Feb 21, 2018 at 10:48 AM Jason Huynh 
<[email protected]<mailto:[email protected]>> wrote:
I just tried similar queries and get the following output
Option1:
struct(ID:1,linkedList:[ObjectA, ObjectB])
struct(ID:1,linkedList:[ObjectA, ObjectB])
struct(ID:3,linkedList:[ObjectC, ObjectD])
struct(ID:3,linkedList:[ObjectC, ObjectD])

If I add a distinct keyword then I get only 2 rows:
struct(ID:1,linkedList:[ObjectA, ObjectB])
struct(ID:3,linkedList:[ObjectC, ObjectD])

Option2:
struct(ID:3,empd:ObjectD)
struct(ID:1,empd:ObjectA)
struct(ID:1,empty:ObjectB)
struct(ID:3,empd:ObjectC)

Adding an order by I can get them ordered by ID and empty
struct(ID:1,empd:ObjectA)
struct(ID:1,empty:ObjectB)
struct(ID:3,empty:ObjectC)
struct(ID:3,empd:ObjectD)


On Wed, Feb 21, 2018 at 10:30 AM Jason Huynh 
<[email protected]<mailto:[email protected]>> wrote:
In option1, are you receiving the linked list or is it not returning the values 
at all?
Is the problem in option1 just a display issue?

For option2,  you might be able to do a distinct with an order by but that will 
force uniqueness in the tupling which you may not be looking for.

On Wed, Feb 21, 2018 at 6:10 AM Thacker, Dharam 
<[email protected]<mailto:[email protected]>> wrote:
Hello Team,

I am unable to apply any filter conditions using OQL if collection is of type 
LinkedList. Below query does not work as expected.
Below query gives me dependencies grouped at service name level and array of 
depenencies under it.

Option1:
select 
service.name<https://secureweb.jpmchase.net/readonly/http://service.name>, 
service.dependencies from /Service service,service.dependancies empd where 
IS_DEFINED(empd.something)

Output:
Each row = serviceName -> {LinkedList}

Option2:
If I change query like below one then it gives filtered result but I don’t get 
grouped by service name at every result comes as individual element.

select 
service.name<https://secureweb.jpmchase.net/readonly/http://service.name>, empd 
from /Service service,service.dependancies empd where IS_DEFINED(empd.something)

Output:
Each row >>
serviceName -> empd1
serviceName -> empd2
serviceName -> empd3

Is there any such limitation?
Anything we can do to achieve this?

Thanks & Regards,
Dharam


This message is confidential and subject to terms at: 
http://www.jpmorgan.com/emaildisclaimer<http://www.jpmorgan.com/emaildisclaimer>
 including on confidentiality, legal privilege, viruses and monitoring of 
electronic messages. If you are not the intended recipient, please delete this 
message and notify the sender immediately. Any unauthorized use is strictly 
prohibited.

This message is confidential and subject to terms at: 
http://www.jpmorgan.com/emaildisclaimer<http://www.jpmorgan.com/emaildisclaimer>
 including on confidentiality, legal privilege, viruses and monitoring of 
electronic messages. If you are not the intended recipient, please delete this 
message and notify the sender immediately. Any unauthorized use is strictly 
prohibited.

This message is confidential and subject to terms at: 
http://www.jpmorgan.com/emaildisclaimer<http://www.jpmorgan.com/emaildisclaimer>
 including on confidentiality, legal privilege, viruses and monitoring of 
electronic messages. If you are not the intended recipient, please delete this 
message and notify the sender immediately. Any unauthorized use is strictly 
prohibited.

This message is confidential and subject to terms at: 
http://www.jpmorgan.com/emaildisclaimer including on confidentiality, legal 
privilege, viruses and monitoring of electronic messages. If you are not the 
intended recipient, please delete this message and notify the sender 
immediately. Any unauthorized use is strictly prohibited.

Reply via email to