You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ignite.apache.org by "Vladimir Ozerov (JIRA)" <ji...@apache.org> on 2017/04/10 10:56:41 UTC
[jira] [Updated] (IGNITE-3458) poor performance on the function “primaryEntrySet()”
[ https://issues.apache.org/jira/browse/IGNITE-3458?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Vladimir Ozerov updated IGNITE-3458:
------------------------------------
Fix Version/s: (was: 2.0)
2.1
> poor performance on the function “primaryEntrySet()”
> ----------------------------------------------------
>
> Key: IGNITE-3458
> URL: https://issues.apache.org/jira/browse/IGNITE-3458
> Project: Ignite
> Issue Type: Improvement
> Components: cache
> Affects Versions: 1.6
> Reporter: bluehu
> Priority: Minor
> Labels: primaryEntrySet
> Fix For: 2.1
>
> Original Estimate: 8h
> Remaining Estimate: 8h
>
> the implement of primaryEntrySet() in ignite 1.6 is this:
> {code:title=GridCacheAdapter.java|borderStyle=solid}
> /**
> * @return Primary entry set.
> */
> public Set<Cache.Entry<K, V>> primaryEntrySet() {
> return new EntrySet(map.entrySet(CU.cachePrimary(ctx.grid().affinity(ctx.name()), ctx.localNode())));
> }
> {code}
> this function may scan all the partitions including backup partitions on local node, then filter each entry with this CacheEntryPredicate:
> {code:title=GridCacheUtils.java|borderStyle=solid}
> /**
> * @param aff Affinity.
> * @param n Node.
> * @return Predicate that evaluates to {@code true} if entry is primary for node.
> */
> public static CacheEntryPredicate cachePrimary(
> final Affinity aff,
> final ClusterNode n
> ) {
> return new CacheEntryPredicateAdapter() {
> @Override public boolean apply(GridCacheEntryEx e) {
> return aff.isPrimary(n, e.key());
> }
> };
> }
> {code}
> I think it has poor performance.
> Since we can get the primary partitions id of localnode from GridAffinityAssignment:
> {code:title=GridAffinityAssignment.java|borderStyle=solid}
> /**
> * Get primary partitions for specified node ID.
> *
> * @param nodeId Node ID to get primary partitions for.
> * @return Primary partitions for specified node ID.
> */
> public Set<Integer> primaryPartitions(UUID nodeId) {
> Set<Integer> set = primary.get(nodeId);
> return set == null ? Collections.<Integer>emptySet() : set;
> }
> {code}
> why not get primary partitions directly(not including backup partitions) and then return all the entry of primary partitions(no need use CacheEntryPredicate to judge each entry)?
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)