Evgenii Zhuravlev created IGNITE-11695:
------------------------------------------

             Summary: AverageGetTime metric doesn't work properly with 
ScanQuery predicate
                 Key: IGNITE-11695
                 URL: https://issues.apache.org/jira/browse/IGNITE-11695
             Project: Ignite
          Issue Type: Bug
            Reporter: Evgenii Zhuravlev


In *GridCacheQueryManager.advance* method *start* variable is set only once, at 
the start of executing the method, while metrics.onRead inside this method 
could be executed multiple times in case if Predicate returns false:

Reproducer:
{code:java}

public class ExampleNodeStartup {

    private static int FILTER_COUNT = 100000;
    /**
     * Start up an empty node with example compute configuration.
     *
     * @param args Command line arguments, none required.
     * @throws IgniteException If failed.
     */
    public static void main(String[] args) throws IgniteException {
        Ignite ignite = Ignition.start();

        IgniteCache cache = ignite.getOrCreateCache(new 
CacheConfiguration<>("test").setStatisticsEnabled(true));

        for (int i = 0; i < 100000; i++)
            cache.put(i, i);

        long start = System.currentTimeMillis();

        Iterator it = cache.query(new ScanQuery().setFilter(new 
IgniteBiPredicate() {
            @Override public boolean apply(Object o, Object o2) {
                if ((int)o2 % FILTER_COUNT == 0)
                    return true;

                return false;
            }
        })).iterator();

        while (it.hasNext())
            System.out.println("iterator value: " + it.next());

        System.out.println("Execution time: " + (System.currentTimeMillis() - 
start));

        System.out.println("GETS: " + cache.metrics().getCacheGets());

        System.out.println("GET times: " + cache.metrics().getAverageGetTime());
    }
}
{code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to