Gremlinq.Extensions.Strategies
Introduction
Gremlinq.Extensions.Strategies enhances Gremlinq with support for traversal strategies. Note, however, that not every graph database provider may support all TinkerPop strategies (especially CosmosDb only supports a very limited set of traversal strategies). Please consult the respective documentation of your graph database provider.
Supported strategies:
AdjacentToIncidentStrategyConnectiveStrategyCountStrategyEarlyLimitStrategyEdgeLabelVerificationStrategyElementIdStrategyFilterRankingStrategyGraphFilterStrategyHaltedTraverserStrategyIdentityRemovalStrategyIncidentToAdjacentStrategyInlineFilterStrategyLambdaRestrictionStrategyLazyBarrierStrategyMatchAlgorithmStrategyMatchPredicateStrategyOptionsStrategyOrderLimitStrategyPartitionStrategyPathProcessorStrategyReadOnlyStrategyRepeatUnrollStrategyReservedKeysVerificationStrategySubgraphStrategyVertexProgramStrategy
Strategies supported on CosmosDb:
PartitionStrategyProjectionStrategy
Setup
After setting up our NuGet package server with your license key, add the package(s) to your project
In your app's initial setup of IGremlinQuerySource, configure the environment and addd a call
to AddStrategySupport, like shown below:
using static ExRam.Gremlinq.Core.GremlinQuerySource;
// (Incomplete) example provider setup and Gremlinq.Extensions.Strategies setup
var source = g
.UseGremlinServer<Vertex, Edge>(_ => _
.AtLocalhost())
.ConfigureEnvironment(env => env
.AddStrategySupport());
For CosmosDb, AddCosmosDbStrategySupport must be called instead. It is not necessary to
call both, AddCosmosDbStrategySupport and AddStrategySupport:
using static ExRam.Gremlinq.Core.GremlinQuerySource;
// (Incomplete) example provider setup and Gremlinq.Extensions.Strategies setup
var source = g
.UseCosmosDb<Vertex, Edge>(_ => _
.AtLocalhost())
.ConfigureEnvironment(env => env
.AddCosmosDbStrategySupport());
Usage example
- General TinkerPop
using static ExRam.Gremlinq.Core.GremlinQuerySource;
// Usage example:
await source
.WithStrategy(SubgraphStrategy
.Build()
.Vertices(__ => __
.Cast<Vertex>()
.Where(x => x.Tenant == "tenantId"))
.Create())
.V();
- CosmosDb
using static ExRam.Gremlinq.Core.GremlinQuerySource;
// (Incomplete) example provider setup and Gremlinq.Extensions.Strategies.CosmosDb setup
var source = g
.UseCosmosDb<Vertex, Edge>(_ => _
.AtLocalhost())
.ConfigureEnvironment(env => env
.AddCosmosDbStrategySupport());
/* Usage example:
Retrieve system properties as part of vertices and
edges. Make sure that the entity classes in your
project contain the respective properties with
appropriate types and names, i.e.
public class Vertex
{
public string? _Etag { get; set; }
public string? _Self { get; set; }
}*/
await source
.WithStrategy(ProjectionStrategy
.Build()
.IncludeSystemProperties(SystemProperty._etag, SystemProperty._self)
.Create())
.V();
await source
.WithStrategy(PartitionStrategy
.Build()
.PartitionKey("PartitionKey")
.ReadPartitions("_partition_1")
.Create())
.V();
Further reading:
Traversal strategies
Access system document properties using Azure Cosmos DB
Pricing
| Quantity (Developer Seats) | Unit price (€) / year |
|---|---|
| For the first 1 to 5 | 249.00 |
| For the next 6 to 10 | 184.00 |
| For the next 11 to 20 | 139.00 |
| For the next 21 to 50 | 99.00 |
| For the next 51 to 100 | 74.00 |
| For the rest | 49.00 |