ignite-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "bluehu (JIRA)" <j...@apache.org>
Subject [jira] [Created] (IGNITE-3458) poor performance on the function “primaryEntrySet()”
Date Sun, 10 Jul 2016 03:13:11 GMT
bluehu created IGNITE-3458:

             Summary: 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
             Fix For: 1.6

the implement of primaryEntrySet() in ignite 1.6 is this:

     * @return Primary entry set.
    public Set<Cache.Entry<K, V>> primaryEntrySet() {
        return new EntrySet(map.entrySet(CU.cachePrimary(ctx.grid().affinity(ctx.name()),

this function may scan all the partitions including backup partitions on local node, then
filter each entry with this CacheEntryPredicate:

     * @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());

I think it has poor performance. 

Since we can get the primary partitions id of localnode from GridAffinityAssignment:

     * 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;

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

View raw message