[jira] [Commented] (TINKERPOP-1632) Create a set of default functions

2017-10-05 Thread ASF GitHub Bot (JIRA)

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

ASF GitHub Bot commented on TINKERPOP-1632:
---

Github user twilmes commented on the issue:

https://github.com/apache/tinkerpop/pull/729
  
This is going to come in super handy.

A hearty VOTE: +1


> Create a set of default functions
> -
>
> Key: TINKERPOP-1632
> URL: https://issues.apache.org/jira/browse/TINKERPOP-1632
> Project: TinkerPop
>  Issue Type: Improvement
>  Components: process
>Affects Versions: 3.3.0
>Reporter: Daniel Kuppitz
>
> We already have a a set of default BiFunctions / operators, that are not 
> treated as lambdas. We should also have a bunch of simple functions, that can 
> then be used in {{map()}} or {{sack()}} and that can be serialized as 
> bytecode. For example:
> {noformat}
> ...map(sqrt)
> ...map(log)
> ...sack(sigmoid) // compute sigmoid of the current sack and update the 
> sack
> ...sack(cos).by("x") // compute the cosine of the current element's "x" and 
> assign / overwrite the current sack value
> {noformat}



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[GitHub] tinkerpop issue #729: TINKERPOP-1632: Create a set of default functions

2017-10-05 Thread twilmes
Github user twilmes commented on the issue:

https://github.com/apache/tinkerpop/pull/729
  
This is going to come in super handy.

A hearty VOTE: +1


---


[GitHub] tinkerpop issue #728: Do not strong-freeze dependencies

2017-10-05 Thread davebshow
Github user davebshow commented on the issue:

https://github.com/apache/tinkerpop/pull/728
  
VOTE +1


---


[jira] [Commented] (TINKERPOP-1761) GremlinExecutor: Timeout future not cancelled on successful script evaluation

2017-10-05 Thread ASF GitHub Bot (JIRA)

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

ASF GitHub Bot commented on TINKERPOP-1761:
---

Github user spmallette commented on the issue:

https://github.com/apache/tinkerpop/pull/709
  
All tests pass with `docker/build.sh -t -n -i`

VOTE +1


> GremlinExecutor: Timeout future not cancelled on successful script evaluation
> -
>
> Key: TINKERPOP-1761
> URL: https://issues.apache.org/jira/browse/TINKERPOP-1761
> Project: TinkerPop
>  Issue Type: Bug
>  Components: groovy
>Affects Versions: 3.2.6
>Reporter: Konstantin Müller
>
> This bug seems to be introduced by TINKERPOP-1714. The timeout future in 
> GremlinExecutor.eval() is not cancelled when the evaluation future is 
> completed successfully before the timeout (lines 304ff). This was done 
> correctly before the changes introduced by TINKERPOP-1714. Code to reproduce:
> {code:java}
> try (GremlinExecutor executor = 
> GremlinExecutor.build().scriptEvaluationTimeout(15_000).create()) {
>   executor.eval("1+1").get();
> } catch (Exception e) {
>   // NOOP
> }
> {code}
> When the code leaves the try-block it calls GremlinExecutor.close() which 
> will clean up executorService and scheduledExecutorService, but because the 
> timeout future is not cancelled this will hang until the future is finished 
> (here 15s).
> Workaround: Provide an own ExecutorService when constructing a 
> GremlinExecutor instance and cancel all tasks when the script evaluation is 
> finished successfully.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[GitHub] tinkerpop issue #728: Do not strong-freeze dependencies

2017-10-05 Thread spmallette
Github user spmallette commented on the issue:

https://github.com/apache/tinkerpop/pull/728
  
All tests pass with `docker/build.sh -t -n -i`

VOTE +1


---


[GitHub] tinkerpop issue #709: TINKERPOP-1761: Cancel script evaluation timeout

2017-10-05 Thread spmallette
Github user spmallette commented on the issue:

https://github.com/apache/tinkerpop/pull/709
  
All tests pass with `docker/build.sh -t -n -i`

VOTE +1


---


[jira] [Commented] (TINKERPOP-1632) Create a set of default functions

2017-10-05 Thread ASF GitHub Bot (JIRA)

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

ASF GitHub Bot commented on TINKERPOP-1632:
---

Github user twilmes commented on a diff in the pull request:

https://github.com/apache/tinkerpop/pull/729#discussion_r142936026
  
--- Diff: 
gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/MathStep.java
 ---
@@ -0,0 +1,171 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+package org.apache.tinkerpop.gremlin.process.traversal.step.map;
+
+import net.objecthunter.exp4j.Expression;
+import net.objecthunter.exp4j.ExpressionBuilder;
+import org.apache.tinkerpop.gremlin.process.traversal.Pop;
+import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
+import org.apache.tinkerpop.gremlin.process.traversal.Traverser;
+import org.apache.tinkerpop.gremlin.process.traversal.step.ByModulating;
+import org.apache.tinkerpop.gremlin.process.traversal.step.PathProcessor;
+import org.apache.tinkerpop.gremlin.process.traversal.step.Scoping;
+import org.apache.tinkerpop.gremlin.process.traversal.step.TraversalParent;
+import 
org.apache.tinkerpop.gremlin.process.traversal.traverser.TraverserRequirement;
+import org.apache.tinkerpop.gremlin.process.traversal.util.TraversalRing;
+import org.apache.tinkerpop.gremlin.process.traversal.util.TraversalUtil;
+import org.apache.tinkerpop.gremlin.structure.util.StringFactory;
+
+import java.util.HashSet;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+public final class MathStep extends MapStep implements 
ByModulating, TraversalParent, Scoping, PathProcessor {
+
+private static final String CURRENT = "_";
+private final String equation;
+private final Set variables;
+private TraversalRing traversalRing = new 
TraversalRing<>();
+private Set keepLabels;
+
+public MathStep(final Traversal.Admin traversal, final String 
equation) {
+super(traversal);
+this.equation = equation;
+this.variables = MathStep.getVariables(this.equation);
+
+}
+
+@Override
+protected Traverser.Admin processNextStart() {
+return 
PathProcessor.processTraverserPathLabels(super.processNextStart(), 
this.keepLabels);
+}
+
+@Override
+protected Double map(final Traverser.Admin traverser) {
+final Expression expression = new ExpressionBuilder(this.equation)
--- End diff --

Yes, good point. I was trying to think of a way to do it with a 
`ThreadLocal` but can't think of one. I think I found a way around the 
threading issue that at least circumvents the repeated expression parsing. We 
can't get away from the extra object creation but the `Expression` constructor 
can take an `Expression` as input. That creates a copy with the tokens already 
pulled out so no parsing is needed. A golden copy of the expression could be 
created in the constructor and then used to seed the method-level expressions.

I ran this quick little test against grateful-dead.kryo. It's a nonsensical 
query, but I wanted to see how much of a difference parsing made.
`clockWithResult(2){g.V().hasLabel("song").math("_ * 100 + 200 / 
300").by('performances').limit(1000).toList()}`

original: 0.87 ms
`new Expression(expression)`: 0.38 ms


> Create a set of default functions
> -
>
> Key: TINKERPOP-1632
> URL: https://issues.apache.org/jira/browse/TINKERPOP-1632
> Project: TinkerPop
>  Issue Type: Improvement
>  Components: process
>Affects Versions: 3.3.0
>Reporter: Daniel Kuppitz
>
> W

[GitHub] tinkerpop pull request #729: TINKERPOP-1632: Create a set of default functio...

2017-10-05 Thread twilmes
Github user twilmes commented on a diff in the pull request:

https://github.com/apache/tinkerpop/pull/729#discussion_r142936026
  
--- Diff: 
gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/MathStep.java
 ---
@@ -0,0 +1,171 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+package org.apache.tinkerpop.gremlin.process.traversal.step.map;
+
+import net.objecthunter.exp4j.Expression;
+import net.objecthunter.exp4j.ExpressionBuilder;
+import org.apache.tinkerpop.gremlin.process.traversal.Pop;
+import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
+import org.apache.tinkerpop.gremlin.process.traversal.Traverser;
+import org.apache.tinkerpop.gremlin.process.traversal.step.ByModulating;
+import org.apache.tinkerpop.gremlin.process.traversal.step.PathProcessor;
+import org.apache.tinkerpop.gremlin.process.traversal.step.Scoping;
+import org.apache.tinkerpop.gremlin.process.traversal.step.TraversalParent;
+import 
org.apache.tinkerpop.gremlin.process.traversal.traverser.TraverserRequirement;
+import org.apache.tinkerpop.gremlin.process.traversal.util.TraversalRing;
+import org.apache.tinkerpop.gremlin.process.traversal.util.TraversalUtil;
+import org.apache.tinkerpop.gremlin.structure.util.StringFactory;
+
+import java.util.HashSet;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+public final class MathStep extends MapStep implements 
ByModulating, TraversalParent, Scoping, PathProcessor {
+
+private static final String CURRENT = "_";
+private final String equation;
+private final Set variables;
+private TraversalRing traversalRing = new 
TraversalRing<>();
+private Set keepLabels;
+
+public MathStep(final Traversal.Admin traversal, final String 
equation) {
+super(traversal);
+this.equation = equation;
+this.variables = MathStep.getVariables(this.equation);
+
+}
+
+@Override
+protected Traverser.Admin processNextStart() {
+return 
PathProcessor.processTraverserPathLabels(super.processNextStart(), 
this.keepLabels);
+}
+
+@Override
+protected Double map(final Traverser.Admin traverser) {
+final Expression expression = new ExpressionBuilder(this.equation)
--- End diff --

Yes, good point. I was trying to think of a way to do it with a 
`ThreadLocal` but can't think of one. I think I found a way around the 
threading issue that at least circumvents the repeated expression parsing. We 
can't get away from the extra object creation but the `Expression` constructor 
can take an `Expression` as input. That creates a copy with the tokens already 
pulled out so no parsing is needed. A golden copy of the expression could be 
created in the constructor and then used to seed the method-level expressions.

I ran this quick little test against grateful-dead.kryo. It's a nonsensical 
query, but I wanted to see how much of a difference parsing made.
`clockWithResult(2){g.V().hasLabel("song").math("_ * 100 + 200 / 
300").by('performances').limit(1000).toList()}`

original: 0.87 ms
`new Expression(expression)`: 0.38 ms


---