internal override GremlinToSqlContext GetContext() { GremlinToSqlContext inputContext = GetInputContext(); RepeatTraversal.GetStartOp().InheritedVariableFromParent(inputContext); GremlinToSqlContext repeatContext = RepeatTraversal.GetEndOp().GetContext(); RepeatCondition repeatCondition = new RepeatCondition(); repeatCondition.StartFromContext = StartFromContext; repeatCondition.IsEmitContext = EmitContext; if (IsEmit) { GremlinToSqlContext emitContext = new GremlinToSqlContext(); emitContext.AddPredicate(SqlUtil.GetTrueBooleanComparisonExpr()); repeatCondition.EmitContext = emitContext; } if (TerminationPredicate != null) { throw new NotImplementedException(); } if (TerminationTraversal != null) { TerminationTraversal.GetStartOp().InheritedVariableFromParent(repeatContext); repeatCondition.TerminationContext = TerminationTraversal.GetEndOp().GetContext(); } if (EmitPredicate != null) { throw new NotImplementedException(); } if (EmitTraversal != null) { EmitTraversal.GetStartOp().InheritedVariableFromParent(repeatContext); repeatCondition.EmitContext = EmitTraversal.GetEndOp().GetContext(); } if (RepeatTimes != -1) { repeatCondition.RepeatTimes = RepeatTimes; } inputContext.PivotVariable.Repeat(inputContext, repeatContext, repeatCondition); return inputContext; }
internal override GremlinToSqlContext GetContext() { GremlinToSqlContext inputContext = GetInputContext(); if (inputContext.PivotVariable == null) { throw new QueryCompilationException("The PivotVariable can't be null."); } RepeatTraversal.GetStartOp().InheritedVariableFromParent(inputContext); GremlinToSqlContext repeatContext = RepeatTraversal.GetEndOp().GetContext(); foreach (var variable in repeatContext.TableReferences) { if (variable is GremlinFoldVariable || variable is GremlinCountVariable || variable is GremlinMinVariable || variable is GremlinMaxVariable || variable is GremlinSumVariable || variable is GremlinMeanVariable || variable is GremlinTreeVariable) { throw new SyntaxErrorException($"The parent of a reducing barrier can not be repeat()-step: {variable.GetType()}"); } var group = variable as GremlinGroupVariable; if (group != null && group.SideEffectKey == null) { throw new SyntaxErrorException($"The parent of a reducing barrier can not be repeat()-step: {variable.GetType()}"); } } foreach (var variable in repeatContext.FetchAllTableVars()) { if (variable is GremlinRepeatVariable) { throw new SyntaxErrorException("The repeat()-step can't include another nesting repeat()-step:"); } } RepeatCondition repeatCondition = new RepeatCondition(); repeatCondition.StartFromContext = StartFromContext; repeatCondition.IsEmitContext = EmitContext; if (IsEmit) { GremlinToSqlContext emitContext = new GremlinToSqlContext(); emitContext.AddPredicate(SqlUtil.GetTrueBooleanComparisonExpr()); repeatCondition.EmitContext = emitContext; } if (TerminationPredicate != null) { throw new NotImplementedException(); } if (TerminationTraversal != null) { if (StartFromContext) { TerminationTraversal.GetStartOp().InheritedVariableFromParent(inputContext); } else { TerminationTraversal.GetStartOp().InheritedVariableFromParent(repeatContext); } repeatCondition.TerminationContext = TerminationTraversal.GetEndOp().GetContext(); } if (EmitPredicate != null) { throw new NotImplementedException(); } if (EmitTraversal != null) { if (EmitContext) { EmitTraversal.GetStartOp().InheritedVariableFromParent(inputContext); } else { EmitTraversal.GetStartOp().InheritedVariableFromParent(repeatContext); } repeatCondition.EmitContext = EmitTraversal.GetEndOp().GetContext(); } if (RepeatTimes != -1) { repeatCondition.RepeatTimes = RepeatTimes; } inputContext.PivotVariable.Repeat(inputContext, repeatContext, repeatCondition); return(inputContext); }