コード例 #1
0
        internal override void OutV(GremlinToSqlContext currentContext)
        {
            if (this.IsTraversalToBound)
            {
                base.OutV(currentContext);
                return;
            }

            for (int index = currentContext.MatchPathList.Count - 1; index >= 0; --index)
            {
                if (currentContext.MatchPathList[index].EdgeVariable == this &&
                    currentContext.MatchPathList[index].SourceVariable == null &&
                    !currentContext.MatchPathList[index].IsReversed)
                {
                    GremlinFreeVertexVariable outVertex = new GremlinFreeVertexVariable();
                    currentContext.VariableList.Add(outVertex);
                    currentContext.TableReferencesInFromClause.Add(outVertex);
                    currentContext.SetPivotVariable(outVertex);
                    currentContext.MatchPathList[index].SourceVariable = outVertex;
                    return;
                }
            }

            base.OutV(currentContext);
        }
コード例 #2
0
ファイル: GremlinEOp.cs プロジェクト: georgeycliu/k-core
        internal override GremlinToSqlContext GetContext()
        {
            GremlinToSqlContext inputContext = GetInputContext();

            if (inputContext.PivotVariable != null)
            {
                throw new QueryCompilationException("This step only can be a start step.");
            }
            GremlinFreeVertexVariable newVariable = new GremlinFreeVertexVariable();

            inputContext.VariableList.Add(newVariable);
            inputContext.TableReferences.Add(newVariable);
            inputContext.SetPivotVariable(newVariable);

            inputContext.PivotVariable.OutE(inputContext, new List <string>());

            if (EdgeIdsOrElements.Count > 0)
            {
                List <WBooleanExpression> booleanExprList = new List <WBooleanExpression>();
                foreach (var id in EdgeIdsOrElements)
                {
                    if (GremlinUtil.IsNumber(id) || id is string)
                    {
                        WScalarExpression            firstExpr   = inputContext.PivotVariable.GetVariableProperty(GremlinKeyword.EdgeID).ToScalarExpression();
                        WScalarExpression            secondExpr  = SqlUtil.GetValueExpr(id);
                        WBooleanComparisonExpression booleanExpr = SqlUtil.GetEqualBooleanComparisonExpr(firstExpr, secondExpr);
                        booleanExprList.Add(booleanExpr);
                    }
                }
                inputContext.AddPredicate(SqlUtil.ConcatBooleanExprWithOr(booleanExprList));
            }

            return(inputContext);
        }
コード例 #3
0
ファイル: GremlinUtil.cs プロジェクト: seanliu96/GraphView
 public GremlinMatchPath(GremlinFreeVertexVariable sourceVariable, GremlinFreeEdgeVariable edgeVariable, GremlinFreeVertexVariable sinkVariable, bool isReversed)
 {
     SourceVariable = sourceVariable;
     EdgeVariable   = edgeVariable;
     SinkVariable   = sinkVariable;
     IsReversed     = isReversed;
 }
コード例 #4
0
ファイル: GremlinVOp.cs プロジェクト: Sun-Jc/GC-GraphView
        internal override GremlinToSqlContext GetContext()
        {
            GremlinToSqlContext inputContext = GetInputContext();

            GremlinFreeVertexVariable newVariable = new GremlinFreeVertexVariable();

            if (VertexIdsOrElements.Count > 0)
            {
                List <WBooleanExpression> booleanExprList = new List <WBooleanExpression>();
                foreach (var id in VertexIdsOrElements)
                {
                    if (id is int || id is string)
                    {
                        WScalarExpression            firstExpr   = newVariable.GetVariableProperty(GremlinKeyword.NodeID).ToScalarExpression();
                        WScalarExpression            secondExpr  = SqlUtil.GetValueExpr(id);
                        WBooleanComparisonExpression booleanExpr = SqlUtil.GetEqualBooleanComparisonExpr(firstExpr, secondExpr);
                        booleanExprList.Add(booleanExpr);
                    }
                }
                inputContext.AddPredicate(SqlUtil.ConcatBooleanExprWithOr(booleanExprList));
            }

            inputContext.VariableList.Add(newVariable);
            inputContext.TableReferences.Add(newVariable);
            inputContext.SetPivotVariable(newVariable);

            return(inputContext);
        }
コード例 #5
0
        internal override GremlinToSqlContext GetContext()
        {
            GremlinToSqlContext inputContext = GetInputContext();

            GremlinFreeVertexVariable newVariable = new GremlinFreeVertexVariable();

            inputContext.VariableList.Add(newVariable);
            inputContext.TableReferences.Add(newVariable);
            inputContext.SetPivotVariable(newVariable);

            inputContext.PivotVariable.OutE(inputContext, new List <string>());

            return(inputContext);
        }
コード例 #6
0
        internal override void Out(GremlinToSqlContext currentContext, List <string> edgeLabels)
        {
            GremlinFreeEdgeTableVariable outEdgeTable = new GremlinFreeEdgeTableVariable(WEdgeType.OutEdge);

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

            GremlinFreeVertexVariable inVertex = new GremlinFreeVertexVariable();

            currentContext.VariableList.Add(inVertex);
            currentContext.TableReferences.Add(inVertex);
            currentContext.AddPath(new GremlinMatchPath(this, outEdgeTable, inVertex));
            currentContext.SetPivotVariable(inVertex);
        }
コード例 #7
0
        internal override void Both(GremlinToSqlContext currentContext, List <string> edgeLabels)
        {
            GremlinFreeEdgeTableVariable bothEdgeTable = new GremlinFreeEdgeTableVariable(WEdgeType.BothEdge);

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

            GremlinFreeVertexVariable bothVertex = new GremlinFreeVertexVariable();

            currentContext.VariableList.Add(bothVertex);

            // In this case, the both-edgeTable variable is not added to the table-reference list.
            // Instead, we populate a path this_variable-[bothEdgeTable]->bothVertex in the context
            currentContext.TableReferences.Add(bothVertex);
            currentContext.AddPath(new GremlinMatchPath(this, bothEdgeTable, bothVertex));
            currentContext.SetPivotVariable(bothVertex);
        }
コード例 #8
0
        internal override void Out(GremlinToSqlContext currentContext, List <string> edgeLabels)
        {
            if (this.IsTraversalToBound)
            {
                base.Out(currentContext, edgeLabels);
                return;
            }
            GremlinFreeEdgeVariable outEdge = new GremlinFreeEdgeVariable(WEdgeType.OutEdge);

            currentContext.VariableList.Add(outEdge);
            currentContext.AddLabelPredicateForEdge(outEdge, edgeLabels);

            GremlinFreeVertexVariable outVertex = new GremlinFreeVertexVariable();

            currentContext.VariableList.Add(outVertex);
            currentContext.TableReferencesInFromClause.Add(outVertex);
            currentContext.MatchPathList.Add(new GremlinMatchPath(this, outEdge, outVertex, false));
            currentContext.SetPivotVariable(outVertex);
        }
コード例 #9
0
        internal override void In(GremlinToSqlContext currentContext, List <string> edgeLabels)
        {
            if (this.isTraversalToBound)
            {
                base.In(currentContext, edgeLabels);
                return;
            }
            GremlinFreeEdgeVariable inEdge = new GremlinFreeEdgeVariable(WEdgeType.InEdge);

            currentContext.VariableList.Add(inEdge);
            currentContext.AddLabelPredicateForEdge(inEdge, edgeLabels);

            GremlinFreeVertexVariable outVertex = new GremlinFreeVertexVariable();

            currentContext.VariableList.Add(outVertex);
            currentContext.TableReferences.Add(outVertex);
            currentContext.MatchPathList.Add(new GremlinMatchPath(outVertex, inEdge, this));
            currentContext.SetPivotVariable(outVertex);
        }
コード例 #10
0
        internal override void Both(GremlinToSqlContext currentContext, List <string> edgeLabels)
        {
            if (this.IsTraversalToBound)
            {
                base.Both(currentContext, edgeLabels);
                return;
            }
            GremlinFreeEdgeVariable bothEdge = new GremlinFreeEdgeVariable(WEdgeType.BothEdge);

            currentContext.VariableList.Add(bothEdge);
            currentContext.AddLabelPredicateForEdge(bothEdge, edgeLabels);

            GremlinFreeVertexVariable bothVertex = new GremlinFreeVertexVariable();

            currentContext.VariableList.Add(bothVertex);

            // In this case, the both-edgeTable variable is not added to the table-reference list.
            // Instead, we populate a path this_variable-[bothEdge]->bothVertex in the context
            currentContext.TableReferencesInFromClause.Add(bothVertex);
            currentContext.MatchPathList.Add(new GremlinMatchPath(this, bothEdge, bothVertex, false));
            currentContext.SetPivotVariable(bothVertex);
        }
コード例 #11
0
 public GremlinMatchPath(GremlinFreeVertexVariable sourceVariable, GremlinFreeEdgeVariable edgeVariable, GremlinFreeVertexVariable sinkVariable)
 {
     SourceVariable = sourceVariable;
     EdgeVariable   = edgeVariable;
     SinkVariable   = sinkVariable;
 }