Exemplo n.º 1
0
        private ISet <KeyValuePair <TKey, TValue> > EntrySetWithPagingPredicate(IPredicate predicate)
        {
            var pagingPredicate = UnwrapPagingPredicate(predicate);

            pagingPredicate.IterationType = IterationType.Entry;
            var pagingPredicateHolder = PagingPredicateHolder.Of(predicate, Client.SerializationService);
            var request          = MapEntriesWithPagingPredicateCodec.EncodeRequest(Name, pagingPredicateHolder);
            var response         = InvokeWithPredicate(request, predicate);
            var resultParameters = MapEntriesWithPagingPredicateCodec.DecodeResponse(response);

            pagingPredicate.AnchorList = resultParameters.AnchorDataList.AsAnchorIterator(Client.SerializationService).ToList();
            return(new ReadOnlyLazyEntrySet <TKey, TValue, IData>(resultParameters.Response, Client.SerializationService));
        }
        public ISet <KeyValuePair <TKey, TValue> > EntrySetWithPagingPredicate(PagingPredicate <TKey, TValue> pagingPredicate)
        {
            pagingPredicate.SetIterationType(IterationType.ENTRY);

            var request = MapEntriesWithPagingPredicateCodec.EncodeRequest(GetName(), ToData(pagingPredicate));
            var entries = Invoke(request, m => MapEntriesWithPagingPredicateCodec.DecodeResponse(m).entrySet);
            ISet <KeyValuePair <TKey, TValue> > entrySet = new HashSet <KeyValuePair <TKey, TValue> >();

            foreach (var dataEntry in entries)
            {
                var key   = ToObject <TKey>(dataEntry.Key);
                var value = ToObject <TValue>(dataEntry.Value);
                entrySet.Add(new KeyValuePair <TKey, TValue>(key, value));
            }

            return(SortingUtil.GetSortedQueryResultSet(entrySet, pagingPredicate, IterationType.ENTRY));
        }
Exemplo n.º 3
0
        private ISet <KeyValuePair <TKey, TValue> > EntrySetWithPagingPredicate(PagingPredicate pagingPredicate)
        {
            pagingPredicate.IterationType = IterationType.Entry;

            var request          = MapEntriesWithPagingPredicateCodec.EncodeRequest(GetName(), ToData(pagingPredicate));
            var response         = Invoke(request);
            var resultParameters = MapEntriesWithPagingPredicateCodec.DecodeResponse(response);

            var entryList = new List <KeyValuePair <object, object> >();

            foreach (var dataEntry in resultParameters.response)
            {
                var key   = ToObject <TKey>(dataEntry.Key);
                var value = ToObject <TValue>(dataEntry.Value);
                entryList.Add(new KeyValuePair <object, object>(key, value));
            }
            var resultEnumerator =
                SortingUtil.GetSortedQueryResultSet <TKey, TValue>(entryList, pagingPredicate, IterationType.Entry);

            return(new HashSet <KeyValuePair <TKey, TValue> >(resultEnumerator.Cast <KeyValuePair <TKey, TValue> >()));
        }
Exemplo n.º 4
0
        private async Task <IReadOnlyDictionary <TKey, TValue> > GetAsync(IPredicate predicate, CancellationToken cancellationToken)
        {
            if (predicate == null)
            {
                throw new ArgumentNullException(nameof(predicate));
            }
            var pagingPredicate = UnwrapPagingPredicate(predicate);

            if (pagingPredicate != null)
            {
                pagingPredicate.IterationType = IterationType.Entry;

                var pagingPredicateHolder = PagingPredicateHolder.Of(predicate, SerializationService);
                var requestMessage        = MapEntriesWithPagingPredicateCodec.EncodeRequest(Name, pagingPredicateHolder);
                var responseMessage       = await Cluster.Messaging.SendAsync(requestMessage, cancellationToken).CAF();

                var response = MapEntriesWithPagingPredicateCodec.DecodeResponse(responseMessage);
                pagingPredicate.UpdateAnchors(response.AnchorDataList.AsAnchorIterator(SerializationService));
                return(new ReadOnlyLazyDictionary <TKey, TValue>(SerializationService)
                {
                    response.Response
                });
            }

            {
                var requestMessage  = MapEntriesWithPredicateCodec.EncodeRequest(Name, ToData(predicate));
                var responseMessage = await(predicate is PartitionPredicate pp
                    ? Cluster.Messaging.SendToKeyPartitionOwnerAsync(requestMessage, SerializationService.ToData(pp.PartitionKey), cancellationToken)
                    : Cluster.Messaging.SendAsync(requestMessage, cancellationToken))
                                      .CAF();
                var response = MapEntriesWithPredicateCodec.DecodeResponse(responseMessage).Response;
                return(new ReadOnlyLazyDictionary <TKey, TValue>(SerializationService)
                {
                    response
                });
            }
        }