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/09/09 14:37:12 UTC
[11/13] incubator-tinkerpop git commit: Merge remote-tracking branch
'origin/master' into TINKERPOP3-333
Merge remote-tracking branch 'origin/master' into TINKERPOP3-333
Conflicts:
gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/util/Parameters.java
tinkergraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/tinkergraph/process/traversal/step/sideEffect/TinkerGraphStep.java
Project: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/commit/781a4667
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/tree/781a4667
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/diff/781a4667
Branch: refs/heads/master
Commit: 781a4667e84be2141c961923d088612557ec2301
Parents: c3de6f8 e643006
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Tue Sep 8 15:09:25 2015 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Tue Sep 8 15:09:25 2015 -0400
----------------------------------------------------------------------
CHANGELOG.asciidoc | 45 +-
RELEASE.asciidoc | 48 ++-
bin/bump.sh | 47 ---
docs/preprocessor/preprocess.sh | 8 +
gremlin-console/src/main/LICENSE | 36 +-
gremlin-console/src/main/NOTICE | 59 +--
.../GephiTraversalVisualizationStrategy.groovy | 6 -
.../gremlin/process/computer/VertexProgram.java | 4 +
.../computer/bulkloading/BulkLoader.java | 115 ++++++
.../bulkloading/BulkLoaderVertexProgram.java | 407 +++++++++++++++++++
.../bulkloading/IncrementalBulkLoader.java | 150 +++++++
.../traversal/TraversalVertexProgram.java | 1 -
.../traversal/VertexTraversalSideEffects.java | 12 +-
.../util/AbstractVertexProgramBuilder.java | 5 +-
.../gremlin/process/traversal/Compare.java | 47 ++-
.../tinkerpop/gremlin/process/traversal/P.java | 31 +-
.../process/traversal/Parameterizing.java | 31 +-
.../gremlin/process/traversal/Pop.java | 31 +-
.../process/traversal/SackFunctions.java | 49 +++
.../gremlin/process/traversal/Traversal.java | 2 +-
.../process/traversal/TraversalSideEffects.java | 28 +-
.../process/traversal/TraversalStrategies.java | 4 +-
.../traversal/dsl/graph/GraphTraversal.java | 12 +-
.../dsl/graph/GraphTraversalSource.java | 64 ++-
.../gremlin/process/traversal/dsl/graph/__.java | 5 +
.../traversal/lambda/FunctionTraverser.java | 31 +-
.../process/traversal/lambda/LoopTraversal.java | 31 +-
.../traversal/lambda/PredicateTraverser.java | 31 +-
.../process/traversal/step/Bypassing.java | 31 +-
.../process/traversal/step/PathProcessor.java | 31 +-
.../gremlin/process/traversal/step/Scoping.java | 31 +-
.../process/traversal/step/filter/NotStep.java | 31 +-
.../step/filter/TraversalFilterStep.java | 31 +-
.../step/filter/WherePredicateStep.java | 31 +-
.../step/filter/WhereTraversalStep.java | 31 +-
.../process/traversal/step/map/AddEdgeStep.java | 6 +-
.../process/traversal/step/map/HasNextStep.java | 31 +-
.../process/traversal/step/map/MapKeysStep.java | 31 +-
.../traversal/step/map/MapValuesStep.java | 31 +-
.../process/traversal/step/map/MatchStep.java | 31 +-
.../step/map/TraversalFlatMapStep.java | 31 +-
.../traversal/step/map/TraversalMapStep.java | 31 +-
.../step/sideEffect/AddPropertyStep.java | 9 +-
.../sideEffect/TraversalSideEffectStep.java | 31 +-
.../step/util/CollectingBarrierStep.java | 2 +-
.../step/util/LambdaCollectingBarrierStep.java | 59 +++
.../traversal/step/util/NoOpBarrierStep.java | 44 --
.../process/traversal/step/util/Parameters.java | 102 +++--
.../strategy/decoration/PartitionStrategy.java | 18 +-
.../finalization/LazyBarrierStrategy.java | 38 +-
.../finalization/MatchAlgorithmStrategy.java | 31 +-
.../ComputerVerificationException.java | 36 --
.../ComputerVerificationStrategy.java | 20 +-
.../verification/LambdaRestrictionStrategy.java | 6 +-
.../strategy/verification/ReadOnlyStrategy.java | 15 +-
.../StandardVerificationStrategy.java | 48 +++
.../verification/VerificationException.java | 36 ++
.../traverser/B_LP_O_P_S_SE_SL_Traverser.java | 4 +-
.../traverser/B_LP_O_S_SE_SL_Traverser.java | 37 +-
.../B_LP_O_S_SE_SL_TraverserGenerator.java | 31 +-
.../traverser/B_O_S_SE_SL_Traverser.java | 21 +-
.../gremlin/process/traversal/util/AndP.java | 31 +-
.../process/traversal/util/ConjunctionP.java | 31 +-
.../util/DefaultTraversalSideEffects.java | 20 +-
.../util/EmptyTraversalSideEffects.java | 20 +-
.../gremlin/process/traversal/util/OrP.java | 31 +-
.../traversal/util/TraversalClassFunction.java | 31 +-
.../tinkerpop/gremlin/structure/Graph.java | 13 +
.../gremlin/structure/io/gryo/GryoMapper.java | 5 +-
.../structure/io/gryo/PairSerializer.java | 42 ++
.../structure/util/reference/ReferenceEdge.java | 31 +-
.../util/reference/ReferenceElement.java | 31 +-
.../util/reference/ReferenceFactory.java | 31 +-
.../structure/util/reference/ReferencePath.java | 31 +-
.../util/reference/ReferenceProperty.java | 31 +-
.../util/reference/ReferenceVertex.java | 31 +-
.../util/reference/ReferenceVertexProperty.java | 31 +-
.../gremlin/structure/util/star/StarGraph.java | 31 +-
.../util/star/StarGraphGryoSerializer.java | 31 +-
.../gremlin/process/traversal/CompareTest.java | 49 ++-
.../gremlin/process/traversal/PathTest.java | 31 +-
.../traversal/dsl/graph/GraphTraversalTest.java | 31 +-
.../process/traversal/step/StepTest.java | 31 +-
.../traversal/step/branch/BranchStepTest.java | 31 +-
.../traversal/step/branch/ChooseStepTest.java | 31 +-
.../traversal/step/branch/LocalStepTest.java | 31 +-
.../traversal/step/branch/RepeatStepTest.java | 31 +-
.../traversal/step/branch/UnionStepTest.java | 31 +-
.../traversal/step/filter/AndStepTest.java | 31 +-
.../traversal/step/filter/CoinStepTest.java | 31 +-
.../step/filter/CyclicPathStepTest.java | 31 +-
.../step/filter/DedupGlobalStepTest.java | 31 +-
.../traversal/step/filter/DropStepTest.java | 31 +-
.../traversal/step/filter/HasStepTest.java | 31 +-
.../traversal/step/filter/IsStepTest.java | 31 +-
.../step/filter/LambdaFilterStepTest.java | 31 +-
.../traversal/step/filter/OrStepTest.java | 31 +-
.../step/filter/RangeGlobalStepTest.java | 31 +-
.../step/filter/SampleGlobalStepTest.java | 31 +-
.../step/filter/SimplePathStepTest.java | 31 +-
.../step/filter/TailGlobalStepTest.java | 31 +-
.../step/filter/TimeLimitStepTest.java | 31 +-
.../traversal/step/filter/WhereStepTest.java | 31 +-
.../traversal/step/map/AddEdgeStepTest.java | 31 +-
.../traversal/step/map/CoalesceStepTest.java | 31 +-
.../traversal/step/map/CountGlobalStepTest.java | 31 +-
.../traversal/step/map/CountLocalStepTest.java | 31 +-
.../traversal/step/map/DedupLocalStepTest.java | 31 +-
.../step/map/EdgeOtherVertexStepTest.java | 31 +-
.../traversal/step/map/EdgeVertexStepTest.java | 31 +-
.../traversal/step/map/FoldStepTest.java | 31 +-
.../traversal/step/map/GroupCountStepTest.java | 31 +-
.../traversal/step/map/GroupStepTest.java | 31 +-
.../process/traversal/step/map/IdStepTest.java | 31 +-
.../traversal/step/map/LabelStepTest.java | 31 +-
.../step/map/LambdaFlatMapStepTest.java | 31 +-
.../traversal/step/map/LambdaMapStepTest.java | 31 +-
.../traversal/step/map/LoopsStepTest.java | 31 +-
.../traversal/step/map/MapKeysStepTest.java | 31 +-
.../traversal/step/map/MapValuesStepTest.java | 31 +-
.../traversal/step/map/MatchStepTest.java | 35 +-
.../traversal/step/map/MaxGlobalStepTest.java | 31 +-
.../traversal/step/map/MaxLocalStepTest.java | 31 +-
.../traversal/step/map/MeanGlobalStepTest.java | 31 +-
.../traversal/step/map/MeanLocalStepTest.java | 31 +-
.../traversal/step/map/MinGlobalStepTest.java | 31 +-
.../traversal/step/map/MinLocalStepTest.java | 31 +-
.../traversal/step/map/OrderGlobalStepTest.java | 31 +-
.../traversal/step/map/OrderLocalStepTest.java | 31 +-
.../traversal/step/map/PathStepTest.java | 31 +-
.../traversal/step/map/PropertiesStepTest.java | 31 +-
.../traversal/step/map/PropertyKeyStepTest.java | 31 +-
.../traversal/step/map/PropertyMapStepTest.java | 31 +-
.../step/map/PropertyValueStepTest.java | 31 +-
.../traversal/step/map/RangeLocalStepTest.java | 31 +-
.../traversal/step/map/SackStepTest.java | 31 +-
.../traversal/step/map/SampleLocalStepTest.java | 31 +-
.../traversal/step/map/SelectOneStepTest.java | 31 +-
.../traversal/step/map/SelectStepTest.java | 31 +-
.../traversal/step/map/SumGlobalStepTest.java | 31 +-
.../traversal/step/map/SumLocalStepTest.java | 31 +-
.../traversal/step/map/TailLocalStepTest.java | 31 +-
.../traversal/step/map/TreeStepTest.java | 31 +-
.../traversal/step/map/UnfoldStepTest.java | 31 +-
.../traversal/step/map/VertexStepTest.java | 31 +-
.../step/sideEffect/AddPropertyStepTest.java | 35 +-
.../step/sideEffect/AggregateStepTest.java | 31 +-
.../GroupCountSideEffectStepTest.java | 31 +-
.../sideEffect/GroupSideEffectStepTest.java | 31 +-
.../step/sideEffect/IdentityStepTest.java | 31 +-
.../step/sideEffect/InjectStepTest.java | 31 +-
.../sideEffect/LambdaSideEffectStepTest.java | 31 +-
.../step/sideEffect/ProfileStepTest.java | 31 +-
.../step/sideEffect/SackValueStepTest.java | 31 +-
.../step/sideEffect/SideEffectCapStepTest.java | 31 +-
.../step/sideEffect/StoreStepTest.java | 31 +-
.../step/sideEffect/SubgraphStepTest.java | 31 +-
.../step/sideEffect/TreeSideEffectStepTest.java | 31 +-
.../step/util/NoOpBarrierStepTest.java | 31 +-
.../traversal/step/util/ParametersTest.java | 45 +-
.../decoration/ConjunctionStrategyTest.java | 31 +-
.../PartitionStrategyTraverseTest.java | 8 +-
.../finalization/LazyBarrierStrategyTest.java | 31 +-
.../optimization/FilterRankingStrategyTest.java | 31 +-
.../IdentityRemovalStrategyTest.java | 31 +-
.../MatchPredicateStrategyTest.java | 31 +-
.../ComputerVerificationStrategyTest.java | 35 +-
.../LambdaRestrictionStrategyTest.java | 4 +-
.../verification/ReadOnlyStrategyTest.java | 8 +-
.../StandardVerificationStrategyTest.java | 79 ++++
.../util/DefaultTraversalStrategiesTest.java | 31 +-
.../gremlin/driver/AuthProperties.java | 34 +-
.../tinkerpop/gremlin/driver/Cluster.java | 46 +++
.../tinkerpop/gremlin/driver/Handler.java | 2 +-
.../step/branch/GroovyRepeatTest.groovy | 5 +
.../traversal/step/filter/GroovyHasTest.groovy | 5 +
.../step/map/GroovyAddVertexTest.groovy | 10 +
.../traversal/step/map/GroovyOrderTest.groovy | 4 +-
.../step/sideEffect/GroovySackTest.groovy | 6 +
.../step/sideEffect/GroovyStoreTest.groovy | 2 +-
.../util/TestableConsolePluginAcceptor.java | 31 +-
.../process/GroovyProcessComputerSuite.java | 24 +-
.../gremlin/groovy/loaders/StepLoader.groovy | 23 +-
.../AbstractImportCustomizerProvider.java | 6 +-
.../groovy/function/GBinaryOperator.java | 55 +++
gremlin-server/src/main/LICENSE | 33 +-
gremlin-server/src/main/NOTICE | 90 +---
.../server/GremlinDriverIntegrateTest.java | 11 +-
.../gremlin/process/GremlinProcessRunner.java | 4 +-
.../gremlin/process/ProcessComputerSuite.java | 2 +
.../BulkLoaderVertexProgramTest.java | 82 ++++
.../traversal/step/branch/RepeatTest.java | 16 +
.../process/traversal/step/filter/HasTest.java | 20 +-
.../traversal/step/map/AddVertexTest.java | 72 +++-
.../process/traversal/step/map/OrderTest.java | 22 +-
.../traversal/step/sideEffect/SackTest.java | 17 +
.../PartitionStrategyProcessTest.java | 4 +
.../util/detached/DetachedGraphTest.java | 31 +-
.../util/reference/ReferenceEdgeTest.java | 31 +-
.../util/reference/ReferenceGraphTest.java | 31 +-
.../reference/ReferenceVertexPropertyTest.java | 31 +-
.../util/reference/ReferenceVertexTest.java | 31 +-
hadoop-gremlin/pom.xml | 6 +
.../computer/AbstractHadoopGraphComputer.java | 31 +-
.../computer/PersistResultGraphAware.java | 31 +-
.../computer/spark/io/InputFormatRDD.java | 31 +-
.../process/computer/spark/io/InputRDD.java | 31 +-
.../computer/spark/io/OutputFormatRDD.java | 31 +-
.../process/computer/spark/io/OutputRDD.java | 31 +-
.../computer/spark/payload/MessagePayload.java | 31 +-
.../process/computer/spark/payload/Payload.java | 31 +-
.../spark/payload/ViewIncomingPayload.java | 31 +-
.../spark/payload/ViewOutgoingPayload.java | 31 +-
.../computer/spark/payload/ViewPayload.java | 31 +-
.../structure/io/HadoopPoolsConfigurable.java | 31 +-
.../structure/io/VertexWritableIterator.java | 31 +-
.../groovy/plugin/HadoopGremlinPluginTest.java | 31 +-
.../hadoop/groovy/plugin/HadoopPluginSuite.java | 31 +-
.../GiraphHadoopGremlinPluginIntegrateTest.java | 31 +-
.../groovy/SparkHadoopGremlinPluginTest.java | 31 +-
.../computer/spark/io/ExampleInputRDD.java | 31 +-
.../computer/spark/io/ExampleOutputRDD.java | 31 +-
.../computer/spark/io/InputOutputRDDTest.java | 31 +-
.../process/computer/spark/io/InputRDDTest.java | 31 +-
.../computer/spark/io/OutputRDDTest.java | 31 +-
.../hadoop/structure/io/VertexWritableTest.java | 31 +-
.../gremlin/neo4j/process/traversal/LabelP.java | 31 +-
.../step/sideEffect/CypherStartStep.java | 31 +-
.../step/sideEffect/Neo4jGraphStep.java | 4 +-
.../gremlin/neo4j/structure/Neo4jGraph.java | 5 +
.../structure/trait/MultiMetaNeo4jTrait.java | 31 +-
.../neo4j/structure/trait/Neo4jTrait.java | 31 +-
.../trait/NoMultiNoMetaNeo4jTrait.java | 31 +-
.../gremlin/neo4j/AbstractNeo4jGremlinTest.java | 31 +-
.../MultiMetaNeo4jGraphNativeNeo4jTest.java | 31 +-
.../gremlin/neo4j/NativeNeo4jSuite.java | 31 +-
.../NoMultiNoMetaNeo4jGraphNativeNeo4jTest.java | 31 +-
.../neo4j/NoMultiNoMetaNeo4jGraphProvider.java | 31 +-
...ultiNoMetaNeo4jGraphProcessStandardTest.java | 31 +-
...MetaNeo4jGraphGroovyProcessStandardTest.java | 31 +-
.../neo4j/structure/NativeNeo4jIndexTest.java | 31 +-
.../structure/NativeNeo4jStructureTest.java | 31 +-
...tiNoMetaNeo4jGraphStructureStandardTest.java | 31 +-
.../step/sideEffect/TinkerGraphStep.java | 5 +-
.../tinkergraph/structure/TinkerGraph.java | 5 +
.../TinkerGraphNoStrategyComputerProvider.java | 31 +-
...hNoStrategyProcessComputerIntegrateTest.java | 31 +-
.../TinkerGraphStepStrategyTest.java | 31 +-
.../tinkergraph/structure/TinkerGraphTest.java | 33 +-
249 files changed, 4369 insertions(+), 3452 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/781a4667/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/util/Parameters.java
----------------------------------------------------------------------
diff --cc gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/util/Parameters.java
index 10d3637,3f03b59..3e46768
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/util/Parameters.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/util/Parameters.java
@@@ -1,24 -1,21 +1,22 @@@
/*
+ * 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
*
- * 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.
+ * 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.step.util;
import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
@@@ -56,20 -50,22 +54,26 @@@ public final class Parameters implement
this.set(newKey, this.parameters.remove(oldKey));
}
- public <S, E> E get(final Traverser.Admin<S> traverser, final Object key, final Supplier<E> defaultValue) {
- final Object object = parameters.get(key);
- return null == object ? defaultValue.get() : object instanceof Traversal.Admin ? TraversalUtil.apply(traverser, (Traversal.Admin<S, E>) object) : (E) object;
+ public <S, E> List<E> get(final Traverser.Admin<S> traverser, final Object key, final Supplier<E> defaultValue) {
+ final List<E> values = (List<E>) this.parameters.get(key);
+ if (null == values) return Collections.singletonList(defaultValue.get());
+ final List<E> result = new ArrayList<>();
+ for (final Object value : values) {
+ result.add(value instanceof Traversal.Admin ? TraversalUtil.apply(traverser, (Traversal.Admin<S, E>) value) : (E) value);
+ }
+ return result;
}
- public <E> E get(final Object key, final Supplier<E> defaultValue) {
- final Object object = parameters.get(key);
- return null == object ? defaultValue.get() : (E) object;
+ public <E> List<E> get(final Object key, final Supplier<E> defaultValue) {
+ final List<E> list = (List<E>) this.parameters.get(key);
+ return (null == list) ? Collections.singletonList(defaultValue.get()) : list;
+
}
+ public Object remove(final Object key) {
+ return parameters.remove(key);
+ }
+
public <S> Object[] getKeyValues(final Traverser.Admin<S> traverser, final Object... exceptKeys) {
if (this.parameters.size() == 0) return EMPTY_ARRAY;
final List<Object> exceptions = Arrays.asList(exceptKeys);
@@@ -83,23 -81,6 +89,23 @@@
return keyValues.toArray(new Object[keyValues.size()]);
}
+ /**
+ * Gets an immutable set of the parameters without evaluating them in the context of a {@link Traverser} as
+ * is done in {@link #getKeyValues(Traverser.Admin, Object...)}.
+ *
+ * @param exceptKeys keys to not include in the returned {@link Map}
+ */
- public Map<Object,Object> getRaw(final Object... exceptKeys) {
++ public Map<Object,List<Object>> getRaw(final Object... exceptKeys) {
+ if (parameters.isEmpty()) return Collections.emptyMap();
+ final List<Object> exceptions = Arrays.asList(exceptKeys);
- final Map<Object,Object> raw = new HashMap<>();
- for (Map.Entry entry : parameters.entrySet()) {
++ final Map<Object,List<Object>> raw = new HashMap<>();
++ for (Map.Entry<Object, List<Object>> entry : parameters.entrySet()) {
+ if (!exceptions.contains(entry.getKey())) raw.put(entry.getKey(), entry.getValue());
+ }
+
+ return Collections.unmodifiableMap(raw);
+ }
+
public void set(final Object... keyValues) {
for (int i = 0; i < keyValues.length; i = i + 2) {
if (keyValues[i + 1] != null) {
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/781a4667/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/decoration/PartitionStrategy.java
----------------------------------------------------------------------
diff --cc gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/decoration/PartitionStrategy.java
index fc344ab,943380c..4ba0b95
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/decoration/PartitionStrategy.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/decoration/PartitionStrategy.java
@@@ -122,100 -83,13 +122,102 @@@ public final class PartitionStrategy ex
stepsToInsertHasAfter.addAll(TraversalHelper.getStepsOfAssignableClass(EdgeOtherVertexStep.class, traversal));
stepsToInsertHasAfter.addAll(TraversalHelper.getStepsOfAssignableClass(EdgeVertexStep.class, traversal));
- // all steps that return a vertex need to have has(paritionKey,within,partitionValues) injected after it
+ // all steps that return a vertex need to have has(partitionKey,within,partitionValues) injected after it
stepsToInsertHasAfter.forEach(step -> TraversalHelper.insertAfterStep(
- new HasStep(traversal, new HasContainer(this.partitionKey, P.within(new ArrayList<>(this.readPartitions)))), step, traversal));
+ new HasStep(traversal, new HasContainer(partitionKey, P.within(new ArrayList<>(readPartitions)))), step, traversal));
+
+ if (includeMetaProperties) {
+ final List<PropertiesStep> propertiesSteps = TraversalHelper.getStepsOfAssignableClass(PropertiesStep.class, traversal);
+ propertiesSteps.forEach(step -> {
+ // check length first because keyExists will return true otherwise
+ if (step.getPropertyKeys().length > 0 && ElementHelper.keyExists(partitionKey, step.getPropertyKeys()))
+ throw new IllegalStateException("Cannot explicitly request the partitionKey in the traversal");
+
+ if (step.getReturnType() == PropertyType.PROPERTY) {
+ // check the following step to see if it is a has(partitionKey, *) - if so then this strategy was
+ // already applied down below via g.V().values() which injects a properties() step
+ final Step next = step.getNextStep();
+ if (!(next instanceof HasStep) || !((HasContainer) ((HasStep) next).getHasContainers().get(0)).getKey().equals(partitionKey)) {
+ // use choose() to determine if the properties() step is called on a Vertex to get a VertexProperty
+ // if not, pass it through.
+ final Traversal choose = __.choose(
+ __.filter(new TypeChecker<>(VertexProperty.class)),
+ __.has(partitionKey, P.within(new ArrayList<>(readPartitions))),
+ __.__()).filter(new PartitionKeyHider());
+ TraversalHelper.insertTraversal(step, choose.asAdmin(), traversal);
+ }
+ } else if (step.getReturnType() == PropertyType.VALUE) {
+ // use choose() to determine if the values() step is called on a Vertex to get a VertexProperty
+ // if not, pass it through otherwise explode g.V().values() to g.V().properties().has().value()
+ final Traversal choose = __.choose(
+ __.filter(new TypeChecker<>(Vertex.class)),
+ __.properties(step.getPropertyKeys()).has(partitionKey, P.within(new ArrayList<>(readPartitions))).filter(new PartitionKeyHider()).value(),
+ __.__().filter(new PartitionKeyHider()));
+ TraversalHelper.insertTraversal(step, choose.asAdmin(), traversal);
+ traversal.removeStep(step);
+ } else {
+ throw new IllegalStateException(String.format("%s is not accounting for a particular %s %s",
+ PartitionStrategy.class.getSimpleName(), PropertyType.class.toString(), step.getReturnType()));
+ }
+ });
+
+ final List<PropertyMapStep> propertyMapSteps = TraversalHelper.getStepsOfAssignableClass(PropertyMapStep.class, traversal);
+ propertyMapSteps.forEach(step -> {
+ // check length first because keyExists will return true otherwise
+ if (step.getPropertyKeys().length > 0 && ElementHelper.keyExists(partitionKey, step.getPropertyKeys()))
+ throw new IllegalStateException("Cannot explicitly request the partitionKey in the traversal");
+
+ if (step.getReturnType() == PropertyType.PROPERTY) {
+ // via map() filter out properties that aren't in the partition if it is a PropertyVertex,
+ // otherwise just let them pass through
+ TraversalHelper.insertAfterStep(new LambdaMapStep<>(traversal, new MapPropertiesFilter()), step, traversal);
+ } else if (step.getReturnType() == PropertyType.VALUE) {
+ // as this is a value map, replace that step with propertiesMap() that returns PropertyType.VALUE.
+ // from there, add the filter as shown above and then unwrap the properties as they would have
+ // been done under valueMap()
+ final PropertyMapStep propertyMapStep = new PropertyMapStep(traversal, step.isIncludeTokens(), PropertyType.PROPERTY, step.getPropertyKeys());
+ TraversalHelper.replaceStep(step, propertyMapStep, traversal);
+
+ final LambdaMapStep mapPropertiesFilterStep = new LambdaMapStep<>(traversal, new MapPropertiesFilter());
+ TraversalHelper.insertAfterStep(mapPropertiesFilterStep, propertyMapStep, traversal);
+ TraversalHelper.insertAfterStep(new LambdaMapStep<>(traversal, new MapPropertiesConverter()), mapPropertiesFilterStep, traversal);
+ } else {
+ throw new IllegalStateException(String.format("%s is not accounting for a particular %s %s",
+ PartitionStrategy.class.getSimpleName(), PropertyType.class.toString(), step.getReturnType()));
+ }
+ });
+ }
+
+ final List<Step> stepsToInsertPropertyMutations = traversal.getSteps().stream().filter(step ->
+ step instanceof AddEdgeStep || step instanceof AddVertexStep ||
+ step instanceof AddVertexStartStep || (includeMetaProperties && step instanceof AddPropertyStep)
+ ).collect(Collectors.toList());
- traversal.getSteps().forEach(step -> {
- if (step instanceof AddEdgeStep || step instanceof AddVertexStep || step instanceof AddVertexStartStep) {
- ((Mutating) step).addPropertyMutations(this.partitionKey, this.writePartition);
+ stepsToInsertPropertyMutations.forEach(step -> {
+ // note that with AddPropertyStep we just add the partition key/value regardless of whether this
+ // ends up being a Vertex or not. AddPropertyStep currently chooses to simply not bother
+ // to use the additional "property mutations" if the Element being mutated is a Edge or
+ // VertexProperty
+ ((Mutating) step).addPropertyMutations(partitionKey, writePartition);
+
+ if (includeMetaProperties) {
+ // GraphTraversal folds g.addV().property('k','v') to just AddVertexStep/AddVertexStartStep so this
+ // has to be exploded back to g.addV().property('k','v','partition','A')
+ if (step instanceof AddVertexStartStep || step instanceof AddVertexStep) {
+ final Parameters parameters = ((Parameterizing) step).getParameters();
- final Map<Object, Object> params = parameters.getRaw();
++ final Map<Object, List<Object>> params = parameters.getRaw();
+ params.forEach((k, v) -> {
- final AddPropertyStep addPropertyStep = new AddPropertyStep(traversal, null, k, v);
- addPropertyStep.addPropertyMutations(partitionKey, writePartition);
- TraversalHelper.insertAfterStep(addPropertyStep, step, traversal);
-
- // need to remove the parameter from the AddVertex/StartStep because it's now being added
- // via the AddPropertyStep
- parameters.remove(k);
++ v.forEach(o -> {
++ final AddPropertyStep addPropertyStep = new AddPropertyStep(traversal, null, k, o);
++ addPropertyStep.addPropertyMutations(partitionKey, writePartition);
++ TraversalHelper.insertAfterStep(addPropertyStep, step, traversal);
++
++ // need to remove the parameter from the AddVertex/StartStep because it's now being added
++ // via the AddPropertyStep
++ parameters.remove(k);
++ });
+ });
+ }
}
});
}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/781a4667/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/step/util/ParametersTest.java
----------------------------------------------------------------------
diff --cc gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/step/util/ParametersTest.java
index c77e0c7,0000000..fcdac02
mode 100644,000000..100644
--- a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/step/util/ParametersTest.java
+++ b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/step/util/ParametersTest.java
@@@ -1,80 -1,0 +1,95 @@@
+/*
+ * 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.step.util;
+
+import org.junit.Test;
+
+import java.util.Collections;
++import java.util.List;
+import java.util.Map;
+
++import static org.hamcrest.MatcherAssert.assertThat;
++import static org.hamcrest.Matchers.contains;
+import static org.junit.Assert.assertEquals;
+
+/**
+ * @author Stephen Mallette (http://stephen.genoprime.com)
+ */
+public class ParametersTest {
+ @Test
+ public void shouldGetRaw() {
+ final Parameters parameters = new Parameters();
+ parameters.set("a", "axe", "b", "bat", "c", "cat");
+
- final Map<Object,Object> params = parameters.getRaw();
++ final Map<Object,List<Object>> params = parameters.getRaw();
+ assertEquals(3, params.size());
- assertEquals("axe", params.get("a"));
- assertEquals("bat", params.get("b"));
- assertEquals("cat", params.get("c"));
++ assertEquals("axe", params.get("a").get(0));
++ assertEquals("bat", params.get("b").get(0));
++ assertEquals("cat", params.get("c").get(0));
++ }
++
++ @Test
++ public void shouldGetRawWithMulti() {
++ final Parameters parameters = new Parameters();
++ parameters.set("a", "axe", "b", "bat", "a", "ant", "c", "cat");
++
++ final Map<Object,List<Object>> params = parameters.getRaw();
++ assertEquals(3, params.size());
++ assertThat(params.get("a"), contains("axe", "ant"));
++ assertEquals("bat", params.get("b").get(0));
++ assertEquals("cat", params.get("c").get(0));
+ }
+
+ @Test
+ public void shouldGetRawEmptyAndUnmodifiable() {
+ final Parameters parameters = new Parameters();
- final Map<Object,Object> params = parameters.getRaw();
++ final Map<Object,List<Object>> params = parameters.getRaw();
+ assertEquals(Collections.emptyMap(), params);
+ }
+
+ @Test
+ public void shouldGetRawExcept() {
+ final Parameters parameters = new Parameters();
+ parameters.set("a", "axe", "b", "bat", "c", "cat");
+
- final Map<Object,Object> params = parameters.getRaw("b");
++ final Map<Object,List<Object>> params = parameters.getRaw("b");
+ assertEquals(2, params.size());
- assertEquals("axe", params.get("a"));
- assertEquals("cat", params.get("c"));
++ assertEquals("axe", params.get("a").get(0));
++ assertEquals("cat", params.get("c").get(0));
+ }
+
+ @Test
+ public void shouldRemove() {
+ final Parameters parameters = new Parameters();
+ parameters.set("a", "axe", "b", "bat", "c", "cat");
+
- final Map<Object,Object> before = parameters.getRaw();
++ final Map<Object,List<Object>> before = parameters.getRaw();
+ assertEquals(3, before.size());
- assertEquals("axe", before.get("a"));
- assertEquals("bat", before.get("b"));
- assertEquals("cat", before.get("c"));
++ assertEquals("axe", before.get("a").get(0));
++ assertEquals("bat", before.get("b").get(0));
++ assertEquals("cat", before.get("c").get(0));
+
+ parameters.remove("b");
+
- final Map<Object,Object> after = parameters.getRaw("b");
++ final Map<Object,List<Object>> after = parameters.getRaw("b");
+ assertEquals(2, after.size());
- assertEquals("axe", after.get("a"));
- assertEquals("cat", after.get("c"));
++ assertEquals("axe", after.get("a").get(0));
++ assertEquals("cat", after.get("c").get(0));
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/781a4667/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/decoration/PartitionStrategyProcessTest.java
----------------------------------------------------------------------
diff --cc gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/decoration/PartitionStrategyProcessTest.java
index e8300dd,0debdae..3f4459d
--- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/decoration/PartitionStrategyProcessTest.java
+++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/decoration/PartitionStrategyProcessTest.java
@@@ -54,199 -48,6 +54,203 @@@ public class PartitionStrategyProcessTe
}
@Test
+ @FeatureRequirementSet(FeatureRequirementSet.Package.VERTICES_ONLY)
+ @FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_META_PROPERTIES)
+ public void shouldAppendPartitionToVertexProperty() {
+ final PartitionStrategy partitionStrategy = PartitionStrategy.build()
+ .includeMetaProperties(true)
+ .partitionKey(partition).writePartition("A").addReadPartition("A").create();
++ Traversal t = create(partitionStrategy).addV().property("any", "thing");
++ System.out.println(t);
++ t.asAdmin().applyStrategies();
++ System.out.println(t);
+ final Vertex v = create(partitionStrategy).addV().property("any", "thing").next();
+
+ assertNotNull(v);
+ assertEquals("thing", v.property("any").value());
+ assertEquals("A", v.property(partition).value());
+ assertEquals("A", v.property("any").value(partition));
+ }
+
+ @Test
+ @FeatureRequirementSet(FeatureRequirementSet.Package.VERTICES_ONLY)
+ @FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_META_PROPERTIES)
+ public void shouldNotAppendPartitionToVertexProperty() {
+ final PartitionStrategy partitionStrategy = PartitionStrategy.build()
+ .includeMetaProperties(false)
+ .partitionKey(partition).writePartition("A").addReadPartition("A").create();
+ final Vertex v = create(partitionStrategy).addV().property("any", "thing").next();
+
+ assertNotNull(v);
+ assertEquals("thing", v.property("any").value());
+ assertEquals("A", v.property(partition).value());
+ assertThat(v.property("any").properties().hasNext(), is(false));
+
+ }
+
+ @Test
+ @FeatureRequirementSet(FeatureRequirementSet.Package.VERTICES_ONLY)
+ @FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_META_PROPERTIES)
+ public void shouldAppendPartitionToAllVertexProperties() {
+ final GraphTraversalSource gOverA = create(PartitionStrategy.build()
+ .includeMetaProperties(true)
+ .partitionKey(partition).writePartition("A").addReadPartition("A").create());
+
+ final GraphTraversalSource gOverB = create(PartitionStrategy.build()
+ .includeMetaProperties(true)
+ .partitionKey(partition).writePartition("B").addReadPartition("B").create());
+
+ final GraphTraversalSource gOverAB = create(PartitionStrategy.build()
+ .includeMetaProperties(true)
+ .partitionKey(partition).writePartition("B").addReadPartition("B").addReadPartition("A").create());
+
+ final Vertex v = gOverA.addV().property("any", "thing").property("some","thing").next();
+
+ assertNotNull(v);
+ assertEquals("thing", v.property("any").value());
+ assertEquals("A", v.property(partition).value());
+ assertEquals("A", v.property("any").value(partition));
+ assertEquals("thing", v.property("some").value());
+ assertEquals("A", v.property("some").value(partition));
+
+ gOverAB.V(v).property("that", "thing").iterate();
+ assertEquals("thing", v.property("that").value());
+ assertEquals("B", v.property("that").value(partition));
+
+ assertThat(gOverAB.V(v).properties("any").hasNext(), is(true));
+ assertThat(gOverAB.V(v).properties("that").hasNext(), is(true));
+ assertThat(gOverA.V(v).properties("that").hasNext(), is(false));
+ assertThat(gOverA.V(v).properties("any").hasNext(), is(true));
+ assertThat(gOverB.V(v).properties("any").hasNext(), is(false));
+ assertThat(gOverB.V(v).properties("that").hasNext(), is(false));
+ assertThat(gOverAB.V(v).properties("partitionKey").hasNext(), is(false));
+
+ assertThat(gOverAB.V(v).values("any").hasNext(), is(true));
+ assertThat(gOverAB.V(v).values("that").hasNext(), is(true));
+ assertThat(gOverA.V(v).values("that").hasNext(), is(false));
+ assertThat(gOverA.V(v).values("any").hasNext(), is(true));
+ assertThat(gOverB.V(v).values("any").hasNext(), is(false));
+ assertThat(gOverB.V(v).values("that").hasNext(), is(false));
+ assertThat(gOverAB.V(v).values("partitionKey").hasNext(), is(false));
+
+ assertThat(gOverAB.V(v).propertyMap().next().containsKey("any"), is(true));
+ assertThat(gOverAB.V(v).propertyMap().next().containsKey("that"), is(true));
+ assertThat(gOverA.V(v).propertyMap().next().containsKey("that"), is(false));
+ assertThat(gOverA.V(v).propertyMap().next().containsKey("any"), is(true));
+ assertThat(gOverB.V(v).propertyMap().hasNext(), is(false));
+ assertThat(gOverB.V(v).propertyMap().hasNext(), is(false));
+ assertThat(gOverAB.V(v).propertyMap().next().containsKey(partition), is(false));
+
+ assertThat(gOverAB.V(v).valueMap().next().containsKey("any"), is(true));
+ assertThat(gOverAB.V(v).valueMap().next().containsKey("that"), is(true));
+ assertThat(gOverA.V(v).valueMap().next().containsKey("that"), is(false));
+ assertThat(gOverA.V(v).valueMap().next().containsKey("any"), is(true));
+ assertThat(gOverB.V(v).valueMap().hasNext(), is(false));
+ assertThat(gOverB.V(v).valueMap().hasNext(), is(false));
+ assertThat(gOverAB.V(v).valueMap().next().containsKey(partition), is(false));
+ }
+
+ @Test(expected = IllegalStateException.class)
+ @FeatureRequirementSet(FeatureRequirementSet.Package.VERTICES_ONLY)
+ @FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_META_PROPERTIES)
+ public void shouldHidePartitionKeyForValues() {
+ final GraphTraversalSource gOverA = create(PartitionStrategy.build()
+ .includeMetaProperties(true)
+ .partitionKey(partition).writePartition("A").addReadPartition("A").create());
+ final Vertex v = gOverA.addV().property("any", "thing").next();
+
+ gOverA.V(v).values(partition).next();
+ }
+
+ @Test
+ @FeatureRequirementSet(FeatureRequirementSet.Package.VERTICES_ONLY)
+ @FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_META_PROPERTIES)
+ public void shouldHidePartitionKeyForValuesWithEmptyKeys() {
+ final GraphTraversalSource gOverA = create(PartitionStrategy.build()
+ .includeMetaProperties(true)
+ .partitionKey(partition).writePartition("A").addReadPartition("A").create());
+ final Vertex v = gOverA.addV().property("any", "thing").next();
+
+ assertEquals(1l, (long) gOverA.V(v).values().count().next());
+ assertEquals("thing", gOverA.V(v).values().next());
+ }
+
+ @Test(expected = IllegalStateException.class)
+ @FeatureRequirementSet(FeatureRequirementSet.Package.VERTICES_ONLY)
+ @FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_META_PROPERTIES)
+ public void shouldHidePartitionKeyForProperties() {
+ final GraphTraversalSource gOverA = create(PartitionStrategy.build()
+ .includeMetaProperties(true)
+ .partitionKey(partition).writePartition("A").addReadPartition("A").create());
+ final Vertex v = gOverA.addV().property("any", "thing").next();
+
+ gOverA.V(v).properties(partition).next();
+ }
+
+ @Test
+ @FeatureRequirementSet(FeatureRequirementSet.Package.VERTICES_ONLY)
+ @FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_META_PROPERTIES)
+ public void shouldHidePartitionKeyForPropertiesWithEmptyKeys() {
+ final GraphTraversalSource gOverA = create(PartitionStrategy.build()
+ .includeMetaProperties(true)
+ .partitionKey(partition).writePartition("A").addReadPartition("A").create());
+ final Vertex v = gOverA.addV().property("any", "thing").next();
+
+ assertEquals(1l, (long) gOverA.V(v).properties().count().next());
+ assertEquals("thing", gOverA.V(v).properties().value().next());
+ }
+
+ @Test(expected = IllegalStateException.class)
+ @FeatureRequirementSet(FeatureRequirementSet.Package.VERTICES_ONLY)
+ @FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_META_PROPERTIES)
+ public void shouldHidePartitionKeyForPropertyMap() {
+ final GraphTraversalSource gOverA = create(PartitionStrategy.build()
+ .includeMetaProperties(true)
+ .partitionKey(partition).writePartition("A").addReadPartition("A").create());
+ final Vertex v = gOverA.addV().property("any", "thing").next();
+
+ gOverA.V(v).propertyMap(partition).next();
+ }
+
+ @Test
+ @FeatureRequirementSet(FeatureRequirementSet.Package.VERTICES_ONLY)
+ @FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_META_PROPERTIES)
+ public void shouldHidePartitionKeyForPropertyMapWithEmptyKeys() {
+ final GraphTraversalSource gOverA = create(PartitionStrategy.build()
+ .includeMetaProperties(true)
+ .partitionKey(partition).writePartition("A").addReadPartition("A").create());
+ final Vertex v = gOverA.addV().property("any", "thing").next();
+
+ assertEquals(1l, (long) gOverA.V(v).propertyMap().count().next());
+ assertEquals("thing", ((List<VertexProperty>) gOverA.V(v).propertyMap().next().get("any")).get(0).value());
+ }
+
+ @Test(expected = IllegalStateException.class)
+ @FeatureRequirementSet(FeatureRequirementSet.Package.VERTICES_ONLY)
+ @FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_META_PROPERTIES)
+ public void shouldHidePartitionKeyForValueMap() {
+ final GraphTraversalSource gOverA = create(PartitionStrategy.build()
+ .includeMetaProperties(true)
+ .partitionKey(partition).writePartition("A").addReadPartition("A").create());
+ final Vertex v = gOverA.addV().property("any", "thing").next();
+
+ gOverA.V(v).valueMap(partition).next();
+ }
+
+ @Test
+ @FeatureRequirementSet(FeatureRequirementSet.Package.VERTICES_ONLY)
+ @FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_META_PROPERTIES)
+ public void shouldHidePartitionKeyForValueMapWithEmptyKeys() {
+ final GraphTraversalSource gOverA = create(PartitionStrategy.build()
+ .includeMetaProperties(true)
+ .partitionKey(partition).writePartition("A").addReadPartition("A").create());
+ final Vertex v = gOverA.addV().property("any", "thing").next();
+
+ assertEquals(1l, (long) gOverA.V(v).valueMap().count().next());
+ assertEquals("thing", ((List) gOverA.V(v).valueMap().next().get("any")).get(0));
+ }
+
+ @Test
@FeatureRequirementSet(FeatureRequirementSet.Package.SIMPLE)
public void shouldAppendPartitionToEdge() {
final PartitionStrategy partitionStrategy = PartitionStrategy.build()
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/781a4667/tinkergraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/tinkergraph/process/traversal/step/sideEffect/TinkerGraphStep.java
----------------------------------------------------------------------