AntonTerekhov / OrientDB-PHP

Binary protocol for OrientDB for PHP applications (Beta)
http://code.google.com/p/orient/wiki/NetworkBinaryProtocol
BSD 3-Clause "New" or "Revised" License
108 stars 23 forks source link

Gremlin and Graph DB support #17

Closed F21 closed 11 years ago

F21 commented 12 years ago

I am looking for a library to allow my application to talk to OrientDB.

This one looks to be very promising (and the binary protocol is quite fast). I would like to contribute some graph db functionality (add vertices, edges, etc) to the project (I will still need to look at the source code to learn the coding standards and style of course:) ).

Having said that, is there gremlin query support at the moment? I plan to have those graph functions query the database using gremlin.

AntonTerekhov commented 12 years ago

No, right now there is no Gremlin support. Its planned, but with no estimation =(

So, if you're wiling to help - you're welcome!

F21 commented 12 years ago

Ahh :( Unfortunately, I have no experience with decoding the binary protocol at all :(

lvca commented 12 years ago

I think that the driver should execute the classic "command" function passing "com.orientechnologies.orient.graph.gremlin.OCommandGremlin" instead of "c". That's all.

AntonTerekhov commented 12 years ago

Luca, it would be nice, but doesn't Gremlin records uses slightly different record (de) serialization?

lvca commented 12 years ago

No, they are documents after all.

AntonTerekhov commented 12 years ago

Well, this is king of "blind coding", but... there is separate branch for gremlin queries, top commit is 1314da396a .

Please let me know, is it works. Reason for "blind" approach is lack of free time to set up gremlin.

Luca, If I've missed some 5-minutes super-easy way for Gremlin with Orient, could you give me a link?

lvca commented 12 years ago

Course: http://code.google.com/p/orient/wiki/Gremlin

AntonTerekhov commented 12 years ago

F21, please try gremlin_query branch. Let me know if its ok.

F21 commented 12 years ago

Confirmed as working :)

Test code (I added 2 vertices to the database using OrientDB Studio):

require 'OrientDB/OrientDB.php';
$db = new OrientDB('localhost', 2424);
$config = $db->DBOpen('test', 'admin', 'admin');
$records = $db->selectGremlin('g.V', '*:-1');
var_dump($records);

Output:

array (size=2)
  0 => 
    object(OrientDBRecord)[15]
      private 'isParsed' => boolean false
      private 'className' => null
      public 'type' => string 'd' (length=1)
      private 'clusterID' => int 8
      private 'recordPos' => int 0
      private 'recordID' => string '8:0' (length=3)
      public 'version' => int 0
      private 'content' => string 'V@' (length=2)
      public 'data' => 
        object(OrientDBData)[17]
          private 'data' => 
            array (size=0)
              empty
          private 'record' => 
            &object(OrientDBRecord)[15]
  1 => 
    object(OrientDBRecord)[16]
      private 'isParsed' => boolean false
      private 'className' => null
      public 'type' => string 'd' (length=1)
      private 'clusterID' => int 8
      private 'recordPos' => int 1
      private 'recordID' => string '8:1' (length=3)
      public 'version' => int 0
      private 'content' => string 'V@' (length=2)
      public 'data' => 
        object(OrientDBData)[19]
          private 'data' => 
            array (size=0)
              empty
          private 'record' => 
            &object(OrientDBRecord)[16]

Great work! :) I hope to see more improvements and more object-oriented functions like $vertex->relateTo($anotherVertex) etc.

AntonTerekhov commented 12 years ago

Well, I'm glad that its working.

As for support of more gremlin functions, it will require a lot more work, and I'm not really sure that such a support is in scope of this low-level driver.

So, I'll wait a couple of days, and if current gremlin code will work as intended, I'll merge branch gremlin_query into master

AntonTerekhov commented 11 years ago

Merged experimental gremlin into master