Git Product home page Git Product logo

Comments (7)

juhasev avatar juhasev commented on August 16, 2024 1

Didn't know about the run method! It works with it just fine. We should add that to the documentation and also mention requirement for using next() to get v extracted from a method. Like:

snowboarding = g.addV("hobby").property("name","Snow Boarding").next()

fails without the next(). All examples are written for gremlin console and there seems to be a lot of differences how things need to be approached. This is my first real journey to Gremlin.

from gremlin-php.

dmill-bz avatar dmill-bz commented on August 16, 2024 1

Yeah seems like there are a few things worth noting. Some of which I should definitely add to the documentation.

NO CONTENT 204 return error

The server processed the request but there is no result to return (e.g. an Iterator with no elements) - there are no messages remaining in this stream.

There is such a thing as an "No content return error". This is how it's communicated back from the server and hasn't been changed on the TinkerPop end because it is (or has been) very useful for debugging purposes. This error just means the server isn't returning any info. It's not really an error so to speak.

Because the driver bubbles up server issues, any empty return value will throw a similar error on the php end (ServerException code 204). It is worth noting that even though you get this error your code is still being executed.
The reason why you get no error on Connection::run() is because run ignores any info returned from the server by default. Just sends and forgets.

People implementing the driver should consider doing one of two things :

$db = new Connection([
     // ... config here ...
]);
$db->open();
try {
   $db->send("g.V().drop()");
} catch (Exception $e) {
   if($e instanceof ServerException && $e->getCode() == 204) {
      /** 
       * best practice would be to log a warning in your application as it will help with 
       * debugging if you have an issue with your gremlin query.
      */
      return []; // return an empty set.
   } else {
      throw $e;
   }
}

The other option is (gremlin-php v 2.2.0+):

$db = new Connection([
     "emptySet" => true, // this will automatically send you an empty array in place of an error.
     // ... config here ...
]);

Worth noting the second case does no log a warning. So some gremlin error debugging may be obscured by this.
In the first case it is obviously best to wrap the the driver's send() in your own send method with the try{}catch{} logic.

Iterations

The way the console works is that it automatically iterates your queries. It's a comfort feature.
Unfortunately whether it be gremlin sent through drivers or in native java you need to do those iterations manually.
It's very misleading because most/all the documentation is done using gremlin console.
The most common (but not the only) cases are like you mentioned:

g.V().drop().iterate();
g.addV("hobby").property("name","Snow Boarding").next();

from gremlin-php.

dmill-bz avatar dmill-bz commented on August 16, 2024

Hey!

Are you saying that both g.V().drop() and g.V().drop().iterate() are failing in php?
Can you let me know what version of the gremlin-php driver you are using as well? And how you're sending the request (using Connection::send() or Connection::run()?)

Bellow is some info I gathered up concerning the setup. Let me know if there's anything out of place:

(Edit: A failing sample php code would be great. Looks like you're using sessions so that might be something to look into)

from gremlin-php.

dmill-bz avatar dmill-bz commented on August 16, 2024

Let me know if you think of a good way of structuring the documentation to mention these points.
Also just to reiterate, you should be using Connection::send() in your case if you care at all about potential server side errors (like server side transaction conflicts)

from gremlin-php.

juhasev avatar juhasev commented on August 16, 2024

Great comments. I totally agree. This has been rather confusing experience due to lack of documentation / relatively small community. Even Tinkerpop 3 docs are outdated right at the tutorial. Need to find some good cook book / reference on this.

from gremlin-php.

dmill-bz avatar dmill-bz commented on August 16, 2024

I just skimmed it but this looked like a good guide : http://kelvinlawrence.net/book/Gremlin-Graph-Guide.html It won't make any mentions of iterations but you can pretty much ask here or on the gremlin user list if you have any questions regarding that.
Otherwise going to the "1. Reference Documentation > The Traversal section" for the correct TinkerPop version is often good too. Look here (Janus graph 0.2.0 uses TinkerPop 3.2.8)

If you have any questions on the driver or gremlin in general feel free to create a new issue. I'll keep this open as a reminder to edit the documentation a bit. Maybe a quick start guide might be useful.

from gremlin-php.

juhasev avatar juhasev commented on August 16, 2024

I discovered his book yesterday and it is indeed best Gremlin guide out there. Thanks for all the detailed the help and pointers!

from gremlin-php.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.