Re: [Neo4j] Gremlin from Java Error

2011-02-23 Thread Alfredas Chmieliauskas
On Tue, Feb 22, 2011 at 4:26 PM, Marko Rodriguez  wrote:
> Hey,
>
>> Thanks a lot. Updated to 0.8-SNAPSHOT. Strangely maven did not resolve
>> groovy dependence automatically. Had to add it by hand.
>
> Huh? Gremlin 0.8-SNAPSHOT uses Groovy 1.7.8 (which was released maybe 1 week 
> ago). Gremlin 0.7 was using Groovy 1.7.5. Perhaps something about that was 
> making it burp? What do you mean "add it by hand?"

I had to add a dependency to groovy in my pom file, i did not need
that with 0.7 (it was inherited?).

>
>> ScriptEngine approach works fine, Gremlin.compile(expr) does not?
>
> Were you compiling a Pipe or a Gremlin statement? Compile can only be used to 
> create a Pipe:
>        public static Pipe compile(final String gremlin);
> See the first section of: 
> https://github.com/tinkerpop/gremlin/wiki/Using-Gremlin-through-Java
>
> If you want to do an arbitrary Gremlin statement, then you use 
> GremlinScriptEngine.eval();
>
> ?? Or, is it because you haven't linked Groovy into your project. Realize 
> that Gremlin class is Gremlin.groovy, not Gremlin.java. Thus, you need to 
> make sure you have gmaven-pluggin support in your pom.xml. See the second 
> section of:
>        https://github.com/tinkerpop/gremlin/wiki/Using-Gremlin-through-Groovy
>
I have that. Read the docs.

>> I understand that it could be faster&cleaner to use groovy, but I need
>> to be able to pass string queries and get results back.
>> In my use-case this is the definite use of gremlin - arbitrary string
>> queries.
>
> Gotcha.
>
>> For "static" business logic I can use Pipes - I'm not
>> bothered by the wordy expressions.
>
>
> Cool. You can get around that by using Gremlin.compile() :P. In that way, you 
> can compile a Gremlin statement to get the raw Pipes.

I like that idea. But still could not get it to work. Will try to
reproduce and send the trace.


Thanks,

A
>
> Enjoy,
> Marko.
>
> http://markorodriguez.com
>
>
>
> ___
> Neo4j mailing list
> User@lists.neo4j.org
> https://lists.neo4j.org/mailman/listinfo/user
>
___
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user


Re: [Neo4j] Gremlin from Java Error

2011-02-22 Thread Marko Rodriguez
Hey,

> Thanks a lot. Updated to 0.8-SNAPSHOT. Strangely maven did not resolve
> groovy dependence automatically. Had to add it by hand.

Huh? Gremlin 0.8-SNAPSHOT uses Groovy 1.7.8 (which was released maybe 1 week 
ago). Gremlin 0.7 was using Groovy 1.7.5. Perhaps something about that was 
making it burp? What do you mean "add it by hand?"

> ScriptEngine approach works fine, Gremlin.compile(expr) does not?

Were you compiling a Pipe or a Gremlin statement? Compile can only be used to 
create a Pipe:
public static Pipe compile(final String gremlin);
See the first section of: 
https://github.com/tinkerpop/gremlin/wiki/Using-Gremlin-through-Java

If you want to do an arbitrary Gremlin statement, then you use 
GremlinScriptEngine.eval();

?? Or, is it because you haven't linked Groovy into your project. Realize that 
Gremlin class is Gremlin.groovy, not Gremlin.java. Thus, you need to make sure 
you have gmaven-pluggin support in your pom.xml. See the second section of:
https://github.com/tinkerpop/gremlin/wiki/Using-Gremlin-through-Groovy  

> I understand that it could be faster&cleaner to use groovy, but I need
> to be able to pass string queries and get results back.
> In my use-case this is the definite use of gremlin - arbitrary string
> queries.

Gotcha.

> For "static" business logic I can use Pipes - I'm not
> bothered by the wordy expressions.


Cool. You can get around that by using Gremlin.compile() :P. In that way, you 
can compile a Gremlin statement to get the raw Pipes.

Enjoy,
Marko.

http://markorodriguez.com



___
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user


Re: [Neo4j] Gremlin from Java Error

2011-02-21 Thread Alfredas Chmieliauskas
Thanks a lot. Updated to 0.8-SNAPSHOT. Strangely maven did not resolve
groovy dependence automatically. Had to add it by hand.

ScriptEngine approach works fine, Gremlin.compile(expr) does not?

I understand that it could be faster&cleaner to use groovy, but I need
to be able to pass string queries and get results back.
In my use-case this is the definite use of gremlin - arbitrary string
queries. For "static" business logic I can use Pipes - I'm not
bothered by the wordy expressions.

Alfredas


On Mon, Feb 21, 2011 at 4:23 PM, Marko Rodriguez  wrote:
> Hi,
>
> outE(String) is in Gremlin 0.8-SNASPHOT, not Gremlin 0.7.
>
> Note at the bottom of the main Wiki page: "Gremlin documentation is up to 
> date with the current Gremlin codebase, not with the latest Gremlin release."
>
> I do this so its easier for me to maintain documentation. The documentation 
> for Gremlin 0.7 is in the doc/wiki directory of the distribution.
>
> If you still want to use Gremlin 0.7, do this:
>
> engine.eval("v.outE[[label='KNOWS']].inV >> results");
>
> Finally, I would recommend using Groovy in your codebase instead of JSR 223 
> ScriptEngine. Groovy and Java work seamlessly together and its so much 
> handier/cleaner/faster than through JSR 223. See:
>        https://github.com/tinkerpop/gremlin/wiki/Using-Gremlin-through-Groovy
>
> Hope that helps,
> Marko.
>
> http://markorodriguez.com
>
>
> On Feb 21, 2011, at 9:15 AM, Alfredas Chmieliauskas wrote:
>
>> Dear all,
>>
>> I have the following code:
>>
>> ScriptEngine engine = new GremlinScriptEngineFactory().getScriptEngine();
>> List results = new ArrayList();
>> engine.getBindings(ScriptContext.ENGINE_SCOPE).put("g", getGraph());
>> engine.getBindings(ScriptContext.ENGINE_SCOPE).put("v", 
>> getVertex(startNode));
>> engine.getBindings(ScriptContext.ENGINE_SCOPE).put("results", results);
>> try {
>>    engine.eval(v.outE('KNOWS').inV >> results");
>> } catch (ScriptException e) {
>>    logger.error(e.getMessage(), e);
>> }
>>
>> produces the following error:
>>
>>
>> ERROR javax.script.ScriptException:
>> groovy.lang.MissingMethodException: No signature of method:
>> com.tinkerpop.blueprints.pgm.impls.neo4j.Neo4jVertex.outE() is
>> applicable for argument types: (java.lang.String) values: [KNOWS]
>> Possible solutions: outE(groovy.lang.Closure), dump(),
>> use([Ljava.lang.Object;), getAt(java.lang.String),
>> getAt(java.lang.String), with(groovy.lang.Closure)
>> javax.script.ScriptException: javax.script.ScriptException:
>> groovy.lang.MissingMethodException: No signature of method:
>> com.tinkerpop.blueprints.pgm.impls.neo4j.Neo4jVertex.outE() is
>> applicable for argument types: (java.lang.String) values: [KNOWS]
>> Possible solutions: outE(groovy.lang.Closure), dump(),
>> use([Ljava.lang.Object;), getAt(java.lang.String),
>> getAt(java.lang.String), with(groovy.lang.Closure)
>>       at 
>> org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:117)
>>       at 
>> com.tinkerpop.gremlin.jsr223.GremlinScriptEngine.eval(GremlinScriptEngine.java:36)
>>       at 
>> javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:247)
>>       at 
>> com.tinkerpop.gremlin.jsr223.GremlinScriptEngine.eval(GremlinScriptEngine.java:32)
>>       at 
>> alfredas.springdatagraph.template.domain.AbstractRepository.findAllByGremlin2(AbstractRepository.java:94)
>>       at alfredas.springdatagraph.template.App.(App.java:84)
>>       at alfredas.springdatagraph.template.App.main(App.java:93)
>> Caused by: javax.script.ScriptException:
>> groovy.lang.MissingMethodException: No signature of method:
>> com.tinkerpop.blueprints.pgm.impls.neo4j.Neo4jVertex.outE() is
>> applicable for argument types: (java.lang.String) values: [KNOWS]
>> Possible solutions: outE(groovy.lang.Closure), dump(),
>> use([Ljava.lang.Object;), getAt(java.lang.String),
>> getAt(java.lang.String), with(groovy.lang.Closure)
>>       at 
>> org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:318)
>>       at 
>> org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:111)
>>       ... 6 more
>> Caused by: groovy.lang.MissingMethodException: No signature of method:
>> com.tinkerpop.blueprints.pgm.impls.neo4j.Neo4jVertex.outE() is
>> applicable for argument types: (java.lang.String) values: [KNOWS]
>> Possible solutions: outE(groovy.lang.Closure), dump(),
>> use([Ljava.lang.Object;), getAt(java.lang.String),
>> getAt(java.lang.String), with(groovy.lang.Closure)
>>       at 
>> org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:54)
>>       at 
>> org.codehaus.groovy.runtime.callsite.PojoMetaClassSite.call(PojoMetaClassSite.java:46)
>>       at 
>> org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:40)
>>       at 
>> org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
>>       at 
>> org.codehaus.groovy.runtime.callsite.AbstractCallSit

Re: [Neo4j] Gremlin from Java Error

2011-02-21 Thread Marko Rodriguez
Hi,

outE(String) is in Gremlin 0.8-SNASPHOT, not Gremlin 0.7.

Note at the bottom of the main Wiki page: "Gremlin documentation is up to date 
with the current Gremlin codebase, not with the latest Gremlin release."

I do this so its easier for me to maintain documentation. The documentation for 
Gremlin 0.7 is in the doc/wiki directory of the distribution.

If you still want to use Gremlin 0.7, do this:

engine.eval("v.outE[[label='KNOWS']].inV >> results");

Finally, I would recommend using Groovy in your codebase instead of JSR 223 
ScriptEngine. Groovy and Java work seamlessly together and its so much 
handier/cleaner/faster than through JSR 223. See:
https://github.com/tinkerpop/gremlin/wiki/Using-Gremlin-through-Groovy

Hope that helps,
Marko.

http://markorodriguez.com


On Feb 21, 2011, at 9:15 AM, Alfredas Chmieliauskas wrote:

> Dear all,
> 
> I have the following code:
> 
> ScriptEngine engine = new GremlinScriptEngineFactory().getScriptEngine();
> List results = new ArrayList();
> engine.getBindings(ScriptContext.ENGINE_SCOPE).put("g", getGraph());
> engine.getBindings(ScriptContext.ENGINE_SCOPE).put("v", getVertex(startNode));
> engine.getBindings(ScriptContext.ENGINE_SCOPE).put("results", results);
> try {
>engine.eval(v.outE('KNOWS').inV >> results");
> } catch (ScriptException e) {
>logger.error(e.getMessage(), e);
> }
> 
> produces the following error:
> 
> 
> ERROR javax.script.ScriptException:
> groovy.lang.MissingMethodException: No signature of method:
> com.tinkerpop.blueprints.pgm.impls.neo4j.Neo4jVertex.outE() is
> applicable for argument types: (java.lang.String) values: [KNOWS]
> Possible solutions: outE(groovy.lang.Closure), dump(),
> use([Ljava.lang.Object;), getAt(java.lang.String),
> getAt(java.lang.String), with(groovy.lang.Closure)
> javax.script.ScriptException: javax.script.ScriptException:
> groovy.lang.MissingMethodException: No signature of method:
> com.tinkerpop.blueprints.pgm.impls.neo4j.Neo4jVertex.outE() is
> applicable for argument types: (java.lang.String) values: [KNOWS]
> Possible solutions: outE(groovy.lang.Closure), dump(),
> use([Ljava.lang.Object;), getAt(java.lang.String),
> getAt(java.lang.String), with(groovy.lang.Closure)
>   at 
> org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:117)
>   at 
> com.tinkerpop.gremlin.jsr223.GremlinScriptEngine.eval(GremlinScriptEngine.java:36)
>   at javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:247)
>   at 
> com.tinkerpop.gremlin.jsr223.GremlinScriptEngine.eval(GremlinScriptEngine.java:32)
>   at 
> alfredas.springdatagraph.template.domain.AbstractRepository.findAllByGremlin2(AbstractRepository.java:94)
>   at alfredas.springdatagraph.template.App.(App.java:84)
>   at alfredas.springdatagraph.template.App.main(App.java:93)
> Caused by: javax.script.ScriptException:
> groovy.lang.MissingMethodException: No signature of method:
> com.tinkerpop.blueprints.pgm.impls.neo4j.Neo4jVertex.outE() is
> applicable for argument types: (java.lang.String) values: [KNOWS]
> Possible solutions: outE(groovy.lang.Closure), dump(),
> use([Ljava.lang.Object;), getAt(java.lang.String),
> getAt(java.lang.String), with(groovy.lang.Closure)
>   at 
> org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:318)
>   at 
> org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:111)
>   ... 6 more
> Caused by: groovy.lang.MissingMethodException: No signature of method:
> com.tinkerpop.blueprints.pgm.impls.neo4j.Neo4jVertex.outE() is
> applicable for argument types: (java.lang.String) values: [KNOWS]
> Possible solutions: outE(groovy.lang.Closure), dump(),
> use([Ljava.lang.Object;), getAt(java.lang.String),
> getAt(java.lang.String), with(groovy.lang.Closure)
>   at 
> org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:54)
>   at 
> org.codehaus.groovy.runtime.callsite.PojoMetaClassSite.call(PojoMetaClassSite.java:46)
>   at 
> org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:40)
>   at 
> org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
>   at 
> org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:124)
>   at Script1.run(Script1.groovy:43)
>   at 
> org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:315)
>   ... 7 more
> 
> 
> And the alternative method:
> 
> Gremlin.compile("outE('KNOWS').inV)";
> 
> gives:
> 
> Exception in thread "main" groovy.lang.MissingMethodException: No
> signature of method: Script1.outE() is applicable for argument types:
> (java.lang.String) values: [KNOWS]
> Possible solutions: run(), run(), dump(), use([Ljava.lang.Object;),
> putAt(java.lang.String, java.lang.Object), with(groovy.lang.Closure)
>   at 
> org.codehaus.groovy.runtime.ScriptBytecodeAdapter.un