internal void DropProperties(GremlinVariable belongToVariable, List <string> PropertyKeys) { List <object> properties = new List <object>(); foreach (var propertyKey in PropertyKeys) { properties.Add(propertyKey); properties.Add(null); } if (PropertyKeys.Count == 0) { properties.Add(GremlinKeyword.Star); properties.Add(null); } GremlinUpdatePropertiesVariable dropVariable = null; switch (belongToVariable.GetVariableType()) { case GremlinVariableType.Vertex: dropVariable = new GremlinUpdateVertexPropertiesVariable(belongToVariable, properties); break; case GremlinVariableType.Edge: dropVariable = new GremlinUpdateEdgePropertiesVariable(belongToVariable, properties); break; } VariableList.Add(dropVariable); TableReferences.Add(dropVariable); SetPivotVariable(dropVariable); }
public DmlUpdateStatement(bool lowPriority, bool ignore, TableReferences tableRefs, IList <Pair <Identifier, IExpression> > values, IExpression where, OrderBy orderBy, Limit limit) { IsLowPriority = lowPriority; IsIgnore = ignore; if (tableRefs == null) { throw new ArgumentException("argument tableRefs is null for update stmt"); } TableRefs = tableRefs; if (values == null || values.Count <= 0) { Values = new List <Pair <Identifier, IExpression> >(0); } else { if (!(values is List <Pair <Identifier, IExpression> >)) { Values = new List <Pair <Identifier, IExpression> >(values); } else { Values = values; } } Where = where; OrderBy = orderBy; Limit = limit; }
internal void Reset() { GremlinVariable inputVariable = null; if (VariableList.First() is GremlinContextVariable) { inputVariable = VariableList.First(); } ParentContext = null; PivotVariable = null; VariableList.Clear(); ProjectedProperties.Clear(); TableReferences.Clear(); MatchPathList.Clear(); Predicates = null; StepList.Clear(); ContextLocalPath = null; //TODO: reserve the InputVariable, used for repeat step, should be refactored later if (inputVariable != null) { VariableList.Add(inputVariable); } }
internal void Reset() { GremlinVariable inputVariable = null; if (VariableList.First() is GremlinContextVariable) { inputVariable = VariableList.First(); } PivotVariable = null; Predicates = null; VariableList.Clear(); TableReferences.Clear(); PathList.Clear(); StepList.Clear(); IsPopulateGremlinPath = false; CurrentContextPath = null; ProjectVariablePropertiesList.Clear(); ProjectedProperties.Clear(); //reserve the InputVariable if (inputVariable != null) { VariableList.Add(inputVariable); } }
/// <exception cref="System.SqlSyntaxErrorException" /> public DmlDeleteStatement(bool lowPriority, bool quick, bool ignore, IList <Identifier> tableNameList, TableReferences tableRefs, IExpression whereCondition) { // ------- multi-row delete------------ IsLowPriority = lowPriority; IsQuick = quick; IsIgnore = ignore; if (tableNameList == null || tableNameList.IsEmpty()) { throw new ArgumentException("argument 'tableNameList' is empty"); } if (tableNameList is List <Identifier> ) { tableNames = tableNameList; } else { tableNames = new List <Identifier>(tableNameList); } if (tableRefs == null) { throw new ArgumentException("argument 'tableRefs' is null"); } TableRefs = tableRefs; WhereCondition = whereCondition; OrderBy = null; Limit = null; }
/// <exception cref="System.SqlSyntaxErrorException" /> public DmlSelectStatement(SelectOption option, IList <Pair <IExpression, string> > selectExprList, TableReferences tables, IExpression where, GroupBy group, IExpression having, OrderBy order, Limit limit) { if (option == null) { throw new ArgumentException("argument 'option' is null"); } Option = option; if (selectExprList == null || selectExprList.IsEmpty()) { this.selectExprList = new List <Pair <IExpression, string> >(0); } else { this.selectExprList = EnsureListType(selectExprList); } Tables = tables; Where = where; Group = group; Having = having; Order = order; Limit = limit; }
internal void Value(GremlinVariable lastVariable) { GremlinValueVariable newVariable = new GremlinValueVariable(lastVariable.DefaultVariableProperty()); VariableList.Add(newVariable); TableReferences.Add(newVariable); SetPivotVariable(newVariable); }
/// <exception cref="System.SqlSyntaxErrorException" /> public DmlDeleteStatement(bool lowPriority, bool quick, bool ignore, IList <Identifier> tableNameList, TableReferences tableRefs) : this(lowPriority, quick, ignore, tableNameList, tableRefs, null) { }
public override IEnumerable <SyntaxNodeOrToken> ChildNodesAndTokens() { yield return(FromKeyword); foreach (var nodeOrToken in TableReferences.GetWithSeparators()) { yield return(nodeOrToken); } }
internal void DropVertex(GremlinVariable dropVertexVariable) { GremlinVariableProperty variableProperty = dropVertexVariable.GetVariableProperty(GremlinKeyword.NodeID); GremlinDropVariable dropVariable = new GremlinDropVertexVariable(variableProperty); VariableList.Add(dropVariable); TableReferences.Add(dropVariable); SetPivotVariable(dropVariable); }
internal void DropEdge(GremlinVariable dropEdgeVariable) { var sourceProperty = dropEdgeVariable.GetVariableProperty(GremlinKeyword.EdgeSourceV); var edgeProperty = dropEdgeVariable.GetVariableProperty(GremlinKeyword.EdgeID); GremlinDropVariable dropVariable = new GremlinDropEdgeVariable(sourceProperty, edgeProperty); VariableList.Add(dropVariable); TableReferences.Add(dropVariable); SetPivotVariable(dropVariable); }
internal void BothV(GremlinVariable lastVariable) { GremlinVariableProperty sourceProperty = lastVariable.GetVariableProperty(GremlinKeyword.EdgeSourceV); GremlinVariableProperty sinkProperty = lastVariable.GetVariableProperty(GremlinKeyword.EdgeSinkV); GremlinBoundVertexVariable bothVertex = new GremlinBoundVertexVariable(lastVariable.GetEdgeType(), sourceProperty, sinkProperty); VariableList.Add(bothVertex); TableReferences.Add(bothVertex); SetPivotVariable(bothVertex); }
internal void Reset() { PivotVariable = null; Predicates = null; VariableList.Clear(); TableReferences.Clear(); PathList.Clear(); StepList.Clear(); IsPopulateGremlinPath = false; CurrentContextPath = null; ProjectVariablePropertiesList.Clear(); ProjectedProperties.Clear(); }
internal void OutE(GremlinVariable lastVariable, List <string> edgeLabels) { GremlinVariableProperty sourceProperty = lastVariable.GetVariableProperty(GremlinKeyword.NodeID); GremlinVariableProperty adjEdge = lastVariable.GetVariableProperty(GremlinKeyword.EdgeAdj); GremlinVariableProperty labelProperty = lastVariable.GetVariableProperty(GremlinKeyword.Label); GremlinBoundEdgeTableVariable outEdgeTable = new GremlinBoundEdgeTableVariable(sourceProperty, adjEdge, labelProperty, WEdgeType.OutEdge); VariableList.Add(outEdgeTable); TableReferences.Add(outEdgeTable); AddLabelPredicateForEdge(outEdgeTable, edgeLabels); AddPath(new GremlinMatchPath(lastVariable, outEdgeTable, null)); SetPivotVariable(outEdgeTable); }
internal void BothE(GremlinVariable lastVariable, List <string> edgeLabels) { GremlinVariableProperty sourceProperty = lastVariable.GetVariableProperty(GremlinKeyword.NodeID); GremlinVariableProperty adjReverseEdge = lastVariable.GetVariableProperty(GremlinKeyword.ReverseEdgeAdj); GremlinVariableProperty adjEdge = lastVariable.GetVariableProperty(GremlinKeyword.EdgeAdj); GremlinVariableProperty labelProperty = lastVariable.GetVariableProperty(GremlinKeyword.Label); GremlinBoundEdgeTableVariable bothEdgeTable = new GremlinBoundEdgeTableVariable(sourceProperty, adjEdge, adjReverseEdge, labelProperty, WEdgeType.BothEdge); VariableList.Add(bothEdgeTable); TableReferences.Add(bothEdgeTable); AddLabelPredicateForEdge(bothEdgeTable, edgeLabels); SetPivotVariable(bothEdgeTable); }
internal void PopulateGremlinPath() { if (IsPopulateGremlinPath) { return; } GremlinPathVariable newVariable = new GremlinPathVariable(GetCurrAndChildGremlinStepList()); VariableList.Add(newVariable); TableReferences.Add(newVariable); CurrentContextPath = newVariable; IsPopulateGremlinPath = true; }
internal void PopulateLocalPath() { if (ContextLocalPath != null) { return; } ProjectedProperties.Add(GremlinKeyword.Path); foreach (var step in StepList) { step.PopulateLocalPath(); } GremlinLocalPathVariable newVariable = new GremlinLocalPathVariable(StepList); VariableList.Add(newVariable); TableReferences.Add(newVariable); ContextLocalPath = newVariable; }
internal void Values(GremlinVariable lastVariable, List <string> propertyKeys) { if (propertyKeys.Count == 0) { lastVariable.Populate(GremlinKeyword.Star); } else { foreach (var property in propertyKeys) { lastVariable.Populate(property); } } GremlinValuesVariable newVariable = new GremlinValuesVariable(lastVariable, propertyKeys); VariableList.Add(newVariable); TableReferences.Add(newVariable); SetPivotVariable(newVariable); }
internal void OutV(GremlinVariable lastVariable) { if (lastVariable is GremlinFreeEdgeTableVariable) { var path = GetPathFromPathList(lastVariable); if (path != null && path.SourceVariable != null) { if (IsVariableInCurrentContext(path.SourceVariable)) { SetPivotVariable(path.SourceVariable); } else { GremlinContextVariable newContextVariable = GremlinContextVariable.Create(path.SourceVariable); VariableList.Add(newContextVariable); SetPivotVariable(newContextVariable); } } else { GremlinVariableProperty sourceProperty = lastVariable.GetVariableProperty(GremlinKeyword.EdgeSourceV); GremlinTableVariable outVertex = lastVariable.CreateAdjVertex(sourceProperty); if (path != null) { path.SetSourceVariable(outVertex); } VariableList.Add(outVertex); TableReferences.Add(outVertex); SetPivotVariable(outVertex); } } else { GremlinVariableProperty sourceProperty = lastVariable.GetVariableProperty(GremlinKeyword.EdgeSourceV); GremlinTableVariable outVertex = new GremlinBoundVertexVariable(lastVariable.GetEdgeType(), sourceProperty); VariableList.Add(outVertex); TableReferences.Add(outVertex); SetPivotVariable(outVertex); } }
internal void OtherV(GremlinVariable lastVariable) { switch (lastVariable.GetEdgeType()) { case WEdgeType.Undefined: case WEdgeType.BothEdge: GremlinVariableProperty otherProperty = lastVariable.GetVariableProperty(GremlinKeyword.EdgeOtherV); GremlinBoundVertexVariable otherVertex = new GremlinBoundVertexVariable(lastVariable.GetEdgeType(), otherProperty); VariableList.Add(otherVertex); TableReferences.Add(otherVertex); SetPivotVariable(otherVertex); break; case WEdgeType.InEdge: OutV(lastVariable); break; case WEdgeType.OutEdge: InV(lastVariable); break; } }
internal void In(GremlinVariable lastVariable, List <string> edgeLabels) { GremlinVariableProperty sourceProperty = lastVariable.GetVariableProperty(GremlinKeyword.NodeID); GremlinVariableProperty adjReverseEdge = lastVariable.GetVariableProperty(GremlinKeyword.ReverseEdgeAdj); GremlinVariableProperty labelProperty = lastVariable.GetVariableProperty(GremlinKeyword.Label); GremlinBoundEdgeTableVariable inEdgeTable = new GremlinBoundEdgeTableVariable(sourceProperty, adjReverseEdge, labelProperty, WEdgeType.InEdge); VariableList.Add(inEdgeTable); TableReferences.Add(inEdgeTable); AddLabelPredicateForEdge(inEdgeTable, edgeLabels); GremlinVariableProperty edgeProperty = inEdgeTable.GetVariableProperty(GremlinKeyword.EdgeSourceV); GremlinBoundVertexVariable outVertex = new GremlinBoundVertexVariable(inEdgeTable.GetEdgeType(), edgeProperty); VariableList.Add(outVertex); TableReferences.Add(outVertex); AddPath(new GremlinMatchPath(outVertex, inEdgeTable, lastVariable)); SetPivotVariable(outVertex); }
public void Visit(TableReferences node) { var list = node.TableReferenceList; VisitChild(1, _verdictColumn, _verdictGroupFunc, list); }
internal bool IsVariableInCurrentContext(GremlinVariable variable) { return(TableReferences.Contains(variable)); }
public virtual void Visit(TableReferences node) { VisitInternal(node.TableReferenceList); }
/// <exception cref="System.SqlSyntaxErrorException" /> public override DmlSelectStatement Select() { Match(MySqlToken.KwSelect); var option = SelectOption(); var exprList = SelectExprList(); TableReferences tables = null; IExpression where = null; GroupBy group = null; IExpression having = null; OrderBy order = null; Limit limit = null; var dual = false; if (lexer.Token() == MySqlToken.KwFrom) { if (lexer.NextToken() == MySqlToken.KwDual) { lexer.NextToken(); dual = true; IList <TableReference> trs = new List <TableReference>(1); trs.Add(new Dual()); tables = new TableReferences(trs); } else { tables = TableRefs(); } } if (lexer.Token() == MySqlToken.KwWhere) { lexer.NextToken(); where = exprParser.Expression(); } if (!dual) { group = GroupBy(); if (lexer.Token() == MySqlToken.KwHaving) { lexer.NextToken(); having = exprParser.Expression(); } order = OrderBy(); } limit = Limit(); if (!dual) { switch (lexer.Token()) { case MySqlToken.KwFor: { lexer.NextToken(); Match(MySqlToken.KwUpdate); option.lockMode = LockMode.ForUpdate; break; } case MySqlToken.KwLock: { lexer.NextToken(); Match(MySqlToken.KwIn); MatchIdentifier("SHARE"); MatchIdentifier("MODE"); option.lockMode = LockMode.LockInShareMode; break; } } } return(new DmlSelectStatement(option, exprList, tables, where, group, having, order, limit)); }