2.1 broke my time series

96 views
Skip to first unread message

Curtis Stanford

unread,
Aug 27, 2015, 5:33:47 PM8/27/15
to orient-...@googlegroups.com
I have a classic time-series case using maps to store year/month/day/hour/minute/second vertices. These maps are all LINKMAPs where the links point to other vertices. They are not embedded, nor do I want them to be embedded. Now, using 2.1, getting these link maps from a vertex results in:

java.lang.ClassCastException: com.tinkerpop.blueprints.impls.orient.OrientElementIterable cannot be cast to java.util.Map

This happens because, in OrientElement.java at line 283, it checks to see if the document is embedded or the class name is null. If the document is not embedded or has a class (my case), it doesn't return the link map but converts it into an OrientElementIterable of just the values in the map. 

Is there no way to store a true LINKMAP with links to external non-embedded vertices that belong to real classes get get it back again?

Thanks

Curtis

EDIT: found I could get the map using vertex.record.field("propName") instead of vertex.getProperty("propName"). 

Curtis Stanford

unread,
Sep 11, 2015, 3:33:37 PM9/11/15
to orient-...@googlegroups.com
This is still causing me grief in Orient 2.1.2. Isn't there any way to get a LINK MAP (i.e. Map<String, ODocument>) from a vertex? The problem with using vertex.getRecord().field("propName") is that any changes to the map are not persisted to the vertex. I have to do a vertex.setProperty("propName", map) to persist it but I'm not sure that's very performant for a small change to a large map.

The problem now seems to be lines 287 - 289 in OrientElement.java:

      if (graph != null)
        // CONVERT IT TO ITERABLE<VERTEX/EDGE>
        return (T) new OrientElementIterable<OrientElement>(graph, OMultiValue.getMultiValueIterable(fieldValue));

I guess the question is, is there any way to get a LINK MAP from a vertex, make a small change to the map, and have it persisted after the transaction is committed? (Using the Java API)

Thanks!

Luigi Dell'Aquila

unread,
Sep 16, 2015, 6:34:25 AM9/16/15
to orient-...@googlegroups.com
Hi Curtis,

I think this behavior was introduced by commit b2c9317f7db3dee26a075d186d32c9eaf6803f21
IMHO the fix should consist in writing a Map implementation that behaves like OrientElementIterable, and just add an IF in that method. 
@laa, @tglman WDYT?

Luigi


2015-09-11 21:33 GMT+02:00 Curtis Stanford <cur...@stanfordcomputing.com>:
This is still causing me grief. Isn't there any way to get a LINK MAP (i.e. Map<String, ODocument>) from a vertex? The problem with using vertex.getRecord().field("propName") is that any changes to the map are not persisted to the vertex. I have to do a vertex.setProperty("propName", map) to persist it but I'm not sure that's very performant for a small change to a large map.

--

---
You received this message because you are subscribed to the Google Groups "OrientDB" group.
To unsubscribe from this group and stop receiving emails from it, send an email to orient-databa...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Curtis Stanford

unread,
Sep 16, 2015, 11:10:24 AM9/16/15
to OrientDB
Hi Luigi. Thanks for your response. I don't understand how a Map could behave like an Iterable. I need to look up values on the map with a key, which you can't do with an Iterable. I wonder what the initial reason was for that change. Why not just return the map instead of explicitly changing it to an iterable of the map values?

Luigi Dell'Aquila

unread,
Sep 16, 2015, 11:35:20 AM9/16/15
to orient-...@googlegroups.com
Hi Curtis,

yes, of course, I was referring to an eventual fix on our side, not on client code ;-)
The initial reason for that was about Graph API, in cases when you have link collections pointing to documents. If you are using Graph API and these documents are also vertices, you expect to have Vertex instances as result, not ODocument instances, this is what the fix does. The problem is that it just supposes it's working on a collection (ignoring that also maps are iterable)

Luigi


Curtis Stanford

unread,
Sep 16, 2015, 12:32:04 PM9/16/15
to OrientDB
Ah, sorry. I get it. Thanks Luigi.
Reply all
Reply to author
Forward
0 new messages