You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by sp...@apache.org on 2015/02/12 14:02:07 UTC
[41/77] [partial] incubator-tinkerpop git commit: moved com/tinkerpop
directories to org/apache/tinkerpop
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/1545201f/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/step/branch/LocalStep.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/step/branch/LocalStep.java b/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/step/branch/LocalStep.java
deleted file mode 100644
index b889883..0000000
--- a/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/step/branch/LocalStep.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * 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 com.tinkerpop.gremlin.process.graph.traversal.step.branch;
-
-import com.tinkerpop.gremlin.process.FastNoSuchElementException;
-import com.tinkerpop.gremlin.process.Traversal;
-import com.tinkerpop.gremlin.process.Traverser;
-import com.tinkerpop.gremlin.process.traversal.step.TraversalParent;
-import com.tinkerpop.gremlin.process.traversal.step.AbstractStep;
-import com.tinkerpop.gremlin.process.traversal.util.TraversalHelper;
-import com.tinkerpop.gremlin.process.traverser.TraverserRequirement;
-
-import java.util.Collections;
-import java.util.List;
-import java.util.NoSuchElementException;
-import java.util.Set;
-
-/**
- * @author Marko A. Rodriguez (http://markorodriguez.com)
- */
-public final class LocalStep<S, E> extends AbstractStep<S, E> implements TraversalParent {
-
- private Traversal.Admin<S, E> localTraversal;
- private boolean first = true;
-
- public LocalStep(final Traversal.Admin traversal, final Traversal.Admin<S, E> localTraversal) {
- super(traversal);
- this.integrateChild(this.localTraversal = localTraversal, TYPICAL_GLOBAL_OPERATIONS);
- }
-
- @Override
- public LocalStep<S, E> clone() throws CloneNotSupportedException {
- final LocalStep<S, E> clone = (LocalStep<S, E>) super.clone();
- clone.localTraversal = clone.integrateChild(this.localTraversal.clone(), TYPICAL_GLOBAL_OPERATIONS);
- clone.first = true;
- return clone;
- }
-
- @Override
- public String toString() {
- return TraversalHelper.makeStepString(this, this.localTraversal);
- }
-
- @Override
- public List<Traversal.Admin<S, E>> getLocalChildren() {
- return Collections.singletonList(this.localTraversal);
- }
-
- @Override
- public Set<TraverserRequirement> getRequirements() {
- return this.localTraversal.getTraverserRequirements();
- }
-
- @Override
- protected Traverser<E> processNextStart() throws NoSuchElementException {
- if (this.first) {
- this.first = false;
- this.localTraversal.addStart(this.starts.next());
- }
- while (true) {
- if (this.localTraversal.hasNext())
- return this.localTraversal.getEndStep().next();
- else if (this.starts.hasNext()) {
- this.localTraversal.reset();
- this.localTraversal.addStart(this.starts.next());
- } else {
- throw FastNoSuchElementException.instance();
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/1545201f/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/step/branch/RepeatStep.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/step/branch/RepeatStep.java b/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/step/branch/RepeatStep.java
deleted file mode 100644
index 1abbcb0..0000000
--- a/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/step/branch/RepeatStep.java
+++ /dev/null
@@ -1,263 +0,0 @@
-/*
- * 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 com.tinkerpop.gremlin.process.graph.traversal.step.branch;
-
-import com.tinkerpop.gremlin.process.Step;
-import com.tinkerpop.gremlin.process.Traversal;
-import com.tinkerpop.gremlin.process.Traverser;
-import com.tinkerpop.gremlin.process.traversal.step.TraversalParent;
-import com.tinkerpop.gremlin.process.graph.traversal.step.util.ComputerAwareStep;
-import com.tinkerpop.gremlin.process.traversal.util.TraversalHelper;
-import com.tinkerpop.gremlin.process.traversal.util.TraversalUtil;
-import com.tinkerpop.gremlin.process.traverser.TraverserRequirement;
-import com.tinkerpop.gremlin.util.iterator.IteratorUtils;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-import java.util.NoSuchElementException;
-import java.util.Set;
-
-/**
- * @author Marko A. Rodriguez (http://markorodriguez.com)
- */
-public final 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;
- public boolean untilFirst = false;
- public boolean emitFirst = false;
-
- public RepeatStep(final Traversal.Admin traversal) {
- super(traversal);
- }
-
- @Override
- public Set<TraverserRequirement> getRequirements() {
- final Set<TraverserRequirement> requirements = this.getSelfAndChildRequirements(TraverserRequirement.BULK);
- if (requirements.contains(TraverserRequirement.SINGLE_LOOP))
- requirements.add(TraverserRequirement.NESTED_LOOP);
- requirements.add(TraverserRequirement.SINGLE_LOOP);
- return requirements;
- }
-
- @SuppressWarnings("unchecked")
- public void setRepeatTraversal(final Traversal.Admin<S, S> repeatTraversal) {
- this.repeatTraversal = repeatTraversal; // .clone();
- this.repeatTraversal.addStep(new RepeatEndStep(this.repeatTraversal));
- this.integrateChild(this.repeatTraversal, TYPICAL_GLOBAL_OPERATIONS);
- }
-
- public void setUntilTraversal(final Traversal.Admin<S, ?> untilTraversal) {
- if (null == this.repeatTraversal) this.untilFirst = true;
- this.integrateChild(this.untilTraversal = untilTraversal, TYPICAL_LOCAL_OPERATIONS);
- }
-
- public void setEmitTraversal(final Traversal.Admin<S, ?> emitTraversal) {
- if (null == this.repeatTraversal) this.emitFirst = true;
- this.integrateChild(this.emitTraversal = emitTraversal, TYPICAL_LOCAL_OPERATIONS);
- }
-
- public List<Traversal.Admin<S, S>> getGlobalChildren() {
- return null == this.repeatTraversal ? Collections.emptyList() : Collections.singletonList(this.repeatTraversal);
- }
-
- public List<Traversal.Admin<S, ?>> getLocalChildren() {
- final List<Traversal.Admin<S, ?>> list = new ArrayList<>();
- if (null != this.untilTraversal)
- list.add(this.untilTraversal);
- if (null != this.emitTraversal)
- list.add(this.emitTraversal);
- return list;
- }
-
- public final 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) {
- return emitFirst == this.emitFirst && null != this.emitTraversal && TraversalUtil.test(traverser, this.emitTraversal);
- }
-
- @Override
- public String toString() {
- if (this.untilFirst && this.emitFirst)
- return TraversalHelper.makeStepString(this, untilString(), emitString(), this.repeatTraversal);
- else if (this.emitFirst)
- return TraversalHelper.makeStepString(this, emitString(), this.repeatTraversal, untilString());
- else if (this.untilFirst)
- return TraversalHelper.makeStepString(this, untilString(), this.repeatTraversal, emitString());
- else
- return TraversalHelper.makeStepString(this, this.repeatTraversal, untilString(), emitString());
- }
-
- private final String untilString() {
- return null == this.untilTraversal ? "until(false)" : "until(" + this.untilTraversal + ')';
- }
-
- private final String emitString() {
- return null == this.emitTraversal ? "emit(false)" : "emit(" + this.emitTraversal + ')';
- }
-
- /////////////////////////
-
- @Override
- public RepeatStep<S> clone() throws CloneNotSupportedException {
- final RepeatStep<S> clone = (RepeatStep<S>) super.clone();
- clone.repeatTraversal = clone.integrateChild(this.repeatTraversal.clone(), TYPICAL_GLOBAL_OPERATIONS);
- if (null != this.untilTraversal)
- clone.untilTraversal = clone.integrateChild(this.untilTraversal.clone(), TYPICAL_LOCAL_OPERATIONS);
- if (null != this.emitTraversal)
- clone.emitTraversal = clone.integrateChild(this.emitTraversal.clone(), TYPICAL_LOCAL_OPERATIONS);
- return clone;
- }
-
- @Override
- protected Iterator<Traverser<S>> standardAlgorithm() throws NoSuchElementException {
- while (true) {
- if (this.repeatTraversal.getEndStep().hasNext()) {
- return this.repeatTraversal.getEndStep();
- } else {
- final Traverser.Admin<S> start = this.starts.next();
- if (doUntil(start, true)) {
- start.resetLoops();
- return IteratorUtils.of(start);
- }
- this.repeatTraversal.addStart(start);
- if (doEmit(start, true)) {
- final Traverser.Admin<S> emitSplit = start.split();
- emitSplit.resetLoops();
- return IteratorUtils.of(emitSplit);
- }
- }
- }
- }
-
- @Override
- protected Iterator<Traverser<S>> computerAlgorithm() throws NoSuchElementException {
- final Traverser.Admin<S> start = this.starts.next();
- if (doUntil(start, true)) {
- start.resetLoops();
- start.setStepId(this.getNextStep().getId());
- return IteratorUtils.of(start);
- } else {
- start.setStepId(this.repeatTraversal.getStartStep().getId());
- if (doEmit(start, true)) {
- final Traverser.Admin<S> emitSplit = start.split();
- emitSplit.resetLoops();
- emitSplit.setStepId(this.getNextStep().getId());
- return IteratorUtils.of(start, emitSplit);
- } else {
- return IteratorUtils.of(start);
- }
- }
- }
-
- /////////////////////////
-
- public static <A, B, C extends Traversal<A, B>> C addRepeatToTraversal(final C traversal, final Traversal.Admin<B, B> repeatTraversal) {
- final Step<?, B> step = traversal.asAdmin().getEndStep();
- if (step instanceof RepeatStep && null == ((RepeatStep) step).repeatTraversal) {
- ((RepeatStep<B>) step).setRepeatTraversal(repeatTraversal);
- } else {
- final RepeatStep<B> repeatStep = new RepeatStep<>(traversal.asAdmin());
- repeatStep.setRepeatTraversal(repeatTraversal);
- traversal.asAdmin().addStep(repeatStep);
- }
- return traversal;
- }
-
- public static <A, B, C extends Traversal<A, B>> C addUntilToTraversal(final C traversal, final Traversal.Admin<B, ?> untilPredicate) {
- final Step<?, B> step = traversal.asAdmin().getEndStep();
- if (step instanceof RepeatStep && null == ((RepeatStep) step).untilTraversal) {
- ((RepeatStep<B>) step).setUntilTraversal(untilPredicate);
- } else {
- final RepeatStep<B> repeatStep = new RepeatStep<>(traversal.asAdmin());
- repeatStep.setUntilTraversal(untilPredicate);
- traversal.asAdmin().addStep(repeatStep);
- }
- return traversal;
- }
-
- public static <A, B, C extends Traversal<A, B>> C addEmitToTraversal(final C traversal, final Traversal.Admin<B, ?> emitPredicate) {
- final Step<?, B> step = traversal.asAdmin().getEndStep();
- if (step instanceof RepeatStep && null == ((RepeatStep) step).emitTraversal) {
- ((RepeatStep<B>) step).setEmitTraversal(emitPredicate);
- } else {
- final RepeatStep<B> repeatStep = new RepeatStep<>(traversal.asAdmin());
- repeatStep.setEmitTraversal(emitPredicate);
- traversal.asAdmin().addStep(repeatStep);
- }
- return traversal;
- }
-
- ///////////////////////////////////
-
- public class RepeatEndStep extends ComputerAwareStep<S, S> {
-
- public RepeatEndStep(final Traversal.Admin traversal) {
- super(traversal);
- }
-
- @Override
- protected Iterator<Traverser<S>> standardAlgorithm() throws NoSuchElementException {
- while (true) {
- final Traverser.Admin<S> start = this.starts.next();
- start.incrLoops(this.getId());
- if (doUntil(start, false)) {
- start.resetLoops();
- return IteratorUtils.of(start);
- } else {
- if (!RepeatStep.this.untilFirst && !RepeatStep.this.emitFirst)
- RepeatStep.this.repeatTraversal.addStart(start);
- else
- RepeatStep.this.addStart(start);
- if (doEmit(start, false)) {
- final Traverser.Admin<S> emitSplit = start.split();
- emitSplit.resetLoops();
- return IteratorUtils.of(emitSplit);
- }
- }
- }
- }
-
- @Override
- protected Iterator<Traverser<S>> computerAlgorithm() throws NoSuchElementException {
- final Traverser.Admin<S> start = this.starts.next();
- start.incrLoops(RepeatStep.this.getId());
- if (doUntil(start, false)) {
- start.resetLoops();
- start.setStepId(RepeatStep.this.getNextStep().getId());
- return IteratorUtils.of(start);
- } else {
- start.setStepId(RepeatStep.this.getId());
- if (doEmit(start, false)) {
- final Traverser.Admin<S> emitSplit = start.split();
- emitSplit.resetLoops();
- emitSplit.setStepId(RepeatStep.this.getNextStep().getId());
- return IteratorUtils.of(start, emitSplit);
- }
- return IteratorUtils.of(start);
- }
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/1545201f/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/step/branch/UnionStep.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/step/branch/UnionStep.java b/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/step/branch/UnionStep.java
deleted file mode 100644
index 91f75b0..0000000
--- a/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/step/branch/UnionStep.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * 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 com.tinkerpop.gremlin.process.graph.traversal.step.branch;
-
-import com.tinkerpop.gremlin.process.Traversal;
-import com.tinkerpop.gremlin.process.graph.traversal.step.TraversalOptionParent;
-import com.tinkerpop.gremlin.process.traversal.lambda.ConstantTraversal;
-import com.tinkerpop.gremlin.process.traversal.util.TraversalHelper;
-
-import java.util.Collections;
-
-/**
- * @author Marko A. Rodriguez (http://markorodriguez.com)
- */
-public final class UnionStep<S, E> extends BranchStep<S, E, TraversalOptionParent.Pick> {
-
- public UnionStep(final Traversal.Admin traversal, final Traversal.Admin<?, E>... unionTraversals) {
- super(traversal);
- this.setBranchTraversal(new ConstantTraversal<>(Pick.any));
- for (final Traversal.Admin<?, E> union : unionTraversals) {
- this.addGlobalChildOption(Pick.any, (Traversal.Admin) union);
- }
- }
-
- @Override
- public void addGlobalChildOption(final Pick pickToken, final Traversal.Admin<S, E> traversalOption) {
- if (Pick.any != pickToken)
- throw new IllegalArgumentException("Union step only supports the any token: " + pickToken);
- super.addGlobalChildOption(pickToken, traversalOption);
- }
-
- @Override
- public String toString() {
- return TraversalHelper.makeStepString(this, this.traversalOptions.getOrDefault(Pick.any, Collections.emptyList()));
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/1545201f/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/step/filter/AndStep.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/step/filter/AndStep.java b/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/step/filter/AndStep.java
deleted file mode 100644
index 6c0a290..0000000
--- a/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/step/filter/AndStep.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * 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 com.tinkerpop.gremlin.process.graph.traversal.step.filter;
-
-import com.tinkerpop.gremlin.process.Traversal;
-import com.tinkerpop.gremlin.process.traversal.step.TraversalParent;
-
-/**
- * @author Marko A. Rodriguez (http://markorodriguez.com)
- */
-public final class AndStep<S> extends ConjunctionStep<S> implements TraversalParent {
-
- public AndStep(final Traversal.Admin traversal, final Traversal.Admin<S, ?>... andTraversals) {
- super(traversal, andTraversals);
-
- }
-
- public static final class AndMarker<S> extends ConjunctionMarker<S> {
- public AndMarker(final Traversal.Admin traversal) {
- super(traversal);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/1545201f/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/step/filter/CoinStep.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/step/filter/CoinStep.java b/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/step/filter/CoinStep.java
deleted file mode 100644
index 041511e..0000000
--- a/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/step/filter/CoinStep.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * 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 com.tinkerpop.gremlin.process.graph.traversal.step.filter;
-
-import com.tinkerpop.gremlin.process.Traversal;
-import com.tinkerpop.gremlin.process.Traverser;
-import com.tinkerpop.gremlin.process.traversal.step.Reversible;
-import com.tinkerpop.gremlin.process.traverser.TraverserRequirement;
-import com.tinkerpop.gremlin.process.traversal.util.TraversalHelper;
-
-import java.util.Collections;
-import java.util.Random;
-import java.util.Set;
-
-/**
- * @author Marko A. Rodriguez (http://markorodriguez.com)
- */
-public final class CoinStep<S> extends FilterStep<S> implements Reversible {
-
- private static final Random RANDOM = new Random();
- private final double probability;
-
- public CoinStep(final Traversal.Admin traversal, final double probability) {
- super(traversal);
- this.probability = probability;
- }
-
- @Override
- protected boolean filter(final Traverser.Admin<S> traverser) {
- long newBulk = 0l;
- for (int i = 0; i < traverser.bulk(); i++) {
- if (this.probability >= RANDOM.nextDouble())
- newBulk++;
- }
- if (0 == newBulk) return false;
- traverser.setBulk(newBulk);
- return true;
- }
-
- @Override
- public String toString() {
- return TraversalHelper.makeStepString(this, this.probability);
- }
-
- @Override
- public Set<TraverserRequirement> getRequirements() {
- return Collections.singleton(TraverserRequirement.BULK);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/1545201f/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/step/filter/ConjunctionStep.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/step/filter/ConjunctionStep.java b/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/step/filter/ConjunctionStep.java
deleted file mode 100644
index f0a7c75..0000000
--- a/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/step/filter/ConjunctionStep.java
+++ /dev/null
@@ -1,193 +0,0 @@
-/*
- * 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 com.tinkerpop.gremlin.process.graph.traversal.step.filter;
-
-import com.tinkerpop.gremlin.process.Step;
-import com.tinkerpop.gremlin.process.Traversal;
-import com.tinkerpop.gremlin.process.Traverser;
-import com.tinkerpop.gremlin.process.graph.util.HasContainer;
-import com.tinkerpop.gremlin.process.traversal.step.AbstractStep;
-import com.tinkerpop.gremlin.process.traversal.step.TraversalParent;
-import com.tinkerpop.gremlin.process.traversal.util.TraversalHelper;
-import com.tinkerpop.gremlin.process.traverser.TraverserRequirement;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-import java.util.NoSuchElementException;
-import java.util.Set;
-
-/**
- * @author Marko A. Rodriguez (http://markorodriguez.com)
- */
-public abstract class ConjunctionStep<S> extends AbstractStep<S, S> implements TraversalParent {
-
- private List<Traversal.Admin<S, ?>> conjunctionTraversals;
- private final boolean isAnd;
-
- public ConjunctionStep(final Traversal.Admin traversal, final Traversal.Admin<S, ?>... conjunctionTraversals) {
- super(traversal);
- this.isAnd = this.getClass().equals(AndStep.class);
- this.conjunctionTraversals = Arrays.asList(conjunctionTraversals);
- for (final Traversal.Admin<S, ?> conjunctionTraversal : this.conjunctionTraversals) {
- this.integrateChild(conjunctionTraversal, TYPICAL_LOCAL_OPERATIONS);
- }
- }
-
- @Override
- protected Traverser<S> processNextStart() throws NoSuchElementException {
- while (true) {
- final Traverser.Admin<S> start = this.starts.next();
- boolean found = false;
- for (final Traversal.Admin<S, ?> traversal : this.conjunctionTraversals) {
- traversal.addStart(start.split());
- found = traversal.hasNext();
- traversal.reset();
- if (this.isAnd) {
- if (!found)
- break;
- } else if (found)
- break;
- }
- if (found) return start;
- }
- }
-
- @Override
- public Set<TraverserRequirement> getRequirements() {
- return this.getSelfAndChildRequirements();
- }
-
- @Override
- public List<Traversal.Admin<S, ?>> getLocalChildren() {
- return Collections.unmodifiableList(this.conjunctionTraversals);
- }
-
- @Override
- public ConjunctionStep<S> clone() throws CloneNotSupportedException {
- final ConjunctionStep<S> clone = (ConjunctionStep<S>) super.clone();
- clone.conjunctionTraversals = new ArrayList<>();
- for (final Traversal.Admin<S, ?> conjunctionTraversal : this.conjunctionTraversals) {
- clone.conjunctionTraversals.add(clone.integrateChild(conjunctionTraversal.clone(), TYPICAL_LOCAL_OPERATIONS));
- }
- return clone;
- }
-
- @Override
- public String toString() {
- return TraversalHelper.makeStepString(this, this.conjunctionTraversals);
- }
-
- public boolean isConjunctionHasTree() {
- for (final Traversal.Admin<S, ?> conjunctionTraversal : this.conjunctionTraversals) {
- for (final Step<?, ?> step : conjunctionTraversal.getSteps()) {
- if (step instanceof ConjunctionStep) {
- if (!((ConjunctionStep) step).isConjunctionHasTree())
- return false;
- } else if (!(step instanceof HasStep))
- return false;
- }
- }
- return true;
- }
-
- public ConjunctionTree getConjunctionHasTree() {
- return new ConjunctionTree(this);
- }
-
-
- ////////
-
- public static class ConjunctionMarker<S> extends AbstractStep<S, S> {
-
- public ConjunctionMarker(final Traversal.Admin traversal) {
- super(traversal);
- }
-
- @Override
- protected Traverser<S> processNextStart() throws NoSuchElementException {
- throw new IllegalStateException("This step should have been removed via a strategy: " + this.getClass().getCanonicalName());
- }
- }
-
- ////////
-
- public static class ConjunctionTree implements Iterable<ConjunctionTree.Entry> {
-
- private final List<Entry> tree = new ArrayList<>();
- private final boolean isAnd;
-
- public ConjunctionTree(final ConjunctionStep<?> conjunctionStep) {
- this.isAnd = conjunctionStep.isAnd;
- for (final Traversal.Admin<?, ?> conjunctionTraversal : conjunctionStep.conjunctionTraversals) {
- for (final Step<?, ?> step : conjunctionTraversal.getSteps()) {
- if (step instanceof HasStep) {
- (((HasStep<?>) step).getHasContainers()).forEach(container -> this.tree.add(new Entry(HasContainer.class, container)));
- } else if (step instanceof ConjunctionStep) {
- this.tree.add(new Entry(ConjunctionTree.class, ((ConjunctionStep) step).getConjunctionHasTree()));
- } else {
- throw new IllegalArgumentException("This conjunction supports more complex steps than HasStep");
- }
- }
- }
- }
-
- @Override
- public String toString() {
- return (this.isAnd ? "and" : "or") + this.tree.toString();
- }
-
- public boolean isAnd() {
- return this.isAnd;
- }
-
- @Override
- public Iterator<Entry> iterator() {
- return this.tree.iterator();
- }
-
- public static class Entry {
- private Class entryClass;
- private Object entryValue;
-
- public Entry(final Class entryClass, final Object entryValue) {
- this.entryClass = entryClass;
- this.entryValue = entryValue;
- }
-
- public <V> V getValue() {
- return (V) this.entryValue;
- }
-
- public boolean isHasContainer() {
- return this.entryClass.equals(HasContainer.class);
- }
-
- public boolean isConjunctionTree() {
- return this.entryClass.equals(ConjunctionTree.class);
- }
-
- public String toString() {
- return this.entryValue.toString();
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/1545201f/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/step/filter/CyclicPathStep.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/step/filter/CyclicPathStep.java b/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/step/filter/CyclicPathStep.java
deleted file mode 100644
index 996ae5c..0000000
--- a/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/step/filter/CyclicPathStep.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * 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 com.tinkerpop.gremlin.process.graph.traversal.step.filter;
-
-import com.tinkerpop.gremlin.process.Traversal;
-import com.tinkerpop.gremlin.process.Traverser;
-import com.tinkerpop.gremlin.process.traversal.step.Reversible;
-import com.tinkerpop.gremlin.process.traverser.TraverserRequirement;
-
-import java.util.Collections;
-import java.util.Set;
-
-/**
- * @author Marko A. Rodriguez (http://markorodriguez.com)
- */
-public final class CyclicPathStep<S> extends FilterStep<S> implements Reversible {
-
- public CyclicPathStep(final Traversal.Admin traversal) {
- super(traversal);
- }
-
- @Override
- protected boolean filter(final Traverser.Admin<S> traverser) {
- return !traverser.path().isSimple();
- }
-
- @Override
- public Set<TraverserRequirement> getRequirements() {
- return Collections.singleton(TraverserRequirement.PATH);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/1545201f/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/step/filter/DedupStep.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/step/filter/DedupStep.java b/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/step/filter/DedupStep.java
deleted file mode 100644
index 1dc3e33..0000000
--- a/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/step/filter/DedupStep.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * 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 com.tinkerpop.gremlin.process.graph.traversal.step.filter;
-
-import com.tinkerpop.gremlin.process.Traversal;
-import com.tinkerpop.gremlin.process.Traverser;
-import com.tinkerpop.gremlin.process.traversal.lambda.IdentityTraversal;
-import com.tinkerpop.gremlin.process.traversal.step.Reducing;
-import com.tinkerpop.gremlin.process.traversal.step.Reversible;
-import com.tinkerpop.gremlin.process.traversal.step.TraversalParent;
-import com.tinkerpop.gremlin.process.traversal.util.TraversalHelper;
-import com.tinkerpop.gremlin.process.traversal.util.TraversalUtil;
-import com.tinkerpop.gremlin.process.traverser.TraverserRequirement;
-
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-/**
- * @author Marko A. Rodriguez (http://markorodriguez.com)
- */
-public final class DedupStep<S> extends FilterStep<S> implements Reversible, Reducing<Set<Object>, S>, TraversalParent {
-
- private Traversal.Admin<S, Object> dedupTraversal = new IdentityTraversal<>();
- private Set<Object> duplicateSet = new HashSet<>();
-
- public DedupStep(final Traversal.Admin traversal) {
- super(traversal);
- }
-
- @Override
- protected boolean filter(final Traverser.Admin<S> traverser) {
- traverser.setBulk(1);
- return this.duplicateSet.add(TraversalUtil.apply(traverser, this.dedupTraversal));
- }
-
-
- @Override
- public List<Traversal<S, Object>> getLocalChildren() {
- return Collections.singletonList(this.dedupTraversal);
- }
-
- @Override
- public void addLocalChild(final Traversal.Admin dedupTraversal) {
- this.dedupTraversal = this.integrateChild(dedupTraversal, TYPICAL_LOCAL_OPERATIONS);
- }
-
- @Override
- public Reducer<Set<Object>, S> getReducer() {
- return new Reducer<>(HashSet::new, (set, start) -> {
- set.add(TraversalUtil.apply(start, this.dedupTraversal));
- return set;
- }, true);
- }
-
- @Override
- public DedupStep<S> clone() throws CloneNotSupportedException {
- final DedupStep<S> clone = (DedupStep<S>) super.clone();
- clone.duplicateSet = new HashSet<>();
- clone.dedupTraversal = clone.integrateChild(this.dedupTraversal.clone(), TYPICAL_LOCAL_OPERATIONS);
- return clone;
- }
-
- @Override
- public void reset() {
- super.reset();
- this.duplicateSet.clear();
- }
-
- @Override
- public String toString() {
- return TraversalHelper.makeStepString(this, this.dedupTraversal);
- }
-
- @Override
- public Set<TraverserRequirement> getRequirements() {
- return this.getSelfAndChildRequirements(TraverserRequirement.SIDE_EFFECTS);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/1545201f/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/step/filter/ExceptStep.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/step/filter/ExceptStep.java b/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/step/filter/ExceptStep.java
deleted file mode 100644
index 6a09462..0000000
--- a/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/step/filter/ExceptStep.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * 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 com.tinkerpop.gremlin.process.graph.traversal.step.filter;
-
-import com.tinkerpop.gremlin.process.Traversal;
-import com.tinkerpop.gremlin.process.Traverser;
-import com.tinkerpop.gremlin.process.traversal.step.Reversible;
-import com.tinkerpop.gremlin.process.traversal.util.TraversalHelper;
-import com.tinkerpop.gremlin.process.traverser.TraverserRequirement;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Set;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-
-/**
- * @author Marko A. Rodriguez (http://markorodriguez.com)
- */
-public final class ExceptStep<S> extends FilterStep<S> implements Reversible {
-
- private final String sideEffectKeyOrPathLabel;
- private final Collection<S> exceptCollection;
- private final S exceptObject;
- private final short choice;
-
- public ExceptStep(final Traversal.Admin traversal, final String sideEffectKeyOrPathLabel) {
- super(traversal);
- this.sideEffectKeyOrPathLabel = sideEffectKeyOrPathLabel;
- this.exceptCollection = null;
- this.exceptObject = null;
- this.choice = 0;
- }
-
- public ExceptStep(final Traversal.Admin traversal, final Collection<S> exceptionCollection) {
- super(traversal);
- this.sideEffectKeyOrPathLabel = null;
- this.exceptCollection = exceptionCollection;
- this.exceptObject = null;
- this.choice = 1;
- }
-
- public ExceptStep(final Traversal.Admin traversal, final S exceptionObject) {
- super(traversal);
- this.sideEffectKeyOrPathLabel = null;
- this.exceptCollection = null;
- this.exceptObject = exceptionObject;
- this.choice = 2;
- }
-
- @Override
- protected boolean filter(final Traverser.Admin<S> traverser) {
- switch (this.choice) {
- case 0: {
- final Object except = traverser.asAdmin().getSideEffects().exists(this.sideEffectKeyOrPathLabel) ?
- traverser.sideEffects(this.sideEffectKeyOrPathLabel) :
- traverser.path(this.sideEffectKeyOrPathLabel);
- return except instanceof Collection ?
- !((Collection) except).contains(traverser.get()) :
- !except.equals(traverser.get());
- }
- case 1:
- return !this.exceptCollection.contains(traverser.get());
- default:
- return !this.exceptObject.equals(traverser.get());
- }
- }
-
- @Override
- public String toString() {
- return TraversalHelper.makeStepString(this, this.sideEffectKeyOrPathLabel);
- }
-
- @Override
- public Set<TraverserRequirement> getRequirements() {
- return null == this.sideEffectKeyOrPathLabel ?
- Collections.singleton(TraverserRequirement.OBJECT) :
- Stream.of(TraverserRequirement.OBJECT,
- TraverserRequirement.SIDE_EFFECTS,
- TraverserRequirement.PATH_ACCESS).collect(Collectors.toSet());
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/1545201f/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/step/filter/FilterStep.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/step/filter/FilterStep.java b/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/step/filter/FilterStep.java
deleted file mode 100644
index 46ed9dc..0000000
--- a/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/step/filter/FilterStep.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * 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 com.tinkerpop.gremlin.process.graph.traversal.step.filter;
-
-import com.tinkerpop.gremlin.process.Traversal;
-import com.tinkerpop.gremlin.process.Traverser;
-import com.tinkerpop.gremlin.process.traversal.step.AbstractStep;
-
-import java.util.function.Predicate;
-
-/**
- * @author Marko A. Rodriguez (http://markorodriguez.com)
- */
-public abstract class FilterStep<S> extends AbstractStep<S, S> {
-
- public FilterStep(final Traversal.Admin traversal) {
- super(traversal);
- }
-
- @Override
- protected Traverser<S> processNextStart() {
- while (true) {
- final Traverser.Admin<S> traverser = this.starts.next();
- if (this.filter(traverser)) {
- return traverser;
- }
- }
- }
-
- protected abstract boolean filter(final Traverser.Admin<S> traverser);
-}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/1545201f/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/step/filter/HasStep.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/step/filter/HasStep.java b/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/step/filter/HasStep.java
deleted file mode 100644
index f3a9f44..0000000
--- a/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/step/filter/HasStep.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * 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 com.tinkerpop.gremlin.process.graph.traversal.step.filter;
-
-import com.tinkerpop.gremlin.process.Traversal;
-import com.tinkerpop.gremlin.process.Traverser;
-import com.tinkerpop.gremlin.process.graph.traversal.step.HasContainerHolder;
-import com.tinkerpop.gremlin.process.graph.util.HasContainer;
-import com.tinkerpop.gremlin.process.traversal.step.Reversible;
-import com.tinkerpop.gremlin.process.traversal.util.TraversalHelper;
-import com.tinkerpop.gremlin.process.traverser.TraverserRequirement;
-import com.tinkerpop.gremlin.structure.Element;
-
-import java.util.Collections;
-import java.util.List;
-import java.util.Set;
-
-/**
- * @author Marko A. Rodriguez (http://markorodriguez.com)
- */
-public class HasStep<S extends Element> extends FilterStep<S> implements HasContainerHolder, Reversible { // TODO: make final when graph strategies are fixed up
-
- private final HasContainer hasContainer;
-
- public HasStep(final Traversal.Admin traversal, final HasContainer hasContainer) {
- super(traversal);
- this.hasContainer = hasContainer;
- }
-
- @Override
- protected boolean filter(final Traverser.Admin<S> traverser) {
- return this.hasContainer.test(traverser.get());
- }
-
- @Override
- public String toString() {
- return TraversalHelper.makeStepString(this, this.hasContainer);
- }
-
- @Override
- public List<HasContainer> getHasContainers() {
- return Collections.singletonList(this.hasContainer);
- }
-
- @Override
- public Set<TraverserRequirement> getRequirements() {
- return Collections.singleton(TraverserRequirement.OBJECT);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/1545201f/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/step/filter/HasTraversalStep.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/step/filter/HasTraversalStep.java b/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/step/filter/HasTraversalStep.java
deleted file mode 100644
index a51d929..0000000
--- a/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/step/filter/HasTraversalStep.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * 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 com.tinkerpop.gremlin.process.graph.traversal.step.filter;
-
-import com.tinkerpop.gremlin.process.Traversal;
-import com.tinkerpop.gremlin.process.Traverser;
-import com.tinkerpop.gremlin.process.traversal.step.TraversalParent;
-import com.tinkerpop.gremlin.process.traversal.step.AbstractStep;
-import com.tinkerpop.gremlin.process.traversal.util.TraversalHelper;
-import com.tinkerpop.gremlin.process.traversal.util.TraversalUtil;
-import com.tinkerpop.gremlin.process.traverser.TraverserRequirement;
-
-import java.util.Collections;
-import java.util.List;
-import java.util.NoSuchElementException;
-import java.util.Set;
-
-/**
- * @author Marko A. Rodriguez (http://markorodriguez.com)
- */
-public final class HasTraversalStep<S> extends AbstractStep<S, S> implements TraversalParent {
-
- private Traversal.Admin<S, ?> hasTraversal;
-
- public HasTraversalStep(final Traversal.Admin traversal, final Traversal.Admin<S, ?> hasTraversal) {
- super(traversal);
- this.integrateChild(this.hasTraversal = hasTraversal, TYPICAL_LOCAL_OPERATIONS);
- }
-
- @Override
- protected Traverser<S> processNextStart() throws NoSuchElementException {
- while (true) {
- final Traverser.Admin<S> start = this.starts.next();
- if (TraversalUtil.test(start, this.hasTraversal))
- return start;
- }
- }
-
- @Override
- public String toString() {
- return TraversalHelper.makeStepString(this, this.hasTraversal);
- }
-
- @Override
- public List<Traversal<S, ?>> getLocalChildren() {
- return Collections.singletonList(this.hasTraversal);
- }
-
- @Override
- public Set<TraverserRequirement> getRequirements() {
- return this.getSelfAndChildRequirements();
- }
-
- @Override
- public HasTraversalStep<S> clone() throws CloneNotSupportedException {
- final HasTraversalStep<S> clone = (HasTraversalStep<S>) super.clone();
- clone.hasTraversal = clone.integrateChild(this.hasTraversal.clone(), TYPICAL_LOCAL_OPERATIONS);
- return clone;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/1545201f/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/step/filter/IsStep.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/step/filter/IsStep.java b/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/step/filter/IsStep.java
deleted file mode 100644
index b3de0c7..0000000
--- a/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/step/filter/IsStep.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * 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 com.tinkerpop.gremlin.process.graph.traversal.step.filter;
-
-import com.tinkerpop.gremlin.process.Traversal;
-import com.tinkerpop.gremlin.process.Traverser;
-import com.tinkerpop.gremlin.process.traversal.step.Reversible;
-import com.tinkerpop.gremlin.process.traverser.TraverserRequirement;
-import com.tinkerpop.gremlin.process.traversal.util.TraversalHelper;
-
-import java.util.Collections;
-import java.util.Set;
-import java.util.function.BiPredicate;
-
-/**
- * @author Daniel Kuppitz (http://gremlin.guru)
- */
-public final class IsStep<S> extends FilterStep<S> implements Reversible {
-
- private final Object value;
- private final BiPredicate<S,Object> biPredicate;
-
- public IsStep(final Traversal.Admin traversal, final BiPredicate<S, Object> biPredicate, final Object value) {
- super(traversal);
- this.value = value;
- this.biPredicate = biPredicate;
- }
-
- @Override
- protected boolean filter(final Traverser.Admin<S> traverser) {
- return this.biPredicate.test(traverser.get(), this.value);
- }
-
- @Override
- public String toString() {
- return TraversalHelper.makeStepString(this, this.biPredicate, this.value);
- }
-
- @Override
- public Set<TraverserRequirement> getRequirements() {
- return Collections.singleton(TraverserRequirement.OBJECT);
- }
-
- public Object getValue() {
- return value;
- }
-
- public BiPredicate<S, Object> getPredicate() {
- return biPredicate;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/1545201f/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/step/filter/LambdaFilterStep.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/step/filter/LambdaFilterStep.java b/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/step/filter/LambdaFilterStep.java
deleted file mode 100644
index a355afb..0000000
--- a/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/step/filter/LambdaFilterStep.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * 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 com.tinkerpop.gremlin.process.graph.traversal.step.filter;
-
-import com.tinkerpop.gremlin.process.Traversal;
-import com.tinkerpop.gremlin.process.Traverser;
-import com.tinkerpop.gremlin.process.traversal.util.TraversalHelper;
-
-import java.util.function.Predicate;
-
-/**
- * @author Marko A. Rodriguez (http://markorodriguez.com)
- */
-public final class LambdaFilterStep<S> extends FilterStep<S> {
-
- private final Predicate<Traverser<S>> predicate;
-
- public LambdaFilterStep(final Traversal.Admin traversal, final Predicate<Traverser<S>> predicate) {
- super(traversal);
- this.predicate = predicate;
- }
-
- @Override
- protected boolean filter(final Traverser.Admin<S> traverser) {
- return this.predicate.test(traverser);
- }
-
- @Override
- public String toString() {
- return TraversalHelper.makeStepString(this,this.predicate);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/1545201f/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/step/filter/OrStep.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/step/filter/OrStep.java b/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/step/filter/OrStep.java
deleted file mode 100644
index deaa89d..0000000
--- a/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/step/filter/OrStep.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * 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 com.tinkerpop.gremlin.process.graph.traversal.step.filter;
-
-import com.tinkerpop.gremlin.process.Traversal;
-import com.tinkerpop.gremlin.process.traversal.step.TraversalParent;
-
-/**
- * @author Marko A. Rodriguez (http://markorodriguez.com)
- */
-public final class OrStep<S> extends ConjunctionStep<S> implements TraversalParent {
-
- public OrStep(final Traversal.Admin traversal, final Traversal.Admin<S, ?>... orTraversals) {
- super(traversal, orTraversals);
-
- }
-
- public static final class OrMarker<S> extends ConjunctionMarker<S> {
- public OrMarker(final Traversal.Admin traversal) {
- super(traversal);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/1545201f/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/step/filter/RangeStep.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/step/filter/RangeStep.java b/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/step/filter/RangeStep.java
deleted file mode 100644
index 69f30c7..0000000
--- a/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/step/filter/RangeStep.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * 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 com.tinkerpop.gremlin.process.graph.traversal.step.filter;
-
-import com.tinkerpop.gremlin.process.FastNoSuchElementException;
-import com.tinkerpop.gremlin.process.Traversal;
-import com.tinkerpop.gremlin.process.Traverser;
-import com.tinkerpop.gremlin.process.graph.traversal.step.Ranging;
-import com.tinkerpop.gremlin.process.traversal.util.TraversalHelper;
-import com.tinkerpop.gremlin.process.traverser.TraverserRequirement;
-
-import java.util.Collections;
-import java.util.Set;
-import java.util.concurrent.atomic.AtomicLong;
-
-/**
- * @author Bob Briody (http://bobbriody.com)
- * @author Marko A. Rodriguez (http://markorodriguez.com)
- */
-public final class RangeStep<S> extends FilterStep<S> implements Ranging {
-
- private final long low;
- private final long high;
- private AtomicLong counter = new AtomicLong(0l);
-
- public RangeStep(final Traversal.Admin traversal, final long low, final long high) {
- super(traversal);
- if (low != -1 && high != -1 && low > high) {
- throw new IllegalArgumentException("Not a legal range: [" + low + ", " + high + ']');
- }
- this.low = low;
- this.high = high;
- }
-
- @Override
- protected boolean filter(final Traverser.Admin<S> traverser) {
- if (this.high != -1 && this.counter.get() >= this.high) {
- throw FastNoSuchElementException.instance();
- }
-
- long avail = traverser.bulk();
- if (this.counter.get() + avail <= this.low) {
- // Will not surpass the low w/ this traverser. Skip and filter the whole thing.
- this.counter.getAndAdd(avail);
- return false;
- }
-
- // Skip for the low and trim for the high. Both can happen at once.
-
- long toSkip = 0;
- if (this.counter.get() < this.low) {
- toSkip = this.low - this.counter.get();
- }
-
- long toTrim = 0;
- if (this.high != -1 && this.counter.get() + avail >= this.high) {
- toTrim = this.counter.get() + avail - this.high;
- }
-
- long toEmit = avail - toSkip - toTrim;
- this.counter.getAndAdd(toSkip + toEmit);
- traverser.asAdmin().setBulk(toEmit);
-
- return true;
- }
-
- @Override
- public void reset() {
- super.reset();
- this.counter.set(0l);
- }
-
- @Override
- public String toString() {
- return TraversalHelper.makeStepString(this, this.low, this.high);
- }
-
- public long getLowRange() {
- return this.low;
- }
-
- public long getHighRange() {
- return this.high;
- }
-
- @Override
- public RangeStep<S> clone() throws CloneNotSupportedException {
- final RangeStep<S> clone = (RangeStep<S>) super.clone();
- clone.counter = new AtomicLong(0l);
- return clone;
- }
-
- @Override
- public Set<TraverserRequirement> getRequirements() {
- return Collections.singleton(TraverserRequirement.BULK);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/1545201f/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/step/filter/RetainStep.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/step/filter/RetainStep.java b/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/step/filter/RetainStep.java
deleted file mode 100644
index 170c187..0000000
--- a/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/step/filter/RetainStep.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * 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 com.tinkerpop.gremlin.process.graph.traversal.step.filter;
-
-import com.tinkerpop.gremlin.process.Traversal;
-import com.tinkerpop.gremlin.process.Traverser;
-import com.tinkerpop.gremlin.process.traversal.step.Reversible;
-import com.tinkerpop.gremlin.process.traversal.util.TraversalHelper;
-import com.tinkerpop.gremlin.process.traverser.TraverserRequirement;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Set;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-
-/**
- * @author Marko A. Rodriguez (http://markorodriguez.com)
- */
-public final class RetainStep<S> extends FilterStep<S> implements Reversible {
-
- private final String sideEffectKeyOrPathLabel;
- private final Collection<S> retainCollection;
- private final S retainObject;
- private final short choice;
-
- public RetainStep(final Traversal.Admin traversal, final String sideEffectKeyOrPathLabel) {
- super(traversal);
- this.sideEffectKeyOrPathLabel = sideEffectKeyOrPathLabel;
- this.retainCollection = null;
- this.retainObject = null;
- this.choice = 0;
- }
-
- public RetainStep(final Traversal.Admin traversal, final Collection<S> retainCollection) {
- super(traversal);
- this.sideEffectKeyOrPathLabel = null;
- this.retainCollection = retainCollection;
- this.retainObject = null;
- this.choice = 1;
- }
-
- public RetainStep(final Traversal.Admin traversal, final S retainObject) {
- super(traversal);
- this.sideEffectKeyOrPathLabel = null;
- this.retainCollection = null;
- this.retainObject = retainObject;
- this.choice = 2;
- }
-
- @Override
- protected boolean filter(final Traverser.Admin<S> traverser) {
- switch (this.choice) {
- case 0: {
- final Object retain = traverser.asAdmin().getSideEffects().exists(this.sideEffectKeyOrPathLabel) ?
- traverser.sideEffects(this.sideEffectKeyOrPathLabel) :
- traverser.path(this.sideEffectKeyOrPathLabel);
- return retain instanceof Collection ?
- ((Collection) retain).contains(traverser.get()) :
- retain.equals(traverser.get());
- }
- case 1:
- return this.retainCollection.contains(traverser.get());
- default:
- return this.retainObject.equals(traverser.get());
- }
- }
-
- @Override
- public String toString() {
- return TraversalHelper.makeStepString(this, this.sideEffectKeyOrPathLabel);
- }
-
- @Override
- public Set<TraverserRequirement> getRequirements() {
- return null == this.sideEffectKeyOrPathLabel ?
- Collections.singleton(TraverserRequirement.OBJECT) :
- Stream.of(TraverserRequirement.OBJECT,
- TraverserRequirement.SIDE_EFFECTS,
- TraverserRequirement.PATH_ACCESS).collect(Collectors.toSet());
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/1545201f/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/step/filter/SampleStep.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/step/filter/SampleStep.java b/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/step/filter/SampleStep.java
deleted file mode 100644
index f3da7eb..0000000
--- a/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/step/filter/SampleStep.java
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * 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 com.tinkerpop.gremlin.process.graph.traversal.step.filter;
-
-import com.tinkerpop.gremlin.process.Traversal;
-import com.tinkerpop.gremlin.process.Traverser;
-import com.tinkerpop.gremlin.process.graph.traversal.step.util.CollectingBarrierStep;
-import com.tinkerpop.gremlin.process.traversal.lambda.ConstantTraversal;
-import com.tinkerpop.gremlin.process.traversal.step.Reversible;
-import com.tinkerpop.gremlin.process.traversal.step.TraversalParent;
-import com.tinkerpop.gremlin.process.traversal.util.TraversalHelper;
-import com.tinkerpop.gremlin.process.traversal.util.TraversalUtil;
-import com.tinkerpop.gremlin.process.traverser.TraverserRequirement;
-import com.tinkerpop.gremlin.process.util.TraverserSet;
-
-import java.util.Collections;
-import java.util.List;
-import java.util.Random;
-import java.util.Set;
-
-/**
- * @author Marko A. Rodriguez (http://markorodriguez.com)
- */
-public final class SampleStep<S> extends CollectingBarrierStep<S> implements Reversible, TraversalParent {
-
- private Traversal.Admin<S, Number> probabilityTraversal = new ConstantTraversal<>(1.0d);
- private final int amountToSample;
- private static final Random RANDOM = new Random();
-
- public SampleStep(final Traversal.Admin traversal, final int amountToSample) {
- super(traversal);
- this.amountToSample = amountToSample;
- }
-
- @Override
- public List<Traversal.Admin<S, Number>> getLocalChildren() {
- return Collections.singletonList(this.probabilityTraversal);
- }
-
- @Override
- public void addLocalChild(final Traversal.Admin<?, ?> probabilityTraversal) {
- this.probabilityTraversal = this.integrateChild(probabilityTraversal, TYPICAL_LOCAL_OPERATIONS);
- }
-
- @Override
- public String toString() {
- return TraversalHelper.makeStepString(this, this.amountToSample, this.probabilityTraversal);
- }
-
- @Override
- public void barrierConsumer(final TraverserSet<S> traverserSet) {
- // return the entire traverser set if the set is smaller than the amount to sample
- if (traverserSet.bulkSize() <= this.amountToSample)
- return;
- //////////////// else sample the set
- double totalWeight = 0.0d;
- for (final Traverser<S> s : traverserSet) {
- totalWeight = totalWeight + TraversalUtil.apply(s.asAdmin(), this.probabilityTraversal).doubleValue() * s.bulk();
- }
- ///////
- final TraverserSet<S> sampledSet = new TraverserSet<>();
- int runningAmountToSample = 0;
- while (runningAmountToSample < this.amountToSample) {
- boolean reSample = false;
- double runningWeight = 0.0d;
- for (final Traverser.Admin<S> s : traverserSet) {
- long sampleBulk = sampledSet.contains(s) ? sampledSet.get(s).bulk() : 0;
- if (sampleBulk < s.bulk()) {
- final double currentWeight = TraversalUtil.apply(s, this.probabilityTraversal).doubleValue();
- for (int i = 0; i < (s.bulk() - sampleBulk); i++) {
- runningWeight = runningWeight + currentWeight;
- if (RANDOM.nextDouble() <= (runningWeight / totalWeight)) {
- final Traverser.Admin<S> split = s.asAdmin().split();
- split.asAdmin().setBulk(1l);
- sampledSet.add(split);
- runningAmountToSample++;
- totalWeight = totalWeight - currentWeight;
- reSample = true;
- break;
- }
- }
- if (reSample || (runningAmountToSample >= this.amountToSample))
- break;
- }
- }
- }
- traverserSet.clear();
- traverserSet.addAll(sampledSet);
- }
-
- @Override
- public Set<TraverserRequirement> getRequirements() {
- return this.getSelfAndChildRequirements(TraverserRequirement.BULK);
- }
-
- @Override
- public SampleStep<S> clone() throws CloneNotSupportedException {
- final SampleStep<S> clone = (SampleStep<S>) super.clone();
- clone.probabilityTraversal = clone.integrateChild(this.probabilityTraversal.clone(), TYPICAL_LOCAL_OPERATIONS);
- return clone;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/1545201f/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/step/filter/SimplePathStep.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/step/filter/SimplePathStep.java b/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/step/filter/SimplePathStep.java
deleted file mode 100644
index e836813..0000000
--- a/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/step/filter/SimplePathStep.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * 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 com.tinkerpop.gremlin.process.graph.traversal.step.filter;
-
-
-import com.tinkerpop.gremlin.process.Traversal;
-import com.tinkerpop.gremlin.process.Traverser;
-import com.tinkerpop.gremlin.process.traversal.step.Reversible;
-import com.tinkerpop.gremlin.process.traverser.TraverserRequirement;
-
-import java.util.Collections;
-import java.util.Set;
-
-/**
- * @author Marko A. Rodriguez (http://markorodriguez.com)
- */
-public final class SimplePathStep<S> extends FilterStep<S> implements Reversible {
-
- public SimplePathStep(final Traversal.Admin traversal) {
- super(traversal);
- }
-
- @Override
- protected boolean filter(final Traverser.Admin<S> traverser) {
- return traverser.path().isSimple();
- }
-
- @Override
- public Set<TraverserRequirement> getRequirements() {
- return Collections.singleton(TraverserRequirement.PATH);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/1545201f/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/step/filter/TimeLimitStep.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/step/filter/TimeLimitStep.java b/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/step/filter/TimeLimitStep.java
deleted file mode 100644
index 34a3b27..0000000
--- a/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/step/filter/TimeLimitStep.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * 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 com.tinkerpop.gremlin.process.graph.traversal.step.filter;
-
-import com.tinkerpop.gremlin.process.FastNoSuchElementException;
-import com.tinkerpop.gremlin.process.Traversal;
-import com.tinkerpop.gremlin.process.Traverser;
-import com.tinkerpop.gremlin.process.traversal.step.Reversible;
-import com.tinkerpop.gremlin.process.traversal.util.TraversalHelper;
-
-import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.concurrent.atomic.AtomicLong;
-
-/**
- * @author Randall Barnhart (random pi)
- * @author Marko A. Rodriguez (http://markorodriguez.com)
- * @author Stephen Mallette (http://stephen.genoprime.com)
- */
-public final class TimeLimitStep<S> extends FilterStep<S> implements Reversible {
-
- private AtomicLong startTime = new AtomicLong(-1);
- private final long timeLimit;
- private AtomicBoolean timedOut = new AtomicBoolean(false);
-
-
- public TimeLimitStep(final Traversal.Admin traversal, final long timeLimit) {
- super(traversal);
- this.timeLimit = timeLimit;
- }
-
- @Override
- protected boolean filter(final Traverser.Admin<S> traverser) {
- if (this.startTime.get() == -1l)
- this.startTime.set(System.currentTimeMillis());
- if ((System.currentTimeMillis() - this.startTime.get()) >= this.timeLimit) {
- this.timedOut.set(true);
- throw FastNoSuchElementException.instance();
- }
- return true;
- }
-
- @Override
- public String toString() {
- return TraversalHelper.makeStepString(this, this.timeLimit);
- }
-
- @Override
- public void reset() {
- super.reset();
- this.startTime.set(-1l);
- this.timedOut.set(false);
- }
-
- public boolean getTimedOut() {
- return this.timedOut.get();
- }
-
- @Override
- public TimeLimitStep<S> clone() throws CloneNotSupportedException {
- final TimeLimitStep<S> clone = (TimeLimitStep<S>) super.clone();
- clone.timedOut = new AtomicBoolean(this.timedOut.get());
- clone.startTime = new AtomicLong(this.startTime.get());
- return clone;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/1545201f/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/step/filter/WhereStep.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/step/filter/WhereStep.java b/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/step/filter/WhereStep.java
deleted file mode 100644
index ccaa0c4..0000000
--- a/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/step/filter/WhereStep.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * 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 com.tinkerpop.gremlin.process.graph.traversal.step.filter;
-
-import com.tinkerpop.gremlin.process.Step;
-import com.tinkerpop.gremlin.process.Traversal;
-import com.tinkerpop.gremlin.process.Traverser;
-import com.tinkerpop.gremlin.process.graph.traversal.step.util.MarkerIdentityStep;
-import com.tinkerpop.gremlin.process.traversal.step.TraversalParent;
-import com.tinkerpop.gremlin.process.traversal.util.TraversalHelper;
-import com.tinkerpop.gremlin.process.traverser.TraverserRequirement;
-
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.function.BiPredicate;
-
-/**
- * @author Marko A. Rodriguez (http://markorodriguez.com)
- */
-public final class WhereStep<E> extends FilterStep<Map<String, E>> implements TraversalParent {
-
- private final String firstKey;
- private final String secondKey;
- private final BiPredicate biPredicate;
- private Traversal.Admin constraint;
-
-
- public WhereStep(final Traversal.Admin traversal, final String firstKey, final String secondKey, final BiPredicate<E, E> biPredicate) {
- super(traversal);
- this.firstKey = firstKey;
- this.secondKey = secondKey;
- this.biPredicate = biPredicate;
- this.constraint = null;
- }
-
- public WhereStep(final Traversal.Admin traversal, final Traversal.Admin constraint) {
- super(traversal);
- this.firstKey = null;
- this.secondKey = null;
- this.biPredicate = null;
- this.constraint = constraint;
- this.integrateChild(this.constraint, Operation.SET_PARENT);
- }
-
- @Override
- protected boolean filter(final Traverser.Admin<Map<String, E>> traverser) {
- if (null == this.constraint) {
- final Map<String, E> map = traverser.get();
- if (!map.containsKey(this.firstKey))
- throw new IllegalArgumentException("The provided key is not in the current map: " + this.firstKey);
- if (!map.containsKey(this.secondKey))
- throw new IllegalArgumentException("The provided key is not in the current map: " + this.secondKey);
- return this.biPredicate.test(map.get(this.firstKey), map.get(this.secondKey));
- } else {
- final Step<?, ?> startStep = this.constraint.getStartStep();
- Step<?, ?> endStep = this.constraint.getEndStep();
- if (endStep instanceof MarkerIdentityStep) // DAH!
- endStep = endStep.getPreviousStep();
-
- final Map<String, E> map = traverser.get();
- if (!map.containsKey(startStep.getLabel().get()))
- throw new IllegalArgumentException("The provided key is not in the current map: " + startStep.getLabel().get());
- final Object startObject = map.get(startStep.getLabel().get());
- final Object endObject;
- if (endStep.getLabel().isPresent()) {
- if (!map.containsKey(endStep.getLabel().get()))
- throw new IllegalArgumentException("The provided key is not in the current map: " + endStep.getLabel().get());
- endObject = map.get(endStep.getLabel().get());
- } else
- endObject = null;
-
- startStep.addStart(this.getTraversal().asAdmin().getTraverserGenerator().generate(startObject, (Step) startStep, traverser.bulk()));
- if (null == endObject) {
- if (this.constraint.hasNext()) {
- this.constraint.reset();
- return true;
- } else {
- return false;
- }
-
- } else {
- while (this.constraint.hasNext()) {
- if (this.constraint.next().equals(endObject)) {
- this.constraint.reset();
- return true;
- }
- }
- return false;
- }
- }
- }
-
- @Override
- public List<Traversal.Admin> getLocalChildren() {
- return null == this.constraint ? Collections.emptyList() : Collections.singletonList(this.constraint);
- }
-
- @Override
- public String toString() {
- return TraversalHelper.makeStepString(this, this.firstKey, this.biPredicate, this.secondKey, this.constraint);
- }
-
- @Override
- public WhereStep<E> clone() throws CloneNotSupportedException {
- final WhereStep<E> clone = (WhereStep<E>) super.clone();
- if (null != this.constraint)
- clone.constraint = clone.integrateChild(this.constraint.clone(), TYPICAL_LOCAL_OPERATIONS);
- return clone;
- }
-
- @Override
- public Set<TraverserRequirement> getRequirements() {
- return this.getSelfAndChildRequirements(TraverserRequirement.OBJECT);
- }
-}