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:03 UTC
[37/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/util/PathIdentityStep.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/step/util/PathIdentityStep.java b/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/step/util/PathIdentityStep.java
deleted file mode 100644
index 1f1b851..0000000
--- a/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/step/util/PathIdentityStep.java
+++ /dev/null
@@ -1,49 +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.util;
-
-import com.tinkerpop.gremlin.process.Traversal;
-import com.tinkerpop.gremlin.process.Traverser;
-import com.tinkerpop.gremlin.process.traverser.TraverserRequirement;
-import com.tinkerpop.gremlin.process.traversal.step.AbstractStep;
-
-import java.util.Collections;
-import java.util.NoSuchElementException;
-import java.util.Set;
-
-/**
- * @author Marko A. Rodriguez (http://markorodriguez.com)
- */
-public final class PathIdentityStep<S> extends AbstractStep<S, S> {
-
- public PathIdentityStep(final Traversal.Admin traversal) {
- super(traversal);
- }
-
- @Override
- protected Traverser<S> processNextStart() throws NoSuchElementException {
- return this.starts.next();
- }
-
- @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/util/ReducingBarrierStep.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/step/util/ReducingBarrierStep.java b/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/step/util/ReducingBarrierStep.java
deleted file mode 100644
index 35a293a..0000000
--- a/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/step/util/ReducingBarrierStep.java
+++ /dev/null
@@ -1,110 +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.util;
-
-import com.tinkerpop.gremlin.process.FastNoSuchElementException;
-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.AbstractStep;
-import com.tinkerpop.gremlin.process.traversal.step.Reducing;
-import com.tinkerpop.gremlin.process.traversal.util.TraversalHelper;
-
-import java.io.Serializable;
-import java.util.function.BiFunction;
-import java.util.function.Supplier;
-
-/**
- * @author Marko A. Rodriguez (http://markorodriguez.com)
- */
-public abstract class ReducingBarrierStep<S, E> extends AbstractStep<S, E> {
-
- private Supplier<E> seedSupplier;
- private BiFunction<E, Traverser<S>, E> reducingBiFunction;
- private boolean done = false;
-
- public ReducingBarrierStep(final Traversal.Admin traversal) {
- super(traversal);
- }
-
- public void setSeedSupplier(final Supplier<E> seedSupplier) {
- this.seedSupplier = seedSupplier;
- }
-
- public void setBiFunction(final BiFunction<E, Traverser<S>, E> reducingBiFunction) {
- this.reducingBiFunction = reducingBiFunction;
- }
-
- public Supplier<E> getSeedSupplier() {
- return this.seedSupplier;
- }
-
- public BiFunction<E, Traverser<S>, E> getBiFunction() {
- return this.reducingBiFunction;
- }
-
- @Override
- public void reset() {
- super.reset();
- this.done = false;
- }
-
- @Override
- public Traverser<E> processNextStart() {
- if (this.done)
- throw FastNoSuchElementException.instance();
- E seed = this.seedSupplier.get();
- while (this.starts.hasNext())
- seed = this.reducingBiFunction.apply(seed, this.starts.next());
- this.done = true;
- return TraversalHelper.getRootTraversal(this.getTraversal()).getTraverserGenerator().generate(Reducing.FinalGet.tryFinalGet(seed), (Step) this, 1l);
- }
-
- @Override
- public ReducingBarrierStep<S, E> clone() throws CloneNotSupportedException {
- final ReducingBarrierStep<S, E> clone = (ReducingBarrierStep<S, E>) super.clone();
- clone.done = false;
- return clone;
- }
-
- ///////
-
- public static class ObjectBiFunction<S, E> implements BiFunction<E, Traverser<S>, E>, Serializable {
-
- private final BiFunction<E, S, E> biFunction;
-
- public ObjectBiFunction(final BiFunction<E, S, E> biFunction) {
- this.biFunction = biFunction;
- }
-
- public final BiFunction<E, S, E> getBiFunction() {
- return this.biFunction;
- }
-
- @Override
- public E apply(final E seed, final Traverser<S> traverser) {
- return this.biFunction.apply(seed, traverser.get());
- }
-
- }
-
- ///////
-
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/1545201f/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/step/util/SupplyingBarrierStep.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/step/util/SupplyingBarrierStep.java b/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/step/util/SupplyingBarrierStep.java
deleted file mode 100644
index f9b8696..0000000
--- a/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/step/util/SupplyingBarrierStep.java
+++ /dev/null
@@ -1,64 +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.util;
-
-import com.tinkerpop.gremlin.process.FastNoSuchElementException;
-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.AbstractStep;
-
-/**
- * @author Marko A. Rodriguez (http://markorodriguez.com)
- */
-public abstract class SupplyingBarrierStep<S, E> extends AbstractStep<S, E> {
-
- private boolean done = false;
-
- public SupplyingBarrierStep(final Traversal.Admin traversal) {
- super(traversal);
- }
-
- public abstract E supply();
-
- @Override
- public void reset() {
- super.reset();
- this.done = false;
- }
-
- @Override
- public Traverser<E> processNextStart() {
- if (this.done)
- throw FastNoSuchElementException.instance();
- while (this.starts.hasNext())
- this.starts.next();
- this.done = true;
- return this.getTraversal().asAdmin().getTraverserGenerator().generate(this.supply(), (Step) this, 1l);
- }
-
- @Override
- public SupplyingBarrierStep<S, E> clone() throws CloneNotSupportedException {
- final SupplyingBarrierStep<S, E> clone = (SupplyingBarrierStep<S, E>) super.clone();
- clone.done = false;
- 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/strategy/AbstractTraversalStrategy.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/strategy/AbstractTraversalStrategy.java b/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/strategy/AbstractTraversalStrategy.java
deleted file mode 100644
index 2ca13da..0000000
--- a/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/strategy/AbstractTraversalStrategy.java
+++ /dev/null
@@ -1,43 +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.strategy;
-
-import com.tinkerpop.gremlin.process.TraversalStrategy;
-import com.tinkerpop.gremlin.structure.util.StringFactory;
-
-/**
- * @author Marko A. Rodriguez (http://markorodriguez.com)
- */
-public abstract class AbstractTraversalStrategy implements TraversalStrategy {
-
- @Override
- public String toString() {
- return StringFactory.traversalStrategyString(this);
- }
-
- @Override
- public int hashCode() {
- return this.getClass().hashCode();
- }
-
- @Override
- public boolean equals(final Object object) {
- return this.getClass().equals(object.getClass());
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/1545201f/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/strategy/ComparatorHolderRemovalStrategy.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/strategy/ComparatorHolderRemovalStrategy.java b/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/strategy/ComparatorHolderRemovalStrategy.java
deleted file mode 100644
index 2b19ccc..0000000
--- a/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/strategy/ComparatorHolderRemovalStrategy.java
+++ /dev/null
@@ -1,54 +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.strategy;
-
-import com.tinkerpop.gremlin.process.Step;
-import com.tinkerpop.gremlin.process.Traversal;
-import com.tinkerpop.gremlin.process.TraversalEngine;
-import com.tinkerpop.gremlin.process.graph.traversal.step.ComparatorHolder;
-import com.tinkerpop.gremlin.process.traversal.util.TraversalHelper;
-
-/**
- * @author Marko A. Rodriguez (http://markorodriguez.com)
- */
-public final class ComparatorHolderRemovalStrategy extends AbstractTraversalStrategy {
-
- private static final ComparatorHolderRemovalStrategy INSTANCE = new ComparatorHolderRemovalStrategy();
-
- private ComparatorHolderRemovalStrategy() {
- }
-
- @Override
- public void apply(final Traversal.Admin<?, ?> traversal, final TraversalEngine engine) {
- if (engine.equals(TraversalEngine.STANDARD))
- return;
-
- if (TraversalHelper.hasStepOfAssignableClass(ComparatorHolder.class, traversal)) {
- final Step endStep = traversal.getEndStep();
- TraversalHelper.getStepsOfAssignableClass(ComparatorHolder.class, traversal)
- .stream()
- .filter(step -> step != endStep)
- .forEach(step -> traversal.removeStep((Step)step));
- }
- }
-
- public static ComparatorHolderRemovalStrategy instance() {
- return INSTANCE;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/1545201f/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/strategy/ConjunctionStrategy.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/strategy/ConjunctionStrategy.java b/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/strategy/ConjunctionStrategy.java
deleted file mode 100644
index a82cb7e..0000000
--- a/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/strategy/ConjunctionStrategy.java
+++ /dev/null
@@ -1,83 +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.strategy;
-
-import com.tinkerpop.gremlin.process.Step;
-import com.tinkerpop.gremlin.process.Traversal;
-import com.tinkerpop.gremlin.process.TraversalEngine;
-import com.tinkerpop.gremlin.process.TraversalStrategy;
-import com.tinkerpop.gremlin.process.graph.traversal.__;
-import com.tinkerpop.gremlin.process.graph.traversal.step.filter.AndStep;
-import com.tinkerpop.gremlin.process.graph.traversal.step.filter.ConjunctionStep;
-import com.tinkerpop.gremlin.process.graph.traversal.step.filter.OrStep;
-import com.tinkerpop.gremlin.process.graph.traversal.step.sideEffect.StartStep;
-import com.tinkerpop.gremlin.process.traversal.step.EmptyStep;
-import com.tinkerpop.gremlin.process.traversal.util.TraversalHelper;
-
-/**
- * @author Marko A. Rodriguez (http://markorodriguez.com)
- */
-public final class ConjunctionStrategy extends AbstractTraversalStrategy implements TraversalStrategy {
-
- private static final ConjunctionStrategy INSTANCE = new ConjunctionStrategy();
-
- private ConjunctionStrategy() {
- }
-
- @Override
- public void apply(final Traversal.Admin<?, ?> traversal, final TraversalEngine traversalEngine) {
- processConjunctionMarker(AndStep.AndMarker.class, traversal);
- processConjunctionMarker(OrStep.OrMarker.class, traversal);
- }
-
- private static final boolean legalCurrentStep(final Step<?, ?> step) {
- return !(step instanceof EmptyStep || step instanceof OrStep.OrMarker || step instanceof AndStep.AndMarker || step instanceof StartStep);
- }
-
- private static final void processConjunctionMarker(final Class<? extends ConjunctionStep.ConjunctionMarker> markerClass, final Traversal.Admin<?, ?> traversal) {
- TraversalHelper.getStepsOfClass(markerClass, traversal).forEach(markerStep -> {
- Step<?, ?> currentStep = markerStep.getNextStep();
- final Traversal.Admin<?, ?> rightTraversal = __.start().asAdmin();
- while (legalCurrentStep(currentStep)) {
- final Step<?, ?> nextStep = currentStep.getNextStep();
- rightTraversal.addStep(currentStep);
- traversal.removeStep(currentStep);
- currentStep = nextStep;
- }
-
- currentStep = markerStep.getPreviousStep();
- final Traversal.Admin<?, ?> leftTraversal = __.start().asAdmin();
- while (legalCurrentStep(currentStep)) {
- final Step<?, ?> previousStep = currentStep.getPreviousStep();
- leftTraversal.addStep(0, currentStep);
- traversal.removeStep(currentStep);
- currentStep = previousStep;
- }
- TraversalHelper.replaceStep(markerStep,
- markerClass.equals(AndStep.AndMarker.class) ?
- new AndStep<Object>(traversal, (Traversal.Admin) leftTraversal, (Traversal.Admin) rightTraversal) :
- new OrStep<Object>(traversal, (Traversal.Admin) leftTraversal, (Traversal.Admin) rightTraversal),
- traversal);
- });
- }
-
- public static ConjunctionStrategy instance() {
- return INSTANCE;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/1545201f/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/strategy/DedupOptimizerStrategy.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/strategy/DedupOptimizerStrategy.java b/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/strategy/DedupOptimizerStrategy.java
deleted file mode 100644
index 0233d03..0000000
--- a/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/strategy/DedupOptimizerStrategy.java
+++ /dev/null
@@ -1,75 +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.strategy;
-
-import com.tinkerpop.gremlin.process.Step;
-import com.tinkerpop.gremlin.process.Traversal;
-import com.tinkerpop.gremlin.process.TraversalEngine;
-import com.tinkerpop.gremlin.process.graph.traversal.step.filter.DedupStep;
-import com.tinkerpop.gremlin.process.graph.traversal.step.map.OrderGlobalStep;
-import com.tinkerpop.gremlin.process.graph.traversal.step.sideEffect.IdentityStep;
-import com.tinkerpop.gremlin.process.traversal.lambda.IdentityTraversal;
-import com.tinkerpop.gremlin.process.traversal.util.TraversalHelper;
-
-import java.util.Arrays;
-import java.util.List;
-
-/**
- * @author Marko A. Rodriguez (http://markorodriguez.com)
- */
-public final class DedupOptimizerStrategy extends AbstractTraversalStrategy {
-
- private static final DedupOptimizerStrategy INSTANCE = new DedupOptimizerStrategy();
-
- private DedupOptimizerStrategy() {
- }
-
- private static final List<Class<? extends Step>> BIJECTIVE_PIPES = Arrays.asList(IdentityStep.class, OrderGlobalStep.class);
-
- @Override
- public void apply(final Traversal.Admin<?, ?> traversal, final TraversalEngine engine) {
- if (!TraversalHelper.hasStepOfClass(DedupStep.class, traversal))
- return;
-
- boolean done = false;
- while (!done) {
- done = true;
- for (int i = 0; i < traversal.getSteps().size(); i++) {
- final Step step1 = traversal.getSteps().get(i);
- if (step1 instanceof DedupStep && !(((DedupStep) step1).getLocalChildren().get(0) instanceof IdentityTraversal)) {
- for (int j = i; j >= 0; j--) {
- final Step step2 = traversal.getSteps().get(j);
- if (BIJECTIVE_PIPES.stream().filter(c -> c.isAssignableFrom(step2.getClass())).findAny().isPresent()) {
- traversal.removeStep(step1);
- traversal.addStep(j, step1);
- done = false;
- break;
- }
- }
- }
- if (!done)
- break;
- }
- }
- }
-
- public static DedupOptimizerStrategy instance() {
- return INSTANCE;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/1545201f/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/strategy/EngineDependentStrategy.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/strategy/EngineDependentStrategy.java b/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/strategy/EngineDependentStrategy.java
deleted file mode 100644
index 0066505..0000000
--- a/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/strategy/EngineDependentStrategy.java
+++ /dev/null
@@ -1,46 +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.strategy;
-
-import com.tinkerpop.gremlin.process.Traversal;
-import com.tinkerpop.gremlin.process.TraversalEngine;
-import com.tinkerpop.gremlin.process.TraversalStrategy;
-import com.tinkerpop.gremlin.process.traversal.step.EngineDependent;
-
-/**
- * @author Marko A. Rodriguez (http://markorodriguez.com)
- */
-public final class EngineDependentStrategy extends AbstractTraversalStrategy implements TraversalStrategy {
-
- private static final EngineDependentStrategy INSTANCE = new EngineDependentStrategy();
-
- private EngineDependentStrategy() {
- }
-
- @Override
- public void apply(final Traversal.Admin<?, ?> traversal, final TraversalEngine traversalEngine) {
- traversal.getSteps().stream()
- .filter(step -> step instanceof EngineDependent)
- .forEach(step -> ((EngineDependent) step).onEngine(traversalEngine));
- }
-
- public static EngineDependentStrategy instance() {
- return INSTANCE;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/1545201f/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/strategy/IdentityRemovalStrategy.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/strategy/IdentityRemovalStrategy.java b/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/strategy/IdentityRemovalStrategy.java
deleted file mode 100644
index 619ea73..0000000
--- a/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/strategy/IdentityRemovalStrategy.java
+++ /dev/null
@@ -1,49 +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.strategy;
-
-import com.tinkerpop.gremlin.process.Traversal;
-import com.tinkerpop.gremlin.process.TraversalEngine;
-import com.tinkerpop.gremlin.process.graph.traversal.step.sideEffect.IdentityStep;
-import com.tinkerpop.gremlin.process.traversal.util.TraversalHelper;
-
-/**
- * @author Marko A. Rodriguez (http://markorodriguez.com)
- */
-public final class IdentityRemovalStrategy extends AbstractTraversalStrategy {
-
- private static final IdentityRemovalStrategy INSTANCE = new IdentityRemovalStrategy();
-
- private IdentityRemovalStrategy() {
- }
-
- @Override
- public void apply(final Traversal.Admin<?, ?> traversal, final TraversalEngine engine) {
- if (!TraversalHelper.hasStepOfClass(IdentityStep.class, traversal))
- return;
-
- TraversalHelper.getStepsOfClass(IdentityStep.class, traversal).stream()
- .filter(step -> !step.getLabel().isPresent())
- .forEach(traversal::removeStep);
- }
-
- public static IdentityRemovalStrategy instance() {
- return INSTANCE;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/1545201f/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/strategy/LabeledEndStepStrategy.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/strategy/LabeledEndStepStrategy.java b/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/strategy/LabeledEndStepStrategy.java
deleted file mode 100644
index d04f9e3..0000000
--- a/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/strategy/LabeledEndStepStrategy.java
+++ /dev/null
@@ -1,50 +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.strategy;
-
-import com.tinkerpop.gremlin.process.Traversal;
-import com.tinkerpop.gremlin.process.TraversalEngine;
-import com.tinkerpop.gremlin.process.graph.traversal.step.util.MarkerIdentityStep;
-import com.tinkerpop.gremlin.structure.util.StringFactory;
-
-/**
- * @author Marko A. Rodriguez (http://markorodriguez.com)
- */
-public final class LabeledEndStepStrategy extends AbstractTraversalStrategy {
-
- private static final LabeledEndStepStrategy INSTANCE = new LabeledEndStepStrategy();
-
- private LabeledEndStepStrategy() {
- }
-
- @Override
- public void apply(final Traversal.Admin<?, ?> traversal, final TraversalEngine engine) {
- if (traversal.getEndStep().getLabel().isPresent())
- traversal.addStep(new MarkerIdentityStep<>(traversal));
- }
-
- public static LabeledEndStepStrategy instance() {
- return INSTANCE;
- }
-
- @Override
- public String toString() {
- return StringFactory.traversalStrategyString(this);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/1545201f/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/strategy/MatchWhereStrategy.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/strategy/MatchWhereStrategy.java b/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/strategy/MatchWhereStrategy.java
deleted file mode 100644
index a4deb00..0000000
--- a/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/strategy/MatchWhereStrategy.java
+++ /dev/null
@@ -1,90 +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.strategy;
-
-import com.tinkerpop.gremlin.process.Step;
-import com.tinkerpop.gremlin.process.Traversal;
-import com.tinkerpop.gremlin.process.TraversalEngine;
-import com.tinkerpop.gremlin.process.TraversalStrategy;
-import com.tinkerpop.gremlin.process.graph.traversal.step.filter.WhereStep;
-import com.tinkerpop.gremlin.process.graph.traversal.step.map.SelectOneStep;
-import com.tinkerpop.gremlin.process.graph.traversal.step.map.SelectStep;
-import com.tinkerpop.gremlin.process.graph.traversal.step.map.match.MatchStep;
-import com.tinkerpop.gremlin.process.graph.traversal.step.sideEffect.IdentityStep;
-import com.tinkerpop.gremlin.process.traversal.util.TraversalHelper;
-
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-/**
- * @author Marko A. Rodriguez (http://markorodriguez.com)
- */
-public final class MatchWhereStrategy extends AbstractTraversalStrategy implements TraversalStrategy {
-
- private static final MatchWhereStrategy INSTANCE = new MatchWhereStrategy();
- private static final Set<Class<? extends TraversalStrategy>> PRIORS = new HashSet<>();
-
- static {
- PRIORS.add(IdentityRemovalStrategy.class);
- }
-
- private MatchWhereStrategy() {
- }
-
- @Override
- public void apply(final Traversal.Admin<?, ?> traversal, TraversalEngine engine) {
- if (!TraversalHelper.hasStepOfClass(MatchStep.class, traversal))
- return;
-
- final List<MatchStep> matchSteps = TraversalHelper.getStepsOfClass(MatchStep.class, traversal);
- for (final MatchStep matchStep : matchSteps) {
- boolean foundWhereWithNoTraversal = false;
- Step currentStep = matchStep.getNextStep();
- while (currentStep instanceof WhereStep || currentStep instanceof SelectStep || currentStep instanceof SelectOneStep || currentStep instanceof IdentityStep) {
- if (currentStep instanceof WhereStep) {
- if (!((WhereStep) currentStep).getLocalChildren().isEmpty()) {
- matchStep.addTraversal(((WhereStep<?>) currentStep).getLocalChildren().get(0));
- traversal.removeStep(currentStep);
- } else {
- foundWhereWithNoTraversal = true;
- }
- } else if (currentStep instanceof SelectStep) {
- if (!((SelectStep) currentStep).getLocalChildren().isEmpty() || foundWhereWithNoTraversal)
- break;
- } else if (currentStep instanceof SelectOneStep) {
- if (!((SelectOneStep) currentStep).getLocalChildren().isEmpty() || foundWhereWithNoTraversal)
- break;
- }
- // else is the identity step
- currentStep = currentStep.getNextStep();
- }
- }
- }
-
- public static MatchWhereStrategy instance() {
- return INSTANCE;
- }
-
- @Override
- public Set<Class<? extends TraversalStrategy>> applyPrior() {
- return PRIORS;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/1545201f/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/strategy/ProfileStrategy.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/strategy/ProfileStrategy.java b/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/strategy/ProfileStrategy.java
deleted file mode 100644
index 7cb6fe7..0000000
--- a/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/strategy/ProfileStrategy.java
+++ /dev/null
@@ -1,84 +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.strategy;
-
-import com.tinkerpop.gremlin.process.Step;
-import com.tinkerpop.gremlin.process.Traversal;
-import com.tinkerpop.gremlin.process.TraversalEngine;
-import com.tinkerpop.gremlin.process.TraversalStrategy;
-import com.tinkerpop.gremlin.process.graph.traversal.step.sideEffect.ProfileStep;
-import com.tinkerpop.gremlin.process.traversal.util.TraversalHelper;
-
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-/**
- * @author Bob Briody (http://bobbriody.com)
- */
-public final class ProfileStrategy extends AbstractTraversalStrategy {
-
- private static final ProfileStrategy INSTANCE = new ProfileStrategy();
- private static final Set<Class<? extends TraversalStrategy>> PRIORS = new HashSet<>();
-
- static {
- // Ensure that this strategy is applied last.
- PRIORS.add(ComparatorHolderRemovalStrategy.class);
- PRIORS.add(DedupOptimizerStrategy.class);
- PRIORS.add(EngineDependentStrategy.class);
- PRIORS.add(IdentityRemovalStrategy.class);
- PRIORS.add(LabeledEndStepStrategy.class);
- PRIORS.add(MatchWhereStrategy.class);
- PRIORS.add(ReducingStrategy.class);
- PRIORS.add(SideEffectCapStrategy.class);
- PRIORS.add(SideEffectRegistrationStrategy.class);
- PRIORS.add(RangeByIsCountStrategy.class);
- }
-
- private ProfileStrategy() {
- }
-
- @Override
- public void apply(final Traversal.Admin<?, ?> traversal, final TraversalEngine traversalEngine) {
- if (!TraversalHelper.hasStepOfClass(ProfileStep.class, traversal))
- return;
-
- // Remove user-specified .profile() steps
- final List<ProfileStep> profileSteps = TraversalHelper.getStepsOfClass(ProfileStep.class, traversal);
- for (ProfileStep step : profileSteps) {
- traversal.removeStep(step);
- }
-
- // Add .profile() step after every pre-existing step.
- final List<Step> steps = traversal.getSteps();
- for (int ii = 0; ii < steps.size(); ii++) {
- traversal.addStep(ii + 1, new ProfileStep(traversal, steps.get(ii)));
- ii++;
- }
- }
-
- @Override
- public Set<Class<? extends TraversalStrategy>> applyPrior() {
- return PRIORS;
- }
-
- public static ProfileStrategy instance() {
- return INSTANCE;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/1545201f/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/strategy/RangeByIsCountStrategy.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/strategy/RangeByIsCountStrategy.java b/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/strategy/RangeByIsCountStrategy.java
deleted file mode 100644
index 7a4af41..0000000
--- a/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/strategy/RangeByIsCountStrategy.java
+++ /dev/null
@@ -1,91 +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.strategy;
-
-import com.tinkerpop.gremlin.process.Step;
-import com.tinkerpop.gremlin.process.Traversal;
-import com.tinkerpop.gremlin.process.TraversalEngine;
-import com.tinkerpop.gremlin.process.TraversalStrategy;
-import com.tinkerpop.gremlin.process.graph.traversal.step.filter.IsStep;
-import com.tinkerpop.gremlin.process.graph.traversal.step.filter.RangeStep;
-import com.tinkerpop.gremlin.process.graph.traversal.step.map.CountStep;
-import com.tinkerpop.gremlin.process.traversal.util.TraversalHelper;
-import com.tinkerpop.gremlin.structure.Compare;
-import com.tinkerpop.gremlin.structure.Contains;
-
-import java.util.*;
-import java.util.function.BiPredicate;
-
-/**
- * @author Daniel Kuppitz (http://gremlin.guru)
- */
-public final class RangeByIsCountStrategy extends AbstractTraversalStrategy implements TraversalStrategy {
-
- private static final Map<BiPredicate, Long> RANGE_PREDICATES = new HashMap<BiPredicate, Long>() {{
- put(Compare.inside, 0L);
- put(Compare.outside, 1L);
- put(Contains.within, 1L);
- put(Contains.without, 0L);
- }};
- private static final Set<Compare> INCREASED_OFFSET_SCALAR_PREDICATES =
- EnumSet.of(Compare.eq, Compare.neq, Compare.lte, Compare.gt);
-
- private static final RangeByIsCountStrategy INSTANCE = new RangeByIsCountStrategy();
-
- private RangeByIsCountStrategy() {
- }
-
- @Override
- public void apply(final Traversal.Admin<?, ?> traversal, final TraversalEngine engine) {
- final int size = traversal.getSteps().size();
- Step prev = null;
- for (int i = 0; i < size; i++) {
- final Step curr = traversal.getSteps().get(i);
- if (curr instanceof CountStep && i < size - 1) {
- final Step next = traversal.getSteps().get(i + 1);
- if (next instanceof IsStep && !(prev instanceof RangeStep)) { // if a RangeStep was provided, assume that the user knows what he's doing
- final IsStep isStep = (IsStep) next;
- final Object value = isStep.getValue();
- final BiPredicate predicate = isStep.getPredicate();
- if (value instanceof Number) {
- final long highRangeOffset = INCREASED_OFFSET_SCALAR_PREDICATES.contains(predicate) ? 1L : 0L;
- final long highRange = ((Number) value).longValue() + highRangeOffset;
- TraversalHelper.insertBeforeStep(new RangeStep<>(traversal, 0L, highRange), curr, traversal);
- i++;
- } else {
- final Long highRangeOffset = RANGE_PREDICATES.get(predicate);
- if (value instanceof Collection && highRangeOffset != null) {
- final Object high = Collections.max((Collection) value);
- if (high instanceof Number) {
- final long highRange = ((Number) high).longValue() + highRangeOffset;
- TraversalHelper.insertBeforeStep(new RangeStep<>(traversal, 0L, highRange), curr, traversal);
- i++;
- }
- }
- }
- }
- }
- prev = curr;
- }
- }
-
- public static RangeByIsCountStrategy instance() {
- return INSTANCE;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/1545201f/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/strategy/ReducingStrategy.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/strategy/ReducingStrategy.java b/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/strategy/ReducingStrategy.java
deleted file mode 100644
index 86db4f5..0000000
--- a/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/strategy/ReducingStrategy.java
+++ /dev/null
@@ -1,78 +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.strategy;
-
-import com.tinkerpop.gremlin.process.Step;
-import com.tinkerpop.gremlin.process.Traversal;
-import com.tinkerpop.gremlin.process.TraversalEngine;
-import com.tinkerpop.gremlin.process.Traverser;
-import com.tinkerpop.gremlin.process.traversal.step.Reducing;
-import com.tinkerpop.gremlin.process.traversal.step.AbstractStep;
-import com.tinkerpop.gremlin.process.traversal.util.TraversalHelper;
-
-/**
- * @author Marko A. Rodriguez (http://markorodriguez.com)
- */
-public final class ReducingStrategy extends AbstractTraversalStrategy {
-
- private static final ReducingStrategy INSTANCE = new ReducingStrategy();
-
- private ReducingStrategy() {
- }
-
- @Override
- public void apply(final Traversal.Admin<?, ?> traversal, final TraversalEngine engine) {
- if (engine.equals(TraversalEngine.STANDARD))
- return;
-
- final Step endStep = traversal.getEndStep();
- if (endStep instanceof Reducing)
- TraversalHelper.replaceStep(endStep, new ReducingIdentity(traversal, (Reducing) endStep), traversal);
- }
-
- public static ReducingStrategy instance() {
- return INSTANCE;
- }
-
- private static class ReducingIdentity extends AbstractStep implements Reducing {
-
- private final Reducer reducer;
- private String reducingStepString;
-
- public ReducingIdentity(final Traversal.Admin traversal, final Reducing reducingStep) {
- super(traversal);
- this.reducer = reducingStep.getReducer();
- this.reducingStepString = reducingStep.toString();
- }
-
- @Override
- public String toString() {
- return TraversalHelper.makeStepString(this, this.reducingStepString);
- }
-
- public Reducer getReducer() {
- return this.reducer;
- }
-
- public Traverser processNextStart() {
- return this.starts.next();
- }
-
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/1545201f/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/strategy/SideEffectCapStrategy.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/strategy/SideEffectCapStrategy.java b/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/strategy/SideEffectCapStrategy.java
deleted file mode 100644
index cd6f786..0000000
--- a/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/strategy/SideEffectCapStrategy.java
+++ /dev/null
@@ -1,58 +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.strategy;
-
-import com.tinkerpop.gremlin.process.Traversal;
-import com.tinkerpop.gremlin.process.TraversalEngine;
-import com.tinkerpop.gremlin.process.TraversalStrategy;
-import com.tinkerpop.gremlin.process.graph.traversal.GraphTraversal;
-import com.tinkerpop.gremlin.process.graph.traversal.step.SideEffectCapable;
-import com.tinkerpop.gremlin.process.traversal.step.EmptyStep;
-
-import java.util.Collections;
-import java.util.Set;
-
-/**
- * @author Marko A. Rodriguez (http://markorodriguez.com)
- */
-
-public final class SideEffectCapStrategy extends AbstractTraversalStrategy implements TraversalStrategy {
-
- private static final SideEffectCapStrategy INSTANCE = new SideEffectCapStrategy();
- private static final Set<Class<? extends TraversalStrategy>> POSTS = Collections.singleton(LabeledEndStepStrategy.class);
-
- private SideEffectCapStrategy() {
- }
-
- @Override
- public void apply(final Traversal.Admin<?, ?> traversal, final TraversalEngine engine) {
- if (traversal.getEndStep() instanceof SideEffectCapable && traversal.getParent() instanceof EmptyStep) {
- ((GraphTraversal) traversal).cap();
- }
- }
-
- @Override
- public Set<Class<? extends TraversalStrategy>> applyPost() {
- return POSTS;
- }
-
- public static SideEffectCapStrategy instance() {
- return INSTANCE;
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/1545201f/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/strategy/SideEffectRegistrationStrategy.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/strategy/SideEffectRegistrationStrategy.java b/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/strategy/SideEffectRegistrationStrategy.java
deleted file mode 100644
index 12fea4d..0000000
--- a/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/strategy/SideEffectRegistrationStrategy.java
+++ /dev/null
@@ -1,55 +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.strategy;
-
-import com.tinkerpop.gremlin.process.Traversal;
-import com.tinkerpop.gremlin.process.TraversalEngine;
-import com.tinkerpop.gremlin.process.TraversalStrategy;
-import com.tinkerpop.gremlin.process.traversal.step.SideEffectRegistrar;
-import com.tinkerpop.gremlin.process.traversal.util.TraversalHelper;
-
-import java.util.Collections;
-import java.util.Set;
-
-/**
- * @author Marko A. Rodriguez (http://markorodriguez.com)
- */
-public final class SideEffectRegistrationStrategy extends AbstractTraversalStrategy implements TraversalStrategy {
-
- private static final SideEffectRegistrationStrategy INSTANCE = new SideEffectRegistrationStrategy();
-
- private static final Set<Class<? extends TraversalStrategy>> PRIORS = Collections.singleton(SideEffectCapStrategy.class);
-
- private SideEffectRegistrationStrategy() {
- }
-
- @Override
- public void apply(final Traversal.Admin<?, ?> traversal, final TraversalEngine engine) {
- TraversalHelper.getStepsOfAssignableClass(SideEffectRegistrar.class, traversal).forEach(SideEffectRegistrar::registerSideEffects);
- }
-
- @Override
- public Set<Class<? extends TraversalStrategy>> applyPrior() {
- return PRIORS;
- }
-
- public static SideEffectRegistrationStrategy instance() {
- return INSTANCE;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/1545201f/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/strategy/TraversalVerificationStrategy.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/strategy/TraversalVerificationStrategy.java b/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/strategy/TraversalVerificationStrategy.java
deleted file mode 100644
index 6ea8957..0000000
--- a/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/strategy/TraversalVerificationStrategy.java
+++ /dev/null
@@ -1,69 +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.strategy;
-
-import com.tinkerpop.gremlin.process.Step;
-import com.tinkerpop.gremlin.process.Traversal;
-import com.tinkerpop.gremlin.process.TraversalEngine;
-import com.tinkerpop.gremlin.process.traversal.step.TraversalParent;
-import com.tinkerpop.gremlin.process.graph.traversal.step.util.ComputerAwareStep;
-import com.tinkerpop.gremlin.process.graph.traversal.step.util.ReducingBarrierStep;
-import com.tinkerpop.gremlin.process.graph.traversal.step.util.SupplyingBarrierStep;
-import com.tinkerpop.gremlin.process.traversal.step.EmptyStep;
-import com.tinkerpop.gremlin.process.traversal.util.TraversalHelper;
-
-import java.util.Optional;
-
-/**
- * @author Marko A. Rodriguez (http://markorodriguez.com)
- */
-public final class TraversalVerificationStrategy extends AbstractTraversalStrategy {
-
- private static final TraversalVerificationStrategy INSTANCE = new TraversalVerificationStrategy();
-
- private TraversalVerificationStrategy() {
- }
-
- @Override
- public void apply(final Traversal.Admin<?, ?> traversal, final TraversalEngine engine) {
- if (engine.equals(TraversalEngine.STANDARD))
- return;
-
- final Step<?, ?> endStep = traversal.getEndStep() instanceof ComputerAwareStep.EndStep ?
- ((ComputerAwareStep.EndStep) traversal.getEndStep()).getPreviousStep() :
- traversal.getEndStep();
-
- for (final Step<?, ?> step : traversal.getSteps()) {
- if ((step instanceof ReducingBarrierStep || step instanceof SupplyingBarrierStep) && (step != endStep || !(traversal.getParent() instanceof EmptyStep))) {
- throw new IllegalStateException("Global traversals on GraphComputer may not contain mid-traversal barriers: " + step);
- }
- if (step instanceof TraversalParent) {
- final Optional<Traversal.Admin<Object, Object>> traversalOptional = ((TraversalParent) step).getLocalChildren().stream()
- .filter(t -> !TraversalHelper.isLocalStarGraph(t.asAdmin()))
- .findAny();
- if (traversalOptional.isPresent())
- throw new IllegalStateException("Local traversals on GraphComputer may not traverse past the local star-graph: " + traversalOptional.get());
- }
- }
- }
-
- public static TraversalVerificationStrategy instance() {
- return INSTANCE;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/1545201f/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/util/EmptyGraphTraversal.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/util/EmptyGraphTraversal.java b/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/util/EmptyGraphTraversal.java
deleted file mode 100644
index 88018f4..0000000
--- a/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/traversal/util/EmptyGraphTraversal.java
+++ /dev/null
@@ -1,70 +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.util;
-
-import com.tinkerpop.gremlin.process.Step;
-import com.tinkerpop.gremlin.process.computer.GraphComputer;
-import com.tinkerpop.gremlin.process.graph.traversal.GraphTraversal;
-import com.tinkerpop.gremlin.process.traversal.util.EmptyTraversal;
-
-/**
- * @author Marko A. Rodriguez (http://markorodriguez.com)
- */
-public final class EmptyGraphTraversal<S, E> extends EmptyTraversal<S, E> implements GraphTraversal.Admin<S, E>, GraphTraversal<S, E> {
-
- private static final EmptyGraphTraversal INSTANCE = new EmptyGraphTraversal<>();
-
- public static <A, B> EmptyGraphTraversal<A, B> instance() {
- return INSTANCE;
- }
-
- private EmptyGraphTraversal() {
-
- }
-
- @Override
- public GraphTraversal.Admin<S, E> asAdmin() {
- return this;
- }
-
- @Override
- public <E2> GraphTraversal.Admin<S, E2> addStep(final Step<?, E2> step) {
- return instance();
- }
-
- @Override
- public GraphTraversal<S, E> withPath() {
- return instance();
- }
-
- @Override
- public GraphTraversal<S, E> submit(final GraphComputer computer) {
- return instance();
- }
-
- @Override
- public GraphTraversal<S, E> iterate() {
- return this;
- }
-
- @Override
- public EmptyGraphTraversal<S, E> clone() throws CloneNotSupportedException {
- return instance();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/1545201f/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/util/HasContainer.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/util/HasContainer.java b/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/util/HasContainer.java
deleted file mode 100644
index 468b4fd..0000000
--- a/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/util/HasContainer.java
+++ /dev/null
@@ -1,114 +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.util;
-
-import com.tinkerpop.gremlin.process.T;
-import com.tinkerpop.gremlin.structure.Contains;
-import com.tinkerpop.gremlin.structure.Element;
-import com.tinkerpop.gremlin.structure.Graph;
-import com.tinkerpop.gremlin.structure.Property;
-import com.tinkerpop.gremlin.structure.Vertex;
-import com.tinkerpop.gremlin.structure.VertexProperty;
-
-import java.io.Serializable;
-import java.util.Iterator;
-import java.util.List;
-import java.util.function.BiPredicate;
-
-/**
- * @author Marko A. Rodriguez (http://markorodriguez.com)
- */
-public final class HasContainer implements Serializable {
-
- public String key;
- public BiPredicate predicate;
- public Object value;
-
- public HasContainer(final String key, final BiPredicate predicate, final Object value) {
- this.key = key;
- this.predicate = predicate;
- this.value = value;
- if (null == this.value && !(this.predicate instanceof Contains)) {
- throw new IllegalArgumentException("For determining the existence of a property, use the Contains predicate");
- }
- }
-
- public HasContainer(final String key, final Contains contains) {
- this(key, contains, null);
- }
-
- public HasContainer(final T accessor, final BiPredicate predicate, final Object value) {
- this(accessor.getAccessor(), predicate, value);
- }
-
- public HasContainer(final T accessor, final Contains contains) {
- this(accessor.getAccessor(), contains, null);
- }
-
- public boolean test(final Element element) {
- if (null != this.value) {
- if (this.key.equals(T.id.getAccessor()))
- return this.predicate.test(element.id(), this.value);
- else if (this.key.equals(T.label.getAccessor()))
- return this.predicate.test(element.label(), this.value);
- else if (element instanceof VertexProperty && this.key.equals(T.value.getAccessor()))
- return this.predicate.test(((VertexProperty) element).value(), this.value);
- else if (element instanceof VertexProperty && this.key.equals(T.key.getAccessor()))
- return this.predicate.test(((VertexProperty) element).key(), this.value);
- else {
- if (element instanceof Vertex) {
- final Iterator<? extends Property> itty = element.iterators().propertyIterator(this.key);
- while (itty.hasNext()) {
- if (this.predicate.test(itty.next().value(), this.value))
- return true;
- }
- return false;
- } else {
- final Property property = element.property(this.key);
- return property.isPresent() && this.predicate.test(property.value(), this.value);
- }
- }
- } else {
- return Contains.within.equals(this.predicate) ?
- element.property(this.key).isPresent() :
- !element.property(this.key).isPresent();
- }
- }
-
- public static boolean testAll(final Element element, final List<HasContainer> hasContainers) {
- if (hasContainers.size() == 0)
- return true;
- else {
- for (final HasContainer hasContainer : hasContainers) {
- if (!hasContainer.test(element))
- return false;
- }
- return true;
- }
- }
-
- // note that if the user is looking for a label property key (e.g.), then it will look the same as looking for the label of the element.
- public String toString() {
- return this.value == null ?
- (this.predicate == Contains.within ?
- '[' + this.key + ']' :
- "[!" + this.key + ']') :
- '[' + this.key + ',' + this.predicate + ',' + this.value + ']';
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/1545201f/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/util/Tree.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/util/Tree.java b/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/util/Tree.java
deleted file mode 100644
index 04d0584..0000000
--- a/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/graph/util/Tree.java
+++ /dev/null
@@ -1,134 +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.util;
-
-import java.io.Serializable;
-import java.util.*;
-
-/**
- * @author Marko A. Rodriguez (http://markorodriguez.com)
- */
-public class Tree<T> extends HashMap<T, Tree<T>> implements Serializable {
-
- public Tree() {
- super();
- }
-
- @SafeVarargs
- public Tree(final T... children) {
- this();
- for (final T t : children) {
- this.put(t, new Tree<>());
- }
- }
-
- @SafeVarargs
- public Tree(final Map.Entry<T, Tree<T>>... children) {
- this();
- for (final Map.Entry<T, Tree<T>> entry : children) {
- this.put(entry.getKey(), entry.getValue());
- }
- }
-
-
- public List<Tree<T>> getTreesAtDepth(final int depth) {
- List<Tree<T>> currentDepth = Collections.singletonList(this);
- for (int i = 0; i < depth; i++) {
- if (i == depth - 1) {
- return currentDepth;
- } else {
- final List<Tree<T>> temp = new ArrayList<Tree<T>>();
- for (final Tree<T> t : currentDepth) {
- temp.addAll(t.values());
- }
- currentDepth = temp;
- }
- }
- return Collections.emptyList();
- }
-
- public List<T> getObjectsAtDepth(final int depth) {
- final List<T> list = new ArrayList<T>();
- for (final Tree<T> t : this.getTreesAtDepth(depth)) {
- list.addAll(t.keySet());
- }
- return list;
- }
-
- public List<Tree<T>> getLeafTrees() {
- final List<Tree<T>> leaves = new ArrayList<>();
- List<Tree<T>> currentDepth = Collections.singletonList(this);
- boolean allLeaves = false;
- while (!allLeaves) {
- allLeaves = true;
- final List<Tree<T>> temp = new ArrayList<>();
- for (final Tree<T> t : currentDepth) {
- if (t.isLeaf()) {
- for (Map.Entry<T, Tree<T>> t2 : t.entrySet()) {
- leaves.add(new Tree<T>(t2));
- }
- } else {
- allLeaves = false;
- temp.addAll(t.values());
- }
- }
- currentDepth = temp;
-
- }
- return leaves;
- }
-
- public List<T> getLeafObjects() {
- final List<T> leaves = new ArrayList<T>();
- for (final Tree<T> t : this.getLeafTrees()) {
- leaves.addAll(t.keySet());
- }
- return leaves;
- }
-
- public boolean isLeaf() {
- final Collection<Tree<T>> values = this.values();
- return values.iterator().next().isEmpty();
-
- }
-
- public void addTree(final Tree<T> tree) {
- tree.forEach((k, t) -> {
- if (this.containsKey(k)) {
- this.get(k).addTree(t);
- } else {
- this.put(k, t);
- }
- });
- }
-
- public List<Tree<T>> splitParents() {
- if (this.keySet().size() == 1) {
- return Collections.singletonList(this);
- } else {
- final List<Tree<T>> parents = new ArrayList<>();
- this.forEach((k, t) -> {
- final Tree<T> parentTree = new Tree<>();
- parentTree.put(k, t);
- parents.add(parentTree);
- });
- return parents;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/1545201f/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/traversal/DefaultTraversal.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/traversal/DefaultTraversal.java b/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/traversal/DefaultTraversal.java
deleted file mode 100644
index c2e93c8..0000000
--- a/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/traversal/DefaultTraversal.java
+++ /dev/null
@@ -1,222 +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.traversal;
-
-import com.tinkerpop.gremlin.process.*;
-import com.tinkerpop.gremlin.process.traversal.step.EmptyStep;
-import com.tinkerpop.gremlin.process.traversal.step.TraversalParent;
-import com.tinkerpop.gremlin.process.traversal.util.TraversalHelper;
-
-import java.util.*;
-
-/**
- * @author Marko A. Rodriguez (http://markorodriguez.com)
- */
-public class DefaultTraversal<S, E> implements Traversal.Admin<S, E> {
-
- private E lastEnd = null;
- private long lastEndCount = 0l;
- private Step<?, E> finalEndStep = EmptyStep.instance();
- private final StepPosition stepPosition = new StepPosition();
-
- protected List<Step> steps = new ArrayList<>();
- protected TraversalStrategies strategies;
- protected TraversalSideEffects sideEffects = new DefaultTraversalSideEffects();
- protected TraversalEngine traversalEngine = null;
-
- protected TraversalParent traversalParent = (TraversalParent) EmptyStep.instance();
-
- public DefaultTraversal(final Class emanatingClass) {
- this.setStrategies(TraversalStrategies.GlobalCache.getStrategies(emanatingClass));
- }
-
- @Override
- public Traversal.Admin<S, E> asAdmin() {
- return this;
- }
-
- @Override
- public void applyStrategies(final TraversalEngine engine) throws IllegalStateException {
- if (null != this.traversalEngine) throw Traversal.Exceptions.traversalIsLocked();
-
- TraversalHelper.reIdSteps(this.stepPosition, this);
- this.strategies.applyStrategies(this, engine);
- for (final Step<?, ?> step : this.getSteps()) {
- if (step instanceof TraversalParent) {
- ((TraversalParent) step).setChildStrategies(this.strategies); // TODO: should we clone?
- for (final Traversal.Admin<?, ?> globalChild : ((TraversalParent) step).getGlobalChildren()) {
- globalChild.applyStrategies(engine);
- }
- for (final Traversal.Admin<?, ?> localChild : ((TraversalParent) step).getLocalChildren()) {
- localChild.applyStrategies(TraversalEngine.STANDARD);
- }
- }
- }
- this.traversalEngine = engine;
- this.finalEndStep = this.getEndStep();
- }
-
- @Override
- public Optional<TraversalEngine> getEngine() {
- return Optional.ofNullable(this.traversalEngine);
- }
-
- @Override
- public List<Step> getSteps() {
- return Collections.unmodifiableList(this.steps);
- }
-
- @Override
- public boolean hasNext() {
- if (null == this.traversalEngine) this.applyStrategies(TraversalEngine.STANDARD);
- return this.lastEndCount > 0l || this.finalEndStep.hasNext();
- }
-
- @Override
- public E next() {
- if (null == this.traversalEngine) this.applyStrategies(TraversalEngine.STANDARD);
- if (this.lastEndCount > 0l) {
- this.lastEndCount--;
- return this.lastEnd;
- } else {
- final Traverser<E> next = this.finalEndStep.next();
- final long nextBulk = next.bulk();
- if (nextBulk == 1) {
- return next.get();
- } else {
- this.lastEndCount = nextBulk - 1;
- this.lastEnd = next.get();
- return this.lastEnd;
- }
- }
- }
-
- @Override
- public void reset() {
- this.steps.forEach(Step::reset);
- this.lastEndCount = 0l;
- }
-
- @Override
- public void addStart(final Traverser<S> start) {
- if (null == this.traversalEngine) this.applyStrategies(TraversalEngine.STANDARD);
- if (!this.steps.isEmpty()) this.steps.get(0).addStart(start);
- }
-
- @Override
- public void addStarts(final Iterator<Traverser<S>> starts) {
- if (null == this.traversalEngine) this.applyStrategies(TraversalEngine.STANDARD);
- if (!this.steps.isEmpty()) this.steps.get(0).addStarts(starts);
- }
-
- @Override
- public String toString() {
- return TraversalHelper.makeTraversalString(this);
- }
-
- @Override
- public Step<S, ?> getStartStep() {
- return this.steps.isEmpty() ? EmptyStep.instance() : this.steps.get(0);
- }
-
- @Override
- public Step<?, E> getEndStep() {
- return this.steps.isEmpty() ? EmptyStep.instance() : this.steps.get(this.steps.size() - 1);
- }
-
- @Override
- public DefaultTraversal<S, E> clone() throws CloneNotSupportedException {
- final DefaultTraversal<S, E> clone = (DefaultTraversal<S, E>) super.clone();
- clone.steps = new ArrayList<>();
- clone.sideEffects = this.sideEffects.clone();
- clone.strategies = this.strategies.clone(); // TODO: does this need to be cloned?
- clone.lastEnd = null;
- clone.lastEndCount = 0l;
- for (final Step<?, ?> step : this.steps) {
- final Step<?, ?> clonedStep = step.clone();
- clonedStep.setTraversal(clone);
- final Step previousStep = clone.steps.isEmpty() ? EmptyStep.instance() : clone.steps.get(clone.steps.size() - 1);
- clonedStep.setPreviousStep(previousStep);
- previousStep.setNextStep(clonedStep);
- clone.steps.add(clonedStep);
- }
- clone.finalEndStep = clone.getEndStep();
- return clone;
- }
-
- @Override
- public void setSideEffects(final TraversalSideEffects sideEffects) {
- this.sideEffects = sideEffects;
- }
-
- @Override
- public TraversalSideEffects getSideEffects() {
- return this.sideEffects;
- }
-
- @Override
- public void setStrategies(final TraversalStrategies strategies) {
- try {
- this.strategies = strategies.clone();
- } catch (CloneNotSupportedException e) {
- throw new IllegalStateException(e.getMessage(), e);
- }
- }
-
- @Override
- public TraversalStrategies getStrategies() {
- return this.strategies;
- }
-
- @Override
- public <S2, E2> Traversal.Admin<S2, E2> addStep(final int index, final Step<?, ?> step) throws IllegalStateException {
- if (null != this.traversalEngine) throw Exceptions.traversalIsLocked();
- step.setId(this.stepPosition.nextXId());
- this.steps.add(index, step);
- final Step previousStep = this.steps.size() > 0 && index != 0 ? steps.get(index - 1) : null;
- final Step nextStep = this.steps.size() > index + 1 ? steps.get(index + 1) : null;
- step.setPreviousStep(null != previousStep ? previousStep : EmptyStep.instance());
- step.setNextStep(null != nextStep ? nextStep : EmptyStep.instance());
- if (null != previousStep) previousStep.setNextStep(step);
- if (null != nextStep) nextStep.setPreviousStep(step);
- return (Traversal.Admin<S2, E2>) this;
- }
-
- @Override
- public <S2, E2> Traversal.Admin<S2, E2> removeStep(final int index) throws IllegalStateException {
- if (null != this.traversalEngine) throw Exceptions.traversalIsLocked();
- final Step previousStep = this.steps.size() > 0 && index != 0 ? steps.get(index - 1) : null;
- final Step nextStep = this.steps.size() > index + 1 ? steps.get(index + 1) : null;
- this.steps.remove(index);
- if (null != previousStep) previousStep.setNextStep(null == nextStep ? EmptyStep.instance() : nextStep);
- if (null != nextStep) nextStep.setPreviousStep(null == previousStep ? EmptyStep.instance() : previousStep);
- return (Traversal.Admin<S2, E2>) this;
- }
-
- @Override
- public void setParent(final TraversalParent step) {
- this.traversalParent = step;
- }
-
- @Override
- public TraversalParent getParent() {
- return this.traversalParent;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/1545201f/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/traversal/DefaultTraversalSideEffects.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/traversal/DefaultTraversalSideEffects.java b/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/traversal/DefaultTraversalSideEffects.java
deleted file mode 100644
index e467bf2..0000000
--- a/gremlin-core/src/main/java/com/tinkerpop/gremlin/process/traversal/DefaultTraversalSideEffects.java
+++ /dev/null
@@ -1,198 +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.traversal;
-
-import com.tinkerpop.gremlin.process.TraversalSideEffects;
-import com.tinkerpop.gremlin.process.traversal.util.SideEffectHelper;
-import com.tinkerpop.gremlin.structure.Property;
-import com.tinkerpop.gremlin.structure.Vertex;
-import com.tinkerpop.gremlin.structure.util.StringFactory;
-
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Optional;
-import java.util.Set;
-import java.util.function.Supplier;
-import java.util.function.UnaryOperator;
-
-/**
- * @author Marko A. Rodriguez (http://markorodriguez.com)
- */
-public class DefaultTraversalSideEffects implements TraversalSideEffects {
-
- protected Map<String, Object> objectMap = new HashMap<>();
- protected Map<String, Supplier> supplierMap = new HashMap<>();
- protected UnaryOperator sackSplitOperator = null;
- protected Supplier sackInitialValue = null;
-
- public DefaultTraversalSideEffects() {
-
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void registerSupplier(final String key, final Supplier supplier) {
- this.supplierMap.put(key, supplier);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public <V> Optional<Supplier<V>> getRegisteredSupplier(final String key) {
- return Optional.ofNullable(this.supplierMap.get(key));
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void registerSupplierIfAbsent(final String key, final Supplier supplier) {
- if (!this.supplierMap.containsKey(key))
- this.supplierMap.put(key, supplier);
- }
-
- @Override
- public <S> void setSack(final Supplier<S> initialValue, final Optional<UnaryOperator<S>> splitOperator) {
- this.sackInitialValue = initialValue;
- this.sackSplitOperator = splitOperator.orElse(null);
- }
-
- @Override
- public <S> Optional<Supplier<S>> getSackInitialValue() {
- return Optional.ofNullable(this.sackInitialValue);
- }
-
- @Override
- public <S> Optional<UnaryOperator<S>> getSackSplitOperator() {
- return Optional.ofNullable(this.sackSplitOperator);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean exists(final String key) {
- return this.objectMap.containsKey(key) || this.supplierMap.containsKey(key);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void set(final String key, final Object value) {
- SideEffectHelper.validateSideEffect(key, value);
- this.objectMap.put(key, value);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public <V> V get(final String key) throws IllegalArgumentException {
- final V value = (V) this.objectMap.get(key);
- if (null != value)
- return value;
- else {
- if (this.supplierMap.containsKey(key)) {
- final V v = (V) this.supplierMap.get(key).get();
- this.objectMap.put(key, v);
- return v;
- } else {
- throw TraversalSideEffects.Exceptions.sideEffectDoesNotExist(key);
- }
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public <V> V getOrCreate(final String key, final Supplier<V> orCreate) {
- if (this.objectMap.containsKey(key))
- return (V) this.objectMap.get(key);
- else if (this.supplierMap.containsKey(key)) {
- final V value = (V) this.supplierMap.get(key).get();
- this.objectMap.put(key, value);
- return value;
- } else {
- final V value = orCreate.get();
- this.objectMap.put(key, value);
- return value;
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void remove(final String key) {
- this.objectMap.remove(key);
- this.supplierMap.remove(key);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public Set<String> keys() {
- final Set<String> keys = new HashSet<>();
- keys.addAll(this.objectMap.keySet());
- keys.addAll(this.supplierMap.keySet());
- return Collections.unmodifiableSet(keys);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void setLocalVertex(final Vertex vertex) {
- final Property<Map<String, Object>> property = vertex.property(SIDE_EFFECTS);
- if (property.isPresent()) {
- this.objectMap = property.value();
- } else {
- this.objectMap = new HashMap<>();
- vertex.property(SIDE_EFFECTS, this.objectMap);
- }
- }
-
- @Override
- public void mergeInto(final TraversalSideEffects sideEffects) {
- this.objectMap.forEach(sideEffects::set);
- this.supplierMap.forEach(sideEffects::registerSupplierIfAbsent);
- // TODO: add sack information?
- }
-
- @Override
- public String toString() {
- return StringFactory.traversalSideEffectsString(this);
- }
-
- @Override
- public DefaultTraversalSideEffects clone() throws CloneNotSupportedException {
- final DefaultTraversalSideEffects sideEffects = (DefaultTraversalSideEffects) super.clone();
- sideEffects.objectMap = new HashMap<>(this.objectMap);
- sideEffects.supplierMap = new HashMap<>(this.supplierMap);
- return sideEffects;
- }
-}