[ 
https://issues.apache.org/jira/browse/TINKERPOP-1230?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15215316#comment-15215316
 ] 

Michael Pollmeier edited comment on TINKERPOP-1230 at 3/29/16 2:50 AM:
-----------------------------------------------------------------------

I am not saying this will work for all cases, but hoping that we can make it 
work for simple lambdas (which by definition does not close over variables 
outside of it's parameter list). Can you describe what exactly the roadblock 
is? That way other people can jump in and help. 

I've created a simple java project that demonstrates that it's possible to 
serialise a lambda and execute it on a different jvm. The serialised lambda is 
actually checked into git, and you should be able to run it on your machine: 

```
git clone https://github.com/mpollmeier/jvm-lambda-serialisation.git
mvn clean compile exec:java -Dexec.mainClass="LambdaDeserialisation"
```

https://github.com/mpollmeier/jvm-lambda-serialisation


was (Author: mpollmeier):
I am not saying this will work for all cases, but hoping that we can make it 
work for simple lambdas (which by definition does not close over variables 
outside of it's parameter list). Can you describe what exactly the roadblock 
is? That way other people can jump in and help. 

I've created a simple java project that demonstrates that it's possible to 
serialise a lambda and execute it on a different jvm. The serialised lambda is 
actually checked into git, and you should be able to run it on your machine: 

git clone https://github.com/mpollmeier/jvm-lambda-serialisation.git
mvn clean compile exec:java -Dexec.mainClass="LambdaDeserialisation"

https://github.com/mpollmeier/jvm-lambda-serialisation

> Serialising lambdas for RemoteGraph
> -----------------------------------
>
>                 Key: TINKERPOP-1230
>                 URL: https://issues.apache.org/jira/browse/TINKERPOP-1230
>             Project: TinkerPop
>          Issue Type: Improvement
>          Components: driver, server
>    Affects Versions: 3.1.1-incubating
>            Reporter: Michael Pollmeier
>            Priority: Minor
>
> I just made an attempt to serialise lambdas and send them via the 
> RemoteGraph. I didn't quite get there, but wanted to share my findings: 
> * it's possible to serialise lambdas on the jvm by just extending 
> `Serializable`:
> http://stackoverflow.com/questions/22807912/how-to-serialize-a-lambda/22808112#22808112
> * sending a normal predicate doesn't work (this is a Scala REPL but it should 
> be pretty easy to convert this to java/groovy)
>   val g = RemoteGraph.open("conf/remote-graph.properties").traversal()
>   val pred1 = new java.util.function.Predicate[Traverser[Vertex]] { def 
> test(v: Traverser[Vertex]) = true }
>   g.V().filter(pred1).toList 
> // java.lang.RuntimeException: java.io.NotSerializableException: $anon$1
>                              // on server: nothing
>                              
> * simply adding Serializable let's us send it over the wire, but the server 
> doesn't deserialise it
>   val pred2 = new java.util.function.Predicate[Traverser[Vertex]] with 
> Serializable { def test(v: Traverser[Vertex]) = true }
>   g.V().filter(pred2).toList 
>   // on server: [WARN] OpExecutorHandler - Could not deserialize the 
> Traversal instance
>         org.apache.tinkerpop.gremlin.server.op.OpProcessorException: Could 
> not deserialize the Traversal instance
>         at 
> org.apache.tinkerpop.gremlin.server.op.traversal.TraversalOpProcessor.iterateOp(TraversalOpProcessor.java:135)
>         at 
> org.apache.tinkerpop.gremlin.server.handler.OpExecutorHandler.channelRead0(OpExecutorHandler.java:68)
>   // on client: 
> org.apache.tinkerpop.gremlin.driver.exception.ResponseException: $anon$1 



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to