Having trouble adding arraylist as a property to a vertex

128 views
Skip to first unread message

Aniruddha Darp

unread,
Jul 15, 2019, 11:52:06 AM7/15/19
to Gremlin-users
I am creating a new vertex and what I'm doing looks something like this:

addV(LabelName)
.property(propertyName1, StringProperty)
.property(VertexProperty.Cardinality.list, propertyName2, ArrayList)
.property(propertyName3, StringProperty)



I keep getting an error: java.lang.IllegalArgumentException: The provided key/value array length must be a multiple of two

What am I doing wrong?

Thanks

Stephen Mallette

unread,
Jul 17, 2019, 10:29:07 AM7/17/19
to gremli...@googlegroups.com
I don't see any problem with what you're code, though I wonder what the actual value of your ArrayList is or if you even mean to use Cardinality.list there. Are you saying you want to store a list of List in that property?

gremlin> g.addV('person').property('name','x').property(list,'l',[1,2,3] as ArrayList)
==>v[0]
gremlin> g.V().valueMap('l')
==>[l:[[1,2,3]]]
gremlin> g.V().has('person','name','x').property(list,'l',[3,2,1] as ArrayList)
==>v[0]
gremlin> g.V().valueMap('l')
==>[l:[[1,2,3],[3,2,1]]]

Note that you can get that error if ArrayList is an actual Array with an even number of arguments (you'll get in correct behavior with an Array anyway because anything with an Array size greater than 1 will be interpreted as meta properties):

gremlin> x = ['x','y'] as String[]
==>x
==>y
gremlin> g.addV('person').property('name','x').property(list,'l',x)

The provided key/value array length must be a multiple of two
Type ':help' or ':h' for help.
Display stack trace? [yN]



--
You received this message because you are subscribed to the Google Groups "Gremlin-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gremlin-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gremlin-users/f1dfb8d4-6d77-461a-9594-283dc826fbec%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages