private async Task <IReadOnlyList <TValue> > GetValuesAsync(IPredicate predicate, CancellationToken cancellationToken) { if (predicate == null) { throw new ArgumentNullException(nameof(predicate)); } var pagingPredicate = UnwrapPagingPredicate(predicate); if (pagingPredicate != null) { pagingPredicate.IterationType = IterationType.Value; var pagingPredicateHolder = PagingPredicateHolder.Of(predicate, SerializationService); var requestMessage = MapValuesWithPagingPredicateCodec.EncodeRequest(Name, pagingPredicateHolder); var responseMessage = await Cluster.Messaging.SendAsync(requestMessage, cancellationToken).CAF(); var response = MapValuesWithPagingPredicateCodec.DecodeResponse(responseMessage); pagingPredicate.UpdateAnchors(response.AnchorDataList.AsAnchorIterator(SerializationService)); return(new ReadOnlyLazyList <TValue>(response.Response, SerializationService)); } { var requestMessage = MapValuesWithPredicateCodec.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 = MapValuesWithPredicateCodec.DecodeResponse(responseMessage).Response; return(new ReadOnlyLazyList <TValue>(response, SerializationService)); } }
private ICollection <TValue> ValuesForPagingPredicate(IPredicate predicate) { var pagingPredicate = UnwrapPagingPredicate(predicate); pagingPredicate.IterationType = IterationType.Value; var pagingPredicateHolder = PagingPredicateHolder.Of(predicate, Client.SerializationService); var request = MapValuesWithPagingPredicateCodec.EncodeRequest(Name, pagingPredicateHolder); var response = InvokeWithPredicate(request, predicate); var resultParameters = MapValuesWithPagingPredicateCodec.DecodeResponse(response); pagingPredicate.AnchorList = resultParameters.AnchorDataList.AsAnchorIterator(Client.SerializationService).ToList(); return(new ReadOnlyLazySet <TValue>(resultParameters.Response, Client.SerializationService)); }
private ICollection <TValue> ValuesForPagingPredicate(PagingPredicate pagingPredicate) { pagingPredicate.IterationType = IterationType.Value; var request = MapValuesWithPagingPredicateCodec.EncodeRequest(GetName(), ToData(pagingPredicate)); var response = Invoke(request); var resultParameters = MapValuesWithPagingPredicateCodec.DecodeResponse(response); var resultList = new List <KeyValuePair <object, object> >(); foreach (var dataEntry in resultParameters.response) { var key = ToObject <TKey>(dataEntry.Key); var value = ToObject <TValue>(dataEntry.Value); resultList.Add(new KeyValuePair <object, object>(key, value)); } var resultEnumerator = SortingUtil.GetSortedQueryResultSet <TKey, TValue>(resultList, pagingPredicate, IterationType.Value); return(resultEnumerator.Cast <TValue>().ToList()); }