Consider tree like graph represented by "Node" verticies and "childOf" 
edges (oriented from child to parent) and command:
Iterable<OrientVertex> roots = (Iterable<OrientVertex>) graph.command(new 
OCommandSQL("select from Node where key = 'root'  fetchplan 
in_childOf:-1")).execute();

Now when I traverse the tree by Vertex.getVerticies(Direction.IN, 
"childOf")/ODocument.field("in_childOf") I expect there won't be any 
further remote lookup calls, because verticies have been already fetched by 
fetch plan.
But is it really the case?

I was trying to find out how accessing related records (edges) works:

The edges are represented as ORidBag:
ORidBag ridBag = (ORidBag) root.getRecord().field("in_childOf");

The ORidBag is a collection of OIdentifiable implemented by ORecordId:
ORecordId rid = (ORecordId) ridBag.iterator().next();

Now I can access the record (implemented by ODocument) representing the 
edge:
ODocument inChild = (ODocument) rid.getRecord();

The implementation of ORecordId.getRecord() is quite simple. It basically 
delegates the record retrieval to current ODatabaseDocument implemented by 
ODatabaseDocumentTx:
return (T) db.load(this);

There the things are getting complicated, but if I summarize my foundings, 
the record is either taken from local cache or requested to be fetched by 
ORemoteStorage.

As you can see I was able to find out only one place where the related 
record is not requested from the storage again and that is obtaining a 
record from local cache by ODatabaseDocumentTx.
However I checked that the related records are not present in local cache 
after the command is executed, so local cache also isn't responsible for 
accessing eagerly fetched records.

So am I really working with fetched records or are they fetched again when 
traversing graph with Document/Graph API in remote mode?
If yes, which component (ODocument/ORidBag/ODatabase/OStorage) is 
responsible for obtaining a record which is possibly loaded eagerly via 
fetch plan? 
And is there a way to tell if the related record (represented for example 
by ORecordId) is already fetched?

-- 

--- 
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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to