Comments (5)
Hi Christian,
The fieldNames of the SUCCESS message are not get replaced, as the two SUCCESS messages are independent.
In the example,
Client: RUN "MATCH (a:Person) RETURN a.name AS name, a.age AS age" {}
Client: PULL_ALL
Server: SUCCESS {"fields": ["name", "age"]} <---- a reply to RUN "MATCH..."
Server: RECORD ["Alice", 33]
Server: RECORD ["Bob", 44]
Server: RECORD ["Carol", 55]
Server: SUCCESS {} <----- a reply to PULL_ALL
As you could see, the first SUCCESS message is an answer to the RUN query, and then the second SUCCESS message is a reply to PULL_ALL. So having the second SUCCESS being empty is not considered to be an error.
Furthermore, we currently have a draft to expand the second empty SUCCESS message to provide more info while using PROFILE
and EXPLAIN
neo4j/neo4j#5271 (doc: https://github.com/neo4j/neo4j/pull/5271/files#diff-1de199999691d6c1b9b19a1da6bb7073R199)
Then for your question: "is there a way to address stream's current Record object directly instead of using the fieldNames()/get() functions and how would fieldNames() be used, if it is empty after a succesful exchange?"
I am not quite understand what you want to achieve here. If I understand you correctly then you want to get the field names when a Record is still a RecordMessage object (the string received from the server)? If so then you need to capture the first SUCESS message and then parse the field names yourself. But why you want to achieve this? Why not just use the Result rs
object?
Driver driver = GraphDatabase.driver( "neo4j://localhost" );
Session session = driver.session();
Result rs = session.run("MATCH (n:TestNode) RETURN n;"); <-------- this one
System.out.println(rs.fieldNames());
And you could find a lot of examples to use the Result object in ITs, e.g. https://github.com/neo4j/neo4j-java-driver/blob/master/driver/src/test/java/org/neo4j/driver/integration/StatementIT.java
Best,
Zhen
from neo4j-java-driver.
Hi Zhen,
thank you for taking the time to look into the issue.
To make the issue more clear, I will try to condense it as much as possible.
I have a clean instance of neo4j 3.0.0 and execute the following query to create a sample node:
CREATE (n:TestNode {name:'test'}) RETURN n;
Afterwards I am trying to run this query to get the created node:
MATCH (n:TestNode) RETURN n;
This works flawlessly in the neo4j webinterface.
When using the neo4j-java-driver and calling the fieldNames() function on the Result object now, it returns an empty Iterable.
Driver driver = GraphDatabase.driver( "neo4j://localhost" );
Session session = driver.session();
Result rs = session.run("MATCH (n:TestNode) RETURN n;");
System.out.println(rs.fieldNames()); <--- returns '[]'
I would have expected it to return '[n]' instead.
The documentation states the following:
/**
* Get an ordered sequence of the field names in this result.
*
* @return field names
*/
Iterable<String> fieldNames();
From my understanding the Result rs from above should point to the first Record returned by session.run(...) and calling fieldNames() on rs should have the same result as using:
rs.single().fieldNames() <- returns '[n]'
I hope this makes the issue more clear and I am looking forward to your reply.
Kind regards,
Christian
from neo4j-java-driver.
Hi Christian,
Thanks a lot for this wonderful explanation. I got this problem now. You are totally correct and your first answer is probably the cause of this bug. We are working on a PR to fix this bug soon.
Thanks a lot again. Please let us know if you have any other problem/suggestion when you are using this driver.
Best,
Zhen
from neo4j-java-driver.
from neo4j-java-driver.
Hello Zhen,
Thank you for your work in providing a fix for this problem.
The issue has been resolved and fieldNames() is working now.
Kind regards,
Christian
from neo4j-java-driver.
Related Issues (20)
- Akka dependencies in neo4j-java-driver v. 4.4.2 HOT 3
- GraalVM native image support broken due to incomplete classpath in 4.4.4
- Routing servers are not updated in time when opening a new session with a different database. HOT 3
- Neo4J Tests: Unable to connect Neo4J server in Tests with `@DataNeo4JTest` HOT 1
- Deadlock in BasicPullResponseHandler from neo4j-java-driver when used in a reactive way while cancelling unfinished Reactor subscription HOT 5
- Regression: Concurrent deletion of a Node no longer results in a TransientException HOT 4
- Unable to catch and properly handle timeout acquiring connection from pool exception
- Spring boot embedded neo4j: not able to connect from client when in docker container HOT 1
- Fatal error occurred in the pipeline HOT 1
- Changing the exception thrown to `RuntimeException` breaks binary / drop-in compatibility
- Invalid OSGi meta-data
- Message PULL .. cannot be handled by a session in the READY state HOT 7
- Java driver & Netty HOT 5
- Neo4j credential rotation during application runtime HOT 3
- Query execution threads are not interrupted/terminated when the driver is closed (neo4j driver version 5.9.0 and above) HOT 8
- Error in reactive flow when adding BlockHound HOT 7
- Possible to Encounter ConcurrentModificationException in SessionFactoryImpl HOT 9
- Use of ReflectionConfigurationResources results in warning starting with GraalVM for JDK 21 (23.1) HOT 3
- Application hang after Neo4j connection did not respond HOT 10
- Vulnerability in the dependency netty-codec HOT 4
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 neo4j-java-driver.