Ejemplo n.º 1
0
        internal void DropProperties(GremlinVariable belongToVariable, List <string> PropertyKeys)
        {
            List <object> properties = new List <object>();

            foreach (var propertyKey in PropertyKeys)
            {
                properties.Add(propertyKey);
                properties.Add(null);
            }
            if (PropertyKeys.Count == 0)
            {
                properties.Add(GremlinKeyword.Star);
                properties.Add(null);
            }

            GremlinUpdatePropertiesVariable dropVariable = null;

            switch (belongToVariable.GetVariableType())
            {
            case GremlinVariableType.Vertex:
                dropVariable = new GremlinUpdateVertexPropertiesVariable(belongToVariable, properties);
                break;

            case GremlinVariableType.Edge:
                dropVariable = new GremlinUpdateEdgePropertiesVariable(belongToVariable, properties);
                break;
            }

            VariableList.Add(dropVariable);
            TableReferences.Add(dropVariable);
            SetPivotVariable(dropVariable);
        }
Ejemplo n.º 2
0
        internal void Value(GremlinVariable lastVariable)
        {
            GremlinValueVariable newVariable = new GremlinValueVariable(lastVariable.DefaultVariableProperty());

            VariableList.Add(newVariable);
            TableReferences.Add(newVariable);
            SetPivotVariable(newVariable);
        }
Ejemplo n.º 3
0
        internal void DropVertex(GremlinVariable dropVertexVariable)
        {
            GremlinVariableProperty variableProperty = dropVertexVariable.GetVariableProperty(GremlinKeyword.NodeID);
            GremlinDropVariable     dropVariable     = new GremlinDropVertexVariable(variableProperty);

            VariableList.Add(dropVariable);
            TableReferences.Add(dropVariable);
            SetPivotVariable(dropVariable);
        }
Ejemplo n.º 4
0
        internal void DropEdge(GremlinVariable dropEdgeVariable)
        {
            var sourceProperty = dropEdgeVariable.GetVariableProperty(GremlinKeyword.EdgeSourceV);
            var edgeProperty   = dropEdgeVariable.GetVariableProperty(GremlinKeyword.EdgeID);
            GremlinDropVariable dropVariable = new GremlinDropEdgeVariable(sourceProperty, edgeProperty);

            VariableList.Add(dropVariable);
            TableReferences.Add(dropVariable);
            SetPivotVariable(dropVariable);
        }
Ejemplo n.º 5
0
        internal void BothV(GremlinVariable lastVariable)
        {
            GremlinVariableProperty    sourceProperty = lastVariable.GetVariableProperty(GremlinKeyword.EdgeSourceV);
            GremlinVariableProperty    sinkProperty   = lastVariable.GetVariableProperty(GremlinKeyword.EdgeSinkV);
            GremlinBoundVertexVariable bothVertex     = new GremlinBoundVertexVariable(lastVariable.GetEdgeType(), sourceProperty, sinkProperty);

            VariableList.Add(bothVertex);
            TableReferences.Add(bothVertex);
            SetPivotVariable(bothVertex);
        }
Ejemplo n.º 6
0
        internal void OutE(GremlinVariable lastVariable, List <string> edgeLabels)
        {
            GremlinVariableProperty       sourceProperty = lastVariable.GetVariableProperty(GremlinKeyword.NodeID);
            GremlinVariableProperty       adjEdge        = lastVariable.GetVariableProperty(GremlinKeyword.EdgeAdj);
            GremlinVariableProperty       labelProperty  = lastVariable.GetVariableProperty(GremlinKeyword.Label);
            GremlinBoundEdgeTableVariable outEdgeTable   = new GremlinBoundEdgeTableVariable(sourceProperty, adjEdge, labelProperty, WEdgeType.OutEdge);

            VariableList.Add(outEdgeTable);
            TableReferences.Add(outEdgeTable);
            AddLabelPredicateForEdge(outEdgeTable, edgeLabels);

            AddPath(new GremlinMatchPath(lastVariable, outEdgeTable, null));
            SetPivotVariable(outEdgeTable);
        }
Ejemplo n.º 7
0
        internal void BothE(GremlinVariable lastVariable, List <string> edgeLabels)
        {
            GremlinVariableProperty       sourceProperty = lastVariable.GetVariableProperty(GremlinKeyword.NodeID);
            GremlinVariableProperty       adjReverseEdge = lastVariable.GetVariableProperty(GremlinKeyword.ReverseEdgeAdj);
            GremlinVariableProperty       adjEdge        = lastVariable.GetVariableProperty(GremlinKeyword.EdgeAdj);
            GremlinVariableProperty       labelProperty  = lastVariable.GetVariableProperty(GremlinKeyword.Label);
            GremlinBoundEdgeTableVariable bothEdgeTable  = new GremlinBoundEdgeTableVariable(sourceProperty, adjEdge, adjReverseEdge, labelProperty,
                                                                                             WEdgeType.BothEdge);

            VariableList.Add(bothEdgeTable);
            TableReferences.Add(bothEdgeTable);
            AddLabelPredicateForEdge(bothEdgeTable, edgeLabels);

            SetPivotVariable(bothEdgeTable);
        }
Ejemplo n.º 8
0
        internal void PopulateGremlinPath()
        {
            if (IsPopulateGremlinPath)
            {
                return;
            }

            GremlinPathVariable newVariable = new GremlinPathVariable(GetCurrAndChildGremlinStepList());

            VariableList.Add(newVariable);
            TableReferences.Add(newVariable);
            CurrentContextPath = newVariable;

            IsPopulateGremlinPath = true;
        }
Ejemplo n.º 9
0
        internal void Values(GremlinVariable lastVariable, List <string> propertyKeys)
        {
            if (propertyKeys.Count == 0)
            {
                lastVariable.Populate(GremlinKeyword.Star);
            }
            else
            {
                foreach (var property in propertyKeys)
                {
                    lastVariable.Populate(property);
                }
            }
            GremlinValuesVariable newVariable = new GremlinValuesVariable(lastVariable, propertyKeys);

            VariableList.Add(newVariable);
            TableReferences.Add(newVariable);
            SetPivotVariable(newVariable);
        }
Ejemplo n.º 10
0
        internal void PopulateLocalPath()
        {
            if (ContextLocalPath != null)
            {
                return;
            }
            ProjectedProperties.Add(GremlinKeyword.Path);

            foreach (var step in StepList)
            {
                step.PopulateLocalPath();
            }

            GremlinLocalPathVariable newVariable = new GremlinLocalPathVariable(StepList);

            VariableList.Add(newVariable);
            TableReferences.Add(newVariable);
            ContextLocalPath = newVariable;
        }
Ejemplo n.º 11
0
        internal void OutV(GremlinVariable lastVariable)
        {
            if (lastVariable is GremlinFreeEdgeTableVariable)
            {
                var path = GetPathFromPathList(lastVariable);

                if (path != null && path.SourceVariable != null)
                {
                    if (IsVariableInCurrentContext(path.SourceVariable))
                    {
                        SetPivotVariable(path.SourceVariable);
                    }
                    else
                    {
                        GremlinContextVariable newContextVariable = GremlinContextVariable.Create(path.SourceVariable);
                        VariableList.Add(newContextVariable);
                        SetPivotVariable(newContextVariable);
                    }
                }
                else
                {
                    GremlinVariableProperty sourceProperty = lastVariable.GetVariableProperty(GremlinKeyword.EdgeSourceV);
                    GremlinTableVariable    outVertex      = lastVariable.CreateAdjVertex(sourceProperty);
                    if (path != null)
                    {
                        path.SetSourceVariable(outVertex);
                    }

                    VariableList.Add(outVertex);
                    TableReferences.Add(outVertex);
                    SetPivotVariable(outVertex);
                }
            }
            else
            {
                GremlinVariableProperty sourceProperty = lastVariable.GetVariableProperty(GremlinKeyword.EdgeSourceV);
                GremlinTableVariable    outVertex      = new GremlinBoundVertexVariable(lastVariable.GetEdgeType(), sourceProperty);
                VariableList.Add(outVertex);
                TableReferences.Add(outVertex);
                SetPivotVariable(outVertex);
            }
        }
Ejemplo n.º 12
0
        internal void OtherV(GremlinVariable lastVariable)
        {
            switch (lastVariable.GetEdgeType())
            {
            case WEdgeType.Undefined:
            case WEdgeType.BothEdge:
                GremlinVariableProperty    otherProperty = lastVariable.GetVariableProperty(GremlinKeyword.EdgeOtherV);
                GremlinBoundVertexVariable otherVertex   = new GremlinBoundVertexVariable(lastVariable.GetEdgeType(), otherProperty);
                VariableList.Add(otherVertex);
                TableReferences.Add(otherVertex);
                SetPivotVariable(otherVertex);
                break;

            case WEdgeType.InEdge:
                OutV(lastVariable);
                break;

            case WEdgeType.OutEdge:
                InV(lastVariable);
                break;
            }
        }
Ejemplo n.º 13
0
        internal void In(GremlinVariable lastVariable, List <string> edgeLabels)
        {
            GremlinVariableProperty       sourceProperty = lastVariable.GetVariableProperty(GremlinKeyword.NodeID);
            GremlinVariableProperty       adjReverseEdge = lastVariable.GetVariableProperty(GremlinKeyword.ReverseEdgeAdj);
            GremlinVariableProperty       labelProperty  = lastVariable.GetVariableProperty(GremlinKeyword.Label);
            GremlinBoundEdgeTableVariable inEdgeTable    = new GremlinBoundEdgeTableVariable(sourceProperty, adjReverseEdge,
                                                                                             labelProperty, WEdgeType.InEdge);

            VariableList.Add(inEdgeTable);
            TableReferences.Add(inEdgeTable);
            AddLabelPredicateForEdge(inEdgeTable, edgeLabels);

            GremlinVariableProperty    edgeProperty = inEdgeTable.GetVariableProperty(GremlinKeyword.EdgeSourceV);
            GremlinBoundVertexVariable outVertex    = new GremlinBoundVertexVariable(inEdgeTable.GetEdgeType(), edgeProperty);

            VariableList.Add(outVertex);
            TableReferences.Add(outVertex);

            AddPath(new GremlinMatchPath(outVertex, inEdgeTable, lastVariable));

            SetPivotVariable(outVertex);
        }