Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TINKERPOP-2927] Relax steps extensibility strictness #2027

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ public class BranchStep<S, E, M> extends ComputerAwareStep<S, E> implements Trav
protected Map<Pick, List<Traversal.Admin<S, E>>> traversalPickOptions = new HashMap<>();
protected List<Pair<Traversal.Admin<M, ?>, Traversal.Admin<S, E>>> traversalOptions = new ArrayList<>();

private boolean first = true;
private boolean hasBarrier;
protected boolean first = true;
protected boolean hasBarrier;

public BranchStep(final Traversal.Admin traversal) {
super(traversal);
Expand Down Expand Up @@ -142,7 +142,7 @@ protected Iterator<Traverser.Admin<E>> standardAlgorithm() {
/**
* Choose the right traversal option to apply and seed those options with this traverser.
*/
private void applyCurrentTraverser(final Traverser.Admin<S> start) {
protected void applyCurrentTraverser(final Traverser.Admin<S> start) {
// first get the value of the choice based on the current traverser and use that to select the right traversal
// option to which that traverser should be routed
final M choice = TraversalUtil.apply(start, this.branchTraversal);
Expand Down Expand Up @@ -188,7 +188,7 @@ protected Iterator<Traverser.Admin<E>> computerAlgorithm() {
return ends.iterator();
}

private List<Traversal.Admin<S, E>> pickBranches(final M choice) {
protected List<Traversal.Admin<S, E>> pickBranches(final M choice) {
final List<Traversal.Admin<S, E>> branches = new ArrayList<>();
if (choice instanceof Pick) {
if (this.traversalPickOptions.containsKey(choice)) {
Expand Down Expand Up @@ -259,4 +259,24 @@ public void reset() {
this.getGlobalChildren().forEach(Traversal.Admin::reset);
this.first = true;
}

public Traversal.Admin<S, M> getBranchTraversal() {
return branchTraversal;
}

public Map<Pick, List<Traversal.Admin<S, E>>> getTraversalPickOptions() {
return traversalPickOptions;
}

public List<Pair<Traversal.Admin<M, ?>, Traversal.Admin<S, E>>> getTraversalOptions() {
return traversalOptions;
}

public boolean isFirst() {
return first;
}

public boolean isHasBarrier() {
return hasBarrier;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
* @author Joshua Shinavier (http://fortytwo.net)
* @author Marko A. Rodriguez (http://markorodriguez.com)
*/
public final class ChooseStep<S, E, M> extends BranchStep<S, E, M> {
public class ChooseStep<S, E, M> extends BranchStep<S, E, M> {

public ChooseStep(final Traversal.Admin traversal, final Traversal.Admin<S, M> choiceTraversal) {
super(traversal);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@
/**
* @author Marko A. Rodriguez (http://markorodriguez.com)
*/
public final class LocalStep<S, E> extends AbstractStep<S, E> implements TraversalParent {
public class LocalStep<S, E> extends AbstractStep<S, E> implements TraversalParent {

private Traversal.Admin<S, E> localTraversal;
private boolean first = true;
protected Traversal.Admin<S, E> localTraversal;
protected boolean first = true;

public LocalStep(final Traversal.Admin traversal, final Traversal.Admin<S, E> localTraversal) {
super(traversal);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@
/**
* @author Marko A. Rodriguez (http://markorodriguez.com)
*/
public final class OptionalStep<S> extends AbstractStep<S, S> implements TraversalParent {
public class OptionalStep<S> extends AbstractStep<S, S> implements TraversalParent {

private Traversal.Admin<S, S> optionalTraversal;
protected Traversal.Admin<S, S> optionalTraversal;

public OptionalStep(final Traversal.Admin traversal, final Traversal.Admin<S, S> optionalTraversal) {
super(traversal);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@
/**
* @author Marko A. Rodriguez (http://markorodriguez.com)
*/
public final class RepeatStep<S> extends ComputerAwareStep<S, S> implements TraversalParent {
public class RepeatStep<S> extends ComputerAwareStep<S, S> implements TraversalParent {

private Traversal.Admin<S, S> repeatTraversal = null;
private Traversal.Admin<S, ?> untilTraversal = null;
private Traversal.Admin<S, ?> emitTraversal = null;
private String loopName = null;
protected Traversal.Admin<S, S> repeatTraversal = null;
protected Traversal.Admin<S, ?> untilTraversal = null;
protected Traversal.Admin<S, ?> emitTraversal = null;
protected String loopName = null;
public boolean untilFirst = false;
public boolean emitFirst = false;

Expand Down Expand Up @@ -113,11 +113,11 @@ public List<Traversal.Admin<S, S>> getGlobalChildren() {
return list;
}

public final boolean doUntil(final Traverser.Admin<S> traverser, boolean utilFirst) {
public boolean doUntil(final Traverser.Admin<S> traverser, boolean utilFirst) {
return utilFirst == this.untilFirst && null != this.untilTraversal && TraversalUtil.test(traverser, this.untilTraversal);
}

public final boolean doEmit(final Traverser.Admin<S> traverser, boolean emitFirst) {
public boolean doEmit(final Traverser.Admin<S> traverser, boolean emitFirst) {
return emitFirst == this.emitFirst && null != this.emitTraversal && TraversalUtil.test(traverser, this.emitTraversal);
}

Expand All @@ -144,11 +144,11 @@ public void reset() {
this.repeatTraversal.reset();
}

private final String untilString() {
protected String untilString() {
return null == this.untilTraversal ? "until(false)" : "until(" + this.untilTraversal + ')';
}

private final String emitString() {
protected String emitString() {
return null == this.emitTraversal ? "emit(false)" : "emit(" + this.emitTraversal + ')';
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
/**
* @author Marko A. Rodriguez (http://markorodriguez.com)
*/
public final class UnionStep<S, E> extends BranchStep<S, E, Pick> {
public class UnionStep<S, E> extends BranchStep<S, E, Pick> {

public UnionStep(final Traversal.Admin traversal, final Traversal.Admin<?, E>... unionTraversals) {
super(traversal);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
/**
* @author Marko A. Rodriguez (http://markorodriguez.com)
*/
public final class AndStep<S> extends ConnectiveStep<S> {
public class AndStep<S> extends ConnectiveStep<S> {

public AndStep(final Traversal.Admin traversal, final Traversal<S, ?>... traversals) {
super(traversal, traversals);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@
/**
* @author Marko A. Rodriguez (http://markorodriguez.com)
*/
public final class ClassFilterStep<S, T> extends FilterStep<S> {
public class ClassFilterStep<S, T> extends FilterStep<S> {

private final Class<T> classFilter;
private final boolean allowClasses;
protected final Class<T> classFilter;
protected final boolean allowClasses;

public ClassFilterStep(final Traversal.Admin traversal, final Class<T> classFilter, final boolean allowClasses) {
super(traversal);
Expand All @@ -48,4 +48,12 @@ public int hashCode() {
public String toString() {
return StringFactory.stepString(this, this.classFilter.getSimpleName());
}

public Class<T> getClassFilter() {
return classFilter;
}

public boolean isAllowClasses() {
return allowClasses;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@
/**
* @author Marko A. Rodriguez (http://markorodriguez.com)
*/
public final class CoinStep<S> extends FilterStep<S> implements Seedable {
public class CoinStep<S> extends FilterStep<S> implements Seedable {

private final Random random = new Random();
private final double probability;
protected final Random random = new Random();
protected final double probability;

public CoinStep(final Traversal.Admin traversal, final double probability) {
super(traversal);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,16 @@
/**
* @author Marko A. Rodriguez (http://markorodriguez.com)
*/
public final class DedupGlobalStep<S> extends FilterStep<S> implements TraversalParent, Scoping, GraphComputing, Barrier<Map<Object, Traverser.Admin<S>>>, ByModulating, PathProcessor {

private Traversal.Admin<S, Object> dedupTraversal = null;
private Set<Object> duplicateSet = new HashSet<>();
private boolean onGraphComputer = false;
private final Set<String> dedupLabels;
private Set<String> keepLabels;
private boolean executingAtMaster = false;
private Map<Object, Traverser.Admin<S>> barrier;
private Iterator<Map.Entry<Object, Traverser.Admin<S>>> barrierIterator;
public class DedupGlobalStep<S> extends FilterStep<S> implements TraversalParent, Scoping, GraphComputing, Barrier<Map<Object, Traverser.Admin<S>>>, ByModulating, PathProcessor {

protected Traversal.Admin<S, Object> dedupTraversal = null;
protected Set<Object> duplicateSet = new HashSet<>();
protected boolean onGraphComputer = false;
protected final Set<String> dedupLabels;
protected Set<String> keepLabels;
protected boolean executingAtMaster = false;
protected Map<Object, Traverser.Admin<S>> barrier;
protected Iterator<Map.Entry<Object, Traverser.Admin<S>>> barrierIterator;

public DedupGlobalStep(final Traversal.Admin traversal, final String... dedupLabels) {
super(traversal);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
*/
public class DropStep<S> extends FilterStep<S> implements Mutating<Event> {

private CallbackRegistry<Event> callbackRegistry;
protected CallbackRegistry<Event> callbackRegistry;

public DropStep(final Traversal.Admin traversal) {
super(traversal);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@
*/
public class HasStep<S extends Element> extends FilterStep<S> implements HasContainerHolder, Configuring {

private final Parameters parameters = new Parameters();
private List<HasContainer> hasContainers;
protected Parameters parameters = new Parameters();
protected List<HasContainer> hasContainers;

public HasStep(final Traversal.Admin traversal, final HasContainer... hasContainers) {
super(traversal);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@
* @author Daniel Kuppitz (http://gremlin.guru)
* @author Marko A. Rodriguez (http://markorodriguez.com)
*/
public final class IsStep<S> extends FilterStep<S> {
public class IsStep<S> extends FilterStep<S> {

private P<S> predicate;
protected P<S> predicate;

public IsStep(final Traversal.Admin traversal, final P<S> predicate) {
super(traversal);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@
/**
* @author Marko A. Rodriguez (http://markorodriguez.com)
*/
public final class LambdaFilterStep<S> extends FilterStep<S> implements LambdaHolder {
public class LambdaFilterStep<S> extends FilterStep<S> implements LambdaHolder {

private final Predicate<Traverser<S>> predicate;
protected final Predicate<Traverser<S>> predicate;

public LambdaFilterStep(final Traversal.Admin traversal, final Predicate<Traverser<S>> predicate) {
super(traversal);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
/**
* @author Marko A. Rodriguez (http://markorodriguez.com)
*/
public final class NoneStep<S> extends FilterStep<S> {
public class NoneStep<S> extends FilterStep<S> {

public NoneStep(final Traversal.Admin traversal) {
super(traversal);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@
/**
* @author Marko A. Rodriguez (http://markorodriguez.com)
*/
public final class NotStep<S> extends FilterStep<S> implements TraversalParent{
public class NotStep<S> extends FilterStep<S> implements TraversalParent{

private Traversal.Admin<S, ?> notTraversal;
protected Traversal.Admin<S, ?> notTraversal;

public NotStep(final Traversal.Admin traversal, final Traversal<S, ?> notTraversal) {
super(traversal);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
/**
* @author Marko A. Rodriguez (http://markorodriguez.com)
*/
public final class OrStep<S> extends ConnectiveStep<S> {
public class OrStep<S> extends ConnectiveStep<S> {

public OrStep(final Traversal.Admin traversal, final Traversal<S, ?>... traversals) {
super(traversal, traversals);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@
/**
* @author Marko A. Rodriguez (http://markorodriguez.com)
*/
public final class PathFilterStep<S> extends FilterStep<S> implements FromToModulating, ByModulating, TraversalParent, PathProcessor {
public class PathFilterStep<S> extends FilterStep<S> implements FromToModulating, ByModulating, TraversalParent, PathProcessor {

protected String fromLabel;
protected String toLabel;
private boolean isSimple;
private TraversalRing<Object, Object> traversalRing;
private Set<String> keepLabels;
protected boolean isSimple;
protected TraversalRing<Object, Object> traversalRing;
protected Set<String> keepLabels;

public PathFilterStep(final Traversal.Admin traversal, final boolean isSimple) {
super(traversal);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@
* @author Bob Briody (http://bobbriody.com)
* @author Marko A. Rodriguez (http://markorodriguez.com)
*/
public final class RangeGlobalStep<S> extends FilterStep<S> implements Ranging, Bypassing, Barrier<TraverserSet<S>> {
public class RangeGlobalStep<S> extends FilterStep<S> implements Ranging, Bypassing, Barrier<TraverserSet<S>> {

private long low;
private final long high;
private AtomicLong counter = new AtomicLong(0l);
private boolean bypass;
protected long low;
protected final long high;
protected AtomicLong counter = new AtomicLong(0l);
protected boolean bypass;

public RangeGlobalStep(final Traversal.Admin traversal, final long low, final long high) {
super(traversal);
Expand Down Expand Up @@ -200,4 +200,20 @@ public TraverserSet<S> apply(final TraverserSet<S> mutatingSeed, final Traverser
return mutatingSeed;
}
}

public long getLow() {
return low;
}

public long getHigh() {
return high;
}

public AtomicLong getCounter() {
return counter;
}

public boolean isBypass() {
return bypass;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@
/**
* @author Marko A. Rodriguez (http://markorodriguez.com)
*/
public final class SampleGlobalStep<S> extends CollectingBarrierStep<S> implements TraversalParent, ByModulating, Seedable {
public class SampleGlobalStep<S> extends CollectingBarrierStep<S> implements TraversalParent, ByModulating, Seedable {

private Traversal.Admin<S, Number> probabilityTraversal = new ConstantTraversal<>(1.0d);
private final int amountToSample;
private final Random random = new Random();
protected Traversal.Admin<S, Number> probabilityTraversal = new ConstantTraversal<>(1.0d);
protected final int amountToSample;
protected final Random random = new Random();

public SampleGlobalStep(final Traversal.Admin traversal, final int amountToSample) {
super(traversal);
Expand Down Expand Up @@ -126,7 +126,7 @@ public void barrierConsumer(final TraverserSet<S> traverserSet) {
}


private Optional<ProjectedTraverser<S, Number>> createProjectedTraverser(final Traverser.Admin<S> traverser) {
protected Optional<ProjectedTraverser<S, Number>> createProjectedTraverser(final Traverser.Admin<S> traverser) {
final TraversalProduct product = TraversalUtil.produce(traverser, this.probabilityTraversal);
if (product.isProductive()) {
final Object o = product.get();
Expand Down
Loading