ignite-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dmitriy Setrakyan <dsetrak...@apache.org>
Subject Re: GridCacheAdapter#size() has O(n) complexity
Date Fri, 23 Jun 2017 21:44:41 GMT
Hm... why not just return the key count? Can we really have nulls in the
near cache?

On Fri, Jun 23, 2017 at 8:25 PM, Mikhail Cherkasov <mcherkasov@gridgain.com>
wrote:

> Hi all,
>
> GridCacheAdapter#size() has O(n) complexity and this can lead for delays
> during metric collection( https://issues.apache.org/
> jira/browse/IGNITE-5521
> ).
> It validates all elements in near cache while count them, so it takes O(n),
> but java doc requires:
>
> "Gets the number of all entries cached on this node. This method will
> return the count of all cache entries and has O(1) complexity on base
> IgniteInternalCache. It is essentially the size of cache key set and is
> semantically identical to {Cache.keySet().size().
> NOTE: this operation is not distributed and returns only the number of
> entries cached on this node."
>
>
> I see two solutions for this:
>
> 1. add special method for metrics that will have relaxed accuracy, but with
> O(1) complexity
> I implemented this solution there:
> https://github.com/gridgain/apache-ignite/commit/
> a68dd81090884d07bd737cbbf48e5f64e9cd27ec
>
> 2. or completely remove entries validation for size method.
>
> What is better solution? Thoughts?
>
> --
> Thanks,
> Mikhail.
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message