Iterate over all indexes of a class : CastError: OSBTreeMapEntry to OrientVertex/Others

59 views
Skip to first unread message

Shishya

unread,
Mar 23, 2014, 3:22:24 PM3/23/14
to orient-...@googlegroups.com
Hi,

I am trying POJO for iterating over an index of class. Purpose is to process all docs in classes.
But I get cast exception from OSBTreeMapEntryIterator. What would be the right way to get Document from each K,V of iterator?
Regards

OrientGraphFactory factory = new OrientGraphFactory("plocal:/dat/odb/orientdb-community-1.7-rc2-SNAPSHOT/databases/"+dbn,"admin","admin").setupPool(1, 10);
        factory
.getTx().getRawGraph().declareIntent(new OIntentMassiveInsert());
       
OrientGraph graph = factory.getTx();
OIndex<?> ptidIdx = graph.getRawGraph().getMetadata().getIndexManager().getIndex("idxptid");

Iterator<Map.Entry<ORID,ODocument>> iter = ptidIdx.iterator();

while (iter.hasNext()) {

Map.Entry<ORID,ODocument> tm = iter.next();
                   
System.out.println("\n"+tm+"");
}

Andrey Lomakin

unread,
Mar 24, 2014, 2:21:35 AM3/24/14
to orient-database
HI,
What exception did you get ?


--

---
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.



--
Best regards,
Andrey Lomakin.

Orient Technologies
the Company behind OrientDB

prabhat

unread,
Mar 24, 2014, 5:58:08 AM3/24/14
to orient-...@googlegroups.com
That was not right syntax but interim.
My error is 
--------------------
position: java.lang.ClassCastException: com.orientechnologies.orient.core.index.sbtree.OSBTreeMapEntryIterator$1$1 cannot be cast to com.orientechnologies.orient.core.record.ORecord
---------------------------------------
with Syntax
 ORecord tm = (ORecord)iter.next();





--

---
You received this message because you are subscribed to a topic in the Google Groups "OrientDB" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/orient-database/tWad9-hRLrg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to orient-databa...@googlegroups.com.

Andrey Lomakin

unread,
Mar 24, 2014, 6:25:41 AM3/24/14
to orient-database
Sorry, but what will be if you try Map.Entry<ORID,ODocument> tm = iter.next();

prabhat

unread,
Mar 24, 2014, 6:45:02 AM3/24/14
to orient-...@googlegroups.com
: error: incompatible types
            Iterator<Map.Entry<Object, ODocument>> iter = ptidIdx.iterator();
                                                                          ^
  required: Iterator<Entry<Object,ODocument>>
  found:    Iterator<Entry<Object,CAP#1>>
  where CAP#1 is a fresh type-variable:
    CAP#1 extends Object from capture of ?
1 error


Andrey Lomakin

unread,
Mar 24, 2014, 6:51:34 AM3/24/14
to orient-database
I see, 
Try following:
 Iterator<Map.Entry<Object, OIdentifiable>> iter = (Iterator<Map.Entry<Object, OIdentifiable>>)ptidIdx.iterator();

prabhat

unread,
Mar 24, 2014, 7:46:48 AM3/24/14
to orient-...@googlegroups.com
Still the same error

            Iterator<Map.Entry<Object, OIdentifiable>> iter = (Iterator<Map.Entry<Object, OIdentifiable>>)ptidIdx.iterator();
                                                                                                                           ^
  required: Iterator<Entry<Object,OIdentifiable>>
  found:    Iterator<Entry<Object,CAP#1>>
  where CAP#1 is a fresh type-variable:
    CAP#1 extends Object from capture of ?
2 errors


prabhat

unread,
Mar 24, 2014, 9:10:08 AM3/24/14
to orient-...@googlegroups.com
Hi Andrey,

Any other method to iterate all records of class(5 million+). So I cant load all in memory.

Regards
Reply all
Reply to author
Forward
0 new messages