Example #1
0
        public AverageResultAt1 AverageResultAt1FromHead(AverageResult ho)
        {
            var o = new AverageResultAt1();

            o.Value = (int)(ho.Value);
            return(o);
        }
Example #2
0
        public override void Write(CompactBinaryWriter writer, object graph)
        {
            ISerializationSurrogate decimalSurrogate = TypeSurrogateSelector.GetSurrogateForType(typeof(decimal), null);

            AverageResult result = (AverageResult)graph;

            decimalSurrogate.Write(writer, result.Sum);
            decimalSurrogate.Write(writer, result.Count);
        }
Example #3
0
        public override object Read(CompactBinaryReader reader)
        {
            ISerializationSurrogate decimalSurrogate = TypeSurrogateSelector.GetSurrogateForType(typeof(decimal), null);

            AverageResult result = new AverageResult();

            result.Sum   = (decimal)decimalSurrogate.Read(reader);
            result.Count = (decimal)decimalSurrogate.Read(reader);
            return(result);
        }
Example #4
0
        private static void SaveAverageValues(List <FrontResult> results)
        {
            var groupped =
                results.GroupBy(
                    r =>
                    r.PopulationSize.ToString(CultureInfo.InvariantCulture) + "_" +
                    r.Iterations.ToString(CultureInfo.InvariantCulture) + "_" +
                    r.MutationProbability.ToString(CultureInfo.InvariantCulture)).ToList();

            var csv = new StringBuilder();

            csv.AppendLine("Iterations;MutationProbability;PopulationSize;Time;pvalue;w;HyperVolume;pvalue;w;Epsilon;pvalue;w");

            foreach (var group in groupped)
            {
                var hvs      = group.Select(i => i.HyperVolume).ToList();
                var times    = group.Select(i => i.Time).ToList();
                var epsolons = group.Select(i => i.EpsilonIndicator).ToList();
                var avg      = new AverageResult();

                if (hvs.Count > 3 && hvs.Any(value => value > 0))
                {
                    avg.NormalityHv = RInvoker.Shapiro(hvs);
                }

                if (times.Count > 3 && hvs.Any(value => value > 0))
                {
                    avg.NormalityTime = RInvoker.Shapiro(times);
                }

                if (epsolons.Count > 3 && epsolons.Any(value => value > 0))
                {
                    avg.NormalityEpsilon = RInvoker.Shapiro(epsolons);
                }

                avg.Hypervolume = group.Select(i => i.HyperVolume).Average();
                avg.Time        = group.Select(i => i.Time).Average();
                avg.Epsilon     = group.Select(i => i.EpsilonIndicator).Average();

                csv.AppendLine(
                    $"{group.First().Iterations};{group.First().MutationProbability};{group.First().PopulationSize};{avg.Time};{avg.NormalityTime.Pvalue};{avg.NormalityTime.Statistic};{avg.Hypervolume};{avg.NormalityHv.Pvalue};{avg.NormalityHv.Statistic};{avg.Epsilon};{avg.NormalityEpsilon.Pvalue};{avg.NormalityEpsilon.Statistic}");
            }

            var filesInOutputDir = Directory.GetFiles(OutputsDirectory);
            var fileIndex        = 0;
            var fileName         = "averageResults.csv";

            while (filesInOutputDir.Any(path => path.EndsWith(fileName)))
            {
                fileIndex++;
                fileName = $"averageResults_{fileIndex}.csv";
            }

            File.WriteAllText($"{OutputsDirectory}\\{fileName}", csv.ToString());
        }
Example #5
0
        internal override void Execute(QueryContext queryContext, Predicate nextPredicate)
        {
            if (ChildPredicate != null)
            {
                ChildPredicate.Execute(queryContext, nextPredicate);
            }

            CacheEntry entry = null;

            decimal sum = 0;

            if (queryContext.InternalQueryResult.Count > 0)
            {
                if (queryContext.CancellationToken != null && queryContext.CancellationToken.IsCancellationRequested)
                {
                    throw new OperationCanceledException(ExceptionsResource.OperationFailed);
                }
                foreach (string key in queryContext.InternalQueryResult)
                {
                    if (queryContext.CancellationToken != null && queryContext.CancellationToken.IsCancellationRequested)
                    {
                        throw new OperationCanceledException(ExceptionsResource.OperationFailed);
                    }
                    CacheEntry cacheentry  = queryContext.Cache.GetEntryInternal(key, false);
                    object     attribValue = queryContext.Index.GetAttributeValue(key, AttributeName, cacheentry.IndexInfo);
                    if (attribValue != null)
                    {
                        Type type = attribValue.GetType();
                        if ((type == typeof(bool)) || (type == typeof(DateTime)) || (type == typeof(string)) || (type == typeof(char)))
                        {
                            throw new Exception("AVG can only be applied to integral data types.");
                        }

                        sum += Convert.ToDecimal(attribValue);
                    }
                }

                AverageResult avgResult = new AverageResult();
                avgResult.Sum   = sum;
                avgResult.Count = queryContext.InternalQueryResult.Count;
                //put the count and the sum
                base.SetResult(queryContext, AggregateFunctionType.AVG, avgResult);
            }
            else
            {
                base.SetResult(queryContext, AggregateFunctionType.AVG, null);
            }
        }
Example #6
0
        internal override void Execute(QueryContext queryContext, Predicate nextPredicate)
        {
            if (ChildPredicate != null)
            {
                ChildPredicate.Execute(queryContext, nextPredicate);
            }

            queryContext.Tree.Reduce();
            CacheEntry entry = null;

            decimal sum = 0;

            if (queryContext.Tree.LeftList.Count > 0)
            {
                foreach (string key in queryContext.Tree.LeftList)
                {
                    object attribValue = queryContext.Index.GetAttributeValue(key, AttributeName);
                    if (attribValue != null)
                    {
                        Type type = attribValue.GetType();
                        if ((type == typeof(bool)) || (type == typeof(DateTime)) || (type == typeof(string)) || (type == typeof(char)))
                        {
                            throw new Exception("AVG can only be applied to integral data types.");
                        }

                        sum += Convert.ToDecimal(attribValue);
                    }
                }

                AverageResult avgResult = new AverageResult();
                avgResult.Sum   = sum;
                avgResult.Count = queryContext.Tree.LeftList.Count;
                //put the count and the sum
                base.SetResult(queryContext, AggregateFunctionType.AVG, avgResult);
            }
            else
            {
                base.SetResult(queryContext, AggregateFunctionType.AVG, null);
            }
        }
Example #7
0
        /// <summary>
        /// Executa o predicado.
        /// </summary>
        /// <param name="queryContext"></param>
        /// <param name="nextPredicate"></param>
        internal override void Execute(QueryContext queryContext, Predicate nextPredicate)
        {
            base.ChildPredicate.Execute(queryContext, nextPredicate);
            queryContext.Tree.Reduce();
            decimal num = 0M;

            if (queryContext.Tree.LeftList.Count > 0)
            {
                foreach (string str in queryContext.Tree.LeftList)
                {
                    var metaInformation = queryContext.Cache.GetEntryInternal(str, true).MetaInformation;
                    if ((metaInformation == null) || !metaInformation.IsAttributeIndexed(base.AttributeName))
                    {
                        throw new Exception("Index is not defined for attribute '" + base.AttributeName + "'");
                    }
                    object obj2 = metaInformation[base.AttributeName];
                    if (obj2 != null)
                    {
                        Type type = obj2.GetType();
                        if (((type == typeof(bool)) || (type == typeof(DateTime))) || ((type == typeof(string)) || (type == typeof(char))))
                        {
                            throw new Exception("AVG can only be applied to integral data types.");
                        }
                        num += Convert.ToDecimal(obj2);
                    }
                }
                AverageResult result = new AverageResult();
                result.Sum   = num;
                result.Count = queryContext.Tree.LeftList.Count;
                base.SetResult(queryContext, AggregateFunctionType.AVG, result);
            }
            else
            {
                base.SetResult(queryContext, AggregateFunctionType.AVG, null);
            }
        }
Example #8
0
        public void Merge(RecordRow row)
        {
            for (int i = 0; i < this._columns.Count; i++)
            {
                if (this._columns[i].ColumnType == ColumnType.AggregateResultColumn)
                {
                    switch (this._columns[i].AggregateFunctionType)
                    {
                    case AggregateFunctionType.SUM:
                        decimal a;
                        decimal b;

                        object thisVal  = this._objects[i];
                        object otherVal = row._objects[i];

                        decimal?sum = null;

                        if (thisVal == null && otherVal != null)
                        {
                            sum = (decimal)otherVal;
                        }
                        else if (thisVal != null && otherVal == null)
                        {
                            sum = (decimal)thisVal;
                        }
                        else if (thisVal != null && otherVal != null)
                        {
                            a   = (decimal)thisVal;
                            b   = (decimal)otherVal;
                            sum = a + b;
                        }

                        if (sum != null)
                        {
                            this._objects[i] = sum;
                        }
                        else
                        {
                            this._objects[i] = null;
                        }
                        break;

                    case AggregateFunctionType.COUNT:
                        a = (decimal)this._objects[i];
                        b = (decimal)row._objects[i];
                        decimal count = a + b;

                        this._objects[i] = count;
                        break;

                    case AggregateFunctionType.MIN:
                        IComparable thisValue  = (IComparable)this._objects[i];
                        IComparable otherValue = (IComparable)row._objects[i];
                        IComparable min        = thisValue;

                        if (thisValue == null && otherValue != null)
                        {
                            min = otherValue;
                        }
                        else if (thisValue != null && otherValue == null)
                        {
                            min = thisValue;
                        }
                        else if (thisValue == null && otherValue == null)
                        {
                            min = null;
                        }
                        else if (otherValue.CompareTo(thisValue) < 0)
                        {
                            min = otherValue;
                        }

                        //this.AggregateFunctionResult = min;
                        this._objects[i] = min;
                        break;

                    case AggregateFunctionType.MAX:
                        thisValue  = (IComparable)this._objects[i];
                        otherValue = (IComparable)row._objects[i];
                        IComparable max = thisValue;

                        if (thisValue == null && otherValue != null)
                        {
                            max = otherValue;
                        }
                        else if (thisValue != null && otherValue == null)
                        {
                            max = thisValue;
                        }
                        else if (thisValue == null && otherValue == null)
                        {
                            max = null;
                        }
                        else if (otherValue.CompareTo(thisValue) > 0)
                        {
                            max = otherValue;
                        }

                        //this.AggregateFunctionResult = max;
                        this._objects[i] = max;
                        break;

                    case AggregateFunctionType.AVG:
                        thisVal  = this._objects[i];
                        otherVal = row._objects[i];

                        AverageResult avg = null;
                        if (thisVal == null && otherVal != null)
                        {
                            avg = (AverageResult)otherVal;
                        }
                        else if (thisVal != null && otherVal == null)
                        {
                            avg = (AverageResult)thisVal;
                        }
                        else if (thisVal != null && otherVal != null)
                        {
                            AverageResult thisResult  = (AverageResult)thisVal;
                            AverageResult otherResult = (AverageResult)otherVal;

                            avg       = new AverageResult();
                            avg.Sum   = thisResult.Sum + otherResult.Sum;
                            avg.Count = thisResult.Count + otherResult.Count;
                        }

                        if (avg != null)
                        {
                            this._objects[i] = avg;
                        }
                        else
                        {
                            this._objects[i] = null;
                        }
                        break;
                    }
                }
            }
        }
Example #9
0
        public void Compile(QueryResultSet resultSet)
        {
            if (!this._isInitialized)
            {
                Initialize(resultSet);
                return;
            }

            switch (this.Type)
            {
            case QueryType.AggregateFunction:

                switch ((AggregateFunctionType)this.AggregateFunctionResult.Key)
                {
                case AggregateFunctionType.SUM:
                    decimal a;
                    decimal b;

                    object thisVal  = this.AggregateFunctionResult.Value;
                    object otherVal = resultSet.AggregateFunctionResult.Value;

                    Nullable <decimal> sum = null;

                    if (thisVal == null && otherVal != null)
                    {
                        sum = (decimal)otherVal;
                    }
                    else if (thisVal != null && otherVal == null)
                    {
                        sum = (decimal)thisVal;
                    }
                    else if (thisVal != null && otherVal != null)
                    {
                        a   = (decimal)thisVal;
                        b   = (decimal)otherVal;
                        sum = a + b;
                    }

                    if (sum != null)
                    {
                        this.AggregateFunctionResult = new DictionaryEntry(AggregateFunctionType.SUM, sum);
                    }
                    else
                    {
                        this.AggregateFunctionResult = new DictionaryEntry(AggregateFunctionType.SUM, null);
                    }
                    break;

                case AggregateFunctionType.COUNT:
                    a = (decimal)this.AggregateFunctionResult.Value;
                    b = (decimal)resultSet.AggregateFunctionResult.Value;
                    decimal count = a + b;

                    this.AggregateFunctionResult = new DictionaryEntry(AggregateFunctionType.COUNT, count);
                    break;

                case AggregateFunctionType.MIN:
                    IComparable thisValue  = (IComparable)this.AggregateFunctionResult.Value;
                    IComparable otherValue = (IComparable)resultSet.AggregateFunctionResult.Value;
                    IComparable min        = thisValue;

                    if (thisValue == null && otherValue != null)
                    {
                        min = otherValue;
                    }
                    else if (thisValue != null && otherValue == null)
                    {
                        min = thisValue;
                    }
                    else if (thisValue == null && otherValue == null)
                    {
                        min = null;
                    }
                    else if (otherValue.CompareTo(thisValue) < 0)
                    {
                        min = otherValue;
                    }

                    this.AggregateFunctionResult = new DictionaryEntry(AggregateFunctionType.MIN, min);
                    break;

                case AggregateFunctionType.MAX:
                    thisValue  = (IComparable)this.AggregateFunctionResult.Value;
                    otherValue = (IComparable)resultSet.AggregateFunctionResult.Value;
                    IComparable max = thisValue;

                    if (thisValue == null && otherValue != null)
                    {
                        max = otherValue;
                    }
                    else if (thisValue != null && otherValue == null)
                    {
                        max = thisValue;
                    }
                    else if (thisValue == null && otherValue == null)
                    {
                        max = null;
                    }
                    else if (otherValue.CompareTo(thisValue) > 0)
                    {
                        max = otherValue;
                    }

                    this.AggregateFunctionResult = new DictionaryEntry(AggregateFunctionType.MAX, max);
                    break;

                case AggregateFunctionType.AVG:
                    thisVal  = this.AggregateFunctionResult.Value;
                    otherVal = resultSet.AggregateFunctionResult.Value;

                    AverageResult avg = null;
                    if (thisVal == null && otherVal != null)
                    {
                        avg = (AverageResult)otherVal;
                    }
                    else if (thisVal != null && otherVal == null)
                    {
                        avg = (AverageResult)thisVal;
                    }
                    else if (thisVal != null && otherVal != null)
                    {
                        AverageResult thisResult  = (AverageResult)thisVal;
                        AverageResult otherResult = (AverageResult)otherVal;

                        avg       = new AverageResult();
                        avg.Sum   = thisResult.Sum + otherResult.Sum;
                        avg.Count = thisResult.Count + otherResult.Count;
                    }

                    if (avg != null)
                    {
                        this.AggregateFunctionResult = new DictionaryEntry(AggregateFunctionType.AVG, avg);
                    }
                    else
                    {
                        this.AggregateFunctionResult = new DictionaryEntry(AggregateFunctionType.AVG, null);
                    }
                    break;
                }

                break;

            case QueryType.SearchKeys:
                if (this.SearchKeysResult == null)
                {
                    this.SearchKeysResult = resultSet.SearchKeysResult;
                }
                else if (resultSet.SearchKeysResult != null && resultSet.SearchKeysResult.Count > 0)
                {
                    ClusteredArrayList skr = this.SearchKeysResult as ClusteredArrayList;
                    if (skr != null)
                    {
                        skr.AddRange(resultSet.SearchKeysResult);
                    }
                    else
                    {
                        IEnumerator ienum = resultSet.SearchKeysResult.GetEnumerator();

                        while (ienum.MoveNext())
                        {
                            this.SearchKeysResult.Add(ienum.Current);
                        }
                    }
                }

                break;

            case QueryType.SearchEntries:
                if (this.SearchEntriesResult == null)
                {
                    this.SearchEntriesResult = resultSet.SearchEntriesResult;
                }
                else
                {
                    IDictionaryEnumerator ide = resultSet.SearchEntriesResult.GetEnumerator();
                    while (ide.MoveNext())
                    {
                        try
                        {
                            this.SearchEntriesResult.Add(ide.Key, ide.Value);
                        }
                        catch (ArgumentException ex)     //Overwrite entry with an updated one
                        {
                            CacheEntry entry         = ide.Value as CacheEntry;
                            CacheEntry existingEntry = this.SearchEntriesResult[ide.Key] as CacheEntry;
                            if (entry != null && existingEntry != null)
                            {
                                if (entry.Version > existingEntry.Version)
                                {
                                    this.SearchEntriesResult[ide.Key] = entry;
                                }
                            }
                        }
                    }
                }
                break;
            }
        }
Example #10
0
        /// <summary>
        /// Merges <see cref="Alachisoft.NosDB.Common.DataStructures.RecordSet"/>
        /// </summary>
        /// <param name="recordSet"><see cref="Alachisoft.NosDB.Common.DataStructures.RecordSet"/> to merge</param>
        public void Union(RecordSet recordSet)
        {
            if (this.ColumnCount != recordSet.ColumnCount)
            {
                throw new InvalidOperationException("Cannot compute union of two RecordSet with different number of columns.");
            }

            int thisRowCount = this._rowCount;

            for (int i = 0; i < recordSet.RowCount; i++)
            {
                bool recordMatch = false;

                for (int l = 0; l < thisRowCount; l++)
                {
                    bool rowMatch = true;
                    System.Collections.Generic.List <string> aggregateColumns = new System.Collections.Generic.List <string>();

                    foreach (System.Collections.Generic.KeyValuePair <string, RecordColumn> kvp in _dataStringIndex)
                    {
                        if (kvp.Value.Type == ColumnType.AggregateResultColumn)
                        {
                            aggregateColumns.Add(kvp.Key);
                            continue;
                        }

                        if (recordSet.GetObject(i, kvp.Key).Equals(this.GetObject(l, kvp.Key)))
                        {
                            continue;
                        }

                        rowMatch = false;
                        break;
                    }

                    if (rowMatch)
                    {
                        //Rows matched, merging aggregate result columns
                        foreach (string column in aggregateColumns)
                        {
                            switch (this.GetAggregateFunctionType(column))
                            {
                            case AggregateFunctionType.SUM:
                                decimal a;
                                decimal b;

                                object thisVal  = this.GetObject(i, column);
                                object otherVal = recordSet.GetObject(i, column);

                                Nullable <decimal> sum = null;

                                if (thisVal == null && otherVal != null)
                                {
                                    sum = (decimal)otherVal;
                                }
                                else if (thisVal != null && otherVal == null)
                                {
                                    sum = (decimal)thisVal;
                                }
                                else if (thisVal != null && otherVal != null)
                                {
                                    a   = (decimal)thisVal;
                                    b   = (decimal)otherVal;
                                    sum = a + b;
                                }

                                if (sum != null)
                                {
                                    this.Add(sum, i, column);
//                                        this.AggregateFunctionResult = sum;
                                }
                                else
                                {
                                    this.Add(null, i, column);
//                                        this.AggregateFunctionResult = null;
                                }
                                break;

                            case AggregateFunctionType.COUNT:
                                a = (decimal)this.GetObject(i, column);
                                b = (decimal)recordSet.GetObject(i, column);
                                decimal count = a + b;

                                this.Add(count, i, column);
                                //this.AggregateFunctionResult = count;
                                break;

                            case AggregateFunctionType.MIN:
                                IComparable thisValue  = (IComparable)this.GetObject(i, column);
                                IComparable otherValue = (IComparable)recordSet.GetObject(i, column);
                                IComparable min        = thisValue;

                                if (thisValue == null && otherValue != null)
                                {
                                    min = otherValue;
                                }
                                else if (thisValue != null && otherValue == null)
                                {
                                    min = thisValue;
                                }
                                else if (thisValue == null && otherValue == null)
                                {
                                    min = null;
                                }
                                else if (otherValue.CompareTo(thisValue) < 0)
                                {
                                    min = otherValue;
                                }

                                //this.AggregateFunctionResult = min;
                                this.Add(min, i, column);
                                break;

                            case AggregateFunctionType.MAX:
                                thisValue  = (IComparable)this.GetObject(i, column);
                                otherValue = (IComparable)recordSet.GetObject(i, column);
                                IComparable max = thisValue;

                                if (thisValue == null && otherValue != null)
                                {
                                    max = otherValue;
                                }
                                else if (thisValue != null && otherValue == null)
                                {
                                    max = thisValue;
                                }
                                else if (thisValue == null && otherValue == null)
                                {
                                    max = null;
                                }
                                else if (otherValue.CompareTo(thisValue) > 0)
                                {
                                    max = otherValue;
                                }

                                //this.AggregateFunctionResult = max;
                                this.Add(max, i, column);
                                break;

                            case AggregateFunctionType.AVG:
                                thisVal  = this.GetObject(i, column);
                                otherVal = recordSet.GetObject(i, column);

                                AverageResult avg = null;
                                if (thisVal == null && otherVal != null)
                                {
                                    avg = (AverageResult)otherVal;
                                }
                                else if (thisVal != null && otherVal == null)
                                {
                                    avg = (AverageResult)thisVal;
                                }
                                else if (thisVal != null && otherVal != null)
                                {
                                    AverageResult thisResult  = (AverageResult)thisVal;
                                    AverageResult otherResult = (AverageResult)otherVal;

                                    avg       = new AverageResult();
                                    avg.Sum   = thisResult.Sum + otherResult.Sum;
                                    avg.Count = thisResult.Count + otherResult.Count;
                                }

                                if (avg != null)
                                {
                                    //this.AggregateFunctionResult = avg;
                                    this.Add(avg, i, column);
                                }
                                else
                                {
                                    //this.AggregateFunctionResult = null;
                                    this.Add(null, i, column);
                                }
                                break;
                            }
                        }
                        recordMatch = true;
                        break;
                    }
                }

                if (recordMatch == true)
                {
                    continue;
                }
                this.AddRow();
                //Append data to current record set
                for (int j = 0; j < this.ColumnCount; j++)
                {
                    this.Add(recordSet.GetObject(i, j), _rowCount - 1, j);
                }
            }
        }
Example #11
0
        public void Compile(QueryResultSet resultSet)
        {
            if (!this._isInitialized)
            {
                Initialize(resultSet);
                return;
            }

            switch (this.Type)
            {
            case QueryType.AggregateFunction:

                switch ((AggregateFunctionType)this.AggregateFunctionResult.Key)
                {
                case AggregateFunctionType.SUM:
                    decimal a;
                    decimal b;

                    object thisVal  = this.AggregateFunctionResult.Value;
                    object otherVal = resultSet.AggregateFunctionResult.Value;

                    Nullable <decimal> sum = null;

                    if (thisVal == null && otherVal != null)
                    {
                        sum = (decimal)otherVal;
                    }
                    else if (thisVal != null && otherVal == null)
                    {
                        sum = (decimal)thisVal;
                    }
                    else if (thisVal != null && otherVal != null)
                    {
                        a   = (decimal)thisVal;
                        b   = (decimal)otherVal;
                        sum = a + b;
                    }

                    if (sum != null)
                    {
                        this.AggregateFunctionResult = new DictionaryEntry(AggregateFunctionType.SUM, sum);
                    }
                    else
                    {
                        this.AggregateFunctionResult = new DictionaryEntry(AggregateFunctionType.SUM, null);
                    }
                    break;

                case AggregateFunctionType.COUNT:
                    a = (decimal)this.AggregateFunctionResult.Value;
                    b = (decimal)resultSet.AggregateFunctionResult.Value;
                    decimal count = a + b;

                    this.AggregateFunctionResult = new DictionaryEntry(AggregateFunctionType.COUNT, count);
                    break;

                case AggregateFunctionType.MIN:
                    IComparable thisValue  = (IComparable)this.AggregateFunctionResult.Value;
                    IComparable otherValue = (IComparable)resultSet.AggregateFunctionResult.Value;
                    IComparable min        = thisValue;

                    if (thisValue == null && otherValue != null)
                    {
                        min = otherValue;
                    }
                    else if (thisValue != null && otherValue == null)
                    {
                        min = thisValue;
                    }
                    else if (thisValue == null && otherValue == null)
                    {
                        min = null;
                    }
                    else if (otherValue.CompareTo(thisValue) < 0)
                    {
                        min = otherValue;
                    }

                    this.AggregateFunctionResult = new DictionaryEntry(AggregateFunctionType.MIN, min);
                    break;

                case AggregateFunctionType.MAX:
                    thisValue  = (IComparable)this.AggregateFunctionResult.Value;
                    otherValue = (IComparable)resultSet.AggregateFunctionResult.Value;
                    IComparable max = thisValue;

                    if (thisValue == null && otherValue != null)
                    {
                        max = otherValue;
                    }
                    else if (thisValue != null && otherValue == null)
                    {
                        max = thisValue;
                    }
                    else if (thisValue == null && otherValue == null)
                    {
                        max = null;
                    }
                    else if (otherValue.CompareTo(thisValue) > 0)
                    {
                        max = otherValue;
                    }

                    this.AggregateFunctionResult = new DictionaryEntry(AggregateFunctionType.MAX, max);
                    break;

                case AggregateFunctionType.AVG:
                    thisVal  = this.AggregateFunctionResult.Value;
                    otherVal = resultSet.AggregateFunctionResult.Value;

                    AverageResult avg = null;
                    if (thisVal == null && otherVal != null)
                    {
                        avg = (AverageResult)otherVal;
                    }
                    else if (thisVal != null && otherVal == null)
                    {
                        avg = (AverageResult)thisVal;
                    }
                    else if (thisVal != null && otherVal != null)
                    {
                        AverageResult thisResult  = (AverageResult)thisVal;
                        AverageResult otherResult = (AverageResult)otherVal;

                        avg       = new AverageResult();
                        avg.Sum   = thisResult.Sum + otherResult.Sum;
                        avg.Count = thisResult.Count + otherResult.Count;
                    }

                    if (avg != null)
                    {
                        this.AggregateFunctionResult = new DictionaryEntry(AggregateFunctionType.AVG, avg);
                    }
                    else
                    {
                        this.AggregateFunctionResult = new DictionaryEntry(AggregateFunctionType.AVG, null);
                    }
                    break;
                }

                break;

            case QueryType.SearchKeys:
                if (this.SearchKeysResult == null)
                {
                    this.SearchKeysResult = resultSet.SearchKeysResult;
                }
                else
                if (resultSet.SearchKeysResult != null)
                {
                    this.SearchKeysResult.AddRange(resultSet.SearchKeysResult);
                }

                break;

            case QueryType.SearchEntries:
                if (this.SearchEntriesResult == null)
                {
                    this.SearchEntriesResult = resultSet.SearchEntriesResult;
                }
                else
                {
                    IDictionaryEnumerator ide = resultSet.SearchEntriesResult.GetEnumerator();
                    while (ide.MoveNext())
                    {
                        this.SearchEntriesResult[ide.Key] = ide.Value;
                    }
                }

                break;
            }
        }