Exemplo n.º 1
0
        private GremlinPathVariable GeneratePath(GremlinToSqlContext currentContext, List <GraphTraversal2> byList = null)
        {
            //TODO: refactor
            List <GremlinToSqlContext> byContexts = new List <GremlinToSqlContext>();
            List <GremlinVariable>     steps      = currentContext.GetGlobalPathStepList();

            if (byList == null)
            {
                byList = new List <GraphTraversal2> {
                    GraphTraversal2.__()
                };
            }


            GremlinGlobalPathVariable newVariable = new GremlinGlobalPathVariable(steps, byContexts);

            currentContext.VariableList.Add(newVariable);
            currentContext.TableReferences.Add(newVariable);

            foreach (var by in byList)
            {
                GremlinToSqlContext       newContext = new GremlinToSqlContext();
                GremlinDecompose1Variable decompose1 = new GremlinDecompose1Variable(newVariable);
                newContext.VariableList.Add(decompose1);
                newContext.TableReferences.Add(decompose1);
                newContext.SetPivotVariable(decompose1);

                by.GetStartOp().InheritedContextFromParent(newContext);
                byContexts.Add(by.GetEndOp().GetContext());
            }
            newVariable.ByContexts = byContexts;

            return(newVariable);
        }
Exemplo n.º 2
0
        internal virtual GremlinSelectVariable GetSelectVar(GremlinToSqlContext currentContext, GremlinKeyword.Pop pop, List <string> selectKeys, List <GraphTraversal2> byList = null)
        {
            //TODO: refactor
            if (byList == null)
            {
                byList = new List <GraphTraversal2>()
                {
                    GraphTraversal2.__()
                };
            }
            List <GremlinToSqlContext> byContexts          = new List <GremlinToSqlContext>();
            List <GremlinVariable>     steps               = currentContext.GetGlobalPathStepList();
            List <GremlinVariable>     sideEffectVariables = currentContext.GetSideEffectVariables();

            GremlinGlobalPathVariable pathVariable = new GremlinGlobalPathVariable(steps);

            currentContext.VariableList.Add(pathVariable);
            currentContext.TableReferences.Add(pathVariable);

            foreach (var by in byList)
            {
                GremlinToSqlContext       newContext = new GremlinToSqlContext();
                GremlinDecompose1Variable decompose1 = new GremlinDecompose1Variable(pathVariable);
                newContext.VariableList.Add(decompose1);
                newContext.TableReferences.Add(decompose1);
                newContext.SetPivotVariable(decompose1);

                by.GetStartOp().InheritedContextFromParent(newContext);
                byContexts.Add(by.GetEndOp().GetContext());
            }

            GremlinSelectVariable newVariable = new GremlinSelectVariable(this, pathVariable, sideEffectVariables, pop, selectKeys, byContexts);

            currentContext.VariableList.Add(newVariable);
            currentContext.TableReferences.Add(newVariable);

            return(newVariable);
        }