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:


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:[,,,20,0,0,0::recentpostdate%252Fsticky,,mixedindex,20,2,0,83929827]

1. Only for the CompositeIndex
2. In your specific example, you could use the java Integer class ([] ), because its constructor takes either integer type or string type and it has the equals() method implemented.

Best wishes,    Marc

Join { to automatically receive all group messages.