Comments (7)
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.
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.
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:
- JanusGraph
0.2.0
seems to be using tinkerpop3.2.8
- gremlin-server.yaml
- janusgraph-cassandra-es-server.properties
(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.
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.
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.
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.
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)
- TitanFactory.open with conf file HOT 6
- Does it support Datastax graph HOT 4
- Driver connects to the server, but cannot find any data HOT 3
- Gremlin server out of memory HOT 2
- PHP7 Warnings on $db->send(...) HOT 3
- Able to connect to db but $db->send('g.V()') gives 400 error no gremlin script supplied HOT 5
- Cannot Try Catch DB->Connection->Open HOT 8
- Connection Error in Connection.php HOT 6
- java.util.ArrayList cannot be cast to java.lang.String HOT 5
- Can't send traversals HOT 12
- Rework Error management HOT 1
- Separate Wsocket functionality
- Having connectivity issues on two different cloud services HOT 1
- valueMap(true) fails to serialize HOT 8
- Cannot use transactions when connecting to Azure CosmosDB HOT 1
- Adding Edge on 2 vertices causes an error HOT 1
- Passing null or empty string value to a Binding Property results into syntax error
- How to use the $result?
- start transaction fail with aws neptune db
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gremlin-php.