Re: What are the implications of using Object.class property type?


Laura Morales <lauretas@...>
 

I'd like to understand a little bit more about what's going on under the hood when creating a new property with .dataType(Object.class) vs any other specific type eg. .dataType(String.class) or .dataType(Integer.class)
I'm able to create a "name" property like this:

mgmt.makePropertyKey('name').dataType(Object.class).make()

and this is what I've noticed:

- it allows me to create these vertexes
g.addV('alice').property('name', 'Alice')
g.addV('terminator').property('name', 42)
- it allows me to create a composite index, but not a mixed index (confirming what was said in the other thread)
- the composite index works when searching for an exact match, ie. .has('name', 'Alice') and .has('name', 42). The composite index does not work when searching by comparison, ie. .has('name', lt(50)) (I get the usual warning "Query requires iterating over all vertices" and it returns zero vertexes)

I'm only interested into this because I have a graph where multiple people contribute, it would be very nice to not having to deal with explicit property types, if Object.class is an option. For my particular use case I could live without mixed indexes, and I wouldn't mind a small performance deficit (size and/or speed) introduced by the usage of Object as a general type. But I really struggle to understand what's going on. What's the difference between Object and specific types from Janus' point of view? Are types only useful for enforcing a particular schema when inserting data, or there's more to it?



Sent: Wednesday, July 21, 2021 at 10:34 AM
From: hadoopmarc@...
To: janusgraph-users@...
Subject: Re: [janusgraph-users] What are the implications of using Object.class property type?
Hi Laura,

A similar question was posed recently:
https://lists.lfaidata.foundation/g/janusgraph-users/message/5986[https://lists.lfaidata.foundation/g/janusgraph-users/message/5986?p=,,,20,0,0,0::recentpostdate%252Fsticky,,mixedindex,20,2,0,83929827]

So,
1. Only for the CompositeIndex
2. In your specific example, you could use the java Integer class ( https://docs.oracle.com/javase/8/docs/api/java/lang/Integer.html[https://docs.oracle.com/javase/8/docs/api/java/lang/Integer.html] ), because its constructor takes either integer type or string type and it has the equals() method implemented.

Best wishes,    Marc

Join {janusgraph-users@lists.lfaidata.foundation to automatically receive all group messages.