Beispiel #1
0
        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));
            }
        }
Beispiel #2
0
        public ICollection <TValue> Values(IPredicate predicate)
        {
            if (predicate is PagingPredicate)
            {
                return(ValuesForPagingPredicate((PagingPredicate)predicate));
            }

            var request = MapValuesWithPredicateCodec.EncodeRequest(Name, ToData(predicate));
            var result  = Invoke(request, predicate, m => MapValuesWithPredicateCodec.DecodeResponse(m).Response);

            return(new ReadOnlyLazyList <TValue, IData>(result, Client.SerializationService));
        }
        public ICollection <TValue> Values(IPredicate predicate)
        {
            if (predicate is PagingPredicate)
            {
                return(ValuesForPagingPredicate((PagingPredicate)predicate));
            }

            var request = MapValuesWithPredicateCodec.EncodeRequest(GetName(), ToData(predicate));
            var result  = Invoke(request, predicate, m => MapValuesWithPredicateCodec.DecodeResponse(m).response);

            return(new ReadOnlyLazyList <TValue>(result, GetContext().GetSerializationService()));
        }
        public ICollection <V> Values(IPredicate <K, V> predicate)
        {
            var       request = MapValuesWithPredicateCodec.EncodeRequest(GetName(), ToData(predicate));
            var       result  = Invoke(request, m => MapValuesWithPredicateCodec.DecodeResponse(m).list);
            IList <V> values  = new List <V>(result.Count);

            foreach (var data in result)
            {
                var value = ToObject <V>(data);
                values.Add(value);
            }
            return(values);
        }
        public ICollection <TValue> Values(IPredicate predicate)
        {
            if (predicate is PagingPredicate)
            {
                return(ValuesForPagingPredicate((PagingPredicate)predicate));
            }

            var            request = MapValuesWithPredicateCodec.EncodeRequest(GetName(), ToData(predicate));
            var            result  = Invoke(request, predicate, m => MapValuesWithPredicateCodec.DecodeResponse(m).response);
            IList <TValue> values  = new List <TValue>(result.Count);

            foreach (var data in result)
            {
                var value = ToObject <TValue>(data);
                values.Add(value);
            }
            return(values);
        }