How can I pass a variable to "within" method?


"d...@gmail.com" <dor...@...>
 

I'm running a groovy script that reads a csv file into a variable.
Then I'm trying to pass the variable into a "within" method but I get no result.
While I'm passing the list as hardcoded value I get the results.

How can I pass the list as a variable?

The following does work:

g.V().union(has('Customer ID', 'CUSTOMER_ID_20200917130654_209').inE().hasLabel('current'), 
                     has('Customer ID', 'CUSTOMER_ID_20200917130654_209').inE().hasLabel('hasState'),
                     has('Customer ID', 'CUSTOMER_ID_20200917130654_209').outE().hasLabel('parent'),
                     has('Customer ID', 'CUSTOMER_ID_20200917130654_209').outE().hasLabel('peer'))

The following doesn't work:

g.V().union(has('Customer ID', within(CustomerList)).inE().hasLabel('current'), 
                     has('Customer ID', within(CustomerList)).inE().hasLabel('hasState'),
                     has('Customer ID', within(CustomerList)).outE().hasLabel('parent'),
                     has('Customer ID', within(CustomerList)).outE().hasLabel('peer'))

Note that when I print the CustomerList on the screen it shows:  'CUSTOMER_ID_20200917130654_209'

Thanks!


HadoopMarc <bi...@...>
 

Hi,

What does CustomerList.getClass() show?  The within() predicate works for individual objects and an ArrayList, not for a String[] array.

HTH,   Marc
Op woensdag 30 september 2020 om 19:56:29 UTC+2 schreef d...@...:

I'm running a groovy script that reads a csv file into a variable.
Then I'm trying to pass the variable into a "within" method but I get no result.
While I'm passing the list as hardcoded value I get the results.

How can I pass the list as a variable?

The following does work:

g.V().union(has('Customer ID', 'CUSTOMER_ID_20200917130654_209').inE().hasLabel('current'), 
                     has('Customer ID', 'CUSTOMER_ID_20200917130654_209').inE().hasLabel('hasState'),
                     has('Customer ID', 'CUSTOMER_ID_20200917130654_209').outE().hasLabel('parent'),
                     has('Customer ID', 'CUSTOMER_ID_20200917130654_209').outE().hasLabel('peer'))

The following doesn't work:

g.V().union(has('Customer ID', within(CustomerList)).inE().hasLabel('current'), 
                     has('Customer ID', within(CustomerList)).inE().hasLabel('hasState'),
                     has('Customer ID', within(CustomerList)).outE().hasLabel('parent'),
                     has('Customer ID', within(CustomerList)).outE().hasLabel('peer'))

Note that when I print the CustomerList on the screen it shows:  'CUSTOMER_ID_20200917130654_209'

Thanks!


HadoopMarc <bi...@...>
 

My reaction above was not accurate: within() also works on a String[] array, provided that all elements of the array are initialized.

Marc

Op donderdag 1 oktober 2020 om 07:50:14 UTC+2 schreef HadoopMarc:

Hi,

What does CustomerList.getClass() show?  The within() predicate works for individual objects and an ArrayList, not for a String[] array.

HTH,   Marc
Op woensdag 30 september 2020 om 19:56:29 UTC+2 schreef d...@...:
I'm running a groovy script that reads a csv file into a variable.
Then I'm trying to pass the variable into a "within" method but I get no result.
While I'm passing the list as hardcoded value I get the results.

How can I pass the list as a variable?

The following does work:

g.V().union(has('Customer ID', 'CUSTOMER_ID_20200917130654_209').inE().hasLabel('current'), 
                     has('Customer ID', 'CUSTOMER_ID_20200917130654_209').inE().hasLabel('hasState'),
                     has('Customer ID', 'CUSTOMER_ID_20200917130654_209').outE().hasLabel('parent'),
                     has('Customer ID', 'CUSTOMER_ID_20200917130654_209').outE().hasLabel('peer'))

The following doesn't work:

g.V().union(has('Customer ID', within(CustomerList)).inE().hasLabel('current'), 
                     has('Customer ID', within(CustomerList)).inE().hasLabel('hasState'),
                     has('Customer ID', within(CustomerList)).outE().hasLabel('parent'),
                     has('Customer ID', within(CustomerList)).outE().hasLabel('peer'))

Note that when I print the CustomerList on the screen it shows:  'CUSTOMER_ID_20200917130654_209'

Thanks!