Skip to content

Commit

Permalink
ignite-sql-tests - fixes after
Browse files Browse the repository at this point in the history
Merge branch 'ignite-112' of https://git-wip-us.apache.org/repos/asf/incubator-ignite into ignite-sql-tests

Conflicts:
	modules/core/src/main/java/org/apache/ignite/IgniteCache.java
	modules/core/src/main/java/org/apache/ignite/cache/query/QueryCursor.java
	modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java
	modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFieldsQuerySelfTest.java
	modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridIndexingWithNoopSwapSelfTest.java
	modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedFieldsQuerySelfTest.java
	modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedQuerySelfTest.java
	modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridCacheReplicatedFieldsQuerySelfTest.java
	modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/IgniteCacheReplicatedQuerySelfTest.java
	modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/local/IgniteCacheLocalQuerySelfTest.java
  • Loading branch information
S.Vladykin committed Feb 5, 2015
1 parent 00ab785 commit a13dbad
Show file tree
Hide file tree
Showing 16 changed files with 162 additions and 160 deletions.
Expand Up @@ -24,25 +24,35 @@
*/ */
public final class QueryTextPredicate extends QueryPredicate { public final class QueryTextPredicate extends QueryPredicate {
/** */ /** */
private Class<?> type; private String type;


/** SQL clause. */ /** SQL clause. */
private String txt; private String txt;


/** /**
* @param type Type to query.
* @param txt Search string. * @param txt Search string.
*/ */
public QueryTextPredicate(Class<?> type, String txt) { public QueryTextPredicate(Class<?> type, String txt) {
this.type = type; setType(type);
this.txt = txt; setText(txt);
}

/**
* @param type Type to query.
* @param txt Search string.
*/
public QueryTextPredicate(String type, String txt) {
setType(type);
setText(txt);
} }


/** /**
* Gets type for query. * Gets type for query.
* *
* @return Type. * @return Type.
*/ */
public Class<?> getType() { public String getType() {
return type; return type;
} }


Expand All @@ -52,6 +62,15 @@ public Class<?> getType() {
* @param type Type. * @param type Type.
*/ */
public void setType(Class<?> type) { public void setType(Class<?> type) {
setType(type == null ? null : type.getName());
}

/**
* Sets type for query.
*
* @param type Type.
*/
public void setType(String type) {
this.type = type; this.type = type;
} }


Expand Down
Expand Up @@ -18,8 +18,8 @@
package org.apache.ignite.internal.processors.cache; package org.apache.ignite.internal.processors.cache;


import org.apache.ignite.cache.*; import org.apache.ignite.cache.*;
import org.apache.ignite.cache.query.*;
import org.apache.ignite.configuration.*; import org.apache.ignite.configuration.*;
import org.apache.ignite.internal.processors.cache.query.*;
import org.apache.ignite.spi.discovery.tcp.*; import org.apache.ignite.spi.discovery.tcp.*;
import org.apache.ignite.spi.discovery.tcp.ipfinder.*; import org.apache.ignite.spi.discovery.tcp.ipfinder.*;
import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*; import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*;
Expand Down Expand Up @@ -74,7 +74,7 @@ public class IgniteCacheFieldsQueryNoDataSelfTest extends GridCommonAbstractTest
*/ */
public void testQuery() throws Exception { public void testQuery() throws Exception {
Collection<Cache.Entry<Object, Object>> res = grid().jcache(null) Collection<Cache.Entry<Object, Object>> res = grid().jcache(null)
.query(new QuerySqlPredicate<>("select _VAL from Integer")).getAll(); .query(new QuerySqlPredicate("select _VAL from Integer")).getAll();


assert res != null; assert res != null;
assert res.isEmpty(); assert res.isEmpty();
Expand Down
Expand Up @@ -19,8 +19,8 @@


import org.apache.ignite.*; import org.apache.ignite.*;
import org.apache.ignite.cache.*; import org.apache.ignite.cache.*;
import org.apache.ignite.cache.query.*;
import org.apache.ignite.cache.query.annotations.*; import org.apache.ignite.cache.query.annotations.*;
import org.apache.ignite.internal.processors.cache.query.*;
import org.apache.ignite.internal.util.typedef.internal.*; import org.apache.ignite.internal.util.typedef.internal.*;


import javax.cache.*; import javax.cache.*;
Expand Down Expand Up @@ -98,7 +98,7 @@ private void checkCache(IgniteCache<Integer, CacheValue> cache) throws Exception
*/ */
private void checkQuery(IgniteCache<Integer, CacheValue> cache) throws Exception { private void checkQuery(IgniteCache<Integer, CacheValue> cache) throws Exception {
QueryCursor<Cache.Entry<Integer, CacheValue>> qry = QueryCursor<Cache.Entry<Integer, CacheValue>> qry =
cache.query(new QuerySqlPredicate<Integer, CacheValue>("val >= 5")); cache.query(new QuerySqlPredicate("val >= 5"));


Collection<Cache.Entry<Integer, CacheValue>> queried = qry.getAll(); Collection<Cache.Entry<Integer, CacheValue>> queried = qry.getAll();


Expand Down
Expand Up @@ -19,13 +19,10 @@


import org.apache.ignite.*; import org.apache.ignite.*;
import org.apache.ignite.cache.*; import org.apache.ignite.cache.*;
import org.apache.ignite.cache.query.*;
import org.apache.ignite.cache.query.annotations.*; import org.apache.ignite.cache.query.annotations.*;
import org.apache.ignite.configuration.*; import org.apache.ignite.configuration.*;
import org.apache.ignite.internal.*; import org.apache.ignite.internal.*;
import org.apache.ignite.internal.processors.cache.query.*;
import org.apache.ignite.spi.discovery.tcp.*;
import org.apache.ignite.spi.discovery.tcp.ipfinder.*;
import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*;
import org.apache.ignite.internal.util.tostring.*; import org.apache.ignite.internal.util.tostring.*;
import org.apache.ignite.internal.util.typedef.*; import org.apache.ignite.internal.util.typedef.*;
import org.apache.ignite.internal.util.typedef.internal.*; import org.apache.ignite.internal.util.typedef.internal.*;
Expand Down Expand Up @@ -153,7 +150,7 @@ public void testLuceneAndSqlMultithreaded() throws Exception {
@Override public void applyx() throws IgniteCheckedException { @Override public void applyx() throws IgniteCheckedException {
while (!done.get()) { while (!done.get()) {
QueryCursor<Cache.Entry<UUID, Person>> master = QueryCursor<Cache.Entry<UUID, Person>> master =
cache0.query(new QueryTextPredicate<UUID, Person>("Master")); cache0.query(new QueryTextPredicate(Person.class, "Master"));


Collection<Cache.Entry<UUID, Person>> entries = master.getAll(); Collection<Cache.Entry<UUID, Person>> entries = master.getAll();


Expand All @@ -174,7 +171,7 @@ public void testLuceneAndSqlMultithreaded() throws Exception {
@Override public void applyx() throws IgniteCheckedException { @Override public void applyx() throws IgniteCheckedException {
while (!done.get()) { while (!done.get()) {
QueryCursor<Cache.Entry<UUID, Person>> bachelors = QueryCursor<Cache.Entry<UUID, Person>> bachelors =
cache0.query(new QuerySqlPredicate<UUID, Person>("degree = 'Bachelor'")); cache0.query(new QuerySqlPredicate(Person.class, "degree = 'Bachelor'"));


Collection<Cache.Entry<UUID, Person>> entries = bachelors.getAll(); Collection<Cache.Entry<UUID, Person>> entries = bachelors.getAll();


Expand Down
Expand Up @@ -21,14 +21,12 @@
import org.apache.ignite.cache.*; import org.apache.ignite.cache.*;
import org.apache.ignite.cache.eviction.fifo.*; import org.apache.ignite.cache.eviction.fifo.*;
import org.apache.ignite.configuration.*; import org.apache.ignite.configuration.*;
import org.apache.ignite.internal.processors.cache.GridCacheAbstractQuerySelfTest.*; import org.apache.ignite.internal.processors.cache.IgniteCacheAbstractQuerySelfTest.*;
import org.apache.ignite.internal.processors.cache.query.*; import org.apache.ignite.internal.processors.cache.query.*;
import org.apache.ignite.internal.processors.cache.GridCacheAbstractQuerySelfTest.*;
import org.apache.ignite.spi.discovery.tcp.*; import org.apache.ignite.spi.discovery.tcp.*;
import org.apache.ignite.spi.discovery.tcp.ipfinder.*; import org.apache.ignite.spi.discovery.tcp.ipfinder.*;
import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*; import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*;
import org.apache.ignite.spi.swapspace.noop.*; import org.apache.ignite.spi.swapspace.noop.*;
import org.apache.ignite.internal.processors.cache.IgniteCacheAbstractQuerySelfTest.*;
import org.apache.ignite.testframework.junits.common.*; import org.apache.ignite.testframework.junits.common.*;


import java.util.*; import java.util.*;
Expand Down
Expand Up @@ -21,13 +21,14 @@
import org.apache.ignite.cache.*; import org.apache.ignite.cache.*;
import org.apache.ignite.cache.affinity.*; import org.apache.ignite.cache.affinity.*;
import org.apache.ignite.cache.query.*; import org.apache.ignite.cache.query.*;
import org.apache.ignite.cache.query.annotations.*;
import org.apache.ignite.configuration.*; import org.apache.ignite.configuration.*;
import org.apache.ignite.internal.util.typedef.*;
import org.apache.ignite.marshaller.optimized.*; import org.apache.ignite.marshaller.optimized.*;
import org.apache.ignite.spi.discovery.*; import org.apache.ignite.spi.discovery.*;
import org.apache.ignite.spi.discovery.tcp.*; import org.apache.ignite.spi.discovery.tcp.*;
import org.apache.ignite.spi.discovery.tcp.ipfinder.*; import org.apache.ignite.spi.discovery.tcp.ipfinder.*;
import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*; import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*;
import org.apache.ignite.internal.util.typedef.*;
import org.apache.ignite.testframework.junits.common.*; import org.apache.ignite.testframework.junits.common.*;
import org.jetbrains.annotations.*; import org.jetbrains.annotations.*;


Expand Down Expand Up @@ -176,7 +177,7 @@ protected CacheAtomicityMode atomicityMode() {
/** @throws Exception If failed. */ /** @throws Exception If failed. */
public void testExecute() throws Exception { public void testExecute() throws Exception {
QueryCursor<List<?>> qry = grid(0).jcache(null) QueryCursor<List<?>> qry = grid(0).jcache(null)
.queryFields(new QuerySqlPredicate<>("select _KEY, name, age from Person")); .queryFields(new QuerySqlPredicate("select _KEY, name, age from Person"));


List<List<?>> res = new ArrayList<>(qry.getAll()); List<List<?>> res = new ArrayList<>(qry.getAll());


Expand Down Expand Up @@ -222,7 +223,7 @@ else if (cnt == 1) {
/** @throws Exception If failed. */ /** @throws Exception If failed. */
public void testExecuteWithArguments() throws Exception { public void testExecuteWithArguments() throws Exception {
QueryCursor<List<?>> qry = grid(0).jcache(null) QueryCursor<List<?>> qry = grid(0).jcache(null)
.queryFields(new QuerySqlPredicate<>("select _KEY, name, age from Person where age > ?", 30)); .queryFields(new QuerySqlPredicate("select _KEY, name, age from Person where age > ?", 30));


List<List<?>> res = new ArrayList<>(qry.getAll()); List<List<?>> res = new ArrayList<>(qry.getAll());


Expand Down Expand Up @@ -263,7 +264,7 @@ else if (cnt == 1) {
/** @throws Exception If failed. */ /** @throws Exception If failed. */
public void testSelectAllJoined() throws Exception { public void testSelectAllJoined() throws Exception {
QueryCursor<List<?>> qry = grid(0).jcache(null) QueryCursor<List<?>> qry = grid(0).jcache(null)
.queryFields(new QuerySqlPredicate<>("select * from Person p, Organization o where p.orgId = o.id")); .queryFields(new QuerySqlPredicate("select * from Person p, Organization o where p.orgId = o.id"));


List<List<?>> res = new ArrayList<>(qry.getAll()); List<List<?>> res = new ArrayList<>(qry.getAll());


Expand Down Expand Up @@ -325,7 +326,7 @@ else if (cnt == 1) {
/** @throws Exception If failed. */ /** @throws Exception If failed. */
public void testEmptyResult() throws Exception { public void testEmptyResult() throws Exception {
QueryCursor<List<?>> qry = grid(0).jcache(null) QueryCursor<List<?>> qry = grid(0).jcache(null)
.queryFields(new QuerySqlPredicate<>("select name from Person where age = 0")); .queryFields(new QuerySqlPredicate("select name from Person where age = 0"));


Collection<List<?>> res = qry.getAll(); Collection<List<?>> res = qry.getAll();


Expand All @@ -335,7 +336,7 @@ public void testEmptyResult() throws Exception {


/** @throws Exception If failed. */ /** @throws Exception If failed. */
public void testQueryString() throws Exception { public void testQueryString() throws Exception {
QueryCursor<List<?>> qry = grid(0).jcache(null).queryFields(new QuerySqlPredicate<>("select * from String")); QueryCursor<List<?>> qry = grid(0).jcache(null).queryFields(new QuerySqlPredicate("select * from String"));


Collection<List<?>> res = qry.getAll(); Collection<List<?>> res = qry.getAll();


Expand All @@ -352,7 +353,7 @@ public void testQueryString() throws Exception {


/** @throws Exception If failed. */ /** @throws Exception If failed. */
public void testQueryIntegersWithJoin() throws Exception { public void testQueryIntegersWithJoin() throws Exception {
QueryCursor<List<?>> qry = grid(0).jcache(null).queryFields(new QuerySqlPredicate<>( QueryCursor<List<?>> qry = grid(0).jcache(null).queryFields(new QuerySqlPredicate(
"select i._KEY, i._VAL, j._KEY, j._VAL from Integer i join Integer j where i._VAL >= 100")); "select i._KEY, i._VAL, j._KEY, j._VAL from Integer i join Integer j where i._VAL >= 100"));


Collection<List<?>> res = qry.getAll(); Collection<List<?>> res = qry.getAll();
Expand All @@ -378,7 +379,7 @@ else if (cacheMode() == REPLICATED)
public void testPagination() throws Exception { public void testPagination() throws Exception {
// Query with page size 20. // Query with page size 20.
QueryCursor<List<?>> qry = grid(0).jcache(null) QueryCursor<List<?>> qry = grid(0).jcache(null)
.queryFields(new QuerySqlPredicate<>("select * from Integer", 20, new Object[0])); .queryFields(new QuerySqlPredicate("select * from Integer", 20, new Object[0]));


List<List<?>> res = new ArrayList<>(qry.getAll()); List<List<?>> res = new ArrayList<>(qry.getAll());


Expand All @@ -403,7 +404,7 @@ public void testNamedCache() throws Exception {
for (int i = 0; i < 200; i++) for (int i = 0; i < 200; i++)
cache.put(i, i); cache.put(i, i);


QueryCursor<List<?>> qry = cache.queryFields(new QuerySqlPredicate<Integer, Integer>("select * from Integer")); QueryCursor<List<?>> qry = cache.queryFields(new QuerySqlPredicate("select * from Integer"));


Collection<List<?>> res = qry.getAll(); Collection<List<?>> res = qry.getAll();


Expand All @@ -417,7 +418,7 @@ public void _testNoPrimitives() throws Exception { // TODO


cache.put("key", "val"); cache.put("key", "val");


QueryCursor<List<?>> qry = cache.queryFields(new QuerySqlPredicate<>("select * from String")); QueryCursor<List<?>> qry = cache.queryFields(new QuerySqlPredicate("select * from String"));


assert qry.getAll().isEmpty(); assert qry.getAll().isEmpty();


Expand All @@ -435,7 +436,7 @@ public void _testComplexKeys() throws Exception { // TODO


cache.put(key, val); cache.put(key, val);


Collection<List<?>> res = cache.queryFields(new QuerySqlPredicate<>("select * from Person")).getAll(); Collection<List<?>> res = cache.queryFields(new QuerySqlPredicate("select * from Person")).getAll();


assertEquals(1, res.size()); assertEquals(1, res.size());


Expand Down Expand Up @@ -481,7 +482,7 @@ public void testPaginationIteratorNamedCache() throws Exception {
*/ */
private void testPaginationIterator(@Nullable String cacheName) throws Exception { private void testPaginationIterator(@Nullable String cacheName) throws Exception {
QueryCursor<List<?>> qry = grid(0).jcache(cacheName) QueryCursor<List<?>> qry = grid(0).jcache(cacheName)
.queryFields(new QuerySqlPredicate<>("select _key, _val from Integer", 10, new Object[0])); .queryFields(new QuerySqlPredicate("select _key, _val from Integer", 10, new Object[0]));


int cnt = 0; int cnt = 0;


Expand All @@ -498,10 +499,24 @@ private void testPaginationIterator(@Nullable String cacheName) throws Exception
assertEquals(size, cnt); assertEquals(size, cnt);
} }


/**
* @param pageSize Page size.
* @param sql Query.
* @param args Arguments.
* @return Predicate.
*/
private QuerySqlPredicate sqlPage(int pageSize, String sql, Object ... args) {
QuerySqlPredicate q = new QuerySqlPredicate(sql, args);

q.setPageSize(pageSize);

return q;
}

/** @throws Exception If failed. */ /** @throws Exception If failed. */
public void testPaginationIteratorKeepAll() throws Exception { public void testPaginationIteratorKeepAll() throws Exception {
QueryCursor<List<?>> qry = grid(0).jcache(null) QueryCursor<List<?>> qry = grid(0).jcache(null)
.queryFields(new QuerySqlPredicate<>("select _key, _val from Integer", 10, new Object[0])); .queryFields(new QuerySqlPredicate("select _key, _val from Integer", 10, new Object[0]));


int cnt = 0; int cnt = 0;


Expand All @@ -517,8 +532,7 @@ public void testPaginationIteratorKeepAll() throws Exception {


assertEquals(size, cnt); assertEquals(size, cnt);


qry = grid(0).jcache(null) qry = grid(0).jcache(null).queryFields(sqlPage(10, "select _key, _val from Integer"));
.queryFields(new QuerySqlPredicate<>("select _key, _val from Integer", 10, new Object[0]));


List<List<?>> list = new ArrayList<>(qry.getAll()); List<List<?>> list = new ArrayList<>(qry.getAll());


Expand Down Expand Up @@ -554,7 +568,7 @@ public void testPaginationGetNamedCache() throws Exception {
*/ */
private void testPaginationGet(@Nullable String cacheName) throws Exception { private void testPaginationGet(@Nullable String cacheName) throws Exception {
QueryCursor<List<?>> qry = grid(0).jcache(null) QueryCursor<List<?>> qry = grid(0).jcache(null)
.queryFields(new QuerySqlPredicate<>("select _key, _val from Integer", 10, new Object[0])); .queryFields(new QuerySqlPredicate("select _key, _val from Integer", 10, new Object[0]));


List<List<?>> list = new ArrayList<>(qry.getAll()); List<List<?>> list = new ArrayList<>(qry.getAll());


Expand All @@ -577,7 +591,7 @@ private void testPaginationGet(@Nullable String cacheName) throws Exception {
/** @throws Exception If failed. */ /** @throws Exception If failed. */
public void testEmptyGrid() throws Exception { public void testEmptyGrid() throws Exception {
QueryCursor<List<?>> qry = grid(0).jcache(null) QueryCursor<List<?>> qry = grid(0).jcache(null)
.queryFields(new QuerySqlPredicate<>("select name, age from Person where age = 25")); .queryFields(new QuerySqlPredicate("select name, age from Person where age = 25"));


List<?> res = F.first(qry.getAll()); List<?> res = F.first(qry.getAll());


Expand Down Expand Up @@ -623,7 +637,7 @@ private void dedup(Collection<List<?>> res) throws Exception {
@SuppressWarnings("UnusedDeclaration") @SuppressWarnings("UnusedDeclaration")
private static class PersonKey implements Serializable { private static class PersonKey implements Serializable {
/** ID. */ /** ID. */
@CacheQuerySqlField @QuerySqlField
private final UUID id; private final UUID id;


/** @param id ID. */ /** @param id ID. */
Expand Down Expand Up @@ -659,15 +673,15 @@ private PersonKey(UUID id) {
@SuppressWarnings("UnusedDeclaration") @SuppressWarnings("UnusedDeclaration")
private static class Person implements Serializable { private static class Person implements Serializable {
/** Name. */ /** Name. */
@CacheQuerySqlField(index = false) @QuerySqlField(index = false)
private final String name; private final String name;


/** Age. */ /** Age. */
@CacheQuerySqlField(index = true) @QuerySqlField(index = true)
private final int age; private final int age;


/** Organization ID. */ /** Organization ID. */
@CacheQuerySqlField(index = true) @QuerySqlField(index = true)
private final int orgId; private final int orgId;


/** /**
Expand Down Expand Up @@ -716,11 +730,11 @@ private Person(String name, int age, int orgId) {
@SuppressWarnings("UnusedDeclaration") @SuppressWarnings("UnusedDeclaration")
private static class Organization implements Serializable { private static class Organization implements Serializable {
/** ID. */ /** ID. */
@CacheQuerySqlField @QuerySqlField
private final int id; private final int id;


/** Name. */ /** Name. */
@CacheQuerySqlField(index = false) @QuerySqlField(index = false)
private final String name; private final String name;


/** /**
Expand Down

0 comments on commit a13dbad

Please sign in to comment.