inthefabric / RexConnect

Connect to Rexster/RexPro via TCP connection.
www.inthefabric.com
Other
10 stars 0 forks source link

Titan "Group" variable is not retained within the session #16

Closed zachkinstner closed 11 years ago

zachkinstner commented 11 years ago

For a request like this:

{

    "reqId": "e2150adb-52dd-483b-aa91-eb0a9b2367e5",
    "cmdList": [
        {
            "cmd": "session",
            "args": [
                "start"
            ]
        },
        {
            "cmd": "query",
            "args": [
                "com.thinkaurelius.titan.core.TypeGroup Group_N = com.thinkaurelius.titan.core.TypeGroup.of(2,'N');",
                "{}"
            ]
        },
        {
            "cmd": "query",
            "args": [
                "com.thinkaurelius.titan.core.TitanKey N_FT = g.makeType().dataType(Integer.class).name('N_FT').unique(OUT).group(Group_N).indexed(Vertex.class).makePropertyKey();",
                "{}"
            ]
        }
}

I get the following error:

{

    "reqId": "e2150adb-52dd-483b-aa91-eb0a9b2367e5",
    "timer": 1500,
    "cmdList": [
        {
            "timer": 135,
            "results": [
                "ef31fec7-19ea-4518-a1f7-0e929e8bf2ab"
            ]
        },
        {
            "timer": 506,
            "results": [
                "G2"
            ]
        },
        {
            "timer": 833,
            "err": "com.tinkerpop.rexster.client.RexProException> An error occurred while processing the script for language [groovy]. All transactions across all graphs in the session have been concluded with failure: java.util.concurrent.ExecutionException: javax.script.ScriptException: javax.script.ScriptException: groovy.lang.MissingPropertyException: No such property: Group_N for class: Script5"
        }
}

The error ("No such property: Group_N for class") shows that the Group_N group variable is not being retained within the session.

zachkinstner commented 11 years ago

Giving the variable type causes this, see int y below. @spmallette, is this a known issue with RexsterClient, and/or expected behavior?

# RexConnect> session
#   ...action (0; string): start

{"timer":626,"results":["e4401167-dd09-483e-a01d-48830c44c730"]}

# RexConnect> query
#   ...script (0; string): x = 5 
#   ...params (1; string; opt): 

{"timer":84,"results":[5]}

# RexConnect> query
#   ...script (0; string): x
#   ...params (1; string; opt): 

{"timer":25,"results":[5]}

# RexConnect> query
#   ...script (0; string): int y = 123 //note the "int" type
#   ...params (1; string; opt): 

{"timer":91,"results":[123]}

# RexConnect> query
#   ...script (0; string): y
#   ...params (1; string; opt): 

{"timer":57,"err":"com.tinkerpop.rexster.client.RexProException> An error occurred while processing the script for language [groovy]. All transactions across all graphs in the session have been concluded with failure: java.util.concurrent.ExecutionException: javax.script.ScriptException: javax.script.ScriptException: groovy.lang.MissingPropertyException: No such property: y for class: Script6"}

# RexConnect> session
#   ...action (0; string): close

{"timer":6}
zachkinstner commented 11 years ago

Removing the variable types from the original Server-mode request fixed the issue.

spmallette commented 11 years ago

I think that's expected behavior and has nothing to do with RexsterClient. don't think you can declare the variable type in groovy script engine. try something like that in gremlin repl and y will not be found:

gremlin> int y = 0
==>0
gremlin> y
No such property: y for class: groovysh_evaluate
Display stack trace? [yN] y
groovy.lang.MissingPropertyException: No such property: y for class: groovysh_evaluate
...
zachkinstner commented 11 years ago

Thanks -- good to know. And good idea about checking the Gremlin REPL, at least when the scenario is simple enough.