public static IGremlinQueryEnvironment UseCosmosDb(this IGremlinQueryEnvironment env, Func <ICosmosDbConfigurationBuilder, IGremlinQueryExecutorBuilder> transformation)
 {
     return(env
            .UseWebSocket(builder => transformation(new CosmosDbConfigurationBuilder(builder.SetSerializationFormat(SerializationFormat.GraphSonV2))))
            .ConfigureFeatureSet(featureSet => featureSet
                                 .ConfigureGraphFeatures(_ => GraphFeatures.Transactions | GraphFeatures.Persistence | GraphFeatures.ConcurrentAccess)
                                 .ConfigureVariableFeatures(_ => VariableFeatures.BooleanValues | VariableFeatures.IntegerValues | VariableFeatures.ByteValues | VariableFeatures.DoubleValues | VariableFeatures.FloatValues | VariableFeatures.IntegerValues | VariableFeatures.LongValues | VariableFeatures.StringValues)
                                 .ConfigureVertexFeatures(_ => VertexFeatures.RemoveVertices | VertexFeatures.MetaProperties | VertexFeatures.AddVertices | VertexFeatures.MultiProperties | VertexFeatures.StringIds | VertexFeatures.UserSuppliedIds | VertexFeatures.AddProperty | VertexFeatures.RemoveProperty)
                                 .ConfigureVertexPropertyFeatures(_ => VertexPropertyFeatures.StringIds | VertexPropertyFeatures.UserSuppliedIds | VertexPropertyFeatures.RemoveProperty | VertexPropertyFeatures.BooleanValues | VertexPropertyFeatures.ByteValues | VertexPropertyFeatures.DoubleValues | VertexPropertyFeatures.FloatValues | VertexPropertyFeatures.IntegerValues | VertexPropertyFeatures.LongValues | VertexPropertyFeatures.StringValues)
                                 .ConfigureEdgeFeatures(_ => EdgeFeatures.AddEdges | EdgeFeatures.RemoveEdges | EdgeFeatures.StringIds | EdgeFeatures.UserSuppliedIds | EdgeFeatures.AddProperty | EdgeFeatures.RemoveProperty)
                                 .ConfigureEdgePropertyFeatures(_ => EdgePropertyFeatures.Properties | EdgePropertyFeatures.BooleanValues | EdgePropertyFeatures.ByteValues | EdgePropertyFeatures.DoubleValues | EdgePropertyFeatures.FloatValues | EdgePropertyFeatures.IntegerValues | EdgePropertyFeatures.LongValues | EdgePropertyFeatures.StringValues))
            .ConfigureOptions(options => options
                              .SetValue(GremlinqOption.VertexProjectionSteps, ImmutableList <Step> .Empty)
                              .SetValue(GremlinqOption.EdgeProjectionSteps, ImmutableList <Step> .Empty))
            .ConfigureSerializer(serializer => serializer
                                 .ConfigureFragmentSerializer(fragmentSerializer => fragmentSerializer
                                                              .Override <byte[]>((bytes, env, overridden, recurse) => recurse.Serialize(Convert.ToBase64String(bytes), env))
                                                              .Override <CosmosDbKey>((key, env, overridden, recurse) => recurse.Serialize(
                                                                                          key.PartitionKey != null
                         ? new[] { key.PartitionKey, key.Id }
                         : (object)key.Id,
                                                                                          env))
                                                              .Override <HasKeyStep>((step, env, overridden, recurse) =>
     {
         return step.Argument is P p && (!p.OperatorName.Equals("eq", StringComparison.OrdinalIgnoreCase))
                         ? recurse.Serialize(new WhereTraversalStep(new Step[] { KeyStep.Instance, new IsStep(p) }), env)
                         : overridden(step, env, recurse);
     })
                                                              .Override <SkipStep>((step, env, overridden, recurse) => recurse.Serialize(new RangeStep(step.Count, -1, step.Scope), env))
                                                              .Override <LimitStep>((step, env, overridden, recurse) =>
     {
         return step.Count <= int.MaxValue
                         ? overridden(step, env, recurse)
                         : throw new ArgumentOutOfRangeException(nameof(step), "CosmosDb doesn't currently support values for 'Limit' outside the range of a 32-bit-integer.");
     })
                                                              .Override <TailStep>((step, env, overridden, recurse) =>
     {
         return step.Count <= int.MaxValue
                         ? overridden(step, env, recurse)
                         : throw new ArgumentOutOfRangeException(nameof(step), "CosmosDb doesn't currently support values for 'Tail' outside the range of a 32-bit-integer.");
     })
                                                              .Override <RangeStep>((step, env, overridden, recurse) =>
     {
         return step.Lower <= int.MaxValue && step.Upper <= int.MaxValue
                         ? overridden(step, env, recurse)
                         : throw new ArgumentOutOfRangeException(nameof(step), "CosmosDb doesn't currently support values for 'Range' outside the range of a 32-bit-integer.");
     }))
                                 .ToGroovy())
            .StoreTimeSpansAsNumbers());
 }
 public static IGremlinQueryEnvironment UseNeptune(this IGremlinQueryEnvironment environment, Func <IWebSocketGremlinQueryExecutorBuilder, IWebSocketGremlinQueryExecutorBuilder> transformation)
 {
     return(environment
            .UseWebSocket(transformation)
            .ConfigureSerializer(serializer => serializer
                                 .ConfigureFragmentSerializer(fragmentSerializer => fragmentSerializer
                                                              .Override <PropertyStep>((step, env, overridden, recurse) => overridden(Cardinality.List.Equals(step.Cardinality) ? new PropertyStep(step.Key, step.Value, step.MetaProperties, Cardinality.Set) : step, env, recurse))))
            .ConfigureFeatureSet(featureSet => featureSet
                                 .ConfigureGraphFeatures(_ => GraphFeatures.Transactions | GraphFeatures.Persistence | GraphFeatures.ConcurrentAccess)
                                 .ConfigureVariableFeatures(_ => VariableFeatures.None)
                                 .ConfigureVertexFeatures(_ => VertexFeatures.AddVertices | VertexFeatures.RemoveVertices | VertexFeatures.MultiProperties | VertexFeatures.UserSuppliedIds | VertexFeatures.AddProperty | VertexFeatures.RemoveProperty | VertexFeatures.StringIds)
                                 .ConfigureVertexPropertyFeatures(_ => VertexPropertyFeatures.RemoveProperty | VertexPropertyFeatures.NumericIds | VertexPropertyFeatures.StringIds | VertexPropertyFeatures.Properties | VertexPropertyFeatures.BooleanValues | VertexPropertyFeatures.ByteValues | VertexPropertyFeatures.DoubleValues | VertexPropertyFeatures.FloatValues | VertexPropertyFeatures.IntegerValues | VertexPropertyFeatures.LongValues | VertexPropertyFeatures.StringValues)
                                 .ConfigureEdgeFeatures(_ => EdgeFeatures.AddEdges | EdgeFeatures.RemoveEdges | EdgeFeatures.UserSuppliedIds | EdgeFeatures.AddProperty | EdgeFeatures.RemoveProperty | EdgeFeatures.NumericIds | EdgeFeatures.StringIds | EdgeFeatures.UuidIds | EdgeFeatures.CustomIds | EdgeFeatures.AnyIds)
                                 .ConfigureEdgePropertyFeatures(_ => EdgePropertyFeatures.Properties | EdgePropertyFeatures.BooleanValues | EdgePropertyFeatures.ByteValues | EdgePropertyFeatures.DoubleValues | EdgePropertyFeatures.FloatValues | EdgePropertyFeatures.IntegerValues | EdgePropertyFeatures.LongValues | EdgePropertyFeatures.StringValues)));
 }
Ejemplo n.º 3
0
        public static IGremlinQueryEnvironment UseGremlinServer(this IGremlinQueryEnvironment environment,
                                                                Func <IWebSocketGremlinQueryExecutorBuilder, IWebSocketGremlinQueryExecutorBuilder> builderAction)
        {
            return(environment
                   .UseWebSocket(builderAction)
                   .ConfigureFeatureSet(featureSet => featureSet
                                        .ConfigureGraphFeatures(graphFeatures => graphFeatures & ~(GraphFeatures.Transactions | GraphFeatures.ThreadedTransactions | GraphFeatures.ConcurrentAccess))
                                        .ConfigureVertexFeatures(vertexFeatures => vertexFeatures & ~(VertexFeatures.Upsert | VertexFeatures.CustomIds))
                                        .ConfigureVertexPropertyFeatures(vPropertiesFeatures => vPropertiesFeatures & ~(VertexPropertyFeatures.CustomIds))
                                        .ConfigureEdgeFeatures(edgeProperties => edgeProperties & ~(EdgeFeatures.Upsert | EdgeFeatures.CustomIds)))
                   .ConfigureSerializer(s => s
                                        .ConfigureFragmentSerializer(fragmentSerializer => fragmentSerializer
                                                                     .Override <IGremlinQueryBase>((query, env, overridden, recurse) =>
            {
                if (env.Options.GetValue(GremlinServerGremlinqOptions.WorkaroundTinkerpop2112))
                {
                    query = query.AsAdmin().ConfigureSteps <IGremlinQueryBase>(steps => ImmutableStack.Create(steps.Reverse().WorkaroundTINKERPOP_2112().ToArray()));
                }

                return overridden(query, env, recurse);
            }))));
        }