public int CompareTo(object obj) { if (obj is IsOfTypePredicate) { IsOfTypePredicate other = (IsOfTypePredicate)obj; if (Inverse == other.Inverse) { return(typename.CompareTo(other.typename)); } } return(-1); }
/// Implements <AverageFunction> ::= 'AVG(' <TypePlusAttribute> ')' public Reduction CreateRULE_AVERAGEFUNCTION_AVGLPARAN_RPARAN(Reduction reduction) { Reduction typePlusAttributeReduction = (Reduction)reduction.GetToken(1).Data; string typeName = ((Reduction)typePlusAttributeReduction.GetToken(0).Data).Tag as string; string memberName = ((Reduction)typePlusAttributeReduction.GetToken(2).Data).Tag as string; Predicate childPredicate = new IsOfTypePredicate(typeName); AggregateFunctionPredicate avgFunctionPredicate = ExpressionBuilder.CreateAverageFunctionPredicate(memberName) as AggregateFunctionPredicate; avgFunctionPredicate.ChildPredicate = childPredicate; reduction.Tag = avgFunctionPredicate; return null; }
/// Implements <Query> ::= SELECT <TypeIdentifier> WHERE <Expression> public Reduction CreateRULE_QUERY_SELECT_WHERE(Reduction reduction) { //selectType can be one of the following depending on the query text: - //1. A plain string that is the name of Type; we can build IsOfTypePredicate from this. //2. AggregateFunctionPredicate that has IsOfTypePredicate set as its ChildPredicate // cant be this, grammer changed //3. IsOfTypePredicate object selectType = ((Reduction)reduction.GetToken(1).Data).Tag; Predicate lhs = null; Predicate rhs = (Predicate)((Reduction)reduction.GetToken(3).Data).Tag; Predicate selectTypePredicate = selectType as Predicate; Predicate result = null; //1. selectType is string if (selectTypePredicate == null) { lhs = new IsOfTypePredicate(selectType.ToString()); result = ExpressionBuilder.CreateLogicalAndPredicate(lhs, rhs); } ////2. selectType is AggregateFunctionPredicate //3. selectType is IsOfTypePredicate else { lhs = selectTypePredicate; result = ExpressionBuilder.CreateLogicalAndPredicate(lhs, rhs); } reduction.Tag = result; if (NCacheLog.IsInfoEnabled) NCacheLog.Info("CreateRULE_QUERY_SELECT_WHERE"); return null; }
/// Implements <CountFunction> ::= 'COUNT(' <Property> ')' public Reduction CreateRULE_COUNTFUNCTION_COUNTLPARAN_TIMES_RPARAN(Reduction reduction) { string typeName = ((Reduction)reduction.GetToken(1).Data).Tag as string; Predicate childPredicate = new IsOfTypePredicate(typeName); AggregateFunctionPredicate countFunctionPredicate = ExpressionBuilder.CreateCountFunctionPredicate() as AggregateFunctionPredicate; countFunctionPredicate.ChildPredicate = childPredicate; reduction.Tag = countFunctionPredicate; return null; }