Ejemplo n.º 1
0
        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));
            }
        }
Ejemplo n.º 2
0
        public ISet <TKey> KeySet(IPredicate predicate)
        {
            if (predicate is PagingPredicate)
            {
                return(KeySetWithPagingPredicate(predicate));
            }
            var request = MapKeySetWithPredicateCodec.EncodeRequest(Name, ToData(predicate));
            var keys    = Invoke(request, predicate, m => MapKeySetWithPredicateCodec.DecodeResponse(m).Response);

            return(new ReadOnlyLazySet <TKey>(keys, Client.SerializationService));
        }
Ejemplo n.º 3
0
        public ISet <TKey> KeySet(IPredicate predicate)
        {
            if (predicate is PagingPredicate)
            {
                return(KeySetWithPagingPredicate((PagingPredicate)predicate));
            }
            var request = MapKeySetWithPredicateCodec.EncodeRequest(GetName(), ToData(predicate));
            var keys    = Invoke(request, predicate, m => MapKeySetWithPredicateCodec.DecodeResponse(m).response);

            return(new ReadOnlyLazySet <TKey>(keys, GetContext().GetSerializationService()));
        }
        public ISet <TKey> KeySet(IPredicate predicate)
        {
            if (predicate is PagingPredicate)
            {
                return(KeySetWithPagingPredicate((PagingPredicate)predicate));
            }
            var request = MapKeySetWithPredicateCodec.EncodeRequest(GetName(), ToData(predicate));
            var keys    = Invoke(request, predicate, m => MapKeySetWithPredicateCodec.DecodeResponse(m).response);

            return(ToSet <TKey>(keys));
        }
        public ISet <K> KeySet(IPredicate <K, V> predicate)
        {
            //TODO not supported yet
            //if (predicate is PagingPredicate)
            //{
            //    return KeySetWithPagingPredicate((PagingPredicate)predicate);
            //}
            var request = MapKeySetWithPredicateCodec.EncodeRequest(GetName(), ToData(predicate));
            var keys    = Invoke(request, m => MapKeySetWithPredicateCodec.DecodeResponse(m).list);

            return(ToSet <K>(keys));
        }