Error getting .next() values from the iterator ExecutionResult columns

74 views
Skip to first unread message

MPM

unread,
Jan 27, 2012, 2:50:54 PM1/27/12
to Neo4j
This error appears with the new version Neo4j 1.6. I haven't this
error with the version Neo4j 1.6.M01.

After generating the new database (with the new libraries, ...) I
execute this Cypher query from Web Admin Console:

START j=node:JobTitles(name="COMERCIAL") MATCH (j)<-[:WORKS_AS]-(x)-
[:EXPERIENCE_BELONGS_TO]->(u) WHERE x.lastExperience = true RETURN
u.disposedToChange, count(*) ORDER BY u.disposedToChange ASC

==> +-------------------------------+
==> | u.disposedToChange | count(*) |
==> +-------------------------------+
==> | 0 | 47 |
==> | 1 | 903 |
==> | 2 | 173 |
==> | 3 | 36 |
==> | 4 | 1149 |
==> +-------------------------------+
==> 5 rows, 239 ms

But if I execute this code in Java with the same query... I get this
surprising result:

====
ExecutionEngine engine = new ExecutionEngine(this.graphDb);
ExecutionResult result = engine.execute(query);

Iterator<Node> item = result.columnAs(itemColumnName);
Iterator<Node> value = result.columnAs(valueColumnName);

while(item.hasNext() ){
try {
System.out.println(item.next() + " | " + value.next());
}
catch(Exception e){
System.out.println("Error with query: " + query);
}
}
====

RESUT:

0 | 903
2 | 36



Does something changed with the new version? It seems that with
"item.next()" produces that the variable "value" takes the next
value...

Any idea how to solve that?

MPM

unread,
Jan 27, 2012, 6:54:29 PM1/27/12
to Neo4j
Changing a bit the code and using the Iterator <Map<String,Object>> it
runs as I expected.

===

ExecutionEngine engine = new ExecutionEngine(this.graphDb);
ExecutionResult result = engine.execute(query);

Iterator <Map<String,Object>> it = result.iterator();

while (it.hasNext()){
Map <String,Object> map = it.next();
System.out.println(map.get("Users").toString() + " | " +
map.get("Count").toString());
}

===

0 | 47
1 | 903
2 | 173
3 | 36
4 | 1149


The difference here is that I only have one iterator and I use the map
to access to the columns values. That make thing that maybe there is a
bug...

Peter Neubauer

unread,
Jan 28, 2012, 4:33:47 AM1/28/12
to ne...@googlegroups.com
Thanks Marc for letting us know. Could you please raise an issue on
the non-working case to track it?

Cheers,

/peter neubauer

G:  neubauer.peter
S:  peter.neubauer
P:  +46 704 106975
L:   http://www.linkedin.com/in/neubauer
T:   @peterneubauer

Neo4j 1.6 released                 - dzone.com/6S4K
The Neo4j Heroku Challenge   - http://neo4j-challenge.herokuapp.com/

Marc Pou

unread,
Jan 31, 2012, 4:34:39 PM1/31/12
to ne...@googlegroups.com
Yes, of course. 

Where can I raise the issue?

--
Marc Pou
marc...@gmail.com

Si el teu objectiu és la Lluna, no et quedis mirant el dit que l'assenyala!

Peter Neubauer

unread,
Jan 31, 2012, 4:37:04 PM1/31/12
to ne...@googlegroups.com
https://github.com/neo4j/community/issues

Cheers,

/peter neubauer

G:  neubauer.peter
S:  peter.neubauer
P:  +46 704 106975
L:   http://www.linkedin.com/in/neubauer
T:   @peterneubauer

Neo4j 1.6 released                 - dzone.com/6S4K
The Neo4j Heroku Challenge   - http://neo4j-challenge.herokuapp.com/

Reply all
Reply to author
Forward
0 new messages