public SubselectForgeNRExistsWGroupByWHaving( ExprSubselectNode subselect, ExprForge havingEval) { this.subselect = subselect; this.havingEval = havingEval; }
private static CodegenExpression MakeEvaluate( SubselectEvaluationType evaluationType, ExprSubselectNode subselectNode, Type resultType, CodegenMethodScope parent, ExprForgeCodegenSymbol symbols, CodegenClassScope classScope) { var method = parent.MakeChild(resultType, typeof(ExprSubselectNode), classScope); CodegenExpression eps = symbols.GetAddEPS(method); var newData = symbols.GetAddIsNewData(method); CodegenExpression evalCtx = symbols.GetAddExprEvalCtx(method); // get matching events CodegenExpression future = classScope.NamespaceScope.AddOrGetDefaultFieldWellKnown( new CodegenFieldNameSubqueryResult(subselectNode.SubselectNumber), typeof(SubordTableLookupStrategy)); var evalMatching = FlexWrap(ExprDotMethod(future, "Lookup", eps, evalCtx)); method.Block.DeclareVar<FlexCollection>(NAME_MATCHINGEVENTS, evalMatching); // process matching events var evalMatchSymbol = new ExprSubselectEvalMatchSymbol(); var processMethod = method .MakeChildWithScope(resultType, typeof(ExprSubselectNode), evalMatchSymbol, classScope) .AddParam(typeof(FlexCollection), NAME_MATCHINGEVENTS) .AddParam(ExprForgeCodegenNames.PARAMS); CodegenExpression process; if (evaluationType == PLAIN) { process = subselectNode.EvalMatchesPlainCodegen(processMethod, evalMatchSymbol, classScope); } else if (evaluationType == GETEVENTCOLL) { process = subselectNode.EvalMatchesGetCollEventsCodegen(processMethod, evalMatchSymbol, classScope); } else if (evaluationType == GETSCALARCOLL) { process = subselectNode.EvalMatchesGetCollScalarCodegen(processMethod, evalMatchSymbol, classScope); } else if (evaluationType == GETEVENT) { process = subselectNode.EvalMatchesGetEventBeanCodegen(processMethod, evalMatchSymbol, classScope); } else if (evaluationType == TYPABLESINGLE) { process = subselectNode.EvalMatchesTypableSingleCodegen(processMethod, evalMatchSymbol, classScope); } else if (evaluationType == TYPABLEMULTI) { process = subselectNode.EvalMatchesTypableMultiCodegen(processMethod, evalMatchSymbol, classScope); } else { throw new IllegalStateException("Unrecognized evaluation type " + evaluationType); } evalMatchSymbol.DerivedSymbolsCodegen(processMethod, processMethod.Block, classScope); processMethod.Block.MethodReturn(process); method.Block.MethodReturn(LocalMethod(processMethod, REF_MATCHINGEVENTS, eps, newData, evalCtx)); return LocalMethod(method); }
public SubselectForgeNRRelOpBase( ExprSubselectNode subselect, ExprForge valueEval, ExprForge selectEval, bool resultWhenNoMatchingEvents, RelationalOpEnumComputer computer) : base(subselect, valueEval, selectEval, resultWhenNoMatchingEvents) { this.computer = computer; }
public SubselectForgeNRBase( ExprSubselectNode subselect, ExprForge valueEval, ExprForge selectEval, bool resultWhenNoMatchingEvents) { this.subselect = subselect; this.valueEval = valueEval; this.selectEval = selectEval; this.resultWhenNoMatchingEvents = resultWhenNoMatchingEvents; }
public SubselectForgeNREqualsInAggregated( ExprSubselectNode subselect, ExprForge valueEval, ExprForge selectEval, bool resultWhenNoMatchingEvents, bool isNotIn, Coercer coercer, ExprForge havingEval) : base(subselect, valueEval, selectEval, resultWhenNoMatchingEvents, isNotIn, coercer) { this.havingEval = havingEval; }
public SubselectForgeNREqualsIn( ExprSubselectNode subselect, ExprForge valueEval, ExprForge selectEval, bool resultWhenNoMatchingEvents, bool isNotIn, Coercer coercer, ExprForge filterEval) : base(subselect, valueEval, selectEval, resultWhenNoMatchingEvents, isNotIn, coercer) { this.filterEval = filterEval; }
public SubselectForgeNREqualsAllAnyWGroupBy( ExprSubselectNode subselect, ExprForge valueEval, ExprForge selectEval, bool resultWhenNoMatchingEvents, bool isNot, Coercer coercer, ExprForge havingEval, bool isAll) : base(subselect, valueEval, selectEval, resultWhenNoMatchingEvents, isNot, coercer) { this.havingEval = havingEval; this.isAll = isAll; }
public SubselectForgeNRRelOpAllAnyAggregated( ExprSubselectNode subselect, ExprForge valueEval, ExprForge selectEval, bool resultWhenNoMatchingEvents, RelationalOpEnumComputer computer, ExprForge havingEval) : base( subselect, valueEval, selectEval, resultWhenNoMatchingEvents, computer) { this.havingEval = havingEval; }
public SubselectForgeNREqualsBase( ExprSubselectNode subselect, ExprForge valueEval, ExprForge selectEval, bool resultWhenNoMatchingEvents, bool isNot, Coercer coercer) : base( subselect, valueEval, selectEval, resultWhenNoMatchingEvents) { this.isNot = isNot; this.coercer = coercer; }
public SubselectForgeNRRelOpAllDefault( ExprSubselectNode subselect, ExprForge valueEval, ExprForge selectEval, bool resultWhenNoMatchingEvents, RelationalOpEnumComputer computer, ExprForge filterOrHavingEval) : base( subselect, valueEval, selectEval, resultWhenNoMatchingEvents, computer) { this.filterOrHavingEval = filterOrHavingEval; }
public SubselectForgeNRExistsWGroupBy(ExprSubselectNode subselect) { this.subselect = subselect; }
public static SubselectForgeNR CreateStrategyAnyAllIn( ExprSubselectNode subselectExpression, bool isNot, bool isAll, bool isAny, RelationalOpEnum? relationalOp, ImportServiceCompileTime importService) { if (subselectExpression.ChildNodes.Length != 1) { throw new ExprValidationException("The Subselect-IN requires 1 child expression"); } var valueExpr = subselectExpression.ChildNodes[0]; // Must be the same boxed type returned by expressions under this var typeOne = subselectExpression.ChildNodes[0].Forge.EvaluationType.GetBoxedType(); // collections, array or map not supported if (typeOne.IsArray || typeOne.IsGenericCollection() || typeOne.IsGenericDictionary()) { throw new ExprValidationException( "Collection or array comparison is not allowed for the IN, ANY, SOME or ALL keywords"); } Type typeTwo; if (subselectExpression.SelectClause != null) { typeTwo = subselectExpression.SelectClause[0].Forge.EvaluationType; } else { typeTwo = subselectExpression.RawEventType.UnderlyingType; } var aggregated = Aggregated(subselectExpression.SubselectAggregationType); var grouped = Grouped(subselectExpression.StatementSpecCompiled.Raw.GroupByExpressions); var selectEval = subselectExpression.SelectClause == null ? null : subselectExpression.SelectClause[0].Forge; var valueEval = valueExpr.Forge; var filterEval = subselectExpression.FilterExpr; var havingEval = subselectExpression.HavingExpr; if (relationalOp != null) { if (typeOne != typeof(string) || typeTwo != typeof(string)) { if (!typeOne.IsNumeric()) { throw new ExprValidationException( "Implicit conversion from datatype '" + typeOne.CleanName() + "' to numeric is not allowed"); } if (!typeTwo.IsNumeric()) { throw new ExprValidationException( "Implicit conversion from datatype '" + typeTwo.CleanName() + "' to numeric is not allowed"); } } var compareType = typeOne.GetCompareToCoercionType(typeTwo); var computer = relationalOp.Value.GetComputer(compareType, typeOne, typeTwo); if (isAny) { if (grouped) { return new SubselectForgeNRRelOpAnyWGroupBy( subselectExpression, valueEval, selectEval, false, computer, havingEval); } if (aggregated) { return new SubselectForgeNRRelOpAllAnyAggregated( subselectExpression, valueEval, selectEval, false, computer, havingEval); } return new SubselectForgeStrategyNRRelOpAnyDefault( subselectExpression, valueEval, selectEval, false, computer, filterEval); } // handle ALL if (grouped) { return new SubselectForgeNRRelOpAllWGroupBy( subselectExpression, valueEval, selectEval, true, computer, havingEval); } if (aggregated) { return new SubselectForgeNRRelOpAllAnyAggregated( subselectExpression, valueEval, selectEval, true, computer, havingEval); } return new SubselectForgeNRRelOpAllDefault( subselectExpression, valueEval, selectEval, true, computer, filterEval); } var coercer = GetCoercer(typeOne, typeTwo); if (isAll) { if (grouped) { return new SubselectForgeNREqualsAllAnyWGroupBy( subselectExpression, valueEval, selectEval, true, isNot, coercer, havingEval, true); } if (aggregated) { return new SubselectForgeNREqualsAllAnyAggregated( subselectExpression, valueEval, selectEval, true, isNot, coercer, havingEval); } return new SubselectForgeNREqualsDefault( subselectExpression, valueEval, selectEval, true, isNot, coercer, filterEval, true); } if (isAny) { if (grouped) { return new SubselectForgeNREqualsAllAnyWGroupBy( subselectExpression, valueEval, selectEval, false, isNot, coercer, havingEval, false); } if (aggregated) { return new SubselectForgeNREqualsAllAnyAggregated( subselectExpression, valueEval, selectEval, true, isNot, coercer, havingEval); } return new SubselectForgeNREqualsDefault( subselectExpression, valueEval, selectEval, false, isNot, coercer, filterEval, false); } if (grouped) { return new SubselectForgeNREqualsInWGroupBy( subselectExpression, valueEval, selectEval, isNot, isNot, coercer, havingEval); } if (aggregated) { return new SubselectForgeNREqualsInAggregated( subselectExpression, valueEval, selectEval, isNot, isNot, coercer, havingEval); } return new SubselectForgeNREqualsIn( subselectExpression, valueEval, selectEval, isNot, isNot, coercer, filterEval); }