internal override void Populate(string property)
        {
            base.Populate(property);

            InputVariable.Populate(property);
            RepeatContext.Populate(property);
        }
        /// <summary>
        /// Processes the inputs.
        /// </summary>
        /// <returns>List of <see cref="InputVariable"/></returns>
        public List <InputVariable> ProcessInputs()
        {
            this.logger.LogInformation("- Importing parameters...");
            var inputVariables = new List <InputVariable>();

            foreach (var p in this.template.Parameters.Concat(this.template.PseudoParameters))
            {
                var inputVariable = InputVariable.CreateParameter(p);

                if (inputVariable == null)
                {
                    var wrn = p is PseudoParameter
                                  ? $"Pseudo-parameter '{p.Name}' cannot be imported as it is not supported by Terraform."
                                  : $"Stack parameter '{p.Name}' cannot be imported.";

                    this.logger.LogWarning(wrn);

                    if (!this.warnings.Contains(wrn))
                    {
                        // When importing multiple stacks, only warn about unsupported pseudo vars once.
                        this.warnings.Add(wrn);
                    }
                }
                else
                {
                    inputVariables.Add(inputVariable);
                }
            }

            return(inputVariables);
        }
        public override WTableReference ToTableReference()
        {
            List <WScalarExpression> parameters = new List <WScalarExpression>();

            if (DedupVariables.Count > 0)
            {
                foreach (var dedupVariable in DedupVariables)
                {
                    parameters.Add(dedupVariable.DefaultVariableProperty().ToScalarExpression());
                }
            }
            else if (DedupContext != null)
            {
                parameters.Add(SqlUtil.GetScalarSubquery(DedupContext.ToSelectQueryBlock()));
            }
            else
            {
                parameters.Add(InputVariable.DefaultVariableProperty().ToScalarExpression());
            }

            var tableRef = SqlUtil.GetFunctionTableReference(
                Scope == GremlinKeyword.Scope.global ? GremlinKeyword.func.DedupGlobal : GremlinKeyword.func.DedupLocal,
                parameters, GetVariableName());

            return(SqlUtil.GetCrossApplyTableReference(tableRef));
        }
        public override WTableReference ToTableReference()
        {
            List <WScalarExpression> parameters = new List <WScalarExpression>();

            parameters.Add(InputVariable.GetDefaultProjection().ToScalarExpression());
            parameters.Add(SqlUtil.GetValueExpr(Column == GremlinKeyword.Column.Keys ? "Keys" : "Values"));
            var tableRef = SqlUtil.GetFunctionTableReference(GremlinKeyword.func.SelectColumn, parameters, GetVariableName());

            return(SqlUtil.GetCrossApplyTableReference(tableRef));
        }
        internal override List <GremlinVariable> FetchAllVars()
        {
            List <GremlinVariable> variableList = new List <GremlinVariable>()
            {
                this
            };

            variableList.AddRange(InputVariable.FetchAllVars());
            return(variableList);
        }
        //---------------------------------------------------------------------

        private void TryReadVar(InputLine line,
                                InputVariable var)
        {
            try {
                line.ReadVar(var);
            }
            catch (System.Exception e) {
                Data.Output.WriteLine(e.Message);
                throw;
            }
        }
Example #7
0
 private WSelectQueryBlock GetSelectQueryBlock(GremlinToSqlContext context)
 {
     if (context == null)
     {
         return(SqlUtil.GetSimpleSelectQueryBlock(InputVariable.DefaultProjection()));
     }
     else
     {
         return(context.ToSelectQueryBlock());
     }
 }
Example #8
0
        public override WTableReference ToTableReference()
        {
            List <WScalarExpression> parameters  = new List <WScalarExpression>();
            List <WSelectQueryBlock> queryBlocks = new List <WSelectQueryBlock>();

            //Must toSelectQueryBlock before toCompose1 of variableList in order to populate needed columns
            foreach (var byContext in ByContexts)
            {
                queryBlocks.Add(byContext.ToSelectQueryBlock(true));
            }

            parameters.Add(InputVariable.GetDefaultProjection().ToScalarExpression());
            parameters.Add(PathVariable.GetDefaultProjection().ToScalarExpression());
            switch (Pop)
            {
            case GremlinKeyword.Pop.All:
                parameters.Add(SqlUtil.GetValueExpr("All"));
                break;

            case GremlinKeyword.Pop.First:
                parameters.Add(SqlUtil.GetValueExpr("First"));
                break;

            case GremlinKeyword.Pop.Last:
                parameters.Add(SqlUtil.GetValueExpr("Last"));
                break;
            }

            foreach (var selectKey in SelectKeys)
            {
                parameters.Add(SqlUtil.GetValueExpr(selectKey));
            }

            foreach (var block in queryBlocks)
            {
                parameters.Add(SqlUtil.GetScalarSubquery(block));
            }

            if (SelectKeys.Count == 1)
            {
                foreach (var projectProperty in ProjectedProperties)
                {
                    parameters.Add(SqlUtil.GetValueExpr(projectProperty));
                }
            }

            var tableRef = SqlUtil.GetFunctionTableReference(
                SelectKeys.Count == 1 ? GremlinKeyword.func.SelectOne: GremlinKeyword.func.Select,
                parameters, GetVariableName());

            return(SqlUtil.GetCrossApplyTableReference(tableRef));
        }
 private WSelectQueryBlock GetSelectQueryBlock(GremlinToSqlContext context)
 {
     if (context == null)
     {
         var queryBlock = new WSelectQueryBlock();
         queryBlock.SelectElements.Add(SqlUtil.GetSelectScalarExpr(InputVariable.GetDefaultProjection().ToScalarExpression()));
         return(queryBlock);
     }
     else
     {
         return(context.ToSelectQueryBlock());
     }
 }
        public ActionResult Output(string country, string adjective1, string noun1, string pastTenseVerb, string noun2, string adjective2, string celebrity, string ingverb, string noun3)
        {
            InputVariable madLibVariable = new InputVariable();

            madLibVariable.Country       = country;
            madLibVariable.Adjective1    = adjective1;
            madLibVariable.Noun1         = noun1;
            madLibVariable.PastTenseVerb = pastTenseVerb;
            madLibVariable.Noun2         = noun2;
            madLibVariable.Adjective2    = adjective2;
            madLibVariable.Celebrity     = celebrity;
            madLibVariable.IngVerb       = ingverb;
            madLibVariable.Noun3         = noun3;
            return(View(madLibVariable));
        }
Example #11
0
        public void WhenInputParameterIsListAndOneElementMatchesThenElementIsFound()
        {
            var resource = new StateFileResourceInstance {
                Attributes = resourceAttributes
            };
            var templateParameter = new Mock <IParameter>();

            templateParameter.Setup(p => p.Name).Returns("PrivateSubnets");
            templateParameter.Setup(p => p.Type).Returns("List<AWS::EC2::Subnet::Id>");
            templateParameter.Setup(p => p.GetCurrentValue()).Returns("subnet-00000000,subnet-11111111");

            var inputVariable = InputVariable.CreateParameter(templateParameter.Object);
            var result        = resource.FindId(inputVariable, false);

            result.Should().HaveCount(2, "there should be 1 property match and 1 array match");
        }
Example #12
0
        private static Layer ParseInputVariableNode(ValueInfoProto node, Dictionary <string, TensorType> types, Dictionary <string, OutputConnector> outputConns)
        {
            var desiredType = TensorType.From(node.Type);

            types.Add(node.Name, desiredType);

            if (desiredType.ElementType == typeof(double))
            {
                var layer = new InputVariable <double>(node.Name, desiredType.Dimensions);
                outputConns.Add(node.Name, layer.Value);
                return(layer);
            }
            else
            {
                throw new NotSupportedException();
            }
        }
Example #13
0
        internal override void Populate(string property)
        {
            if (ProjectedProperties.Contains(property))
            {
                return;
            }
            base.Populate(property);

            InputVariable.Populate(property);
            if (SelectedVariableList.Exists(p => p.Item1 != property))
            {
                RepeatContext.Populate(property);
            }
            else
            {
                RepeatContext.Populate(property);
            }
        }
Example #14
0
        public void WhenInputParameterIsStringAndAttributeArrayValueMatchesThenElementIsFound()
        {
            var resource = new StateFileResourceInstance {
                Attributes = resourceAttributes
            };
            var templateParameter = new Mock <IParameter>();

            templateParameter.Setup(p => p.Name).Returns("VpcId");
            templateParameter.Setup(p => p.Type).Returns("AWS::EC2::SecurityGroup::Id");
            templateParameter.Setup(p => p.GetCurrentValue()).Returns("sg-00000000");

            var inputVariable = InputVariable.CreateParameter(templateParameter.Object);

            var result = resource.FindId(inputVariable, false);

            result.Should().HaveCount(1).And
            .AllBeOfType <JArray>("array returned contains the element we are looking for");
        }
Example #15
0
        public void WhenInputParameterIsStringAndAttributeScalarValueMatchesThenElementIsFound()
        {
            var resource = new StateFileResourceInstance {
                Attributes = resourceAttributes
            };
            var templateParameter = new Mock <IParameter>();

            templateParameter.Setup(p => p.Name).Returns("VpcId");
            templateParameter.Setup(p => p.Type).Returns("AWS::EC2::VPC::Id");
            templateParameter.Setup(p => p.GetCurrentValue()).Returns("vpc-00000000");

            var inputVariable = InputVariable.CreateParameter(templateParameter.Object);

            var result = resource.FindId(inputVariable, false);

            result.Should().HaveCount(1).And
            .AllBeOfType <JProperty>("property returned has the element we are looking for as its value");
        }
        internal override List <GremlinVariable> FetchAllVars()
        {
            List <GremlinVariable> variableList = new List <GremlinVariable>()
            {
                this
            };

            variableList.AddRange(InputVariable.FetchAllVars());
            variableList.AddRange(RepeatContext.FetchAllVars());
            if (RepeatCondition.EmitContext != null)
            {
                variableList.AddRange(RepeatCondition.EmitContext.FetchAllVars());
            }
            if (RepeatCondition.TerminationContext != null)
            {
                variableList.AddRange(RepeatCondition.TerminationContext.FetchAllVars());
            }
            return(variableList);
        }
    //checks the list to see if all of the required buttons are down
    public void CheckButtons(InputVariable input)
    {
        bool allPressed = true;

        foreach (var button in input.AxisNames)
        {
            if (Input.GetAxisRaw(button) != 1 && Input.GetAxisRaw(button) != -1)
            {
                allPressed = false;
                if (input.ButtonUpMessage != "")
                {
                    SendMessage(input.ButtonUpMessage);
                }
                break;
            }
        }
        if (allPressed)
        {
            SendMessage(input.ButtonDownMessage);
        }
    }
 //checks the list to see if any of the button are down
 public void CheckButton(InputVariable input)
 {
     if (Input.GetAxisRaw(input.Axis) == 1)
     {
         if (input.CheckTime())
         {
             SendMessage(input.ButtonDownMessage, input.Arg);
         }
     }
     else if (Input.GetAxisRaw(input.Axis) == -1)
     {
         if (input.CheckTime())
         {
             SendMessage(input.ButtonNegativeMessage);
         }
     }
     else if (input.ButtonUpMessage != "")
     {
         SendMessage(input.ButtonUpMessage);
     }
 }
Example #19
0
        public static BaseCalculator Create(CalculateOperationCommand cmd)
        {
            var input = new InputVariable(cmd.NumberA, cmd.NumberB);

            switch (cmd.Operation)
            {
            case OperationEnum.Add:
                return(new AddCalculator(input));

            case OperationEnum.Minus:
                return(new MinusCalculator(input));

            case OperationEnum.Multiply:
                return(new MultiplyCalculator(input));

            case OperationEnum.Divide:
                return(new DivideCalculator(input));

            default:
                throw new BusinessException("Invalid Operation");
            }
        }
Example #20
0
        internal override void Populate(string property)
        {
            InputVariable.Populate(property);
            PathVariable.Populate(property);
            foreach (var sideEffectVariable in SideEffectVariables)
            {
                sideEffectVariable.Populate(property);
            }
            foreach (var context in ByContexts)
            {
                context.Populate(property);
            }

            if (SelectKeys.Count() > 1 && property != GremlinKeyword.TableDefaultColumnName)
            {
                //block the select multi label to populate column
                return;
            }
            else
            {
                base.Populate(property);
            }
        }
Example #21
0
            protected override IDataFlowGraphExpressionNode Visit(Variable var)
            {
                // If this is an external variable add a new input node
                if (var.Name.IsExternal)
                {
                    var external = new InputVariable(Guid.NewGuid(), var.Name);
                    _dataFlowGraph._inputs.Add(external);
                    return(external);
                }

                // It's not external, try to find an output node which was previously assigned
                var output = _dataFlowGraph._outputs.OfType <AssignmentOutput>().SingleOrDefault(a => a.Name.Equals(var.Name));

                if (output != null)
                {
                    return(output);
                }

                // It wasn't previously assigned, add a new input
                var input = new InputVariable(Guid.NewGuid(), var.Name);

                _dataFlowGraph._inputs.Add(input);
                return(input);
            }
Example #22
0
 public MultiplyCalculator(InputVariable _input) : base(_input)
 {
 }
Example #23
0
 public AddCalculator(InputVariable _input) : base(_input)
 {
 }
 //adds an input to the list
 public void AddInput(string Axis, string message1, string message2, string message3, object Arg, bool hasMultiInput, List <string> buttons)
 {
     newInput = InputVariable.CreateInstance(Axis, message1, message2, message3, Arg, inputBuffer, hasMultiInput, buttons);
     inputs.Add(newInput);
 }
Example #25
0
        public override WTableReference ToTableReference()
        {
            Dictionary <GremlinVariableProperty, string> map  = new Dictionary <GremlinVariableProperty, string>();
            Dictionary <GremlinVariableProperty, string> map2 = new Dictionary <GremlinVariableProperty, string>();
            Dictionary <GremlinVariableProperty, string> map3 = new Dictionary <GremlinVariableProperty, string>();
            Dictionary <GremlinVariableProperty, string> map4 = new Dictionary <GremlinVariableProperty, string>();

            WRepeatConditionExpression conditionExpr = GetRepeatConditionExpression();

            List <WSelectScalarExpression> inputSelectList        = GetInputSelectList(ref map);
            List <WSelectScalarExpression> outerSelectList        = GetOuterSelectList(ref map);
            List <WSelectScalarExpression> terminateSelectList    = GetConditionSelectList(ref map2);
            List <WSelectScalarExpression> repeatPathOuterList    = GetRepeatPathOuterVariableList(ref map3);
            List <WSelectScalarExpression> conditionPathOuterList = GetConditionPathOuterVariableList(ref map4);

            WSelectQueryBlock selectQueryBlock = RepeatContext.ToSelectQueryBlock();

            selectQueryBlock.SelectElements.Clear();

            foreach (var selectElement in inputSelectList)
            {
                selectQueryBlock.SelectElements.Add(selectElement);
            }
            foreach (var selectElement in outerSelectList)
            {
                selectQueryBlock.SelectElements.Add(selectElement);
            }
            foreach (var selectElement in terminateSelectList)
            {
                selectQueryBlock.SelectElements.Add(selectElement);
            }
            foreach (var selectElement in repeatPathOuterList)
            {
                selectQueryBlock.SelectElements.Add(selectElement);
            }
            foreach (var selectElement in conditionPathOuterList)
            {
                selectQueryBlock.SelectElements.Add(selectElement);
            }

            WSelectQueryBlock firstQueryExpr = new WSelectQueryBlock();

            foreach (var item in map)
            {
                firstQueryExpr.SelectElements.Add(SqlUtil.GetSelectScalarExpr(item.Key.ToScalarExpression(), item.Value));
            }
            foreach (var item in map2)
            {
                firstQueryExpr.SelectElements.Add(SqlUtil.GetSelectScalarExpr(SqlUtil.GetValueExpr(null), item.Value));
            }
            foreach (var item in map3)
            {
                firstQueryExpr.SelectElements.Add(SqlUtil.GetSelectScalarExpr(item.Key.ToScalarExpression(), item.Value));
            }
            foreach (var item in map4)
            {
                firstQueryExpr.SelectElements.Add(SqlUtil.GetSelectScalarExpr(item.Key.ToScalarExpression(), item.Value));
            }

            //firstQueryExpr.SelectElements.Add(SqlUtil.GetSelectScalarExpr(FirstVariable.DefaultProjection().ToScalarExpression(), GremlinKeyword.TableDefaultColumnName));
            //selectQueryBlock.SelectElements.Add(SqlUtil.GetSelectScalarExpr(RepeatContext.PivotVariable.DefaultProjection().ToScalarExpression(), GremlinKeyword.TableDefaultColumnName));
            foreach (var property in ProjectedProperties)
            {
                if (InputVariable.ProjectedProperties.Contains(property))
                {
                    firstQueryExpr.SelectElements.Add(
                        SqlUtil.GetSelectScalarExpr(
                            InputVariable.GetVariableProperty(property).ToScalarExpression(), property));
                }
                else
                {
                    firstQueryExpr.SelectElements.Add(
                        SqlUtil.GetSelectScalarExpr(SqlUtil.GetValueExpr(null), property));
                }
                if (RepeatContext.PivotVariable.ProjectedProperties.Contains(property))
                {
                    selectQueryBlock.SelectElements.Add(
                        SqlUtil.GetSelectScalarExpr(
                            RepeatContext.PivotVariable.GetVariableProperty(property).ToScalarExpression(), property));
                }
                else
                {
                    selectQueryBlock.SelectElements.Add(
                        SqlUtil.GetSelectScalarExpr(SqlUtil.GetValueExpr(null), property));
                }
            }

            if (SelectedVariableList.Count != 0)
            {
                foreach (var selectedVariableTuple in SelectedVariableList)
                {
                    var columnName       = selectedVariableTuple.Item1;
                    var selectedVariable = selectedVariableTuple.Item2;
                    firstQueryExpr.SelectElements.Add(SqlUtil.GetSelectScalarExpr(SqlUtil.GetValueExpr(null), columnName));

                    List <WScalarExpression> compose2Paramters = new List <WScalarExpression>();
                    compose2Paramters.Add(selectedVariable.RealVariable.ToCompose1());
                    compose2Paramters.Add(SqlUtil.GetColumnReferenceExpr("R", columnName));
                    WFunctionCall compose2 = SqlUtil.GetFunctionCall(GremlinKeyword.func.Compose2, compose2Paramters);
                    selectQueryBlock.SelectElements.Add(SqlUtil.GetSelectScalarExpr(compose2, columnName));
                }
            }

            if (RepeatContext.IsPopulateGremlinPath)
            {
                var columnName   = GremlinKeyword.Path;
                var pathVariable = RepeatContext.CurrentContextPath;
                firstQueryExpr.SelectElements.Add(SqlUtil.GetSelectScalarExpr(SqlUtil.GetValueExpr(null), columnName));
                selectQueryBlock.SelectElements.Add(SqlUtil.GetSelectScalarExpr(pathVariable.DefaultProjection().ToScalarExpression(), columnName));
            }

            var WBinaryQueryExpression = SqlUtil.GetBinaryQueryExpr(firstQueryExpr, selectQueryBlock);


            ModifyColumnNameVisitor newVisitor = new ModifyColumnNameVisitor();

            newVisitor.Invoke(selectQueryBlock, map);
            newVisitor.Invoke(conditionExpr, map2);
            newVisitor.Invoke(selectQueryBlock, map3);
            newVisitor.Invoke(conditionExpr, map4);

            List <WScalarExpression> repeatParameters = new List <WScalarExpression>();

            repeatParameters.Add(SqlUtil.GetScalarSubquery(WBinaryQueryExpression));
            repeatParameters.Add(conditionExpr);
            var secondTableRef = SqlUtil.GetFunctionTableReference(GremlinKeyword.func.Repeat, repeatParameters, this, GetVariableName());

            return(SqlUtil.GetCrossApplyTableReference(null, secondTableRef));
        }
Example #26
0
 public DivideCalculator(InputVariable _input) : base(_input)
 {
 }
        public override WTableReference ToTableReference()
        {
            if (RepeatContext.ContextLocalPath != null)
            {
                RepeatContext.ContextLocalPath.PathList.Insert(0, null);
                RepeatContext.ContextLocalPath.IsInRepeatContext = true;
            }

            //The following two variables are used for manually creating SelectScalarExpression of repeat
            List <WSelectScalarExpression> repeatFirstSelect  = new List <WSelectScalarExpression>();
            List <WSelectScalarExpression> repeatSecondSelect = new List <WSelectScalarExpression>();

            // The following two variables are used for Generating a Map
            // such as N_0.id -> key_0
            // Then we will use this map to replace ColumnRefernceExpression in the syntax tree which matchs n_0.id to R_0.key_0
            Dictionary <WColumnReferenceExpression, string> repeatVistorMap    = new Dictionary <WColumnReferenceExpression, string>();
            Dictionary <WColumnReferenceExpression, string> conditionVistorMap = new Dictionary <WColumnReferenceExpression, string>();

            //We should generate the syntax tree firstly
            //Some variables will populate ProjectProperty only when we call the ToTableReference function where they appear.
            WRepeatConditionExpression repeatConditionExpr = GetRepeatConditionExpression();
            WSelectQueryBlock          repeatQueryBlock    = RepeatContext.ToSelectQueryBlock();

            // TODO: explain this step in detail
            var repeatNewToOldSelectedVarMap = GetNewToOldSelectedVarMap(RepeatContext);

            if (!repeatNewToOldSelectedVarMap.ContainsKey(RepeatContext.PivotVariable))
            {
                repeatNewToOldSelectedVarMap[RepeatContext.PivotVariable] = RepeatContext.VariableList.First();
            }
            foreach (var pair in repeatNewToOldSelectedVarMap)
            {
                GremlinVariable newVariable = pair.Key;
                GremlinVariable oldVariable = pair.Value;
                foreach (var property in pair.Value.ProjectedProperties)
                {
                    var aliasName          = GenerateKey();
                    var firstSelectColumn  = oldVariable.GetVariableProperty(property).ToScalarExpression() as WColumnReferenceExpression;
                    var secondSelectColumn = newVariable.GetVariableProperty(property).ToScalarExpression() as WColumnReferenceExpression;

                    repeatFirstSelect.Add(SqlUtil.GetSelectScalarExpr(firstSelectColumn, aliasName));
                    repeatSecondSelect.Add(SqlUtil.GetSelectScalarExpr(secondSelectColumn, aliasName));
                    repeatVistorMap[firstSelectColumn.Copy()] = aliasName;
                }
            }

            if (RepeatCondition.TerminationContext != null && RepeatCondition.TerminationContext.VariableList.Count > 0)
            {
                var terminatedNewToOldSelectedVarMap = GetNewToOldSelectedVarMap(RepeatCondition.TerminationContext);
                if (!terminatedNewToOldSelectedVarMap.ContainsKey(RepeatContext.PivotVariable))
                {
                    terminatedNewToOldSelectedVarMap[RepeatContext.PivotVariable] = RepeatCondition.TerminationContext.VariableList.First();
                }
                foreach (var pair in terminatedNewToOldSelectedVarMap)
                {
                    GremlinVariable newVariable = pair.Key;
                    GremlinVariable oldVariable = pair.Value;
                    foreach (var property in oldVariable.ProjectedProperties)
                    {
                        var aliasName         = GenerateKey();
                        var firstSelectColumn = RepeatCondition.StartFromContext
                            ? oldVariable.GetVariableProperty(property).ToScalarExpression()
                            : SqlUtil.GetValueExpr(null);
                        var secondSelectColumn = newVariable.GetVariableProperty(property).ToScalarExpression() as WColumnReferenceExpression;

                        repeatFirstSelect.Add(SqlUtil.GetSelectScalarExpr(firstSelectColumn, aliasName));
                        repeatSecondSelect.Add(SqlUtil.GetSelectScalarExpr(secondSelectColumn, aliasName));

                        if (RepeatCondition.StartFromContext)
                        {
                            conditionVistorMap[(firstSelectColumn as WColumnReferenceExpression).Copy()] = aliasName;
                        }
                        else
                        {
                            conditionVistorMap[secondSelectColumn.Copy()] = aliasName;
                        }
                    }
                }
            }

            if (RepeatCondition.EmitContext != null && RepeatCondition.EmitContext.VariableList.Count > 0)
            {
                var terminatedNewToOldSelectedVarMap = GetNewToOldSelectedVarMap(RepeatCondition.EmitContext);
                if (!terminatedNewToOldSelectedVarMap.ContainsKey(RepeatContext.PivotVariable))
                {
                    terminatedNewToOldSelectedVarMap[RepeatContext.PivotVariable] = RepeatCondition.EmitContext.VariableList.First();
                }
                foreach (var pair in terminatedNewToOldSelectedVarMap)
                {
                    GremlinVariable newVariable = pair.Key;
                    GremlinVariable oldVariable = pair.Value;
                    foreach (var property in pair.Value.ProjectedProperties)
                    {
                        var aliasName         = GenerateKey();
                        var firstSelectColumn = RepeatCondition.IsEmitContext
                            ? oldVariable.GetVariableProperty(property).ToScalarExpression()
                            : SqlUtil.GetValueExpr(null);
                        var secondSelectColumn = newVariable.GetVariableProperty(property).ToScalarExpression() as WColumnReferenceExpression;

                        repeatFirstSelect.Add(SqlUtil.GetSelectScalarExpr(firstSelectColumn, aliasName));
                        repeatSecondSelect.Add(SqlUtil.GetSelectScalarExpr(secondSelectColumn, aliasName));

                        if (RepeatCondition.IsEmitContext)
                        {
                            conditionVistorMap[(firstSelectColumn as WColumnReferenceExpression).Copy()] = aliasName;
                        }
                        else
                        {
                            conditionVistorMap[secondSelectColumn.Copy()] = aliasName;
                        }
                    }
                }
            }

            foreach (var property in ProjectedProperties)
            {
                if (property == GremlinKeyword.Path)
                {
                    repeatFirstSelect.Add(SqlUtil.GetSelectScalarExpr(SqlUtil.GetValueExpr(null), GremlinKeyword.Path));
                    repeatSecondSelect.Add(SqlUtil.GetSelectScalarExpr(RepeatContext.ContextLocalPath.GetDefaultProjection().ToScalarExpression(), GremlinKeyword.Path));
                    continue;
                }
                WScalarExpression firstExpr = InputVariable.ProjectedProperties.Contains(property)
                    ? InputVariable.GetVariableProperty(property).ToScalarExpression()
                    : SqlUtil.GetValueExpr(null);

                WScalarExpression secondExpr = RepeatContext.PivotVariable.ProjectedProperties.Contains(property)
                    ? RepeatContext.PivotVariable.GetVariableProperty(property).ToScalarExpression()
                    : SqlUtil.GetValueExpr(null);

                repeatFirstSelect.Add(SqlUtil.GetSelectScalarExpr(firstExpr, property));
                repeatSecondSelect.Add(SqlUtil.GetSelectScalarExpr(secondExpr, property));
            }

            WSelectQueryBlock firstQueryExpr = new WSelectQueryBlock();

            foreach (var selectColumnExpr in repeatFirstSelect)
            {
                firstQueryExpr.SelectElements.Add(selectColumnExpr);
            }

            repeatQueryBlock = RepeatContext.ToSelectQueryBlock();
            repeatQueryBlock.SelectElements.Clear();
            foreach (var selectColumnExpr in repeatSecondSelect)
            {
                repeatQueryBlock.SelectElements.Add(selectColumnExpr);
            }

            //Replace N_0.id -> R_0.key_0, when N_0 is a outer variable
            new ModifyColumnNameVisitor().Invoke(repeatQueryBlock, repeatVistorMap);
            new ModifyColumnNameVisitor().Invoke(repeatConditionExpr, conditionVistorMap);

            List <WScalarExpression> repeatParameters = new List <WScalarExpression>()
            {
                SqlUtil.GetScalarSubquery(SqlUtil.GetBinaryQueryExpr(firstQueryExpr, repeatQueryBlock)),
                repeatConditionExpr
            };
            var tableRef = SqlUtil.GetFunctionTableReference(GremlinKeyword.func.Repeat, repeatParameters, GetVariableName());

            return(SqlUtil.GetCrossApplyTableReference(tableRef));
        }
Example #28
0
 public MinusCalculator(InputVariable _input) : base(_input)
 {
 }
Example #29
0
 public BaseCalculator(InputVariable _input)
 {
     input = _input;
 }