Merge branch 'ignite-543' of https://git-wip-us.apache.org/repos/asf/incubator-ignite into ignite-45
Conflicts: examples/src/main/java/org/apache/ignite/examples/datagrid/CachePopularNumbersExample.java examples/src/main/java/org/apache/ignite/examples/datagrid/CacheQueryExample.java modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/728528fb Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/728528fb Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/728528fb Branch: refs/heads/ignite-45 Commit: 728528fb9641891fd98f9d127d85717ac58b4935 Parents: 95d690b 0eec3ba Author: Valentin Kulichenko <vkuliche...@gridgain.com> Authored: Fri Mar 20 20:14:27 2015 -0700 Committer: Valentin Kulichenko <vkuliche...@gridgain.com> Committed: Fri Mar 20 20:14:27 2015 -0700 ---------------------------------------------------------------------- .../datagrid/CachePopularNumbersExample.java | 2 +- .../examples/datagrid/CacheQueryExample.java | 31 +++-- .../java/org/apache/ignite/IgniteCache.java | 30 +---- .../ignite/cache/query/ContinuousQuery.java | 68 ++++------ .../org/apache/ignite/cache/query/Query.java | 39 ++++-- .../apache/ignite/cache/query/ScanQuery.java | 28 +++-- .../org/apache/ignite/cache/query/SpiQuery.java | 17 ++- .../ignite/cache/query/SqlFieldsQuery.java | 17 ++- .../org/apache/ignite/cache/query/SqlQuery.java | 21 +++- .../apache/ignite/cache/query/TextQuery.java | 21 +++- .../processors/cache/IgniteCacheProxy.java | 125 +++---------------- .../continuous/CacheContinuousQueryManager.java | 4 +- .../query/jdbc/GridCacheQueryJdbcTask.java | 2 +- ...ridCacheContinuousQueryAbstractSelfTest.java | 10 +- .../GridContinuousOperationsLoadTest.java | 2 +- .../cache/GridCacheCrossCacheQuerySelfTest.java | 6 +- .../GridCacheQueryIndexDisabledSelfTest.java | 16 +-- .../cache/GridCacheQuerySimpleBenchmark.java | 2 +- .../IgniteCacheAbstractFieldsQuerySelfTest.java | 36 +++--- .../cache/IgniteCacheAbstractQuerySelfTest.java | 87 ++++++------- ...gniteCacheSqlQueryMultiThreadedSelfTest.java | 4 +- .../IgniteCacheAtomicFieldsQuerySelfTest.java | 2 +- .../IgniteCachePartitionedQuerySelfTest.java | 8 +- ...gniteCacheReplicatedFieldsQuerySelfTest.java | 2 +- .../IgniteCacheReplicatedQuerySelfTest.java | 16 +-- .../local/IgniteCacheLocalQuerySelfTest.java | 7 +- .../ignite/scalar/pimps/ScalarCachePimp.scala | 4 +- .../cache/IgniteSqlQueryJoinBenchmark.java | 2 +- 28 files changed, 280 insertions(+), 329 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/728528fb/examples/src/main/java/org/apache/ignite/examples/datagrid/CachePopularNumbersExample.java ---------------------------------------------------------------------- diff --cc examples/src/main/java/org/apache/ignite/examples/datagrid/CachePopularNumbersExample.java index 0150fc7,f2cd74b..b1cc6d8 --- a/examples/src/main/java/org/apache/ignite/examples/datagrid/CachePopularNumbersExample.java +++ b/examples/src/main/java/org/apache/ignite/examples/datagrid/CachePopularNumbersExample.java @@@ -128,9 -117,9 +128,9 @@@ public class CachePopularNumbersExampl IgniteCache<Integer, Long> cache = ignite.jcache(CACHE_NAME); try { - List<List<?>> results = cache.queryFields( - List<List<?>> results = new ArrayList<>(cache.query( ++ List<List<?>> results = cache.query( new SqlFieldsQuery("select _key, _val from Long order by _val desc, _key limit ?").setArgs(cnt)) - .getAll()); + .getAll(); for (List<?> res : results) System.out.println(res.get(0) + "=" + res.get(1)); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/728528fb/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheQueryExample.java ---------------------------------------------------------------------- diff --cc examples/src/main/java/org/apache/ignite/examples/datagrid/CacheQueryExample.java index 982c8a6,2a7ad19..ca3e91c --- a/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheQueryExample.java +++ b/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheQueryExample.java @@@ -82,42 -79,30 +82,42 @@@ public class CacheQueryExample System.out.println(); System.out.println(">>> Cache query example started."); - // Clean up caches on all nodes before run. - ignite.jcache(CACHE_NAME).removeAll(); + CacheConfiguration<?, ?> cfg = new CacheConfiguration<>(); - // Populate cache. - initialize(); + cfg.setCacheMode(CacheMode.PARTITIONED); + cfg.setName(CACHE_NAME); + cfg.setIndexedTypes( + UUID.class, Organization.class, + CacheAffinityKey.class, Person.class + ); - // Example for SQL-based querying employees based on salary ranges. - sqlQuery(); + try (IgniteCache<?, ?> cache = ignite.createCache(cfg)) { + // Populate cache. + initialize(); - // Example for SQL-based querying employees for a given organization (includes SQL join). - sqlQueryWithJoin(); + // Example for SQL-based querying employees based on salary ranges. + sqlQuery(); - // Example for TEXT-based querying for a given string in peoples resumes. - textQuery(); + // Example for SQL-based querying employees for a given organization (includes SQL join). + sqlQueryWithJoin(); - // Example for SQL-based querying to calculate average salary among all employees within a company. - sqlQueryWithAggregation(); + // Example for TEXT-based querying for a given string in peoples resumes. + textQuery(); - + - // Example for SQL-based fields queries that return only required - // fields instead of whole key-value pairs. - sqlFieldsQuery(); + // Example for SQL-based querying to calculate average salary among all employees within a company. + sqlQueryWithAggregation(); - + - // Example for SQL-based fields queries that uses joins. - sqlFieldsQueryWithJoin(); + // Example for SQL-based fields queries that return only required + // fields instead of whole key-value pairs. + sqlFieldsQuery(); + + // Example for SQL-based fields queries that return only required + // fields instead of whole key-value pairs. + sqlFieldsQuery(); + + // Example for SQL-based fields queries that uses joins. + sqlFieldsQueryWithJoin(); + } print("Cache query example finished."); } @@@ -235,9 -237,12 +240,9 @@@ /** * Populate cache with test data. - * - * @throws IgniteCheckedException In case of error. - * @throws InterruptedException In case of error. */ - private static void initialize() throws IgniteCheckedException, InterruptedException { - IgniteCache<Object, Object> cache = Ignition.ignite().jcache(CACHE_NAME); + private static void initialize() { - IgniteCache cache = Ignition.ignite().jcache(CACHE_NAME); ++ IgniteCache cache<Object, Object> = Ignition.ignite().jcache(CACHE_NAME); // Organizations. Organization org1 = new Organization("GridGain"); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/728528fb/modules/core/src/main/java/org/apache/ignite/cache/query/ContinuousQuery.java ---------------------------------------------------------------------- diff --cc modules/core/src/main/java/org/apache/ignite/cache/query/ContinuousQuery.java index aebe5a4,0adc346..b920b54 --- a/modules/core/src/main/java/org/apache/ignite/cache/query/ContinuousQuery.java +++ b/modules/core/src/main/java/org/apache/ignite/cache/query/ContinuousQuery.java @@@ -18,8 -18,8 +18,9 @@@ package org.apache.ignite.cache.query; import org.apache.ignite.*; +import org.apache.ignite.cache.*; + import javax.cache.*; import javax.cache.event.*; /** @@@ -130,11 -130,8 +131,8 @@@ public final class ContinuousQuery<K, V private CacheEntryUpdatedListener<K, V> locLsnr; /** Remote filter. */ - private CacheEntryEventFilter<K, V> rmtFilter; + private IgniteCacheEntryEventFilter<K, V> rmtFilter; - /** Buffer size. */ - private int bufSize = DFLT_BUF_SIZE; - /** Time interval. */ private long timeInterval = DFLT_TIME_INTERVAL; http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/728528fb/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java ---------------------------------------------------------------------- diff --cc modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java index 766e9b8,22bb330..8deb256 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java @@@ -462,50 -450,11 +467,9 @@@ public class IgniteCacheProxy<K, V> ext if (!ctx.isReplicated()) return false; - ClusterGroup grp = ctx.kernalContext().grid().cluster().forDataNodes(ctx.name()); - - return grp.node(ctx.localNodeId()) != null; + return ctx.affinityNode(); } - /** {@inheritDoc} */ - @Override public QueryCursor<List<?>> queryFields(SqlFieldsQuery qry) { - A.notNull(qry, "qry"); - - GridCacheProjectionImpl<K, V> prev = gate.enter(prj); - - try { - validate(qry); - - if (isReplicatedDataNode() || ctx.isLocal()) - return doLocalFieldsQuery(qry); - - return ctx.kernalContext().query().queryTwoStep(ctx, qry); - } - catch (Exception e) { - if (e instanceof CacheException) - throw e; - - throw new CacheException(e); - } - finally { - gate.leave(prev); - } - } - - /** - * @param p Query. - * @return Cursor. - */ - private QueryCursor<Entry<K,V>> doLocalQuery(SqlQuery p) { - return new QueryCursorImpl<>(ctx.kernalContext().query().<K,V>queryLocal(ctx, p)); - } - - /** - * @param q Query. - * @return Cursor. - */ - private QueryCursor<List<?>> doLocalFieldsQuery(SqlFieldsQuery q) { - return ctx.kernalContext().query().queryLocalFields(ctx, q); - } - /** * Checks query. * http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/728528fb/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryManager.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/728528fb/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/jdbc/GridCacheQueryJdbcTask.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/728528fb/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryAbstractSelfTest.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/728528fb/modules/core/src/test/java/org/apache/ignite/loadtests/continuous/GridContinuousOperationsLoadTest.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/728528fb/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheCrossCacheQuerySelfTest.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/728528fb/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheQuerySimpleBenchmark.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/728528fb/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractQuerySelfTest.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/728528fb/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheSqlQueryMultiThreadedSelfTest.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/728528fb/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheAtomicFieldsQuerySelfTest.java ----------------------------------------------------------------------