Esempio n. 1
0
        public static string GetGraphPartition(this IGraphElementGrain grain)
        {
            grain.GetPrimaryKey(out var keyExt);
            var split = keyExt.Split('|');

            return(split.Length == 2 ? split[1] : null);
        }
Esempio n. 2
0
        public static string GetGraphLabel(this IGraphElementGrain grain)
        {
            grain.GetPrimaryKey(out var keyExt);
            var split = keyExt.Split('|');

            return(split[0]);
        }
Esempio n. 3
0
        /// <summary>
        /// </summary>
        /// <param name="grain"></param>
        /// <returns></returns>
        public static string ToKeyString(this IGraphElementGrain grain)
        {
            const int    trimStartLength = 14;
            const int    trimEndLength   = 11;
            const string prefix          = "GrainReference=";

            string identityString = grain.GetGrainIdentity().IdentityString;

            return(prefix + identityString.Substring(trimStartLength, (identityString.Length - trimEndLength) - trimStartLength));
        }
 private static IEdgeResult CreateUpdateExpression(GrainReference grainReference, EdgeState edgeState, IGraphElementGrain graphElementGrain)
 {
     return(g.E()
            .has(graphElementGrain.GetGraphLabel(), "id", grainReference.ToKeyString())
            .property(edgeState, p => (p.Key, p.Value)));
 }
        private static IEdgeResult CreateInsertExpression(GrainReference grainReference, EdgeState edgeState, IGraphElementGrain graphElementGrain)
        {
            var inVertex  = edgeState.GetInVertex();
            var outVertex = edgeState.GetOutVertex();

            var inVertexKeyString  = inVertex.ToKeyString();
            var outVertexKeyString = outVertex.ToKeyString();

            var insertExpression = g.V(inVertexKeyString)
                                   .addE(graphElementGrain.GetGraphLabel())
                                   .to(g.V(outVertexKeyString))
                                   .property("id", grainReference.ToKeyString());

            var partition = graphElementGrain.GetGraphPartition();

            if (!string.IsNullOrEmpty(partition))
            {
                insertExpression = insertExpression.property("partition", partition);
            }

            return(insertExpression.property(edgeState, p => (p.Key, p.Value)));
        }
        private static IVertexResult CreateInsertExpression(GrainReference grainReference, VertexState vertexState, IGraphElementGrain graphElementGrain)
        {
            var insertExpression = g.AddV(graphElementGrain.GetGraphLabel())
                                   .property("id", grainReference.ToKeyString());

            var partition = graphElementGrain.GetGraphPartition();

            if (!string.IsNullOrEmpty(partition))
            {
                insertExpression = insertExpression.property("partition", partition);
            }

            return(insertExpression.property(vertexState));
        }
 private static IVertexResult CreateUpdateExpression(GrainReference grainReference, VertexState vertexState, IGraphElementGrain grainWithGraphElement)
 {
     return(g.V().has(grainWithGraphElement.GetGraphLabel(), "id", grainReference.ToKeyString()).property(vertexState));
 }
Esempio n. 8
0
 /// <summary>
 /// </summary>
 /// <param name="grain"></param>
 /// <returns></returns>
 public static Guid GetGraphRuntimeId(this IGraphElementGrain grain) => grain.GetPrimaryKey(out _);
Esempio n. 9
0
 public static string GetGraphRuntimeIdString(this IGraphElementGrain grain) => grain.GetGraphRuntimeId().ToString();