You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by ly...@apache.org on 2022/05/20 17:16:31 UTC

[tinkerpop] branch 3.5-dev updated: Adding strategy support to cucumber world for gremlin-go

This is an automated email from the ASF dual-hosted git repository.

lyndonb pushed a commit to branch 3.5-dev
in repository https://gitbox.apache.org/repos/asf/tinkerpop.git


The following commit(s) were added to refs/heads/3.5-dev by this push:
     new aa2820bc4c Adding strategy support to cucumber world for gremlin-go
aa2820bc4c is described below

commit aa2820bc4cd223e97cb814e7edf2d8a0007ade5c
Author: Lyndon Bauto <ly...@bitquilltech.com>
AuthorDate: Fri May 20 10:16:16 2022 -0700

    Adding strategy support to cucumber world for gremlin-go
---
 gremlin-go/driver/cucumber/cucumberWorld.go | 31 +++++++++++++++++++++++++++
 gremlin-go/driver/strategies.go             | 33 ++++++++++++++++-------------
 2 files changed, 49 insertions(+), 15 deletions(-)

diff --git a/gremlin-go/driver/cucumber/cucumberWorld.go b/gremlin-go/driver/cucumber/cucumberWorld.go
index 7b8c569b55..a4e43303c3 100644
--- a/gremlin-go/driver/cucumber/cucumberWorld.go
+++ b/gremlin-go/driver/cucumber/cucumberWorld.go
@@ -223,6 +223,37 @@ func strategyFactory(strategyName string, params map[string]interface{}) interfa
 			Configuration: nil,
 		}
 		return gremlingo.VertexProgramStrategy(config)
+	case "ProductiveByStrategy":
+		productiveKeys, _ := params["productiveKeys"]
+		productiveKeysInterface := productiveKeys.([]interface{})
+		var productiveKeysStrings = make([]string, len(productiveKeysInterface))
+		for i := range productiveKeysInterface {
+			productiveKeysStrings[i] = productiveKeysInterface[i].(string)
+		}
+		config := gremlingo.ProductiveByStrategyConfig{
+			ProductiveKeys: productiveKeysStrings,
+		}
+		return gremlingo.ProductiveByStrategy(config)
+	case "ReadOnlyStrategy":
+		return gremlingo.ReadOnlyStrategy()
+	case "SubgraphStrategy":
+		edges, _ := params["edges"].(*gremlingo.GraphTraversal)
+		vertices, _ := params["vertices"].(*gremlingo.GraphTraversal)
+		vertexProperties, _ := params["vertexProperties"].(*gremlingo.GraphTraversal)
+		checkAdjacentVertices, _ := params["checkAdjacentVertices"]
+		config := gremlingo.SubgraphStrategyConfig{
+			Edges:                 edges,
+			Vertices:              vertices,
+			VertexProperties:      vertexProperties,
+			CheckAdjacentVertices: checkAdjacentVertices,
+		}
+		return gremlingo.SubgraphStrategy(config)
+	case "SeedStrategy":
+		seed, _ := params["seed"]
+		config := gremlingo.SeedStrategyConfig{
+			Seed: int64(seed.(int)),
+		}
+		return gremlingo.SeedStrategy(config)
 	}
 	return nil
 }
diff --git a/gremlin-go/driver/strategies.go b/gremlin-go/driver/strategies.go
index b7d25c9f1f..c6b751907b 100644
--- a/gremlin-go/driver/strategies.go
+++ b/gremlin-go/driver/strategies.go
@@ -67,7 +67,6 @@ type HaltedTraverserStrategyConfig struct {
 	HaltedTraverserFactoryName string
 }
 
-
 // OptionsStrategy will not alter the Traversal. It is only a holder for configuration options associated with the
 // Traversal meant to be accessed by steps or other classes that might have some interaction with it. It is
 // essentially a way for users to provide Traversal level configuration options that can be used in various ways
@@ -96,9 +95,9 @@ func PartitionStrategy(config PartitionStrategyConfig) TraversalStrategy {
 // PartitionStrategyConfig provides configuration options for PartitionStrategy.
 // Zeroed (unset) values are ignored except IncludeMetaProperties.
 type PartitionStrategyConfig struct {
-	PartitionKey string
-	WritePartition string
-	ReadPartitions []string
+	PartitionKey          string
+	WritePartition        string
+	ReadPartitions        []string
 	IncludeMetaProperties bool
 }
 
@@ -133,14 +132,18 @@ func SubgraphStrategy(config SubgraphStrategyConfig) TraversalStrategy {
 	if config.VertexProperties != nil {
 		configMap["vertexProperties"] = config.VertexProperties
 	}
+	if config.CheckAdjacentVertices != nil {
+		configMap["checkAdjacentVertices"] = config.CheckAdjacentVertices.(bool)
+	}
 	return &traversalStrategy{name: decorationNamespace + "SubgraphStrategy", configuration: configMap}
 }
 
 // SubgraphStrategyConfig provides configuration options for SubgraphStrategy. Zeroed (unset) values are ignored.
 type SubgraphStrategyConfig struct {
-	Vertices *GraphTraversal
-	Edges *GraphTraversal
-	VertexProperties *GraphTraversal
+	Vertices              *GraphTraversal
+	Edges                 *GraphTraversal
+	VertexProperties      *GraphTraversal
+	CheckAdjacentVertices interface{}
 }
 
 func VertexProgramStrategy(config VertexProgramStrategyConfig) TraversalStrategy {
@@ -173,11 +176,11 @@ func VertexProgramStrategy(config VertexProgramStrategyConfig) TraversalStrategy
 // Zeroed (unset) values are ignored.
 type VertexProgramStrategyConfig struct {
 	GraphComputer string
-	Workers int
-	Persist string
-	Result string
-	Vertices *GraphTraversal
-	Edges *GraphTraversal
+	Workers       int
+	Persist       string
+	Result        string
+	Vertices      *GraphTraversal
+	Edges         *GraphTraversal
 	Configuration map[string]interface{}
 }
 
@@ -214,7 +217,7 @@ func EdgeLabelVerificationStrategy(config EdgeLabelVerificationStrategyConfig) T
 // EdgeLabelVerificationStrategyConfig provides configuration options for EdgeLabelVerificationStrategy.
 // Zeroed (unset) values are used.
 type EdgeLabelVerificationStrategyConfig struct {
-	LogWarning bool
+	LogWarning      bool
 	ThrowExcecption bool
 }
 
@@ -247,9 +250,9 @@ func ReservedKeysVerificationStrategy(config ReservedKeysVerificationStrategyCon
 // ReservedKeysVerificationStrategyConfig provides configuration options for ReservedKeysVerificationStrategy.
 // Zeroed (unset) values are used except Keys.
 type ReservedKeysVerificationStrategyConfig struct {
-	LogWarning bool
+	LogWarning     bool
 	ThrowException bool
-	Keys []string
+	Keys           []string
 }
 
 // Optimization strategies