Esempio n. 1
0
 public void Initialize(QueryResultSet resultSet)
 {
     if (!_isInitialized)
     {
         this.Type = resultSet.Type;
         this.AggregateFunctionType   = resultSet.AggregateFunctionType;
         this.AggregateFunctionResult = resultSet.AggregateFunctionResult;
         this.SearchKeysResult        = resultSet.SearchKeysResult;
         this.SearchEntriesResult     = resultSet.SearchEntriesResult;
         this._isInitialized          = true;
     }
 }
Esempio n. 2
0
 public void Initialize(QueryResultSet resultSet)
 {
     if (!_isInitialized)
     {
         this.Type = resultSet.Type;
         this.AggregateFunctionType = resultSet.AggregateFunctionType;
         this.AggregateFunctionResult = resultSet.AggregateFunctionResult;
         this.SearchKeysResult = resultSet.SearchKeysResult;
         this.SearchEntriesResult = resultSet.SearchEntriesResult;
         this._isInitialized = true;
     }
 }
Esempio n. 3
0
        /// <summary>
        /// Retrieve the list of keys and values from the cache based on the specified query.
        /// </summary>
        protected QueryResultSet Clustered_SearchEntries(ArrayList dests, string queryText, IDictionary values, OperationContext operationContext)
        {
            QueryResultSet resultSet = new QueryResultSet();

            try
            {
                Function func = new Function((int)OpCodes.SearchEntries, new object[] { queryText, values, operationContext }, false);
                RspList results = Cluster.Multicast(dests, func, GroupRequest.GET_ALL, false, Cluster.Timeout * 10);

                if (results == null)
                    return null;
                ClusterHelper.ValidateResponses(results, typeof(QueryResultSet), Name);
                ArrayList rspList = ClusterHelper.GetAllNonNullRsp(results, typeof(QueryResultSet));
                if (rspList.Count <= 0)
                {
                    return null;
                }
                else
                {
                    IEnumerator im = rspList.GetEnumerator();
                    while (im.MoveNext())
                    {
                        Rsp rsp = (Rsp)im.Current;
                        QueryResultSet cResultSet = (QueryResultSet)rsp.Value;
                        resultSet.Compile(cResultSet);
                    }
                }

                return resultSet;
            }
            catch (CacheException e)
            {
                throw;
            }
            catch (Exception e)
            {
                throw new GeneralFailureException(e.Message, e);
            }
        }
Esempio n. 4
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;
            }
        }
        public static IList<byte[]> BuildResponse(QueryResultSet resultSet, int commandVersion, string RequestId, IList<byte[]> _serializedResponse)
        {
            long requestId = Convert.ToInt64(RequestId);
            try
            {
                switch (commandVersion)
                {
                    case 0: //Version from NCache 3.8 to NCache 3.8 SP3
                        {
                            Alachisoft.NCache.Common.Protobuf.Response response = new Alachisoft.NCache.Common.Protobuf.Response();
                            Alachisoft.NCache.Common.Protobuf.SearchEntriesResponse searchEntriesResponse = new Alachisoft.NCache.Common.Protobuf.SearchEntriesResponse();
                            response.requestId = requestId;
                            searchEntriesResponse.keyValuePackage = Alachisoft.NCache.SocketServer.Util.KeyPackageBuilder.PackageKeysValues(resultSet.SearchEntriesResult, searchEntriesResponse.keyValuePackage);
                            response.responseType = Alachisoft.NCache.Common.Protobuf.Response.Type.SEARCH_ENTRIES;
                            response.searchEntries = searchEntriesResponse;
                            _serializedResponse.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeResponse(response));
                        }
                        break;
                    case 1: //From Version 3.8 SP4 onwards //Offically announcing support in 4.1// So not supporting 3.8 SP4 clients in case of aggregate functions with 4.1 Cache Server Decision taken by Kashif Butt
                    case 2: //NCache 4.1 SP1
                        {
                            switch (resultSet.Type)
                            {
                                case QueryType.AggregateFunction:
                                {
                                        Alachisoft.NCache.Common.Protobuf.Response response = new Alachisoft.NCache.Common.Protobuf.Response();
                                        Alachisoft.NCache.Common.Protobuf.SearchEntriesResponse searchEntriesResponse = new Alachisoft.NCache.Common.Protobuf.SearchEntriesResponse();
                                        searchEntriesResponse.queryResultSet = new Alachisoft.NCache.Common.Protobuf.QueryResultSet();
                                        response.requestId = requestId;
                                        searchEntriesResponse.queryResultSet.queryType = Alachisoft.NCache.Common.Protobuf.QueryType.AGGREGATE_FUNCTIONS;
                                        searchEntriesResponse.queryResultSet.aggregateFunctionType = (Alachisoft.NCache.Common.Protobuf.AggregateFunctionType)(int)resultSet.AggregateFunctionType;
                                        searchEntriesResponse.queryResultSet.aggregateFunctionResult =  new Alachisoft.NCache.Common.Protobuf.DictionaryItem();
                                        searchEntriesResponse.queryResultSet.aggregateFunctionResult.key = resultSet.AggregateFunctionResult.Key.ToString();
                                        searchEntriesResponse.queryResultSet.aggregateFunctionResult.value = resultSet.AggregateFunctionResult.Value != null ? CompactBinaryFormatter.ToByteBuffer(resultSet.AggregateFunctionResult.Value, null) : null;
                                        response.responseType = Alachisoft.NCache.Common.Protobuf.Response.Type.SEARCH_ENTRIES;
                                        response.searchEntries = searchEntriesResponse;
                                        _serializedResponse.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeResponse(response));
                                }
                                break;

                                case QueryType.SearchEntries:
                                {
                                        int sequenceId = 1;
                                        List<Alachisoft.NCache.Common.Protobuf.KeyValuePackageResponse> keyValuesPackageChuncks = Alachisoft.NCache.SocketServer.Util.KeyPackageBuilder.PackageKeysValues(resultSet.SearchEntriesResult);
                                        Alachisoft.NCache.Common.Protobuf.Response response = new Alachisoft.NCache.Common.Protobuf.Response();
                                        Alachisoft.NCache.Common.Protobuf.SearchEntriesResponse searchEntriesResponse = new Alachisoft.NCache.Common.Protobuf.SearchEntriesResponse();
                                        searchEntriesResponse.queryResultSet = new Alachisoft.NCache.Common.Protobuf.QueryResultSet();
                                        response.requestId = requestId;
                                        searchEntriesResponse.queryResultSet.queryType = Alachisoft.NCache.Common.Protobuf.QueryType.SEARCH_ENTRIES;
                                        response.numberOfChuncks = keyValuesPackageChuncks.Count;
                                        response.responseType = Alachisoft.NCache.Common.Protobuf.Response.Type.SEARCH_ENTRIES;

                                        foreach (Alachisoft.NCache.Common.Protobuf.KeyValuePackageResponse package in keyValuesPackageChuncks)
                                        {
                                            response.sequenceId = sequenceId++;
                                            searchEntriesResponse.queryResultSet.searchKeyEnteriesResult = package;
                                            response.searchEntries = searchEntriesResponse;
                                            _serializedResponse.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeResponse(response));
                                        }
                                }
                                break;
                            }
                        }
                        break;
                    default:
                        {
                            throw new Exception("Unsupported Command Version");
                        }
                }
            }
            catch (Exception ex)
            {
                if (SocketServer.Logger.IsErrorLogsEnabled)
                {
                    SocketServer.Logger.NCacheLog.Error(ex.ToString());
                    if (resultSet == null)
                    {
                        SocketServer.Logger.NCacheLog.Error("QueryResultSet is null");
                    }
                    else if (resultSet.AggregateFunctionResult.Key == null)
                    {
                        SocketServer.Logger.NCacheLog.Error("QueryResultSet.AggregateFunctionResult.Key is null");
                    }
                    else if (resultSet.AggregateFunctionResult.Value == null)
                    {
                        SocketServer.Logger.NCacheLog.Error("QueryResultSet.AggregateFunctionResult.Value is null");
                    }
                }
            }

            return _serializedResponse;
        }
Esempio n. 6
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;
            }
        }
Esempio n. 7
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;
            }
        }
        public static Alachisoft.NCache.Common.Protobuf.SearchResponse BuildResponse(QueryResultSet resultSet, int commandVersion)
        {
            Alachisoft.NCache.Common.Protobuf.SearchResponse searchResponse = new Alachisoft.NCache.Common.Protobuf.SearchResponse();
            try
            {
                switch (commandVersion)
                {
                    case 0: //Version from NCache 3.8 to NCache 3.8 SP3
                        {
                            Alachisoft.NCache.SocketServer.Util.KeyPackageBuilder.PackageKeys(resultSet.SearchKeysResult.GetEnumerator(), searchResponse.keys);
                        }
                        break;
                    case 1: //From Version 3.8 SP4 onwards // offically announced support in 4.1
                    case 2: //NCache 4.1 SP1
                        {
                            searchResponse.queryResultSet = new Alachisoft.NCache.Common.Protobuf.QueryResultSet();

                            switch (resultSet.Type)
                            {
                                case QueryType.AggregateFunction:
                                    searchResponse.queryResultSet.queryType = Alachisoft.NCache.Common.Protobuf.QueryType.AGGREGATE_FUNCTIONS;
                                    searchResponse.queryResultSet.aggregateFunctionType = (Alachisoft.NCache.Common.Protobuf.AggregateFunctionType)(int)resultSet.AggregateFunctionType;

                                    searchResponse.queryResultSet.aggregateFunctionResult = new Alachisoft.NCache.Common.Protobuf.DictionaryItem();
                                    searchResponse.queryResultSet.aggregateFunctionResult.key = resultSet.AggregateFunctionResult.Key.ToString();
                                    searchResponse.queryResultSet.aggregateFunctionResult.value = resultSet.AggregateFunctionResult.Value != null ? CompactBinaryFormatter.ToByteBuffer(resultSet.AggregateFunctionResult.Value, null) : null;
                                    break;

                                case QueryType.SearchKeys:
                                    searchResponse.queryResultSet.queryType = Alachisoft.NCache.Common.Protobuf.QueryType.SEARCH_KEYS;
                                    Alachisoft.NCache.SocketServer.Util.KeyPackageBuilder.PackageKeys(resultSet.SearchKeysResult.GetEnumerator(), searchResponse.queryResultSet.searchKeyResults);
                                    break;
                            }
                        }
                        break;
                    default:
                        {
                            throw new Exception("Unsupported Command Version");
                        }
                }
            }
            catch (Exception ex)
            {
                if (SocketServer.Logger.IsErrorLogsEnabled)
                {
                    SocketServer.Logger.NCacheLog.Error(ex.ToString());
                    if (resultSet == null)
                    {
                        SocketServer.Logger.NCacheLog.Error("QueryResultSet is null");
                    }
                    else if (resultSet.AggregateFunctionResult.Key == null)
                    {
                        SocketServer.Logger.NCacheLog.Error("QueryResultSet.AggregateFunctionResult.Key is null");
                    }
                    else if (resultSet.AggregateFunctionResult.Value == null)
                    {
                        SocketServer.Logger.NCacheLog.Error("QueryResultSet.AggregateFunctionResult.Value is null");
                    }
                }
            }

            return searchResponse;
        }