added math()-step to the reference docs and updated CHANGELOG and upgrade docs.
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/7217823c Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/7217823c Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/7217823c Branch: refs/heads/TINKERPOP-1799 Commit: 7217823c3ea73f2d32ffa975e417dcd49d40cbdd Parents: dfddcca Author: Marko A. Rodriguez <[email protected]> Authored: Wed Oct 4 11:30:55 2017 -0600 Committer: Marko A. Rodriguez <[email protected]> Committed: Wed Oct 4 11:30:55 2017 -0600 ---------------------------------------------------------------------- CHANGELOG.asciidoc | 1 + docs/src/reference/the-traversal.asciidoc | 44 ++++++++++++++++++++++++++ docs/src/upgrade/release-3.3.x.asciidoc | 36 +++++++++++++++++++++ 3 files changed, 81 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/7217823c/CHANGELOG.asciidoc ---------------------------------------------------------------------- diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc index c958d1e..102586d 100644 --- a/CHANGELOG.asciidoc +++ b/CHANGELOG.asciidoc @@ -25,6 +25,7 @@ image::https://raw.githubusercontent.com/apache/tinkerpop/master/docs/static/ima This release also includes changes from <<release-3-2-7, 3.2.7>>. +* Added `math()`-step which supports scientific calculator capabilities for numbers within a traversal. * Added missing `GraphTraversalSource.addE()`-method to `GremlinDslProcessor`. * Changed `to()` and `from()` traversal-based steps to take a wildcard `?` instead of of `E`. * Added `addV(traversal)` and `addE(traversal)` so that created element labels can be determined dynamically. http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/7217823c/docs/src/reference/the-traversal.asciidoc ---------------------------------------------------------------------- diff --git a/docs/src/reference/the-traversal.asciidoc b/docs/src/reference/the-traversal.asciidoc index de99b7f..de64a6c 100644 --- a/docs/src/reference/the-traversal.asciidoc +++ b/docs/src/reference/the-traversal.asciidoc @@ -1207,6 +1207,50 @@ system to leverage the filter for index lookups. IMPORTANT: A `where()`-step is a filter and thus, variables within a `where()` clause are not globally bound to the path of the traverser in `match()`. As such, `where()`-steps in `match()` are used for filtering, not binding. +[[math-step]] +=== Math Step + +The `math()`-step (*math*) enables scientific calculator functionality within Gremlin. This step deviates from the common +function composition and nesting formalisms to provide an easy to read string-based math processor. Variables within the +equation map to scopes in Gremlin -- e.g. path labels, side-effects, or incoming map keys. This step supports +`by()`-modulation where the `by()`-modulators are applied in the order in which the variables are first referenced +within the equation. Note that the reserved variable `_` refers to the current numeric traverser object incoming to the +`math()`-step. + +[gremlin-groovy,modern] +---- +g.V().as('a').out('knows').as('b').math('a + b').by('age') +g.V().as('a').out('created').as('b'). + math('b + a'). + by(both().count().math('_ + 100')). + by('age') +g.withSideEffect('x',10).V().values('age').math('_ / x') +g.withSack(1).V(1).repeat(sack(sum).by(constant(1))).times(10).emit().sack().math('sin _') +---- + +The operators supported by the calculator include: `*`, `+`, `\`, `^`, and `%`. +Furthermore, the following built in functions are provided: + +* `abs`: absolute value +* `acos`: arc cosine +* `asin`: arc sine +* `atan`: arc tangent +* `cbrt`: cubic root +* `ceil`: nearest upper integer +* `cos`: cosine +* `cosh`: hyperbolic cosine +* `exp`: euler's number raised to the power (`e^x`) +* `floor`: nearest lower integer +* `log`: logarithmus naturalis (base e) +* `log10`: logarithm (base 10) +* `log2`: logarithm (base 2) +* `sin`: sine +* `sinh`: hyperbolic sine +* `sqrt`: square root +* `tan`: tangent +* `tanh`: hyperbolic tangent +* `signum`: signum function + [[max-step]] === Max Step http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/7217823c/docs/src/upgrade/release-3.3.x.asciidoc ---------------------------------------------------------------------- diff --git a/docs/src/upgrade/release-3.3.x.asciidoc b/docs/src/upgrade/release-3.3.x.asciidoc index f18dcd1..e36bdf1 100644 --- a/docs/src/upgrade/release-3.3.x.asciidoc +++ b/docs/src/upgrade/release-3.3.x.asciidoc @@ -29,11 +29,45 @@ Please see the link:https://github.com/apache/tinkerpop/blob/3.3.1/CHANGELOG.asc === Upgrading for Users +==== Added `math()`-step for Scientific Traversal Computing + +`GraphTraversal.math(String)` was added. This step provides scientific calculator capabilities to a Gremlin traversal. + +[source,groovy] +---- +gremlin> g.V().as('a').out('knows').as('b').math('a + b').by('age') +==>56.0 +==>61.0 +gremlin> g.V().as('a').out('created').as('b'). +......1> math('b + a'). +......2> by(both().count().math('_ + 100')). +......3> by('age') +==>132.0 +==>133.0 +==>135.0 +==>138.0 +gremlin> g.withSack(1).V(1).repeat(sack(sum).by(constant(1))).times(10).emit().sack().math('sin _') +==>0.9092974268256817 +==>0.1411200080598672 +==>-0.7568024953079282 +==>-0.9589242746631385 +==>-0.27941549819892586 +==>0.6569865987187891 +==>0.9893582466233818 +==>0.4121184852417566 +==>-0.5440211108893698 +==>-0.9999902065507035 +---- + +See: link:https://issues.apache.org/jira/browse/TINKERPOP-1632[TINKERPOP-1632] + ==== Changed Typing on `from()` and `to()` The `from()` and `to()` steps of `GraphTraversal` have a `Traversal<E,Vertex>` overload. The `E` has been changed to `?` in order to reduce `< >`-based coersion in strongly type Gremlin language variants. +See: link:https://issues.apache.org/jira/browse/TINKERPOP-1793[TINKERPOP-1793] + ==== addV(traversal) and addE(traversal) The `GraphTraversal` and `GraphTraversalSource` methods of `addV()` and `addE()` have been extended to support dynamic @@ -58,6 +92,8 @@ gremlin> g.V().has('name','stephen').outE().valueMap(true) gremlin> ---- +See: link:https://issues.apache.org/jira/browse/TINKERPOP-1793[TINKERPOP-1793] + ==== PageRankVertexProgram There were two major bugs in the way in which PageRank was being calculated in `PageRankVertexProgram`. First, teleportation
