Esempio n. 1
0
        public GremlinRepeatVariable(
            GremlinVariable inputVariable,
            GremlinToSqlContext repeatContext,
            RepeatCondition repeatCondition,
            GremlinVariableType variableType) : base(variableType)
        {
            this.InputVariable   = new GremlinContextVariable(inputVariable);
            this.RepeatContext   = repeatContext;
            this.RepeatCondition = repeatCondition;
            this.Count           = 0;
            GremlinRepeatContextVariable repeatContextVariable = this.RepeatContext.VariableList.First() as GremlinRepeatContextVariable;
            GremlinUntilContextVariable  untilContextVariable  = null;

            if (this.RepeatCondition.TerminationContext?.VariableList.Count > 0)
            {
                untilContextVariable = this.RepeatCondition.TerminationContext.VariableList.First() as GremlinUntilContextVariable;
            }
            GremlinEmitContextVariable emitContextVariable = null;

            if (this.RepeatCondition.EmitContext?.VariableList.Count > 0)
            {
                emitContextVariable = this.RepeatCondition.EmitContext?.VariableList?.First() as GremlinEmitContextVariable;
            }
            if (repeatContextVariable?.LabelPropertyList.Count > 0 ||
                untilContextVariable?.LabelPropertyList.Count > 0 || emitContextVariable?.LabelPropertyList.Count > 0)
            {
                this.PopulateLocalPath();
                repeatContextVariable?.SetContextLocalPath(this.RepeatContext.ContextLocalPath);
                untilContextVariable?.SetContextLocalPath(this.RepeatContext.ContextLocalPath);
                emitContextVariable?.SetContextLocalPath(this.RepeatContext.ContextLocalPath);
            }
        }
 public GremlinOptionalVariable(GremlinVariable inputVariable, GremlinToSqlContext context,
                                GremlinVariableType variableType) : base(variableType)
 {
     inputVariable.ProjectedProperties.Clear();
     this.OptionalContext = context;
     this.InputVariable   = new GremlinContextVariable(inputVariable);
 }
Esempio n. 3
0
        internal virtual void Repeat(GremlinToSqlContext currentContext, GremlinToSqlContext repeatContext,
                                     RepeatCondition repeatCondition)
        {
            GremlinVariableType variableType = repeatContext.PivotVariable.GetVariableType() == GetVariableType()
                ? GetVariableType()
                : GremlinVariableType.Table;

            GremlinRepeatVariable repeatVariable = new GremlinRepeatVariable(this, repeatContext, repeatCondition, variableType);

            currentContext.VariableList.Add(repeatVariable);
            currentContext.TableReferences.Add(repeatVariable);
            currentContext.SetPivotVariable(repeatVariable);

            //TODO: refactor
            List <GremlinVariable> allTableVars = repeatVariable.FetchAllTableVars();

            foreach (var variable in allTableVars)
            {
                var pathVariable = variable as GremlinGlobalPathVariable;
                if (pathVariable != null)
                {
                    repeatVariable.PopulateLocalPath();
                    foreach (var property in pathVariable.ProjectedProperties)
                    {
                        repeatContext.ContextLocalPath.Populate(property);
                    }
                    pathVariable.IsInRepeatContext = true;
                    pathVariable.PathList.Insert(pathVariable.PathList.FindLastIndex(p => p == repeatContext.StepList.First()), null);
                }
            }
        }
Esempio n. 4
0
 public GremlinOptionalVariable(GremlinVariable inputVariable,
                                GremlinToSqlContext context,
                                GremlinVariableType variableType)
     : base(variableType)
 {
     OptionalContext = context;
     InputVariable   = inputVariable;
 }
 public GremlinChooseVariable(GremlinToSqlContext predicateContext, GremlinToSqlContext trueChoiceContext,
                              GremlinToSqlContext falseChocieContext, GremlinVariableType variableType) : base(variableType)
 {
     this.PredicateContext   = predicateContext;
     this.TrueChoiceContext  = trueChoiceContext;
     this.FalseChocieContext = falseChocieContext;
     this.Options            = new Dictionary <object, GremlinToSqlContext>();
 }
 public GremlinRepeatVariable(GremlinVariable inputVariable,
                              GremlinToSqlContext repeatContext,
                              RepeatCondition repeatCondition,
                              GremlinVariableType variableType)
     : base(variableType)
 {
     RepeatContext   = repeatContext;
     InputVariable   = inputVariable;
     RepeatCondition = repeatCondition;
 }
Esempio n. 7
0
        public GremlinLabelVariable(GremlinVariable projectVariable)
        {
            GremlinVariableType inputVariableType = projectVariable.GetVariableType();

            if (!(inputVariableType <= GremlinVariableType.Unknown))
            {
                throw new SyntaxErrorException("The inputVariable of label() can not be " + inputVariableType);
            }

            this.ProjectVariable = projectVariable;
        }
Esempio n. 8
0
        internal virtual void Optional(GremlinToSqlContext currentContext, GremlinToSqlContext optionalContext)
        {
            GremlinVariableType variableType = GetVariableType() == optionalContext.PivotVariable.GetVariableType()
                ? GetVariableType()
                : GremlinVariableType.Table;
            GremlinOptionalVariable newVariable = new GremlinOptionalVariable(this, optionalContext, variableType);

            currentContext.VariableList.Add(newVariable);
            currentContext.TableReferences.Add(newVariable);
            currentContext.SetPivotVariable(newVariable);
        }
Esempio n. 9
0
        public GremlinMeanLocalVariable(GremlinVariable inputVariable)
        {
            GremlinVariableType inputVariableType = inputVariable.GetVariableType();

            if (!(inputVariableType == GremlinVariableType.List || GremlinVariableType.NULL <= inputVariableType && inputVariableType <= GremlinVariableType.Unknown))
            {
                throw new SyntaxErrorException("The inputVariable of mean(local) can not be " + inputVariableType);
            }

            this.InputVariable = inputVariable;
        }
Esempio n. 10
0
        public GremlinEdgeToVertexVariable(GremlinVariable edgeVariable)
        {
            GremlinVariableType inputVariableType = edgeVariable.GetVariableType();

            if (!(inputVariableType <= GremlinVariableType.Unknown && inputVariableType != GremlinVariableType.Vertex))
            {
                throw new SyntaxErrorException("The inputVariable of VertexToEdgeVariable must be a Edge");
            }

            this.EdgeVariable = edgeVariable;
        }
 public GremlinRepeatVariable(GremlinVariable inputVariable,
                              GremlinToSqlContext repeatContext,
                              RepeatCondition repeatCondition,
                              GremlinVariableType variableType)
     : base(variableType)
 {
     RepeatContext = repeatContext;
     RepeatContext.HomeVariable = this;
     InputVariable        = inputVariable;
     RepeatCondition      = repeatCondition;
     SelectedVariableList = new List <Tuple <string, GremlinRepeatSelectedVariable> >();
 }
Esempio n. 12
0
        public GremlinIdVariable(GremlinVariable projectVariable)
        {
            GremlinVariableType inputVariableType = projectVariable.GetVariableType();

            if (!(inputVariableType <= GremlinVariableType.Unknown || inputVariableType == GremlinVariableType.VertexProperty ||
                  inputVariableType == GremlinVariableType.Property))
            {
                throw new SyntaxErrorException("The inputVariable of id() can not be " + inputVariableType);
            }

            this.ProjectVariable = projectVariable;
        }
        public GremlinPropertiesVariable(GremlinVariable inputVariable, List <string> propertyKeys)
        {
            GremlinVariableType inputVariableType = inputVariable.GetVariableType();

            if (!(inputVariableType <= GremlinVariableType.Unknown || inputVariableType == GremlinVariableType.VertexProperty))
            {
                throw new SyntaxErrorException("The inputVariable of properties() can not be " + inputVariableType);
            }

            this.InputVariable = inputVariable;
            this.PropertyKeys  = new List <string>(propertyKeys);
        }
        public GremlinPropertyMapVariable(GremlinVariable inputVariable, List <string> propertyKeys)
        {
            GremlinVariableType inputVariableType = inputVariable.GetVariableType();

            if (!(inputVariableType <= GremlinVariableType.Unknown))
            {
                throw new SyntaxErrorException("The inputVariable of propertyMap() can not be " + inputVariableType);
            }

            this.InputVariable = inputVariable;
            this.PropertyKeys  = propertyKeys;
        }
Esempio n. 15
0
        public GremlinValuesVariable(GremlinVariable projectVariable, List <string> propertyKeys)
        {
            GremlinVariableType inputVariableType = projectVariable.GetVariableType();

            if (!(inputVariableType <= GremlinVariableType.Unknown))
            {
                throw new SyntaxErrorException("The inputVariable of values() can not be " + inputVariableType);
            }

            this.ProjectVariable = projectVariable;
            this.PropertyKeys    = new List <string>(propertyKeys);
        }
Esempio n. 16
0
        internal virtual void Repeat(GremlinToSqlContext currentContext, GremlinToSqlContext repeatContext,
                                     RepeatCondition repeatCondition)
        {
            GremlinVariableType variableType = repeatContext.PivotVariable.GetVariableType() == GetVariableType()
                ? GetVariableType()
                : GremlinVariableType.Table;
            GremlinRepeatVariable newVariable = new GremlinRepeatVariable(this, repeatContext, repeatCondition, variableType);

            currentContext.VariableList.Add(newVariable);
            currentContext.TableReferences.Add(newVariable);
            currentContext.SetPivotVariable(newVariable);
        }
Esempio n. 17
0
        internal static string GenerateTableAlias(GremlinVariableType variableType)
        {
            switch (variableType)
            {
            case GremlinVariableType.Vertex:
                return("N_" + _vertexCount++);

            case GremlinVariableType.Edge:
                return("E_" + _edgeCount++);
            }
            return("R_" + _tableCount++);
        }
Esempio n. 18
0
        public GremlinValueMapVariable(GremlinVariable inputVariable, bool isIncludeTokens, List <string> propertyKeys)
        {
            GremlinVariableType inputVariableType = inputVariable.GetVariableType();

            if (!(inputVariableType <= GremlinVariableType.Unknown))
            {
                throw new SyntaxErrorException("The inputVariable of valueMap() can not be " + inputVariableType);
            }

            this.InputVariable   = inputVariable;
            this.IsIncludeTokens = isIncludeTokens;
            this.PropertyKeys    = propertyKeys;
        }
Esempio n. 19
0
        public GremlinSelectColumnVariable(GremlinVariable inputVariable, GremlinKeyword.Column column) : base(GremlinVariableType.Unknown)
        {
            GremlinVariableType inputVariableType = inputVariable.GetVariableType();

            if (!(GremlinVariableType.NULL <= inputVariableType && inputVariableType <= GremlinVariableType.Map ||
                  inputVariableType == GremlinVariableType.Path || inputVariableType == GremlinVariableType.Tree))
            {
                throw new SyntaxErrorException("The inputVariable of select() can not be " + inputVariableType);
            }

            this.InputVariable = inputVariable;
            this.Column        = column;
        }
        internal override GremlinToSqlContext GetContext()
        {
            GremlinToSqlContext inputContext = GetInputContext();

            if (inputContext.PivotVariable == null)
            {
                throw new QueryCompilationException("The PivotVariable can't be null.");
            }

            GremlinVariableType pivotType = inputContext.PivotVariable.GetVariableType();

            if (pivotType != GremlinVariableType.Vertex &&
                pivotType != GremlinVariableType.Table &&
                (this.property.Cardinality == GremlinKeyword.PropertyCardinality.list ||
                 this.property.MetaProperties.Count > 0))
            {
                throw new QueryCompilationException("Only vertex can use PropertyCardinality.list and have meta properties");
            }
            inputContext.PivotVariable.Property(inputContext, property);

            return(inputContext);
        }
Esempio n. 21
0
 protected GremlinTableVariable(GremlinVariableType variableType)
 {
     VariableType = variableType;
     VariableName = GremlinUtil.GenerateTableAlias(VariableType);
 }
 public GremlinFlatMapVariable(GremlinToSqlContext flatMapContext, GremlinVariableType variableType)
     : base(variableType)
 {
     FlatMapContext = flatMapContext;
 }
Esempio n. 23
0
 public GremlinLocalVariable(GremlinToSqlContext localContext, GremlinVariableType variableType)
     : base(variableType)
 {
     this.LocalContext = localContext;
 }
 public GremlinLocalVariable(GremlinToSqlContext localContext, GremlinVariableType variableType)
     : base(variableType)
 {
     LocalContext = localContext;
     LocalContext.HomeVariable = this;
 }
 public GremlinDerivedTableVariable(GremlinToSqlContext subqueryContext, GremlinVariableType variableType) : base(variableType)
 {
     this.SubqueryContext = subqueryContext;
 }
Esempio n. 26
0
 public GremlinUnionVariable(List <GremlinToSqlContext> unionContextList, GremlinVariableType variableType) : base(variableType)
 {
     this.UnionContextList = unionContextList;
 }
 public GremlinCoalesceVariable(List <GremlinToSqlContext> coalesceContextList, GremlinVariableType variableType)
     : base(variableType)
 {
     CoalesceContextList = new List <GremlinToSqlContext>(coalesceContextList);
     foreach (var context in coalesceContextList)
     {
         context.HomeVariable = this;
     }
 }
Esempio n. 28
0
 public GremlinUnfoldVariable(GremlinVariable unfoldVariable, GremlinVariableType variableType)
     : base(variableType)
 {
     UnfoldVariable = unfoldVariable;
 }
 public GremlinMapVariable(GremlinToSqlContext mapContext, GremlinVariableType variableType)
     : base(variableType)
 {
     MapContext = mapContext;
 }
Esempio n. 30
0
 public GremlinCoalesceVariable(List <GremlinToSqlContext> coalesceContextList, GremlinVariableType variableType)
     : base(variableType)
 {
     this.CoalesceContextList = new List <GremlinToSqlContext>(coalesceContextList);
 }