/// <summary> /// Return the collection with only one element, the result size. /// </summary> /// <param name="results"></param> /// <returns></returns> public IList Apply(IList results) { IList nonNullResults = ExitOperationUtils.GetNonNullList(results); ReadOnlyCollection <object> readOnlyCollection = new ReadOnlyCollection <object>(new object[] { nonNullResults.Count }); return(readOnlyCollection); }
public IList Apply(IList results) { IList nonNullResults = ExitOperationUtils.GetNonNullList(results); if (nonNullResults.Count <= firstResult) { return(new List <object>()); } return(ExitOperationUtils.GetSubList(nonNullResults, firstResult, nonNullResults.Count - 1)); }
public IList Apply(IList results) { IList uniqueSet = new List <object>(); foreach (object t in ExitOperationUtils.GetNonNullList(results)) { if (!uniqueSet.Contains(t)) { uniqueSet.Add(t); } } return(uniqueSet); }
public IList Apply(IList results) { IList nonNullList = ExitOperationUtils.GetNonNullList(results); IComparer <object> comparer = new ExitOperationUtils.PropertyComparer(propertyName); List <object> sortedList = new List <object>((IEnumerable <object>)nonNullList); sortedList.Sort(comparer); if (IsDesc) { sortedList.Reverse(); } return(sortedList); }
public IList Apply(IList results) { IList nonNullResults = ExitOperationUtils.GetNonNullList(results); Double?total = null; int numResults = 0; foreach (Object result in nonNullResults) { // We expect all entries to be Object arrays. // the first entry in the array is the average (a double) // the second entry in the array is the number of rows that were examined // to arrive at the average. Pair <Double?, Int32?> pair = GetResultPair(result); Double?shardAvg = pair.first; if (shardAvg == null) { // if there's no result from this shard it doesn't go into the // calculation. This is consistent with how avg is implemented // in the database continue; } int? shardResults = pair.second; Double?shardTotal = shardAvg * shardResults; if (total == null) { total = shardTotal; } else { total += shardTotal; } numResults += shardResults ?? 0; } if (numResults == 0 || total == null) { return(new List <object> { null }); } return(new List <object> { total / numResults }); }
public IList Apply(IList results) { IList nonNullResults = ExitOperationUtils.GetNonNullList(results); switch (_aggregate.ToString().ToLower()) { case "max": return(ExitOperationUtils.GetMaxList(nonNullResults)); case "min": return(ExitOperationUtils.GetMinList(nonNullResults)); case "sum": IList sumList = new ArrayList(); sumList.Add(GetSum(results, _fieldName)); return(sumList); default: throw new NotSupportedException("Aggregation Projected is unsupported: " + _aggregate); } }
private static double GetNumber(object obj, string fieldName) { return(Double.Parse(ExitOperationUtils.GetPropertyValue(obj, fieldName).ToString())); }
public static SortOrder Descending(string propertyName) { return(new SortOrder(o => ExitOperationUtils.GetPropertyValue(o, propertyName), true)); }
public IList Apply(IList results) { IList nonNullResults = ExitOperationUtils.GetNonNullList(results); return(ExitOperationUtils.GetSubList(nonNullResults, 0, Math.Min(nonNullResults.Count - 1, maxResult - 1))); }