GitHub user okram opened a pull request:

    https://github.com/apache/tinkerpop/pull/447

    TINKERPOP-1455: Provide String-based withStrategy()/withoutStrategy() for 
language variant usage

    https://issues.apache.org/jira/browse/TINKERPOP-1455
    
    Added TraversalSource.withStrategy(String, Object...) and 
TraversalSource.withoutStrategy(String). This allows Gremlin language variants 
(e.g. Gremlin-Python) to add and remove strategies from a traversal source. 
Prior to this moment, strategy addition/removal was via strategy instances 
(Java objects) and classes (Class objects). That is not language variants 
friendly.
    
    This branch is backwards compatible. If a `TraversalStrategy` does not have 
a builder and exposes a static `instance()`-method, then 
`g.withStrategy('com.blah.MyStrategy')` will work as expected. If a 
`TraversalStrategy` does have a builder (that is, can be configured), then it 
should expose a static `create(Configuration)`-method. Note Gremlin language 
variants could not use `withStrategies()` prior to this and thus, this addition 
is backwards compatible. Finally, `TraversalSource.withComputer(Object...)` was 
added as well for the same reasons.
    
    ```
    >>> g = 
g.withStrategy('org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.SubgraphStrategy','vertices',hasLabel('person'),'edges',has('weight',gt(0.5)))
    >>> g.V().name.toList()
    [u'marko', u'vadas', u'josh', u'peter']
    ```
    
    The CHANGELOG, gremlin-variants.asciidoc, and upgrade doc have all been 
updated accordingly.
    
    VOTE +1

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/apache/tinkerpop TINKERPOP-1455

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/tinkerpop/pull/447.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #447
    
----
commit e6e59e417f119c1b71a43141fce04cb212bc0a58
Author: Marko A. Rodriguez <okramma...@gmail.com>
Date:   2016-10-04T14:37:07Z

    first push. We now have TraversalSource.withStrategy(String, Object...) and 
TraversalSource.withoutStrategy(String). Added a test case to Gremlin-Python 
that uses SubgraphStrategy and it works :).

commit 95557bf3aac279282e3f3779d68ce195bd4ca058
Author: Marko A. Rodriguez <okramma...@gmail.com>
Date:   2016-10-04T16:26:12Z

    added static create(Configuration) methods to all Builder-based strategies 
except EventStrategy as that requires Java objects :(. Deprecated 
PartitionStrategy.Builder.addReadParition() in favor of 
readParitions(String...). Computer now has a Configuration-based constructor 
and corresponding withComputer(Object...) arguments.

commit 20dec2076b79441c7dcf06827014ace72fcaea6c
Author: Marko A. Rodriguez <okramma...@gmail.com>
Date:   2016-10-04T18:15:31Z

    updated gremlin-variants.asciidoc with new withStrategy()/withoutStrategy() 
method discussion. Built docs. Success.

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to