public ISet <KeyValuePair <K, V> > EntrySet(IPredicate <K, V> predicate) { var request = MapEntriesWithPredicateCodec.EncodeRequest(GetName(), ToData(predicate)); var entries = Invoke(request, m => MapEntriesWithPredicateCodec.DecodeResponse(m).entrySet); ISet <KeyValuePair <K, V> > entrySet = new HashSet <KeyValuePair <K, V> >(); foreach (var dataEntry in entries) { var key = ToObject <K>(dataEntry.Key); var value = ToObject <V>(dataEntry.Value); entrySet.Add(new KeyValuePair <K, V>(key, value)); } return(entrySet); }
public ISet <KeyValuePair <TKey, TValue> > EntrySet(IPredicate predicate) { if (predicate is PagingPredicate) { return(EntrySetWithPagingPredicate((PagingPredicate)predicate)); } var request = MapEntriesWithPredicateCodec.EncodeRequest(GetName(), ToData(predicate)); var entries = Invoke(request, predicate, (response) => { var resultQueue = new ConcurrentQueue <KeyValuePair <IData, object> >(); MapEntriesWithPredicateCodec.DecodeResponse(response, resultQueue); return(resultQueue); }); return(new ReadOnlyLazyEntrySet <TKey, TValue>(entries, GetContext().GetSerializationService())); }
public ISet <KeyValuePair <TKey, TValue> > EntrySet(IPredicate predicate) { if (ContainsPagingPredicate(predicate)) { return(EntrySetWithPagingPredicate(predicate)); } var request = MapEntriesWithPredicateCodec.EncodeRequest(Name, ToData(predicate)); var entries = Invoke(request, predicate, (response) => { var resultQueue = new List <KeyValuePair <IData, object> >(); foreach (var kvp in MapEntriesWithPredicateCodec.DecodeResponse(response).Response) { resultQueue.Add(new KeyValuePair <IData, object>(kvp.Key, kvp.Value)); } return(resultQueue); }); return(new ReadOnlyLazyEntrySet <TKey, TValue, object>(entries, Client.SerializationService)); }
public ISet <KeyValuePair <TKey, TValue> > EntrySet(IPredicate predicate) { if (predicate is PagingPredicate) { return(EntrySetWithPagingPredicate((PagingPredicate)predicate)); } var request = MapEntriesWithPredicateCodec.EncodeRequest(GetName(), ToData(predicate)); var entries = Invoke(request, predicate, m => MapEntriesWithPredicateCodec.DecodeResponse(m).response); 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(entrySet); }
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 }); } }