Exemplo n.º 1
0
 internal object ReplaceTraversalToContext(object value, GremlinToSqlContext propertyInputContext)
 {
     if (value is GraphTraversal)
     {
         GraphTraversal propertyTraversal = value as GraphTraversal;
         propertyTraversal.GetStartOp().InheritedVariableFromParent(propertyInputContext);
         return(propertyTraversal.GetEndOp().GetContext());
     }
     return(value);
 }
Exemplo n.º 2
0
        internal override GremlinToSqlContext GetContext()
        {
            GremlinToSqlContext inputContext = GetInputContext();

            if (inputContext.PivotVariable == null)
            {
                throw new TranslationException("The PivotVariable of subgraph()-step can't be null.");
            }

            GraphTraversal traversalAux = GraphTraversal.__();

            traversalAux.GetStartOp().InheritedVariableFromParent(inputContext);

            inputContext.PivotVariable.Subgraph(inputContext, SideEffectKey, traversalAux.GetEndOp().GetContext());

            return(inputContext);
        }
Exemplo n.º 3
0
        internal override GremlinToSqlContext GetContext()
        {
            GremlinToSqlContext inputContext = GetInputContext();

            if (inputContext.PivotVariable == null)
            {
                throw new TranslationException("The PivotVariable of order()-step can't be null.");
            }

            if (ByModulatingList.Count == 0)
            {
                ByModulatingList.Add(new Tuple <GraphTraversal, IComparer>(GraphTraversal.__(), new IncrOrder()));
            }

            var newByModulatingList = new List <Tuple <GremlinToSqlContext, IComparer> >();

            foreach (var pair in ByModulatingList)
            {
                GraphTraversal      traversal = pair.Item1;
                GremlinToSqlContext context   = null;

                if (Scope == GremlinKeyword.Scope.Global)
                {
                    traversal.GetStartOp().InheritedVariableFromParent(inputContext);
                    context = traversal.GetEndOp().GetContext();
                }

                if (Scope == GremlinKeyword.Scope.Local)
                {
                    //g.V().groupCount().order(Local).by(Keys) or g.V().groupCount().order(Local).by(__.select(Keys))
                    if (traversal.GremlinTranslationOpList.Count >= 2 && traversal.GremlinTranslationOpList[1] is GremlinSelectColumnOp)
                    {
                        //FROM selectColumn(C._value, "Keys"/"Values")
                        GremlinToSqlContext           newContext = new GremlinToSqlContext();
                        GremlinOrderLocalInitVariable initVar    = new GremlinOrderLocalInitVariable(inputContext.PivotVariable);
                        newContext.VariableList.Add(initVar);
                        newContext.SetPivotVariable(initVar);

                        traversal.GetStartOp().InheritedContextFromParent(newContext);
                        context = traversal.GetEndOp().GetContext();
                    }
                    else
                    {
                        //FROM decompose1(C._value)
                        GremlinToSqlContext       newContext = new GremlinToSqlContext();
                        GremlinDecompose1Variable decompose1 = new GremlinDecompose1Variable(inputContext.PivotVariable);
                        newContext.VariableList.Add(decompose1);
                        newContext.TableReferencesInFromClause.Add(decompose1);
                        newContext.SetPivotVariable(decompose1);

                        traversal.GetStartOp().InheritedContextFromParent(newContext);
                        context = traversal.GetEndOp().GetContext();
                    }
                }

                newByModulatingList.Add(new Tuple <GremlinToSqlContext, IComparer>(context, pair.Item2));
            }

            inputContext.PivotVariable.Order(inputContext, newByModulatingList, Scope);

            return(inputContext);
        }