Return-Path: X-Original-To: apmail-tinkerpop-commits-archive@minotaur.apache.org Delivered-To: apmail-tinkerpop-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id F0638182F0 for ; Tue, 1 Dec 2015 22:56:33 +0000 (UTC) Received: (qmail 78565 invoked by uid 500); 1 Dec 2015 22:56:33 -0000 Delivered-To: apmail-tinkerpop-commits-archive@tinkerpop.apache.org Received: (qmail 78541 invoked by uid 500); 1 Dec 2015 22:56:33 -0000 Mailing-List: contact commits-help@tinkerpop.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@tinkerpop.incubator.apache.org Delivered-To: mailing list commits@tinkerpop.incubator.apache.org Received: (qmail 78532 invoked by uid 99); 1 Dec 2015 22:56:33 -0000 Received: from Unknown (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 01 Dec 2015 22:56:33 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id 099CEC2E33 for ; Tue, 1 Dec 2015 22:56:33 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 1.771 X-Spam-Level: * X-Spam-Status: No, score=1.771 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, T_RP_MATCHES_RCVD=-0.01, URIBL_BLOCKED=0.001] autolearn=disabled Received: from mx1-us-west.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id dnWjz_1fo5sN for ; Tue, 1 Dec 2015 22:56:27 +0000 (UTC) Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx1-us-west.apache.org (ASF Mail Server at mx1-us-west.apache.org) with SMTP id C65D520CFA for ; Tue, 1 Dec 2015 22:56:26 +0000 (UTC) Received: (qmail 78446 invoked by uid 99); 1 Dec 2015 22:56:26 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 01 Dec 2015 22:56:26 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 76828E07EC; Tue, 1 Dec 2015 22:56:26 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: okram@apache.org To: commits@tinkerpop.incubator.apache.org Date: Tue, 01 Dec 2015 22:56:27 -0000 Message-Id: <3075e9a6bcad482e92c441b7d53966e7@git.apache.org> In-Reply-To: <3ce3a51c8c1947c9812b5220d339b981@git.apache.org> References: <3ce3a51c8c1947c9812b5220d339b981@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [2/2] incubator-tinkerpop git commit: this is an intense commit. No more traverser species. There is now JUST DefaultTraverser. Its super ghetto rigged right now, but I will be able to make it cleaner. This completely changes the complexity of traversal this is an intense commit. No more traverser species. There is now JUST DefaultTraverser. Its super ghetto rigged right now, but I will be able to make it cleaner. This completely changes the complexity of traversal compilation and traverser generation. I was a fool to overoptimize all this. Next up -- get rid of TraverserRequirements and add Path.onlyLabeledObjects(). Project: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/commit/beebbbc7 Tree: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/tree/beebbbc7 Diff: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/diff/beebbbc7 Branch: refs/heads/TINKERPOP3-1014 Commit: beebbbc7fcf9f8e1d57437d55937aa02ce988710 Parents: e6a1141 Author: Marko A. Rodriguez Authored: Tue Dec 1 15:56:13 2015 -0700 Committer: Marko A. Rodriguez Committed: Tue Dec 1 15:56:13 2015 -0700 ---------------------------------------------------------------------- .../lambda/AbstractLambdaTraversal.java | 5 +- .../traversal/step/map/AddVertexStartStep.java | 2 +- .../traverser/B_LP_O_P_S_SE_SL_Traverser.java | 97 -------- .../B_LP_O_P_S_SE_SL_TraverserGenerator.java | 59 ----- .../traverser/B_LP_O_S_SE_SL_Traverser.java | 102 -------- .../B_LP_O_S_SE_SL_TraverserGenerator.java | 58 ----- .../traverser/B_O_S_SE_SL_Traverser.java | 126 ---------- .../B_O_S_SE_SL_TraverserGenerator.java | 59 ----- .../traversal/traverser/B_O_Traverser.java | 70 ------ .../traverser/B_O_TraverserGenerator.java | 55 ----- .../traversal/traverser/DefaultTraverser.java | 244 +++++++++++++++++++ .../traverser/DefaultTraverserGenerator.java | 61 +++++ .../DefaultTraverserGeneratorFactory.java | 73 ++++++ .../traversal/traverser/EmptyTraverser.java | 167 +++++++++++++ .../traverser/LP_O_OB_P_S_SE_SL_Traverser.java | 98 -------- .../LP_O_OB_P_S_SE_SL_TraverserGenerator.java | 62 ----- .../traverser/LP_O_OB_S_SE_SL_Traverser.java | 99 -------- .../LP_O_OB_S_SE_SL_TraverserGenerator.java | 61 ----- .../traverser/O_OB_S_SE_SL_Traverser.java | 137 ----------- .../O_OB_S_SE_SL_TraverserGenerator.java | 59 ----- .../traversal/traverser/O_Traverser.java | 72 ------ .../traverser/O_TraverserGenerator.java | 52 ---- .../traverser/util/AbstractTraverser.java | 191 --------------- .../util/DefaultTraverserGeneratorFactory.java | 82 ------- .../traverser/util/EmptyTraverser.java | 167 ------------- .../util/DefaultTraversalStrategies.java | 2 +- .../util/EmptyTraversalStrategies.java | 2 +- .../gremlin/structure/io/gryo/GryoMapper.java | 21 +- .../traversal/step/map/MatchStepTest.java | 7 +- .../DefaultTraverserGeneratorFactoryTest.java | 85 ------- .../apache/tinkerpop/gremlin/GraphProvider.java | 15 +- 31 files changed, 561 insertions(+), 1829 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/beebbbc7/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/lambda/AbstractLambdaTraversal.java ---------------------------------------------------------------------- diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/lambda/AbstractLambdaTraversal.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/lambda/AbstractLambdaTraversal.java index 3f3af00..abd6011 100644 --- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/lambda/AbstractLambdaTraversal.java +++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/lambda/AbstractLambdaTraversal.java @@ -28,7 +28,7 @@ import org.apache.tinkerpop.gremlin.process.traversal.TraverserGenerator; import org.apache.tinkerpop.gremlin.process.traversal.engine.StandardTraversalEngine; import org.apache.tinkerpop.gremlin.process.traversal.step.TraversalParent; import org.apache.tinkerpop.gremlin.process.traversal.step.util.EmptyStep; -import org.apache.tinkerpop.gremlin.process.traversal.traverser.O_TraverserGenerator; +import org.apache.tinkerpop.gremlin.process.traversal.traverser.DefaultTraverserGenerator; import org.apache.tinkerpop.gremlin.process.traversal.traverser.TraverserRequirement; import org.apache.tinkerpop.gremlin.process.traversal.util.EmptyTraversalSideEffects; import org.apache.tinkerpop.gremlin.process.traversal.util.EmptyTraversalStrategies; @@ -37,7 +37,6 @@ import org.apache.tinkerpop.gremlin.structure.Graph; import java.util.Collections; import java.util.List; import java.util.Optional; -import java.util.Set; /** * @author Marko A. Rodriguez (http://markorodriguez.com) @@ -79,7 +78,7 @@ public abstract class AbstractLambdaTraversal implements Traversal.Admin extends B_O_S_SE_SL_Traverser { - - protected Path path; - - protected B_LP_O_P_S_SE_SL_Traverser() { - } - - public B_LP_O_P_S_SE_SL_Traverser(final T t, final Step step, final long initialBulk) { - super(t, step, initialBulk); - this.path = ImmutablePath.make().extend(t, step.getLabels()); - } - - ///////////////// - - @Override - public Path path() { - return this.path; - } - - ///////////////// - - @Override - public Traverser.Admin detach() { - super.detach(); - this.path = ReferenceFactory.detach(this.path); - return this; - } - - ///////////////// - - @Override - public Traverser.Admin split(final R r, final Step step) { - final B_LP_O_P_S_SE_SL_Traverser clone = (B_LP_O_P_S_SE_SL_Traverser) super.split(r, step); - clone.path = clone.path.clone().extend(r, step.getLabels()); - return clone; - } - - @Override - public Traverser.Admin split() { - final B_LP_O_P_S_SE_SL_Traverser clone = (B_LP_O_P_S_SE_SL_Traverser) super.split(); - clone.path = clone.path.clone(); - return clone; - } - - @Override - public void addLabels(final Set labels) { - if (!labels.isEmpty()) - this.path = this.path.extend(labels); - } - - @Override - public int hashCode() { - return super.hashCode() + this.path.hashCode(); - } - - @Override - public boolean equals(final Object object) { - return (object instanceof B_LP_O_P_S_SE_SL_Traverser) - && ((B_LP_O_P_S_SE_SL_Traverser) object).get().equals(this.t) - && ((B_LP_O_P_S_SE_SL_Traverser) object).getStepId().equals(this.getStepId()) - && ((B_LP_O_P_S_SE_SL_Traverser) object).loops() == this.loops() - && (null == this.sack || null != this.sideEffects.getSackMerger()) - && ((B_LP_O_P_S_SE_SL_Traverser) object).path().equals(this.path); - } - -} http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/beebbbc7/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/B_LP_O_P_S_SE_SL_TraverserGenerator.java ---------------------------------------------------------------------- diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/B_LP_O_P_S_SE_SL_TraverserGenerator.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/B_LP_O_P_S_SE_SL_TraverserGenerator.java deleted file mode 100644 index d0c4d78..0000000 --- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/B_LP_O_P_S_SE_SL_TraverserGenerator.java +++ /dev/null @@ -1,59 +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 org.apache.tinkerpop.gremlin.process.traversal.traverser; - -import org.apache.tinkerpop.gremlin.process.traversal.Step; -import org.apache.tinkerpop.gremlin.process.traversal.Traverser; -import org.apache.tinkerpop.gremlin.process.traversal.TraverserGenerator; - -import java.util.EnumSet; -import java.util.Set; - -/** - * @author Marko A. Rodriguez (http://markorodriguez.com) - */ -public final class B_LP_O_P_S_SE_SL_TraverserGenerator implements TraverserGenerator { - - private static final B_LP_O_P_S_SE_SL_TraverserGenerator INSTANCE = new B_LP_O_P_S_SE_SL_TraverserGenerator(); - private static final Set REQUIREMENTS = EnumSet.of( - TraverserRequirement.BULK, - TraverserRequirement.LABELED_PATH, - TraverserRequirement.OBJECT, - TraverserRequirement.PATH, - TraverserRequirement.SACK, - TraverserRequirement.SIDE_EFFECTS, - TraverserRequirement.SINGLE_LOOP); - - private B_LP_O_P_S_SE_SL_TraverserGenerator() { - } - - @Override - public Traverser.Admin generate(final S start, final Step startStep, final long initialBulk) { - return new B_LP_O_P_S_SE_SL_Traverser<>(start, startStep, initialBulk); - } - - @Override - public Set getProvidedRequirements() { - return REQUIREMENTS; - } - - public static B_LP_O_P_S_SE_SL_TraverserGenerator instance() { - return INSTANCE; - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/beebbbc7/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/B_LP_O_S_SE_SL_Traverser.java ---------------------------------------------------------------------- diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/B_LP_O_S_SE_SL_Traverser.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/B_LP_O_S_SE_SL_Traverser.java deleted file mode 100644 index b32126b..0000000 --- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/B_LP_O_S_SE_SL_Traverser.java +++ /dev/null @@ -1,102 +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 org.apache.tinkerpop.gremlin.process.traversal.traverser; - -import org.apache.tinkerpop.gremlin.process.traversal.Path; -import org.apache.tinkerpop.gremlin.process.traversal.Pop; -import org.apache.tinkerpop.gremlin.process.traversal.Step; -import org.apache.tinkerpop.gremlin.process.traversal.Traverser; -import org.apache.tinkerpop.gremlin.process.traversal.step.util.ImmutablePath; -import org.apache.tinkerpop.gremlin.structure.util.reference.ReferenceFactory; - -import java.util.Set; - -/** - * @author Marko A. Rodriguez (http://markorodriguez.com) - */ -public class B_LP_O_S_SE_SL_Traverser extends B_O_S_SE_SL_Traverser { - - protected Path path; - - protected B_LP_O_S_SE_SL_Traverser() { - } - - public B_LP_O_S_SE_SL_Traverser(final T t, final Step step, final long initialBulk) { - super(t, step, initialBulk); - this.path = ImmutablePath.make(); - if (!step.getLabels().isEmpty()) this.path = this.path.extend(t, step.getLabels()); - } - - ///////////////// - - @Override - public Path path() { - return this.path; - } - - ///////////////// - - @Override - public Traverser.Admin detach() { - super.detach(); - this.path = ReferenceFactory.detach(this.path); - return this; - } - - ///////////////// - - @Override - public Traverser.Admin split(final R r, final Step step) { - final B_LP_O_S_SE_SL_Traverser clone = (B_LP_O_S_SE_SL_Traverser) super.split(r, step); - clone.path = clone.path.clone(); - if (!step.getLabels().isEmpty()) clone.path = clone.path.extend(r, step.getLabels()); - return clone; - } - - @Override - public Traverser.Admin split() { - final B_LP_O_S_SE_SL_Traverser clone = (B_LP_O_S_SE_SL_Traverser) super.split(); - clone.path = clone.path.clone(); - return clone; - } - - @Override - public void addLabels(final Set labels) { - if (!labels.isEmpty()) - this.path = this.path.size() == 0 || !this.path.get(this.path.size() - 1).equals(this.t) ? - this.path.extend(this.t, labels) : - this.path.extend(labels); - } - - @Override - public int hashCode() { - return super.hashCode() + this.path.hashCode(); - } - - @Override - public boolean equals(final Object object) { - return (object instanceof B_LP_O_S_SE_SL_Traverser) - && ((B_LP_O_S_SE_SL_Traverser) object).get().equals(this.t) - && ((B_LP_O_S_SE_SL_Traverser) object).getStepId().equals(this.getStepId()) - && ((B_LP_O_S_SE_SL_Traverser) object).loops() == this.loops() - && (null == this.sack || null != this.sideEffects.getSackMerger()) - && ((B_LP_O_S_SE_SL_Traverser) object).path().popEquals(Pop.last, this.path); // this should be Pop.all? - } - -} http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/beebbbc7/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/B_LP_O_S_SE_SL_TraverserGenerator.java ---------------------------------------------------------------------- diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/B_LP_O_S_SE_SL_TraverserGenerator.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/B_LP_O_S_SE_SL_TraverserGenerator.java deleted file mode 100644 index 1c7e0d6..0000000 --- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/B_LP_O_S_SE_SL_TraverserGenerator.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 org.apache.tinkerpop.gremlin.process.traversal.traverser; - -import org.apache.tinkerpop.gremlin.process.traversal.Step; -import org.apache.tinkerpop.gremlin.process.traversal.Traverser; -import org.apache.tinkerpop.gremlin.process.traversal.TraverserGenerator; - -import java.util.EnumSet; -import java.util.Set; - -/** - * @author Marko A. Rodriguez (http://markorodriguez.com) - */ -public final class B_LP_O_S_SE_SL_TraverserGenerator implements TraverserGenerator { - - private static final B_LP_O_S_SE_SL_TraverserGenerator INSTANCE = new B_LP_O_S_SE_SL_TraverserGenerator(); - private static final Set REQUIREMENTS = EnumSet.of( - TraverserRequirement.BULK, - TraverserRequirement.LABELED_PATH, - TraverserRequirement.OBJECT, - TraverserRequirement.SACK, - TraverserRequirement.SIDE_EFFECTS, - TraverserRequirement.SINGLE_LOOP); - - private B_LP_O_S_SE_SL_TraverserGenerator() { - } - - @Override - public Traverser.Admin generate(final S start, final Step startStep, final long initialBulk) { - return new B_LP_O_S_SE_SL_Traverser<>(start, startStep, initialBulk); - } - - @Override - public Set getProvidedRequirements() { - return REQUIREMENTS; - } - - public static B_LP_O_S_SE_SL_TraverserGenerator instance() { - return INSTANCE; - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/beebbbc7/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/B_O_S_SE_SL_Traverser.java ---------------------------------------------------------------------- diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/B_O_S_SE_SL_Traverser.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/B_O_S_SE_SL_Traverser.java deleted file mode 100644 index 5dc1313..0000000 --- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/B_O_S_SE_SL_Traverser.java +++ /dev/null @@ -1,126 +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 org.apache.tinkerpop.gremlin.process.traversal.traverser; - - -import org.apache.tinkerpop.gremlin.process.traversal.Step; -import org.apache.tinkerpop.gremlin.process.traversal.TraversalSideEffects; -import org.apache.tinkerpop.gremlin.process.traversal.Traverser; - -/** - * @author Marko A. Rodriguez (http://markorodriguez.com) - */ -public class B_O_S_SE_SL_Traverser extends B_O_Traverser { - - protected Object sack = null; - protected short loops = 0; // an optimization hack to use a short internally to save bits :) - protected transient TraversalSideEffects sideEffects; - - protected B_O_S_SE_SL_Traverser() { - } - - public B_O_S_SE_SL_Traverser(final T t, final Step step, final long initialBulk) { - super(t, initialBulk); - this.sideEffects = step.getTraversal().getSideEffects(); - if (null != this.sideEffects.getSackInitialValue()) - this.sack = this.sideEffects.getSackInitialValue().get(); - } - - ///////////////// - - @Override - public S sack() { - return (S) this.sack; - } - - @Override - public void sack(final S object) { - this.sack = object; - } - - ///////////////// - - @Override - public int loops() { - return this.loops; - } - - @Override - public void incrLoops(final String stepLabel) { - this.loops++; - } - - @Override - public void resetLoops() { - this.loops = 0; - } - - ///////////////// - - @Override - public TraversalSideEffects getSideEffects() { - return this.sideEffects; - } - - - @Override - public void setSideEffects(final TraversalSideEffects sideEffects) { - this.sideEffects = sideEffects; - } - - ///////////////// - - @Override - public Traverser.Admin split(final R r, final Step step) { - final B_O_S_SE_SL_Traverser clone = (B_O_S_SE_SL_Traverser) super.split(r, step); - clone.sack = null == clone.sack ? null : null == clone.sideEffects.getSackSplitter() ? clone.sack : clone.sideEffects.getSackSplitter().apply(clone.sack); - return clone; - } - - @Override - public Traverser.Admin split() { - final B_O_S_SE_SL_Traverser clone = (B_O_S_SE_SL_Traverser) super.split(); - clone.sack = null == clone.sack ? null : null == clone.sideEffects.getSackSplitter() ? clone.sack : clone.sideEffects.getSackSplitter().apply(clone.sack); - return clone; - } - - @Override - public void merge(final Traverser.Admin other) { - super.merge(other); - if (null != this.sack && null != this.sideEffects.getSackMerger()) - this.sack = this.sideEffects.getSackMerger().apply(this.sack, other.sack()); - - } - - ///////////////// - - @Override - public int hashCode() { - return this.t.hashCode() + this.future.hashCode() + this.loops; - } - - @Override - public boolean equals(final Object object) { - return object instanceof B_O_S_SE_SL_Traverser - && ((B_O_S_SE_SL_Traverser) object).get().equals(this.t) - && ((B_O_S_SE_SL_Traverser) object).getStepId().equals(this.getStepId()) - && ((B_O_S_SE_SL_Traverser) object).loops() == this.loops() - && (null == this.sack || (null != this.sideEffects && null != this.sideEffects.getSackMerger())); // hmmm... serialization in OLAP destroys the transient sideEffects - } -} http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/beebbbc7/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/B_O_S_SE_SL_TraverserGenerator.java ---------------------------------------------------------------------- diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/B_O_S_SE_SL_TraverserGenerator.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/B_O_S_SE_SL_TraverserGenerator.java deleted file mode 100644 index 4c5ce57..0000000 --- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/B_O_S_SE_SL_TraverserGenerator.java +++ /dev/null @@ -1,59 +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 org.apache.tinkerpop.gremlin.process.traversal.traverser; - -import org.apache.tinkerpop.gremlin.process.traversal.Step; -import org.apache.tinkerpop.gremlin.process.traversal.Traverser; -import org.apache.tinkerpop.gremlin.process.traversal.TraverserGenerator; - -import java.util.EnumSet; -import java.util.Set; - -/** - * @author Marko A. Rodriguez (http://markorodriguez.com) - */ -public final class B_O_S_SE_SL_TraverserGenerator implements TraverserGenerator { - - private static final B_O_S_SE_SL_TraverserGenerator INSTANCE = new B_O_S_SE_SL_TraverserGenerator(); - - private static final Set REQUIREMENTS = EnumSet.of( - TraverserRequirement.BULK, - TraverserRequirement.OBJECT, - TraverserRequirement.SACK, - TraverserRequirement.SIDE_EFFECTS, - TraverserRequirement.SINGLE_LOOP); - - - private B_O_S_SE_SL_TraverserGenerator() { - } - - @Override - public Traverser.Admin generate(final S start, final Step startStep, final long initialBulk) { - return new B_O_S_SE_SL_Traverser<>(start, startStep, initialBulk); - } - - @Override - public Set getProvidedRequirements() { - return REQUIREMENTS; - } - - public static B_O_S_SE_SL_TraverserGenerator instance() { - return INSTANCE; - } -} http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/beebbbc7/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/B_O_Traverser.java ---------------------------------------------------------------------- diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/B_O_Traverser.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/B_O_Traverser.java deleted file mode 100644 index 4c64fb0..0000000 --- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/B_O_Traverser.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 org.apache.tinkerpop.gremlin.process.traversal.traverser; - -import org.apache.tinkerpop.gremlin.process.traversal.Traverser; - -/** - * @author Marko A. Rodriguez (http://markorodriguez.com) - */ -public class B_O_Traverser extends O_Traverser { - - protected long bulk = 1l; - protected String future = HALT; - - protected B_O_Traverser() { - } - - public B_O_Traverser(final T t, final long initialBulk) { - super(t); - this.bulk = initialBulk; - } - - @Override - public void setBulk(final long count) { - this.bulk = count; - } - - @Override - public long bulk() { - return this.bulk; - } - - @Override - public void merge(final Traverser.Admin other) { - this.bulk = this.bulk + other.bulk(); - } - - @Override - public String getStepId() { - return this.future; - } - - @Override - public void setStepId(final String stepId) { - this.future = stepId; - } - - @Override - public boolean equals(final Object object) { - return object instanceof B_O_Traverser && - ((B_O_Traverser) object).t.equals(this.t) && - ((B_O_Traverser) object).future.equals(this.future); - } -} http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/beebbbc7/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/B_O_TraverserGenerator.java ---------------------------------------------------------------------- diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/B_O_TraverserGenerator.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/B_O_TraverserGenerator.java deleted file mode 100644 index 0ee1e68..0000000 --- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/B_O_TraverserGenerator.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 org.apache.tinkerpop.gremlin.process.traversal.traverser; - -import org.apache.tinkerpop.gremlin.process.traversal.Step; -import org.apache.tinkerpop.gremlin.process.traversal.Traverser; -import org.apache.tinkerpop.gremlin.process.traversal.TraverserGenerator; - -import java.util.EnumSet; -import java.util.Set; - -/** - * @author Marko A. Rodriguez (http://markorodriguez.com) - */ -public final class B_O_TraverserGenerator implements TraverserGenerator { - - private static final Set REQUIREMENTS = EnumSet.of( - TraverserRequirement.BULK, - TraverserRequirement.OBJECT); - - private static final B_O_TraverserGenerator INSTANCE = new B_O_TraverserGenerator(); - - private B_O_TraverserGenerator() { - } - - @Override - public Traverser.Admin generate(final S start, final Step startStep, final long initialBulk) { - return new B_O_Traverser<>(start, initialBulk); - } - - @Override - public Set getProvidedRequirements() { - return REQUIREMENTS; - } - - public static B_O_TraverserGenerator instance() { - return INSTANCE; - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/beebbbc7/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/DefaultTraverser.java ---------------------------------------------------------------------- diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/DefaultTraverser.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/DefaultTraverser.java new file mode 100644 index 0000000..7f71ad9 --- /dev/null +++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/DefaultTraverser.java @@ -0,0 +1,244 @@ +/* + * 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 org.apache.tinkerpop.gremlin.process.traversal.traverser; + +import org.apache.tinkerpop.gremlin.process.traversal.Path; +import org.apache.tinkerpop.gremlin.process.traversal.Step; +import org.apache.tinkerpop.gremlin.process.traversal.TraversalSideEffects; +import org.apache.tinkerpop.gremlin.process.traversal.Traverser; +import org.apache.tinkerpop.gremlin.process.traversal.step.util.EmptyPath; +import org.apache.tinkerpop.gremlin.structure.util.Attachable; +import org.apache.tinkerpop.gremlin.structure.util.reference.ReferenceFactory; + +import java.util.HashSet; +import java.util.Set; +import java.util.function.Function; + +/** + * @author Marko A. Rodriguez (http://markorodriguez.com) + */ +public final class DefaultTraverser implements Traverser.Admin { + + private T t; + private long bulk = 1l; + private String stepId; + private Path path; + private short loops = 0; + private Set tags = null; + private transient TraversalSideEffects sideEffects; + private boolean onlyLabeledPaths; + private boolean oneBulk; + private Object sack = null; + + /** + * A no-args constructor is necessary for Kryo serialization. + */ + private DefaultTraverser() { + + } + + public DefaultTraverser(final T t, final Step step, final long initialBulk, final Path path, boolean onlyLabeledPaths, boolean oneBulk) { + this.t = t; + this.stepId = step.getId(); + this.bulk = initialBulk; + this.path = path; + this.sideEffects = step.getTraversal().getSideEffects(); + this.onlyLabeledPaths = onlyLabeledPaths; + this.oneBulk = oneBulk; + if (null != this.sideEffects.getSackInitialValue()) + this.sack = this.sideEffects.getSackInitialValue().get(); + } + + + @Override + public void addLabels(final Set labels) { + if (this.onlyLabeledPaths) { + if (!labels.isEmpty()) + this.path = this.path.size() == 0 || !this.path.get(this.path.size() - 1).equals(this.t) ? + this.path.extend(this.t, labels) : + this.path.extend(labels); + } else + this.path = this.path.extend(labels); + } + + @Override + public void set(final T t) { + this.t = t; + } + + @Override + public void incrLoops(final String stepLabel) { + if (!this.oneBulk) + this.loops++; + } + + @Override + public void resetLoops() { + this.loops = 0; + } + + @Override + public String getStepId() { + return this.stepId; + } + + @Override + public void setStepId(final String stepId) { + this.stepId = stepId; + } + + @Override + public void setBulk(final long count) { + this.bulk = count; + } + + @Override + public Admin detach() { + this.t = ReferenceFactory.detach(this.t); + if (!(this.path instanceof EmptyPath)) + this.path = ReferenceFactory.detach(this.path); + return this; + } + + @Override + public T attach(final Function, T> method) { + // you do not want to attach a path because it will reference graph objects not at the current vertex + if (this.t instanceof Attachable && !(((Attachable) this.t).get() instanceof Path)) + this.t = ((Attachable) this.t).attach(method); + return this.t; + } + + @Override + public void setSideEffects(final TraversalSideEffects sideEffects) { + this.sideEffects = sideEffects; + } + + @Override + public TraversalSideEffects getSideEffects() { + return this.sideEffects; + } + + public Set getTags() { + if (null == this.tags) this.tags = new HashSet<>(); + return this.tags; + } + + @Override + public Admin split(final R r, final Step step) { + final DefaultTraverser clone = (DefaultTraverser) this.clone(); + clone.t = r; + if (this.onlyLabeledPaths) { + if (!step.getLabels().isEmpty()) + clone.path = this.path.clone().extend(r, step.getLabels()); + } else + clone.path = this.path.clone().extend(r, step.getLabels()); + if (null != this.tags) + clone.tags = new HashSet<>(this.tags); + clone.sack = null == clone.sack ? null : null == clone.sideEffects.getSackSplitter() ? clone.sack : clone.sideEffects.getSackSplitter().apply(clone.sack); + return clone; + } + + @Override + public Admin split() { + final DefaultTraverser clone = (DefaultTraverser) this.clone(); + clone.path = this.path.clone(); + if (null != this.tags) + clone.tags = new HashSet<>(this.tags); + clone.sack = null == clone.sack ? null : null == clone.sideEffects.getSackSplitter() ? clone.sack : clone.sideEffects.getSackSplitter().apply(clone.sack); + return clone; + } + + @Override + public void merge(final Traverser.Admin other) { + if (!this.oneBulk) + this.bulk = this.bulk + other.bulk(); + if (!other.getTags().isEmpty()) { + if (this.tags == null) this.tags = new HashSet<>(); + this.tags.addAll(other.getTags()); + } + if (null != this.sack && null != this.sideEffects.getSackMerger()) + this.sack = this.sideEffects.getSackMerger().apply(this.sack, other.sack()); + } + + @Override + public T get() { + return this.t; + } + + @Override + public S sack() { + return (S) this.sack; + } + + @Override + public void sack(final S object) { + this.sack = object; + } + + @Override + public Path path() { + return this.path; + } + + @Override + public int loops() { + return this.loops; + } + + @Override + public long bulk() { + return this.bulk; + } + + @Override + public Traverser clone() { + try { + final DefaultTraverser clone = (DefaultTraverser) super.clone(); + if (this.tags != null) + clone.getTags().addAll(this.tags); + clone.path = this.path.clone(); + return clone; + } catch (final CloneNotSupportedException e) { + throw new IllegalStateException(e.getMessage(), e); + } + } + + /////////// + + @Override + public int hashCode() { + return this.t.hashCode() + this.stepId.hashCode() + this.loops + this.path.hashCode(); + } + + @Override + public boolean equals(final Object object) { + return object instanceof DefaultTraverser && + ((DefaultTraverser) object).get().equals(this.t) && + ((DefaultTraverser) object).stepId.equals(this.stepId) && + ((DefaultTraverser) object).loops() == this.loops && + (null == this.sack || (null != this.sideEffects && null != this.sideEffects.getSackMerger())) && // hmmm... serialization in OLAP destroys the transient sideEffects + ((DefaultTraverser) object).path().equals(this.path); + } + + @Override + public String toString() { + return this.t.toString(); + } +} http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/beebbbc7/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/DefaultTraverserGenerator.java ---------------------------------------------------------------------- diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/DefaultTraverserGenerator.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/DefaultTraverserGenerator.java new file mode 100644 index 0000000..f399549 --- /dev/null +++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/DefaultTraverserGenerator.java @@ -0,0 +1,61 @@ +/* + * 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 org.apache.tinkerpop.gremlin.process.traversal.traverser; + +import org.apache.tinkerpop.gremlin.process.traversal.Step; +import org.apache.tinkerpop.gremlin.process.traversal.Traverser; +import org.apache.tinkerpop.gremlin.process.traversal.TraverserGenerator; +import org.apache.tinkerpop.gremlin.process.traversal.step.util.EmptyPath; +import org.apache.tinkerpop.gremlin.process.traversal.step.util.ImmutablePath; +import org.apache.tinkerpop.gremlin.process.traversal.util.TraversalHelper; + +import java.util.Collections; +import java.util.Set; + +/** + * @author Marko A. Rodriguez (http://markorodriguez.com) + */ +public final class DefaultTraverserGenerator implements TraverserGenerator { + + private static final DefaultTraverserGenerator INSTANCE = new DefaultTraverserGenerator(); + + private DefaultTraverserGenerator() { + } + + @Override + public Traverser.Admin generate(final S start, final Step startStep, final long initialBulk) { + final Set requirements = TraversalHelper.getRootTraversal(startStep.getTraversal()).getTraverserRequirements(); + if (requirements.contains(TraverserRequirement.PATH)) + return new DefaultTraverser<>(start, startStep, initialBulk, ImmutablePath.make().extend(start, startStep.getLabels()), false, requirements.contains(TraverserRequirement.ONE_BULK)); + else if (requirements.contains(TraverserRequirement.LABELED_PATH)) + return new DefaultTraverser<>(start, startStep, initialBulk, ImmutablePath.make().extend(start, startStep.getLabels()), true, requirements.contains(TraverserRequirement.ONE_BULK)); + else + return new DefaultTraverser<>(start, startStep, initialBulk, EmptyPath.instance(), true, requirements.contains(TraverserRequirement.ONE_BULK)); + } + + @Override + public Set getProvidedRequirements() { + return Collections.emptySet(); + } + + public static DefaultTraverserGenerator instance() { + return INSTANCE; + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/beebbbc7/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/DefaultTraverserGeneratorFactory.java ---------------------------------------------------------------------- diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/DefaultTraverserGeneratorFactory.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/DefaultTraverserGeneratorFactory.java new file mode 100644 index 0000000..85957a2 --- /dev/null +++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/DefaultTraverserGeneratorFactory.java @@ -0,0 +1,73 @@ +/* + * 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 org.apache.tinkerpop.gremlin.process.traversal.traverser; + +import org.apache.tinkerpop.gremlin.process.traversal.Traversal; +import org.apache.tinkerpop.gremlin.process.traversal.TraverserGenerator; + +import java.util.Set; + +/** + * @author Marko A. Rodriguez (http://markorodriguez.com) + */ +public final class DefaultTraverserGeneratorFactory implements TraverserGeneratorFactory { + + private static DefaultTraverserGeneratorFactory INSTANCE = new DefaultTraverserGeneratorFactory(); + + public static DefaultTraverserGeneratorFactory instance() { + return INSTANCE; + } + + private DefaultTraverserGeneratorFactory() { + } + + @Override + public TraverserGenerator getTraverserGenerator(final Traversal.Admin traversal) { + final Set requirements = traversal.getTraverserRequirements(); + + return DefaultTraverserGenerator.instance(); + /*if (requirements.contains(TraverserRequirement.ONE_BULK)) { + if (O_OB_S_SE_SL_TraverserGenerator.instance().getProvidedRequirements().containsAll(requirements)) + return O_OB_S_SE_SL_TraverserGenerator.instance(); + + if (LP_O_OB_S_SE_SL_TraverserGenerator.instance().getProvidedRequirements().containsAll(requirements)) + return LP_O_OB_S_SE_SL_TraverserGenerator.instance(); + + if (LP_O_OB_P_S_SE_SL_TraverserGenerator.instance().getProvidedRequirements().containsAll(requirements)) + return LP_O_OB_P_S_SE_SL_TraverserGenerator.instance(); + } else { + if (O_TraverserGenerator.instance().getProvidedRequirements().containsAll(requirements)) + return O_TraverserGenerator.instance(); + + if (B_O_TraverserGenerator.instance().getProvidedRequirements().containsAll(requirements)) + return B_O_TraverserGenerator.instance(); + + if (B_O_S_SE_SL_TraverserGenerator.instance().getProvidedRequirements().containsAll(requirements)) + return B_O_S_SE_SL_TraverserGenerator.instance(); + + if (B_LP_O_S_SE_SL_TraverserGenerator.instance().getProvidedRequirements().containsAll(requirements)) + return B_LP_O_S_SE_SL_TraverserGenerator.instance(); + + if (B_LP_O_P_S_SE_SL_TraverserGenerator.instance().getProvidedRequirements().containsAll(requirements)) + return B_LP_O_P_S_SE_SL_TraverserGenerator.instance(); + }*/ + + //throw new IllegalStateException("The provided traverser generator factory does not support the requirements of the traversal: " + this.getClass().getCanonicalName() + requirements); + } +} http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/beebbbc7/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/EmptyTraverser.java ---------------------------------------------------------------------- diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/EmptyTraverser.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/EmptyTraverser.java new file mode 100644 index 0000000..0ed2d48 --- /dev/null +++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/EmptyTraverser.java @@ -0,0 +1,167 @@ +/* + * 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 org.apache.tinkerpop.gremlin.process.traversal.traverser; + +import org.apache.tinkerpop.gremlin.process.traversal.Path; +import org.apache.tinkerpop.gremlin.process.traversal.Step; +import org.apache.tinkerpop.gremlin.process.traversal.TraversalSideEffects; +import org.apache.tinkerpop.gremlin.process.traversal.Traverser; +import org.apache.tinkerpop.gremlin.process.traversal.step.util.EmptyPath; +import org.apache.tinkerpop.gremlin.structure.util.Attachable; + +import java.util.Collections; +import java.util.Set; +import java.util.function.Function; + +/** + * @author Marko A. Rodriguez (http://markorodriguez.com) + */ +public final class EmptyTraverser implements Traverser, Traverser.Admin { + + private static final EmptyTraverser INSTANCE = new EmptyTraverser(); + + public static EmptyTraverser instance() { + return INSTANCE; + } + + private EmptyTraverser() { + + } + + @Override + public void addLabels(final Set labels) { + + } + + @Override + public void set(final T t) { + + } + + @Override + public void incrLoops(final String stepLabel) { + + } + + @Override + public void resetLoops() { + + } + + @Override + public String getStepId() { + return HALT; + } + + @Override + public void setStepId(final String stepId) { + + } + + @Override + public void setBulk(long count) { + + } + + @Override + public Admin split(final R r, final Step step) { + return INSTANCE; + } + + @Override + public Admin split() { + return this; + } + + @Override + public Admin detach() { + return this; + } + + @Override + public T attach(final Function, T> method) { + return null; + } + + @Override + public void setSideEffects(final TraversalSideEffects sideEffects) { + + } + + @Override + public T get() { + return null; + } + + @Override + public S sack() { + return null; + } + + @Override + public void sack(final S object) { + + } + + @Override + public void merge(final Traverser.Admin other) { + + } + + @Override + public Path path() { + return EmptyPath.instance(); + } + + @Override + public int loops() { + return 0; + } + + @Override + public long bulk() { + return 0l; + } + + @Override + public TraversalSideEffects getSideEffects() { + return null; + } + + @Override + public Set getTags() { + return Collections.emptySet(); + } + + @Override + public int hashCode() { + return 380473707; + } + + @Override + public boolean equals(final Object object) { + return object instanceof EmptyTraverser; + } + + @Override + @SuppressWarnings("CloneDoesntCallSuperClone") + public EmptyTraverser clone() { + return this; + } +} http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/beebbbc7/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/LP_O_OB_P_S_SE_SL_Traverser.java ---------------------------------------------------------------------- diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/LP_O_OB_P_S_SE_SL_Traverser.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/LP_O_OB_P_S_SE_SL_Traverser.java deleted file mode 100644 index 353d1ef..0000000 --- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/LP_O_OB_P_S_SE_SL_Traverser.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 org.apache.tinkerpop.gremlin.process.traversal.traverser; - -import org.apache.tinkerpop.gremlin.process.traversal.Path; -import org.apache.tinkerpop.gremlin.process.traversal.Step; -import org.apache.tinkerpop.gremlin.process.traversal.Traverser; -import org.apache.tinkerpop.gremlin.process.traversal.step.util.ImmutablePath; -import org.apache.tinkerpop.gremlin.structure.util.reference.ReferenceFactory; - -import java.util.Set; - -/** - * @author Marko A. Rodriguez (http://markorodriguez.com) - */ -public class LP_O_OB_P_S_SE_SL_Traverser extends O_OB_S_SE_SL_Traverser { - - protected Path path; - - protected LP_O_OB_P_S_SE_SL_Traverser() { - } - - public LP_O_OB_P_S_SE_SL_Traverser(final T t, final Step step) { - super(t, step); - this.path = ImmutablePath.make().extend(t, step.getLabels()); - } - - ///////////////// - - @Override - public Path path() { - return this.path; - } - - ///////////////// - - @Override - public Traverser.Admin detach() { - super.detach(); - this.path = ReferenceFactory.detach(this.path); - return this; - } - - ///////////////// - - @Override - public Traverser.Admin split(final R r, final Step step) { - final LP_O_OB_P_S_SE_SL_Traverser clone = (LP_O_OB_P_S_SE_SL_Traverser) super.split(r, step); - clone.path = clone.path.clone().extend(r, step.getLabels()); - return clone; - } - - @Override - public Traverser.Admin split() { - final LP_O_OB_P_S_SE_SL_Traverser clone = (LP_O_OB_P_S_SE_SL_Traverser) super.split(); - clone.path = clone.path.clone(); - return clone; - } - - @Override - public void addLabels(final Set labels) { - if (!labels.isEmpty()) - this.path = this.path.extend(labels); - } - - @Override - public int hashCode() { - return super.hashCode() + this.path.hashCode(); - } - - @Override - public boolean equals(final Object object) { - return (object instanceof LP_O_OB_P_S_SE_SL_Traverser) - && ((LP_O_OB_P_S_SE_SL_Traverser) object).get().equals(this.t) - && ((LP_O_OB_P_S_SE_SL_Traverser) object).getStepId().equals(this.getStepId()) - && ((LP_O_OB_P_S_SE_SL_Traverser) object).loops() == this.loops() - && (null == this.sack || null != this.sideEffects.getSackMerger()) - && ((LP_O_OB_P_S_SE_SL_Traverser) object).path().equals(this.path); - } - -} http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/beebbbc7/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/LP_O_OB_P_S_SE_SL_TraverserGenerator.java ---------------------------------------------------------------------- diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/LP_O_OB_P_S_SE_SL_TraverserGenerator.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/LP_O_OB_P_S_SE_SL_TraverserGenerator.java deleted file mode 100644 index 546ed6d..0000000 --- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/LP_O_OB_P_S_SE_SL_TraverserGenerator.java +++ /dev/null @@ -1,62 +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 org.apache.tinkerpop.gremlin.process.traversal.traverser; - -import org.apache.tinkerpop.gremlin.process.traversal.Step; -import org.apache.tinkerpop.gremlin.process.traversal.Traverser; -import org.apache.tinkerpop.gremlin.process.traversal.TraverserGenerator; - -import java.util.EnumSet; -import java.util.Set; - -/** - * @author Marko A. Rodriguez (http://markorodriguez.com) - */ -public final class LP_O_OB_P_S_SE_SL_TraverserGenerator implements TraverserGenerator { - - private static final Set REQUIREMENTS = EnumSet.of( - TraverserRequirement.LABELED_PATH, - TraverserRequirement.OBJECT, - TraverserRequirement.ONE_BULK, - TraverserRequirement.PATH, - TraverserRequirement.SACK, - TraverserRequirement.SIDE_EFFECTS, - TraverserRequirement.SINGLE_LOOP); - - - private static final LP_O_OB_P_S_SE_SL_TraverserGenerator INSTANCE = new LP_O_OB_P_S_SE_SL_TraverserGenerator(); - - private LP_O_OB_P_S_SE_SL_TraverserGenerator() { - } - - @Override - public Traverser.Admin generate(final S start, final Step startStep, final long initialBulk) { - return new LP_O_OB_P_S_SE_SL_Traverser<>(start, startStep); - } - - @Override - public Set getProvidedRequirements() { - return REQUIREMENTS; - } - - public static LP_O_OB_P_S_SE_SL_TraverserGenerator instance() { - return INSTANCE; - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/beebbbc7/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/LP_O_OB_S_SE_SL_Traverser.java ---------------------------------------------------------------------- diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/LP_O_OB_S_SE_SL_Traverser.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/LP_O_OB_S_SE_SL_Traverser.java deleted file mode 100644 index 9781f84..0000000 --- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/LP_O_OB_S_SE_SL_Traverser.java +++ /dev/null @@ -1,99 +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 org.apache.tinkerpop.gremlin.process.traversal.traverser; - -import org.apache.tinkerpop.gremlin.process.traversal.Path; -import org.apache.tinkerpop.gremlin.process.traversal.Pop; -import org.apache.tinkerpop.gremlin.process.traversal.Step; -import org.apache.tinkerpop.gremlin.process.traversal.Traverser; -import org.apache.tinkerpop.gremlin.process.traversal.step.util.ImmutablePath; -import org.apache.tinkerpop.gremlin.structure.util.reference.ReferenceFactory; - -import java.util.Set; - -/** - * @author Marko A. Rodriguez (http://markorodriguez.com) - */ -public class LP_O_OB_S_SE_SL_Traverser extends O_OB_S_SE_SL_Traverser { - - protected Path path; - - public LP_O_OB_S_SE_SL_Traverser(final T t, final Step step) { - super(t, step); - this.path = ImmutablePath.make(); - if (!step.getLabels().isEmpty()) this.path = this.path.extend(t, step.getLabels()); - } - - ///////////////// - - @Override - public Path path() { - return this.path; - } - - ///////////////// - - @Override - public Traverser.Admin detach() { - super.detach(); - this.path = ReferenceFactory.detach(this.path); - return this; - } - - ///////////////// - - @Override - public Traverser.Admin split(final R r, final Step step) { - final LP_O_OB_S_SE_SL_Traverser clone = (LP_O_OB_S_SE_SL_Traverser) super.split(r, step); - clone.path = clone.path.clone(); - if (!step.getLabels().isEmpty()) clone.path = clone.path.extend(r, step.getLabels()); - return clone; - } - - @Override - public Traverser.Admin split() { - final LP_O_OB_S_SE_SL_Traverser clone = (LP_O_OB_S_SE_SL_Traverser) super.split(); - clone.path = clone.path.clone(); - return clone; - } - - @Override - public void addLabels(final Set labels) { - if (!labels.isEmpty()) - this.path = this.path.size() == 0 || !this.path.get(this.path.size() - 1).equals(this.t) ? - this.path.extend(this.t, labels) : - this.path.extend(labels); - } - - @Override - public int hashCode() { - return super.hashCode() + this.path.hashCode(); - } - - @Override - public boolean equals(final Object object) { - return (object instanceof LP_O_OB_S_SE_SL_Traverser) - && ((LP_O_OB_S_SE_SL_Traverser) object).get().equals(this.t) - && ((LP_O_OB_S_SE_SL_Traverser) object).getStepId().equals(this.getStepId()) - && ((LP_O_OB_S_SE_SL_Traverser) object).loops() == this.loops() - && (null == this.sack || null != this.sideEffects.getSackMerger()) - && ((LP_O_OB_S_SE_SL_Traverser) object).path().popEquals(Pop.last, this.path); // this should be Pop.all? - } -} http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/beebbbc7/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/LP_O_OB_S_SE_SL_TraverserGenerator.java ---------------------------------------------------------------------- diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/LP_O_OB_S_SE_SL_TraverserGenerator.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/LP_O_OB_S_SE_SL_TraverserGenerator.java deleted file mode 100644 index f30eced..0000000 --- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/LP_O_OB_S_SE_SL_TraverserGenerator.java +++ /dev/null @@ -1,61 +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 org.apache.tinkerpop.gremlin.process.traversal.traverser; - -import org.apache.tinkerpop.gremlin.process.traversal.Step; -import org.apache.tinkerpop.gremlin.process.traversal.Traverser; -import org.apache.tinkerpop.gremlin.process.traversal.TraverserGenerator; - -import java.util.EnumSet; -import java.util.Set; - -/** - * @author Marko A. Rodriguez (http://markorodriguez.com) - */ -public final class LP_O_OB_S_SE_SL_TraverserGenerator implements TraverserGenerator { - - private static final Set REQUIREMENTS = EnumSet.of( - TraverserRequirement.LABELED_PATH, - TraverserRequirement.OBJECT, - TraverserRequirement.ONE_BULK, - TraverserRequirement.SACK, - TraverserRequirement.SIDE_EFFECTS, - TraverserRequirement.SINGLE_LOOP); - - - private static final LP_O_OB_S_SE_SL_TraverserGenerator INSTANCE = new LP_O_OB_S_SE_SL_TraverserGenerator(); - - private LP_O_OB_S_SE_SL_TraverserGenerator() { - } - - @Override - public Traverser.Admin generate(final S start, final Step startStep, final long initialBulk) { - return new LP_O_OB_S_SE_SL_Traverser<>(start, startStep); - } - - @Override - public Set getProvidedRequirements() { - return REQUIREMENTS; - } - - public static LP_O_OB_S_SE_SL_TraverserGenerator instance() { - return INSTANCE; - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/beebbbc7/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/O_OB_S_SE_SL_Traverser.java ---------------------------------------------------------------------- diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/O_OB_S_SE_SL_Traverser.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/O_OB_S_SE_SL_Traverser.java deleted file mode 100644 index 7196e72..0000000 --- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/O_OB_S_SE_SL_Traverser.java +++ /dev/null @@ -1,137 +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 org.apache.tinkerpop.gremlin.process.traversal.traverser; - -import org.apache.tinkerpop.gremlin.process.traversal.Step; -import org.apache.tinkerpop.gremlin.process.traversal.TraversalSideEffects; -import org.apache.tinkerpop.gremlin.process.traversal.Traverser; - -/** - * @author Marko A. Rodriguez (http://markorodriguez.com) - */ -public class O_OB_S_SE_SL_Traverser extends O_Traverser { - - protected Object sack = null; - protected short loops = 0; // an optimization hack to use a short internally to save bits :) - protected transient TraversalSideEffects sideEffects; - protected String future = HALT; - - protected O_OB_S_SE_SL_Traverser() { - } - - public O_OB_S_SE_SL_Traverser(final T t, final Step step) { - super(t); - this.sideEffects = step.getTraversal().getSideEffects(); - if (null != this.sideEffects.getSackInitialValue()) - this.sack = this.sideEffects.getSackInitialValue().get(); - } - - ///////////////// - - @Override - public S sack() { - return (S) this.sack; - } - - @Override - public void sack(final S object) { - this.sack = object; - } - - ///////////////// - - @Override - public int loops() { - return this.loops; - } - - @Override - public void incrLoops(final String stepLabel) { - this.loops++; - } - - @Override - public void resetLoops() { - this.loops = 0; - } - - ///////////////// - - @Override - public String getStepId() { - return this.future; - } - - @Override - public void setStepId(final String stepId) { - this.future = stepId; - } - - ///////////////// - - @Override - public TraversalSideEffects getSideEffects() { - return this.sideEffects; - } - - - @Override - public void setSideEffects(final TraversalSideEffects sideEffects) { - this.sideEffects = sideEffects; - } - - ///////////////// - - @Override - public Traverser.Admin split(final R r, final Step step) { - final O_OB_S_SE_SL_Traverser clone = (O_OB_S_SE_SL_Traverser) super.split(r, step); - clone.sack = null == clone.sack ? null : null == clone.sideEffects.getSackSplitter() ? clone.sack : clone.sideEffects.getSackSplitter().apply(clone.sack); - return clone; - } - - @Override - public Traverser.Admin split() { - final O_OB_S_SE_SL_Traverser clone = (O_OB_S_SE_SL_Traverser) super.split(); - clone.sack = null == clone.sack ? null : null == clone.sideEffects.getSackSplitter() ? clone.sack : clone.sideEffects.getSackSplitter().apply(clone.sack); - return clone; - } - - @Override - public void merge(final Traverser.Admin other) { - if (null != this.sack && null != this.sideEffects.getSackMerger()) - this.sack = this.sideEffects.getSackMerger().apply(this.sack, other.sack()); - } - - ///////////////// - - @Override - public int hashCode() { - return this.t.hashCode() + this.future.hashCode() + this.loops; - } - - @Override - public boolean equals(final Object object) { - return object instanceof O_OB_S_SE_SL_Traverser - && ((O_OB_S_SE_SL_Traverser) object).get().equals(this.t) - && ((O_OB_S_SE_SL_Traverser) object).getStepId().equals(this.getStepId()) - && ((O_OB_S_SE_SL_Traverser) object).loops() == this.loops() - && (null == this.sack || (null != this.sideEffects && null != this.sideEffects.getSackMerger())); // hmmm... serialization in OLAP destroys the transient sideEffects - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/beebbbc7/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/O_OB_S_SE_SL_TraverserGenerator.java ---------------------------------------------------------------------- diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/O_OB_S_SE_SL_TraverserGenerator.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/O_OB_S_SE_SL_TraverserGenerator.java deleted file mode 100644 index 8369bef..0000000 --- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/O_OB_S_SE_SL_TraverserGenerator.java +++ /dev/null @@ -1,59 +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 org.apache.tinkerpop.gremlin.process.traversal.traverser; - -import org.apache.tinkerpop.gremlin.process.traversal.Step; -import org.apache.tinkerpop.gremlin.process.traversal.Traverser; -import org.apache.tinkerpop.gremlin.process.traversal.TraverserGenerator; - -import java.util.EnumSet; -import java.util.Set; - -/** - * @author Marko A. Rodriguez (http://markorodriguez.com) - */ -public final class O_OB_S_SE_SL_TraverserGenerator implements TraverserGenerator { - - private static final Set REQUIREMENTS = EnumSet.of( - TraverserRequirement.OBJECT, - TraverserRequirement.ONE_BULK, - TraverserRequirement.SACK, - TraverserRequirement.SIDE_EFFECTS, - TraverserRequirement.SINGLE_LOOP); - - private static final O_OB_S_SE_SL_TraverserGenerator INSTANCE = new O_OB_S_SE_SL_TraverserGenerator(); - - private O_OB_S_SE_SL_TraverserGenerator() { - } - - @Override - public Traverser.Admin generate(final S start, final Step startStep, final long initialBulk) { - return new O_OB_S_SE_SL_Traverser<>(start, startStep); - } - - @Override - public Set getProvidedRequirements() { - return REQUIREMENTS; - } - - public static O_OB_S_SE_SL_TraverserGenerator instance() { - return INSTANCE; - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/beebbbc7/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/O_Traverser.java ---------------------------------------------------------------------- diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/O_Traverser.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/O_Traverser.java deleted file mode 100644 index 44e0f6e..0000000 --- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/O_Traverser.java +++ /dev/null @@ -1,72 +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 org.apache.tinkerpop.gremlin.process.traversal.traverser; - -import org.apache.tinkerpop.gremlin.process.traversal.Step; -import org.apache.tinkerpop.gremlin.process.traversal.Traverser; -import org.apache.tinkerpop.gremlin.process.traversal.traverser.util.AbstractTraverser; - -import java.util.HashSet; -import java.util.Set; - -/** - * @author Marko A. Rodriguez (http://markorodriguez.com) - */ -public class O_Traverser extends AbstractTraverser { - - protected Set tags = null; - - protected O_Traverser() { - } - - public O_Traverser(final T t) { - super(t); - } - - - public Set getTags() { - if (null == this.tags) this.tags = new HashSet<>(); - return this.tags; - } - - @Override - public Admin split(final R r, final Step step) { - final O_Traverser clone = (O_Traverser) super.split(r, step); - if (null != this.tags) - clone.tags = new HashSet<>(this.tags); - return clone; - } - - @Override - public Admin split() { - final O_Traverser clone = (O_Traverser) super.split(); - if (null != this.tags) - clone.tags = new HashSet<>(this.tags); - return clone; - } - - @Override - public void merge(final Traverser.Admin other) { - super.merge(other); - if (!other.getTags().isEmpty()) { - if (this.tags == null) this.tags = new HashSet<>(); - this.tags.addAll(other.getTags()); - } - } -} http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/beebbbc7/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/O_TraverserGenerator.java ---------------------------------------------------------------------- diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/O_TraverserGenerator.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/O_TraverserGenerator.java deleted file mode 100644 index 8a67b18..0000000 --- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/O_TraverserGenerator.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 org.apache.tinkerpop.gremlin.process.traversal.traverser; - -import org.apache.tinkerpop.gremlin.process.traversal.Step; -import org.apache.tinkerpop.gremlin.process.traversal.Traverser; -import org.apache.tinkerpop.gremlin.process.traversal.TraverserGenerator; - -import java.util.Collections; -import java.util.Set; - -/** - * @author Marko A. Rodriguez (http://markorodriguez.com) - */ -public final class O_TraverserGenerator implements TraverserGenerator { - - private static final Set REQUIREMENTS = Collections.singleton(TraverserRequirement.OBJECT); - private static final O_TraverserGenerator INSTANCE = new O_TraverserGenerator(); - - private O_TraverserGenerator() { - } - - @Override - public Traverser.Admin generate(final S start, final Step startStep, final long initialBulk) { - return new O_Traverser<>(start); - } - - @Override - public Set getProvidedRequirements() { - return REQUIREMENTS; - } - - public static O_TraverserGenerator instance() { - return INSTANCE; - } -} \ No newline at end of file