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