This is an automated email from the ASF dual-hosted git repository.
av pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ignite.git
The following commit(s) were added to refs/heads/master by this push:
new 242f3a6 IGNITE-15391 Add support for creating IndexQuery without
index name (#9407)
242f3a6 is described below
commit 242f3a675a2c990f15d7db90128b2f5e93c25046
Author: Maksim Timonin <[email protected]>
AuthorDate: Mon Sep 27 16:47:42 2021 +0300
IGNITE-15391 Add support for creating IndexQuery without index name (#9407)
---
.../org/apache/ignite/cache/query/IndexQuery.java | 29 +++-
.../cache/query/index/IndexQueryProcessor.java | 68 ++++++++-
.../ignite/internal/util/GridArgumentCheck.java | 14 ++
.../ignite/cache/query/IndexQueryAliasTest.java | 32 ++++-
.../ignite/cache/query/IndexQueryAllTypesTest.java | 17 ++-
.../ignite/cache/query/IndexQueryFailoverTest.java | 57 ++++----
.../cache/query/IndexQueryQueryEntityTest.java | 50 ++++---
.../ignite/cache/query/IndexQueryRangeTest.java | 4 +-
.../ignite/cache/query/IndexQuerySqlIndexTest.java | 65 ++++++---
.../ignite/cache/query/IndexQueryTestSuite.java | 1 +
.../cache/query/IndexQueryWrongIndexTest.java | 85 +++++++++++
.../ignite/cache/query/MultiTableIndexQuery.java | 61 +++++---
.../cache/query/MultifieldIndexQueryTest.java | 156 +++++++++++----------
13 files changed, 469 insertions(+), 170 deletions(-)
diff --git
a/modules/core/src/main/java/org/apache/ignite/cache/query/IndexQuery.java
b/modules/core/src/main/java/org/apache/ignite/cache/query/IndexQuery.java
index e7f0315..b81c9e0 100644
--- a/modules/core/src/main/java/org/apache/ignite/cache/query/IndexQuery.java
+++ b/modules/core/src/main/java/org/apache/ignite/cache/query/IndexQuery.java
@@ -26,6 +26,7 @@ import java.util.Set;
import javax.cache.Cache;
import org.apache.ignite.internal.util.typedef.internal.A;
import org.apache.ignite.lang.IgniteExperimental;
+import org.jetbrains.annotations.Nullable;
/**
* Index query runs over internal index structure and returns cache entries
for index rows that match specified criteria.
@@ -41,8 +42,26 @@ public final class IndexQuery<K, V> extends
Query<Cache.Entry<K, V>> {
/** Cache Value type. Describes a table within a cache that runs a query.
*/
private final String valType;
- /** Index name. */
- private final String idxName;
+ /** Index name. If {@code null} then Ignite tries to find an index by
{@link #criteria} fields. */
+ private final @Nullable String idxName;
+
+ /**
+ * Specify index with cache value class.
+ *
+ * @param valCls Cache value class.
+ */
+ public IndexQuery(Class<?> valCls) {
+ this(valCls, null);
+ }
+
+ /**
+ * Specify index with cache value type.
+ *
+ * @param valType Cache value type.
+ */
+ public IndexQuery(String valType) {
+ this(valType, null);
+ }
/**
* Specify index with cache value class and index name.
@@ -50,7 +69,7 @@ public final class IndexQuery<K, V> extends
Query<Cache.Entry<K, V>> {
* @param valCls Cache value class.
* @param idxName Index name.
*/
- public IndexQuery(Class<?> valCls, String idxName) {
+ public IndexQuery(Class<?> valCls, @Nullable String idxName) {
this(valCls.getName(), idxName);
}
@@ -60,9 +79,9 @@ public final class IndexQuery<K, V> extends
Query<Cache.Entry<K, V>> {
* @param valType Cache value type.
* @param idxName Index name.
*/
- public IndexQuery(String valType, String idxName) {
+ public IndexQuery(String valType, @Nullable String idxName) {
A.notEmpty(valType, "valType");
- A.notEmpty(idxName, "idxName");
+ A.nullableNotEmpty(idxName, "idxName");
this.valType = valType;
this.idxName = idxName;
diff --git
a/modules/core/src/main/java/org/apache/ignite/internal/cache/query/index/IndexQueryProcessor.java
b/modules/core/src/main/java/org/apache/ignite/internal/cache/query/index/IndexQueryProcessor.java
index bfbadd6..3f7e074 100644
---
a/modules/core/src/main/java/org/apache/ignite/internal/cache/query/index/IndexQueryProcessor.java
+++
b/modules/core/src/main/java/org/apache/ignite/internal/cache/query/index/IndexQueryProcessor.java
@@ -18,12 +18,16 @@
package org.apache.ignite.internal.cache.query.index;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.PriorityQueue;
+import java.util.Set;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteException;
import org.apache.ignite.cache.query.IndexQuery;
@@ -119,10 +123,19 @@ public class IndexQueryProcessor {
if (tableName == null)
throw failIndexQuery("No table found for type: " +
idxQryDesc.valType(), null, idxQryDesc);
- Index idx = indexByName(cctx, idxQryDesc, tableName);
+ if (idxQryDesc.idxName() != null) {
+ Index idx = indexByName(cctx, idxQryDesc, tableName);
+
+ if (idx == null)
+ throw failIndexQuery("No index found for name: " +
idxQryDesc.idxName(), null, idxQryDesc);
+
+ return idx;
+ }
+
+ Index idx = indexByCriteria(cctx, idxQryDesc, tableName);
if (idx == null)
- throw failIndexQuery("No index found: " + idxQryDesc.idxName(),
null, idxQryDesc);
+ throw failIndexQuery("No index found for criteria", null,
idxQryDesc);
return idx;
}
@@ -148,6 +161,55 @@ public class IndexQueryProcessor {
return idxProc.index(origIdxName);
}
+ /**
+ * Get index by list of fields to query, or return {@code null}.
+ */
+ private Index indexByCriteria(GridCacheContext<?, ?> cctx, IndexQueryDesc
idxQryDesc, String tableName) {
+ Collection<Index> idxs = idxProc.indexes(cctx);
+
+ // Check both fields (original and normalized).
+ final Set<String> critFields = idxQryDesc.criteria().stream()
+ .map(IndexQueryCriterion::field)
+ .flatMap(f -> Stream.of(f, QueryUtils.normalizeObjectName(f,
false)))
+ .collect(Collectors.toSet());
+
+ for (Index idx: idxs) {
+ IndexDefinition idxDef = idxProc.indexDefinition(idx.id());
+
+ if (!tableName.equals(idxDef.idxName().tableName()))
+ continue;
+
+ if (checkIndex(idxDef, idxQryDesc.criteria().size(), critFields))
+ return idx;
+ }
+
+ return null;
+ }
+
+ /**
+ * Checks that specified index matches index query criteria.
+ *
+ * Criteria fields have to match to a prefix of the index. Order of fields
in criteria doesn't matter.
+ */
+ private boolean checkIndex(IndexDefinition idxDef, int critLen, final
Set<String> criteriaFlds) {
+ if (critLen > idxDef.indexKeyDefinitions().size())
+ return false;
+
+ int matches = 0;
+
+ for (int i = 0; i < idxDef.indexKeyDefinitions().size(); i++) {
+ String fld = idxDef.indexKeyDefinitions().get(i).name();
+
+ if (!criteriaFlds.contains(fld))
+ return false;
+
+ if (++matches == critLen)
+ return true;
+ }
+
+ return false;
+ }
+
/** */
private IgniteCheckedException failIndexQueryCriteria(IndexDefinition
idxDef, IndexQueryDesc idxQryDesc) {
return failIndexQuery( "Index doesn't match query", idxDef,
idxQryDesc);
@@ -160,7 +222,7 @@ public class IndexQueryProcessor {
if (idxDef != null)
exMsg += " Index=" + idxDef;
- return new IgniteCheckedException(exMsg + "; Query=" + desc);
+ return new IgniteCheckedException(exMsg + " Query=" + desc);
}
/** Checks that specified index matches index query criteria. */
diff --git
a/modules/core/src/main/java/org/apache/ignite/internal/util/GridArgumentCheck.java
b/modules/core/src/main/java/org/apache/ignite/internal/util/GridArgumentCheck.java
index 7ae41f4..9b2704c 100644
---
a/modules/core/src/main/java/org/apache/ignite/internal/util/GridArgumentCheck.java
+++
b/modules/core/src/main/java/org/apache/ignite/internal/util/GridArgumentCheck.java
@@ -189,6 +189,20 @@ public class GridArgumentCheck {
}
/**
+ * Checks that given String is nullable but not empty.
+ *
+ * @param str String.
+ * @param name Argument name.
+ */
+ public static void nullableNotEmpty(String str, String name) {
+ if (str == null)
+ return;
+
+ if (str.isEmpty())
+ throw new IllegalArgumentException(INVALID_ARG_MSG_PREFIX + name +
NOT_EMPTY_SUFFIX);
+ }
+
+ /**
* Checks that a String is not null or empty.
*
* @param value Value to check.
diff --git
a/modules/indexing/src/test/java/org/apache/ignite/cache/query/IndexQueryAliasTest.java
b/modules/indexing/src/test/java/org/apache/ignite/cache/query/IndexQueryAliasTest.java
index fbd046a..29afaf7 100644
---
a/modules/indexing/src/test/java/org/apache/ignite/cache/query/IndexQueryAliasTest.java
+++
b/modules/indexing/src/test/java/org/apache/ignite/cache/query/IndexQueryAliasTest.java
@@ -36,10 +36,13 @@ import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
import static org.apache.ignite.cache.query.IndexQueryCriteriaBuilder.lt;
/** */
+@RunWith(Parameterized.class)
public class IndexQueryAliasTest extends GridCommonAbstractTest {
/** */
private static final String CACHE = "TEST_CACHE";
@@ -53,6 +56,23 @@ public class IndexQueryAliasTest extends
GridCommonAbstractTest {
/** */
private static final int CNT = 10_000;
+ /** Query index, {@code null} or index name. */
+ @Parameterized.Parameter
+ public String qryIdx;
+
+ /** Query desc index, {@code null} or index name. */
+ @Parameterized.Parameter(1)
+ public String qryDescIdx;
+
+ /** */
+ @Parameterized.Parameters(name = "qryIdx={0}, qryDescIdx={1}")
+ public static List<Object[]> params() {
+ return F.asList(
+ new Object[] {null, null},
+ new Object[] {ID_IDX, DESC_ID_IDX}
+ );
+ }
+
/** */
private static IgniteCache<Long, Person> cache;
@@ -95,13 +115,13 @@ public class IndexQueryAliasTest extends
GridCommonAbstractTest {
int pivot = new Random().nextInt(CNT);
// Lt.
- IndexQuery<Long, Person> qry = new IndexQuery<Long,
Person>(Person.class, ID_IDX)
+ IndexQuery<Long, Person> qry = new IndexQuery<Long,
Person>(Person.class, qryIdx)
.setCriteria(lt("asId", pivot));
check(cache.query(qry), 0, pivot);
// Lt, desc index.
- IndexQuery<Long, Person> descQry = new IndexQuery<Long,
Person>(Person.class, DESC_ID_IDX)
+ IndexQuery<Long, Person> descQry = new IndexQuery<Long,
Person>(Person.class, qryDescIdx)
.setCriteria(lt("asDescId", pivot));
check(cache.query(descQry), 0, pivot);
@@ -112,14 +132,18 @@ public class IndexQueryAliasTest extends
GridCommonAbstractTest {
public void testAliasCaseRangeQueries() {
int pivot = new Random().nextInt(CNT);
+ String idIdx = qryIdx != null ? qryIdx.toLowerCase() : null;
+
// Lt.
- IndexQuery<Long, Person> qry = new IndexQuery<Long,
Person>(Person.class, ID_IDX.toLowerCase())
+ IndexQuery<Long, Person> qry = new IndexQuery<Long,
Person>(Person.class, idIdx)
.setCriteria(lt("ASID", pivot));
check(cache.query(qry), 0, pivot);
+ String idDescIdx = qryDescIdx != null ? qryDescIdx.toLowerCase() :
null;
+
// Lt, desc index.
- IndexQuery<Long, Person> descQry = new IndexQuery<Long,
Person>(Person.class, DESC_ID_IDX.toLowerCase())
+ IndexQuery<Long, Person> descQry = new IndexQuery<Long,
Person>(Person.class, idDescIdx)
.setCriteria(lt("ASDESCID", pivot));
check(cache.query(descQry), 0, pivot);
diff --git
a/modules/indexing/src/test/java/org/apache/ignite/cache/query/IndexQueryAllTypesTest.java
b/modules/indexing/src/test/java/org/apache/ignite/cache/query/IndexQueryAllTypesTest.java
index 470b894..9ab6593 100644
---
a/modules/indexing/src/test/java/org/apache/ignite/cache/query/IndexQueryAllTypesTest.java
+++
b/modules/indexing/src/test/java/org/apache/ignite/cache/query/IndexQueryAllTypesTest.java
@@ -41,8 +41,11 @@ import org.apache.ignite.IgniteCache;
import org.apache.ignite.cache.query.annotations.QuerySqlField;
import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
import static org.apache.ignite.cache.query.IndexQueryCriteriaBuilder.gt;
import static org.apache.ignite.cache.query.IndexQueryCriteriaBuilder.gte;
@@ -50,6 +53,7 @@ import static
org.apache.ignite.cache.query.IndexQueryCriteriaBuilder.lt;
import static org.apache.ignite.cache.query.IndexQueryCriteriaBuilder.lte;
/** */
+@RunWith(Parameterized.class)
public class IndexQueryAllTypesTest extends GridCommonAbstractTest {
/** */
private static final String CACHE = "TEST_CACHE";
@@ -60,6 +64,16 @@ public class IndexQueryAllTypesTest extends
GridCommonAbstractTest {
/** */
private static IgniteCache<Long, Person> cache;
+ /** Whether to specify index name in IndexQuery. */
+ @Parameterized.Parameter
+ public boolean useIdxName;
+
+ /** */
+ @Parameterized.Parameters(name = "useIdxName={0}")
+ public static List<Boolean> params() {
+ return F.asList(false, true);
+ }
+
/** {@inheritDoc} */
@Override protected void beforeTestsStarted() throws Exception {
Ignite crd = startGrids(2);
@@ -301,8 +315,7 @@ public class IndexQueryAllTypesTest extends
GridCommonAbstractTest {
/** */
private String idxName(String field) {
- // TODO: test case for escaping (true / false) separately.
- return ("Person_" + field + "_idx").toUpperCase();
+ return useIdxName ? ("Person_" + field + "_idx").toUpperCase() : null;
}
/** */
diff --git
a/modules/indexing/src/test/java/org/apache/ignite/cache/query/IndexQueryFailoverTest.java
b/modules/indexing/src/test/java/org/apache/ignite/cache/query/IndexQueryFailoverTest.java
index c336cdd..06728a8 100644
---
a/modules/indexing/src/test/java/org/apache/ignite/cache/query/IndexQueryFailoverTest.java
+++
b/modules/indexing/src/test/java/org/apache/ignite/cache/query/IndexQueryFailoverTest.java
@@ -19,6 +19,7 @@ package org.apache.ignite.cache.query;
import java.util.Collections;
import java.util.Iterator;
+import java.util.List;
import java.util.Objects;
import javax.cache.Cache;
import org.apache.ignite.Ignite;
@@ -32,14 +33,18 @@ import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.internal.cache.query.index.IndexName;
import org.apache.ignite.internal.processors.cache.GatewayProtectedCacheProxy;
import org.apache.ignite.internal.processors.cache.GridCacheContext;
+import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.testframework.GridTestUtils;
import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
import static org.apache.ignite.cache.query.IndexQueryCriteriaBuilder.between;
import static org.apache.ignite.cache.query.IndexQueryCriteriaBuilder.lt;
/** */
+@RunWith(Parameterized.class)
public class IndexQueryFailoverTest extends GridCommonAbstractTest {
/** */
private static final String CACHE = "TEST_CACHE";
@@ -53,6 +58,16 @@ public class IndexQueryFailoverTest extends
GridCommonAbstractTest {
/** */
private static IgniteCache<Long, Person> cache;
+ /** Query index, {@code null} or index name. */
+ @Parameterized.Parameter
+ public String qryIdx;
+
+ /** */
+ @Parameterized.Parameters(name = "qryIdx={0}")
+ public static List<String> params() {
+ return F.asList(null, IDX);
+ }
+
/** {@inheritDoc} */
@Override protected void beforeTest() throws Exception {
Ignite crd = startGrids(2);
@@ -82,14 +97,14 @@ public class IndexQueryFailoverTest extends
GridCommonAbstractTest {
@Test
public void testQueryWithWrongCriteria() {
GridTestUtils.assertThrowsAnyCause(null, () -> {
- IndexQuery<Long, Person> qryNoCriteria = new
IndexQuery<>(Person.class, IDX);
+ IndexQuery<Long, Person> qryNoCriteria = new
IndexQuery<>(Person.class, qryIdx);
return cache.query(qryNoCriteria);
},
NullPointerException.class, "Ouch! Argument cannot be null:
criteria");
GridTestUtils.assertThrowsAnyCause(null, () -> {
- IndexQuery<Long, Person> qryNullCriteria = new
IndexQuery<Long, Person>(Person.class, IDX)
+ IndexQuery<Long, Person> qryNullCriteria = new
IndexQuery<Long, Person>(Person.class, qryIdx)
.setCriteria(lt(null, 12));
return cache.query(qryNullCriteria);
@@ -97,7 +112,7 @@ public class IndexQueryFailoverTest extends
GridCommonAbstractTest {
NullPointerException.class, "Ouch! Argument cannot be null:
field");
GridTestUtils.assertThrowsAnyCause(null, () -> {
- IndexQuery<Long, Person> qryDuplicateField = new
IndexQuery<Long, Person>(Person.class, IDX)
+ IndexQuery<Long, Person> qryDuplicateField = new
IndexQuery<Long, Person>(Person.class, qryIdx)
.setCriteria(lt("id", 12), lt("id", 32));
return cache.query(qryDuplicateField);
@@ -108,14 +123,14 @@ public class IndexQueryFailoverTest extends
GridCommonAbstractTest {
/** */
@Test
public void testQueryWrongType() {
- GridTestUtils.assertThrows(null, () -> new IndexQuery<Long,
Integer>((String) null, IDX),
+ GridTestUtils.assertThrows(null, () -> new IndexQuery<Long,
Integer>((String) null, qryIdx),
NullPointerException.class, "Ouch! Argument cannot be null:
valType");
- GridTestUtils.assertThrows(null, () -> new IndexQuery<Long,
Integer>("", IDX),
+ GridTestUtils.assertThrows(null, () -> new IndexQuery<Long,
Integer>("", qryIdx),
IllegalArgumentException.class, "Ouch! Argument is invalid:
valType must not be empty");
GridTestUtils.assertThrowsAnyCause(null, () -> {
- IndexQuery<Long, Integer> qry = new IndexQuery<Long,
Integer>(Integer.class, IDX)
+ IndexQuery<Long, Integer> qry = new IndexQuery<Long,
Integer>(Integer.class, qryIdx)
.setCriteria(lt("id", Integer.MAX_VALUE));
return cache.query(qry).getAll();
@@ -127,14 +142,6 @@ public class IndexQueryFailoverTest extends
GridCommonAbstractTest {
@Test
public void testQueryWrongIndexName() {
GridTestUtils.assertThrowsAnyCause(null, () -> {
- IndexQuery<Long, Person> qry = new IndexQuery<Long,
Person>(Person.class, null)
- .setCriteria(lt("id", Integer.MAX_VALUE));
-
- return cache.query(qry).getAll();
- },
- NullPointerException.class, "Ouch! Argument cannot be null:
idxName");
-
- GridTestUtils.assertThrowsAnyCause(null, () -> {
IndexQuery<Long, Person> qry = new IndexQuery<Long,
Person>(Person.class, "")
.setCriteria(lt("id", Integer.MAX_VALUE));
@@ -148,14 +155,14 @@ public class IndexQueryFailoverTest extends
GridCommonAbstractTest {
return cache.query(qry).getAll();
},
- IgniteCheckedException.class, "No index found: DUMMY");
+ IgniteCheckedException.class, "No index found for name: DUMMY");
}
/** */
@Test
public void testQueryWrongQuery() {
GridTestUtils.assertThrowsAnyCause(null, () -> {
- IndexQuery<Long, Person> qry = new IndexQuery<Long,
Person>(Person.class, IDX)
+ IndexQuery<Long, Person> qry = new IndexQuery<Long,
Person>(Person.class, qryIdx)
.setCriteria();
return cache.query(qry).getAll();
@@ -163,30 +170,32 @@ public class IndexQueryFailoverTest extends
GridCommonAbstractTest {
IllegalArgumentException.class, "Ouch! Argument is invalid:
criteria must not be empty.");
GridTestUtils.assertThrowsAnyCause(null, () -> {
- IndexQuery<Long, Person> qry = new IndexQuery<Long,
Person>(Person.class, IDX)
+ IndexQuery<Long, Person> qry = new IndexQuery<Long,
Person>(Person.class, qryIdx)
.setCriteria(Collections.emptyList());
return cache.query(qry).getAll();
},
IllegalArgumentException.class, "Ouch! Argument is invalid:
criteria must not be empty.");
+ String errMsg = qryIdx != null ? "Index doesn't match query." : "No
index found for criteria.";
+
GridTestUtils.assertThrowsAnyCause(null, () -> {
- IndexQuery<Long, Person> qry = new IndexQuery<Long,
Person>(Person.class, IDX)
+ IndexQuery<Long, Person> qry = new IndexQuery<Long,
Person>(Person.class, qryIdx)
.setCriteria(lt("dummy", Integer.MAX_VALUE));
return cache.query(qry).getAll();
},
- IgniteCheckedException.class, "Index doesn't match query.");
+ IgniteCheckedException.class, errMsg);
GridTestUtils.assertThrowsAnyCause(null, () -> {
- IndexQuery<Long, Person> qry = new IndexQuery<Long,
Person>(Person.class, IDX)
+ IndexQuery<Long, Person> qry = new IndexQuery<Long,
Person>(Person.class, qryIdx)
.setCriteria(
lt("id", Integer.MAX_VALUE),
lt("nonExistedField", Integer.MAX_VALUE));
return cache.query(qry).getAll();
},
- IgniteCheckedException.class, "Index doesn't match query.");
+ IgniteCheckedException.class, errMsg);
}
/** */
@@ -194,7 +203,7 @@ public class IndexQueryFailoverTest extends
GridCommonAbstractTest {
public void testRangeQueries() {
insertData(0, CNT);
- IndexQuery<Long, Person> qry = new IndexQuery<Long,
Person>(Person.class, IDX)
+ IndexQuery<Long, Person> qry = new IndexQuery<Long,
Person>(Person.class, qryIdx)
.setCriteria(lt("id", CNT));
QueryCursor<Cache.Entry<Long, Person>> cursor = cache.query(qry);
@@ -211,7 +220,7 @@ public class IndexQueryFailoverTest extends
GridCommonAbstractTest {
public void testDestroyIndex() {
insertData(0, CNT);
- IndexQuery<Long, Person> qry = new IndexQuery<Long,
Person>(Person.class, IDX)
+ IndexQuery<Long, Person> qry = new IndexQuery<Long,
Person>(Person.class, qryIdx)
.setCriteria(lt("id", CNT));
Iterator<Cache.Entry<Long, Person>> cursor =
cache.query(qry).iterator();
@@ -236,7 +245,7 @@ public class IndexQueryFailoverTest extends
GridCommonAbstractTest {
public void testConcurrentUpdateIndex() {
insertData(0, CNT);
- IndexQuery<Long, Person> qry = new IndexQuery<Long,
Person>(Person.class, IDX)
+ IndexQuery<Long, Person> qry = new IndexQuery<Long,
Person>(Person.class, qryIdx)
.setCriteria(between("id", CNT / 2, CNT + CNT / 2));
Iterator<Cache.Entry<Long, Person>> cursor =
cache.query(qry).iterator();
diff --git
a/modules/indexing/src/test/java/org/apache/ignite/cache/query/IndexQueryQueryEntityTest.java
b/modules/indexing/src/test/java/org/apache/ignite/cache/query/IndexQueryQueryEntityTest.java
index 19902da..00b0b7e 100644
---
a/modules/indexing/src/test/java/org/apache/ignite/cache/query/IndexQueryQueryEntityTest.java
+++
b/modules/indexing/src/test/java/org/apache/ignite/cache/query/IndexQueryQueryEntityTest.java
@@ -29,19 +29,20 @@ import java.util.stream.LongStream;
import javax.cache.Cache;
import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteCache;
-import org.apache.ignite.IgniteException;
import org.apache.ignite.cache.QueryEntity;
import org.apache.ignite.cache.QueryIndex;
import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.internal.util.typedef.F;
-import org.apache.ignite.testframework.GridTestUtils;
import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
import static org.apache.ignite.cache.query.IndexQueryCriteriaBuilder.lt;
/** */
+@RunWith(Parameterized.class)
public class IndexQueryQueryEntityTest extends GridCommonAbstractTest {
/** */
private static final String CACHE = "TEST_CACHE";
@@ -61,6 +62,23 @@ public class IndexQueryQueryEntityTest extends
GridCommonAbstractTest {
/** */
private static final int CNT = 10_000;
+ /** Query index, {@code null} or index name. */
+ @Parameterized.Parameter
+ public String qryIdx;
+
+ /** Query desc index, {@code null} or index name. */
+ @Parameterized.Parameter(1)
+ public String qryDescIdx;
+
+ /** */
+ @Parameterized.Parameters(name = "qryIdx={0}, qryDescIdx={1}")
+ public static List<Object[]> params() {
+ return F.asList(
+ new Object[] {null, null},
+ new Object[] {ID_IDX, DESC_ID_IDX}
+ );
+ }
+
/** */
private static IgniteCache<Long, Person> cache;
@@ -113,44 +131,36 @@ public class IndexQueryQueryEntityTest extends
GridCommonAbstractTest {
/** */
@Test
public void testEmptyCache() {
- IndexQuery<Long, Person> qry = new IndexQuery<Long,
Person>(Person.class, ID_IDX)
+ IndexQuery<Long, Person> qry = new IndexQuery<Long,
Person>(Person.class, qryIdx)
.setCriteria(lt("id", Integer.MAX_VALUE));
assertTrue(cache.query(qry).getAll().isEmpty());
- qry = new IndexQuery<Long, Person>(Person.class, DESC_ID_IDX)
+ qry = new IndexQuery<Long, Person>(Person.class, qryDescIdx)
.setCriteria(lt("descId", Integer.MAX_VALUE));
assertTrue(cache.query(qry).getAll().isEmpty());
-
- // Wrong fields in query.
- GridTestUtils.assertThrows(null, () -> {
- IndexQuery<Long, Person> wrongQry = new IndexQuery<Long,
Person>(Person.class, DESC_ID_IDX)
- .setCriteria(lt("id", Integer.MAX_VALUE));
-
- cache.query(wrongQry).getAll();
- }, IgniteException.class, null);
}
/** */
@Test
public void testEmptyCacheTableName() {
- IndexQuery<Long, Person> qry = new IndexQuery<Long,
Person>(Person.class, ID_IDX)
+ IndexQuery<Long, Person> qry = new IndexQuery<Long,
Person>(Person.class, qryIdx)
.setCriteria(lt("id", Integer.MAX_VALUE));
assertTrue(cacheTblName.query(qry).getAll().isEmpty());
- qry = new IndexQuery<Long, Person>(Person.class, DESC_ID_IDX)
+ qry = new IndexQuery<Long, Person>(Person.class, qryDescIdx)
.setCriteria(lt("descId", Integer.MAX_VALUE));
assertTrue(cacheTblName.query(qry).getAll().isEmpty());
- qry = new IndexQuery<Long, Person>(Person.class, ID_IDX)
+ qry = new IndexQuery<Long, Person>(Person.class, qryIdx)
.setCriteria(lt("id", Integer.MAX_VALUE));
assertTrue(cacheTblName.query(qry).getAll().isEmpty());
- qry = new IndexQuery<Long, Person>(Person.class, DESC_ID_IDX)
+ qry = new IndexQuery<Long, Person>(Person.class, qryDescIdx)
.setCriteria(lt("descId", Integer.MAX_VALUE));
assertTrue(cacheTblName.query(qry).getAll().isEmpty());
@@ -164,13 +174,13 @@ public class IndexQueryQueryEntityTest extends
GridCommonAbstractTest {
int pivot = new Random().nextInt(CNT);
// Lt.
- IndexQuery<Long, Person> qry = new IndexQuery<Long,
Person>(Person.class, ID_IDX)
+ IndexQuery<Long, Person> qry = new IndexQuery<Long,
Person>(Person.class, qryIdx)
.setCriteria(lt("id", pivot));
check(cache.query(qry), 0, pivot);
// Lt, desc index.
- IndexQuery<Long, Person> descQry = new IndexQuery<Long,
Person>(Person.class, DESC_ID_IDX)
+ IndexQuery<Long, Person> descQry = new IndexQuery<Long,
Person>(Person.class, qryDescIdx)
.setCriteria(lt("descId", pivot));
check(cache.query(descQry), 0, pivot);
@@ -184,13 +194,13 @@ public class IndexQueryQueryEntityTest extends
GridCommonAbstractTest {
int pivot = new Random().nextInt(CNT);
// Lt.
- IndexQuery<Long, Person> qry = new IndexQuery<Long,
Person>(Person.class, ID_IDX)
+ IndexQuery<Long, Person> qry = new IndexQuery<Long,
Person>(Person.class, qryIdx)
.setCriteria(lt("id", pivot));
check(cacheTblName.query(qry), 0, pivot);
// Lt, desc index.
- IndexQuery<Long, Person> descQry = new IndexQuery<Long,
Person>(Person.class, DESC_ID_IDX)
+ IndexQuery<Long, Person> descQry = new IndexQuery<Long,
Person>(Person.class, qryDescIdx)
.setCriteria(lt("descId", pivot));
check(cacheTblName.query(descQry), 0, pivot);
diff --git
a/modules/indexing/src/test/java/org/apache/ignite/cache/query/IndexQueryRangeTest.java
b/modules/indexing/src/test/java/org/apache/ignite/cache/query/IndexQueryRangeTest.java
index 747e385..adb9653 100644
---
a/modules/indexing/src/test/java/org/apache/ignite/cache/query/IndexQueryRangeTest.java
+++
b/modules/indexing/src/test/java/org/apache/ignite/cache/query/IndexQueryRangeTest.java
@@ -253,8 +253,8 @@ public class IndexQueryRangeTest extends
GridCommonAbstractTest {
/** */
public void checkRangeDescQueries() {
// Query empty cache.
- IndexQuery<Long, Person> qry = new IndexQuery<Long,
Person>(Person.class, IDX)
- .setCriteria(lt("id", Integer.MAX_VALUE));
+ IndexQuery<Long, Person> qry = new IndexQuery<Long,
Person>(Person.class, DESC_IDX)
+ .setCriteria(lt("descId", Integer.MAX_VALUE));
assertTrue(cache.query(qry).getAll().isEmpty());
diff --git
a/modules/indexing/src/test/java/org/apache/ignite/cache/query/IndexQuerySqlIndexTest.java
b/modules/indexing/src/test/java/org/apache/ignite/cache/query/IndexQuerySqlIndexTest.java
index 24b0dc2..9e646bb 100644
---
a/modules/indexing/src/test/java/org/apache/ignite/cache/query/IndexQuerySqlIndexTest.java
+++
b/modules/indexing/src/test/java/org/apache/ignite/cache/query/IndexQuerySqlIndexTest.java
@@ -17,6 +17,8 @@
package org.apache.ignite.cache.query;
+import java.util.Arrays;
+import java.util.Collection;
import java.util.List;
import java.util.Objects;
import java.util.Random;
@@ -32,12 +34,15 @@ import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.testframework.GridTestUtils;
import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
import static org.apache.ignite.cache.query.IndexQueryCriteriaBuilder.eq;
import static org.apache.ignite.cache.query.IndexQueryCriteriaBuilder.lt;
import static org.apache.ignite.cache.query.IndexQueryCriteriaBuilder.lte;
/** */
+@RunWith(Parameterized.class)
public class IndexQuerySqlIndexTest extends GridCommonAbstractTest {
/** */
private static final String CACHE = "TEST_CACHE";
@@ -57,6 +62,16 @@ public class IndexQuerySqlIndexTest extends
GridCommonAbstractTest {
/** */
private static final int CNT = 10_000;
+ /** Query index, {@code null} of index name. */
+ @Parameterized.Parameter()
+ public String qryDescIdxName;
+
+ /** */
+ @Parameterized.Parameters(name = "qryIdxName={0}")
+ public static Collection<?> testParams() {
+ return Arrays.asList(null, DESC_ID_IDX);
+ }
+
/** */
private IgniteCache<Object, Object> cache;
@@ -85,7 +100,7 @@ public class IndexQuerySqlIndexTest extends
GridCommonAbstractTest {
tblCache = crd.cache(CACHE_TABLE);
- IndexQuery<Long, Object> qry = new IndexQuery<Long,
Object>(Person.class.getName(), DESC_ID_IDX)
+ IndexQuery<Long, Object> qry = new IndexQuery<Long,
Object>(Person.class.getName(), qryDescIdxName)
.setCriteria(lte("descId", Integer.MAX_VALUE));
assertTrue(tblCache.query(qry).getAll().isEmpty());
@@ -99,17 +114,19 @@ public class IndexQuerySqlIndexTest extends
GridCommonAbstractTest {
tblCache = crd.cache(CACHE_TABLE);
// Wrong fields in query.
- GridTestUtils.assertThrowsAnyCause(null, () -> {
- IndexQuery<Long, Object> wrongQry = new IndexQuery<Long,
Object>(Person.class.getName(), DESC_ID_IDX)
- .setCriteria(lt("id", Integer.MAX_VALUE));
+ if (qryDescIdxName != null) {
+ GridTestUtils.assertThrowsAnyCause(null, () -> {
+ IndexQuery<Long, Object> wrongQry = new IndexQuery<Long,
Object>(Person.class.getName(), qryDescIdxName)
+ .setCriteria(lt("id", Integer.MAX_VALUE));
- return tblCache.query(wrongQry).getAll();
+ return tblCache.query(wrongQry).getAll();
- }, IgniteCheckedException.class, "Index doesn't match query.");
+ }, IgniteCheckedException.class, "Index doesn't match query.");
+ }
// Wrong cache.
GridTestUtils.assertThrowsAnyCause(null, () -> {
- IndexQuery<Long, Object> wrongQry = new IndexQuery<Long,
Object>(Person.class.getName(), DESC_ID_IDX)
+ IndexQuery<Long, Object> wrongQry = new IndexQuery<Long,
Object>(Person.class.getName(), qryDescIdxName)
.setCriteria(lt("descId", Integer.MAX_VALUE));
return cache.query(wrongQry).getAll();
@@ -126,12 +143,12 @@ public class IndexQuerySqlIndexTest extends
GridCommonAbstractTest {
tblCache = crd.cache(CACHE_TABLE);
- IndexQuery<Long, Person> qry = new IndexQuery<Long,
Person>(Person.class.getName(), DESC_ID_IDX)
+ IndexQuery<Long, Person> qry = new IndexQuery<Long,
Person>(Person.class.getName(), qryDescIdxName)
.setCriteria(lt("descId", pivot));
check(tblCache.query(qry), 0, pivot);
- qry = new IndexQuery<Long, Person>(Person.class.getName(), DESC_ID_IDX)
+ qry = new IndexQuery<Long, Person>(Person.class.getName(),
qryDescIdxName)
.setCriteria(lt("DESCID", pivot));
check(tblCache.query(qry), 0, pivot);
@@ -146,18 +163,20 @@ public class IndexQuerySqlIndexTest extends
GridCommonAbstractTest {
tblCache = crd.cache(CACHE_TABLE);
- IndexQuery<Long, Person> qry = new IndexQuery<Long,
Person>(Person.class.getName(), DESC_ID_IDX)
+ IndexQuery<Long, Person> qry = new IndexQuery<Long,
Person>(Person.class.getName(), qryDescIdxName)
.setCriteria(lt("descId", pivot));
check(tblCache.query(qry), 0, pivot);
+ String errMsg = qryDescIdxName != null ? "Index doesn't match query."
: "No index found for criteria.";
+
GridTestUtils.assertThrowsAnyCause(null, () -> {
- IndexQuery<Long, Object> wrongQry = new IndexQuery<Long,
Object>(Person.class.getName(), DESC_ID_IDX)
+ IndexQuery<Long, Object> wrongQry = new IndexQuery<Long,
Object>(Person.class.getName(), qryDescIdxName)
.setCriteria(lt("DESCID", Integer.MAX_VALUE));
return tblCache.query(wrongQry).getAll();
- }, IgniteCheckedException.class, "Index doesn't match query.");
+ }, IgniteCheckedException.class, errMsg);
}
/** Should support only original field. */
@@ -169,18 +188,22 @@ public class IndexQuerySqlIndexTest extends
GridCommonAbstractTest {
tblCache = crd.cache(CACHE_TABLE);
- IndexQuery<Long, Person> qry = new IndexQuery<Long,
Person>(Person.class.getName(), DESC_ID_IDX.toLowerCase())
+ String idx = qryDescIdxName == null ? qryDescIdxName :
qryDescIdxName.toLowerCase();
+
+ IndexQuery<Long, Person> qry = new IndexQuery<Long,
Person>(Person.class.getName(), idx)
.setCriteria(lt("descId", pivot));
check(tblCache.query(qry), 0, pivot);
- GridTestUtils.assertThrowsAnyCause(null, () -> {
- IndexQuery<Long, Object> wrongQry = new IndexQuery<Long,
Object>(Person.class.getName(), DESC_ID_IDX)
- .setCriteria(lt("descId", Integer.MAX_VALUE));
+ if (qryDescIdxName != null) {
+ GridTestUtils.assertThrowsAnyCause(null, () -> {
+ IndexQuery<Long, Object> wrongQry = new IndexQuery<Long,
Object>(Person.class.getName(), qryDescIdxName)
+ .setCriteria(lt("descId", Integer.MAX_VALUE));
- return tblCache.query(wrongQry).getAll();
+ return tblCache.query(wrongQry).getAll();
- }, IgniteCheckedException.class, "No index found");
+ }, IgniteCheckedException.class, "No index found");
+ }
}
/** */
@@ -192,7 +215,7 @@ public class IndexQuerySqlIndexTest extends
GridCommonAbstractTest {
tblCache = crd.cache(CACHE_TABLE).withKeepBinary();
- IndexQuery<Long, BinaryObject> qry = new IndexQuery<Long,
BinaryObject>(Person.class.getName(), DESC_ID_IDX)
+ IndexQuery<Long, BinaryObject> qry = new IndexQuery<Long,
BinaryObject>(Person.class.getName(), qryDescIdxName)
.setCriteria(lt("descId", pivot));
checkBinary(tblCache.query(qry), 0, pivot);
@@ -207,7 +230,7 @@ public class IndexQuerySqlIndexTest extends
GridCommonAbstractTest {
tblCache = crd.cache(CACHE_TABLE).withKeepBinary();
- IndexQuery<Long, BinaryObject> qry = new IndexQuery<Long,
BinaryObject>(VALUE_TYPE, DESC_ID_IDX)
+ IndexQuery<Long, BinaryObject> qry = new IndexQuery<Long,
BinaryObject>(VALUE_TYPE, qryDescIdxName)
.setCriteria(lt("descId", pivot));
checkBinary(tblCache.query(qry), 0, pivot);
@@ -222,7 +245,7 @@ public class IndexQuerySqlIndexTest extends
GridCommonAbstractTest {
tblCache = crd.cache(CACHE_TABLE);
- IndexQuery<Long, Person> qry = new IndexQuery<Long,
Person>(Person.class.getName(), DESC_ID_IDX)
+ IndexQuery<Long, Person> qry = new IndexQuery<Long,
Person>(Person.class.getName(), qryDescIdxName)
.setCriteria(eq("_KEY", (long) pivot), lte("descId", pivot));
check(tblCache.query(qry), pivot, pivot + 1);
diff --git
a/modules/indexing/src/test/java/org/apache/ignite/cache/query/IndexQueryTestSuite.java
b/modules/indexing/src/test/java/org/apache/ignite/cache/query/IndexQueryTestSuite.java
index cc2a7c1..dc0fac9 100644
---
a/modules/indexing/src/test/java/org/apache/ignite/cache/query/IndexQueryTestSuite.java
+++
b/modules/indexing/src/test/java/org/apache/ignite/cache/query/IndexQueryTestSuite.java
@@ -33,6 +33,7 @@ import org.junit.runners.Suite;
IndexQueryAliasTest.class,
IndexQuerySqlIndexTest.class,
IndexQueryRangeTest.class,
+ IndexQueryWrongIndexTest.class,
MultifieldIndexQueryTest.class,
MultiTableIndexQuery.class
})
diff --git
a/modules/indexing/src/test/java/org/apache/ignite/cache/query/IndexQueryWrongIndexTest.java
b/modules/indexing/src/test/java/org/apache/ignite/cache/query/IndexQueryWrongIndexTest.java
new file mode 100644
index 0000000..781b58f
--- /dev/null
+++
b/modules/indexing/src/test/java/org/apache/ignite/cache/query/IndexQueryWrongIndexTest.java
@@ -0,0 +1,85 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.cache.query;
+
+import javax.cache.CacheException;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.cache.query.annotations.QuerySqlField;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.testframework.GridTestUtils;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.junit.Test;
+
+import static org.apache.ignite.cache.query.IndexQueryCriteriaBuilder.lt;
+
+/** */
+public class IndexQueryWrongIndexTest extends GridCommonAbstractTest {
+ /** */
+ private static final String ID_IDX = "ID_IDX";
+
+ /** */
+ private static final String DESC_ID_IDX = "DESC_ID_IDX";
+
+ /** */
+ @Test
+ public void testWrongIndexAndFieldsMatching() throws Exception {
+ Ignite crd = startGrids(2);
+
+ IgniteCache<Integer, Person> cache = crd.getOrCreateCache(new
CacheConfiguration<Integer, Person>()
+ .setName("CACHE")
+ .setIndexedTypes(Integer.class, Person.class));
+
+ // Wrong fields in query.
+ GridTestUtils.assertThrows(null, () -> {
+ IndexQuery<Integer, Person> wrongQry = new IndexQuery<Integer,
Person>(Person.class, DESC_ID_IDX)
+ .setCriteria(lt("id", Integer.MAX_VALUE));
+
+ cache.query(wrongQry).getAll();
+
+ return null;
+ }, CacheException.class, null);
+
+ // Wrong fields in query.
+ GridTestUtils.assertThrows(null, () -> {
+ IndexQuery<Integer, Person> wrongQry = new IndexQuery<Integer,
Person>(Person.class, ID_IDX)
+ .setCriteria(lt("descId", Integer.MAX_VALUE));
+
+ cache.query(wrongQry).getAll();
+
+ return null;
+ }, CacheException.class, null);
+ }
+
+ /** */
+ private static class Person {
+ /** */
+ @QuerySqlField(orderedGroups = @QuerySqlField.Group(name = ID_IDX,
order = 0))
+ final int id;
+
+ /** */
+ @QuerySqlField(orderedGroups = @QuerySqlField.Group(name =
DESC_ID_IDX, order = 0))
+ final int descId;
+
+ /** */
+ Person(int id) {
+ this.id = id;
+ descId = id;
+ }
+ }
+}
diff --git
a/modules/indexing/src/test/java/org/apache/ignite/cache/query/MultiTableIndexQuery.java
b/modules/indexing/src/test/java/org/apache/ignite/cache/query/MultiTableIndexQuery.java
index 685fe6e..dbb63f6 100644
---
a/modules/indexing/src/test/java/org/apache/ignite/cache/query/MultiTableIndexQuery.java
+++
b/modules/indexing/src/test/java/org/apache/ignite/cache/query/MultiTableIndexQuery.java
@@ -17,6 +17,7 @@
package org.apache.ignite.cache.query;
+import java.util.Collection;
import java.util.List;
import java.util.Objects;
import java.util.Random;
@@ -29,8 +30,11 @@ import org.apache.ignite.IgniteCache;
import org.apache.ignite.cache.query.annotations.QuerySqlField;
import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
import static org.apache.ignite.cache.query.IndexQueryCriteriaBuilder.gt;
import static org.apache.ignite.cache.query.IndexQueryCriteriaBuilder.gte;
@@ -38,6 +42,7 @@ import static
org.apache.ignite.cache.query.IndexQueryCriteriaBuilder.lt;
import static org.apache.ignite.cache.query.IndexQueryCriteriaBuilder.lte;
/** */
+@RunWith(Parameterized.class)
public class MultiTableIndexQuery extends GridCommonAbstractTest {
/** */
private static final String CACHE = "TEST_CACHE";
@@ -54,6 +59,26 @@ public class MultiTableIndexQuery extends
GridCommonAbstractTest {
/** */
private static IgniteCache<Long, Object> cache;
+ /** */
+ @Parameterized.Parameter(value = 0)
+ public String qryPersIdx;
+
+ /** */
+ @Parameterized.Parameter(value = 1)
+ public String qrySecPersIdx;
+
+ /** */
+ @Parameterized.Parameter(value = 2)
+ public String qryKeyPkIdx;
+
+ /** */
+ @Parameterized.Parameters(name = "IDX={0}, SEC_IDX={1}, PK={2}")
+ public static Collection<Object[]> params() {
+ return F.asList(
+ new Object[] {null, null, null},
+ new Object[] {IDX, SEC_IDX, "_key_PK"});
+ }
+
/** {@inheritDoc} */
@Override protected void beforeTestsStarted() throws Exception {
Ignite crd = startGrids(4);
@@ -83,14 +108,14 @@ public class MultiTableIndexQuery extends
GridCommonAbstractTest {
/** */
@Test
public void testEmptyCache() {
- IndexQuery<Long, Person> qry = new IndexQuery<Long,
Person>(Person.class, IDX)
+ IndexQuery<Long, Person> qry = new IndexQuery<Long,
Person>(Person.class, qryPersIdx)
.setCriteria(lt("id", Integer.MAX_VALUE));
QueryCursor<Cache.Entry<Long, Person>> cursor = cache.query(qry);
assertTrue(cursor.getAll().isEmpty());
- IndexQuery<Long, SecondPerson> secQry = new IndexQuery<Long,
SecondPerson>(SecondPerson.class, SEC_IDX)
+ IndexQuery<Long, SecondPerson> secQry = new IndexQuery<Long,
SecondPerson>(SecondPerson.class, qrySecPersIdx)
.setCriteria(lt("id", Integer.MAX_VALUE));
QueryCursor<Cache.Entry<Long, SecondPerson>> secCursor =
cache.query(secQry);
@@ -106,45 +131,45 @@ public class MultiTableIndexQuery extends
GridCommonAbstractTest {
int pivot = new Random().nextInt(CNT);
// Lt.
- IndexQuery<Long, SecondPerson> secQry = new IndexQuery<Long,
SecondPerson>(SecondPerson.class, SEC_IDX)
+ IndexQuery<Long, SecondPerson> secQry = new IndexQuery<Long,
SecondPerson>(SecondPerson.class, qrySecPersIdx)
.setCriteria(lt("id", CNT + pivot));
checkSecondPerson(cache.query(secQry), CNT, CNT + pivot);
- IndexQuery<Long, Person> qry = new IndexQuery<Long,
Person>(Person.class, IDX)
+ IndexQuery<Long, Person> qry = new IndexQuery<Long,
Person>(Person.class, qryPersIdx)
.setCriteria(lt("id", pivot));
checkPerson(cache.query(qry), 0, pivot);
// Lte.
- secQry = new IndexQuery<Long, SecondPerson>(SecondPerson.class,
SEC_IDX)
+ secQry = new IndexQuery<Long, SecondPerson>(SecondPerson.class,
qrySecPersIdx)
.setCriteria(lte("id", CNT + pivot));
checkSecondPerson(cache.query(secQry), CNT, CNT + pivot + 1);
- qry = new IndexQuery<Long, Person>(Person.class, IDX)
+ qry = new IndexQuery<Long, Person>(Person.class, qryPersIdx)
.setCriteria(lte("id", pivot));
checkPerson(cache.query(qry), 0, pivot + 1);
// Gt.
- secQry = new IndexQuery<Long, SecondPerson>(SecondPerson.class,
SEC_IDX)
+ secQry = new IndexQuery<Long, SecondPerson>(SecondPerson.class,
qrySecPersIdx)
.setCriteria(gt("id", CNT + pivot));
checkSecondPerson(cache.query(secQry), CNT + pivot + 1, 2 * CNT);
- qry = new IndexQuery<Long, Person>(Person.class, IDX)
+ qry = new IndexQuery<Long, Person>(Person.class, qryPersIdx)
.setCriteria(gt("id", pivot));
checkPerson(cache.query(qry), pivot + 1, CNT);
// Gte.
- secQry = new IndexQuery<Long, SecondPerson>(SecondPerson.class,
SEC_IDX)
+ secQry = new IndexQuery<Long, SecondPerson>(SecondPerson.class,
qrySecPersIdx)
.setCriteria(gte("id", CNT + pivot));
checkSecondPerson(cache.query(secQry), CNT + pivot, 2 * CNT);
- qry = new IndexQuery<Long, Person>(Person.class, IDX)
+ qry = new IndexQuery<Long, Person>(Person.class, qryPersIdx)
.setCriteria(gte("id", pivot));
checkPerson(cache.query(qry), pivot, CNT);
@@ -158,45 +183,45 @@ public class MultiTableIndexQuery extends
GridCommonAbstractTest {
int pivot = new Random().nextInt(CNT);
// Lt.
- IndexQuery<Long, SecondPerson> secQry = new IndexQuery<Long,
SecondPerson>(SecondPerson.class, "_key_PK")
+ IndexQuery<Long, SecondPerson> secQry = new IndexQuery<Long,
SecondPerson>(SecondPerson.class, qryKeyPkIdx)
.setCriteria(lt("_KEY", (long) (CNT + pivot)));
checkSecondPerson(cache.query(secQry), CNT, CNT + pivot);
- IndexQuery<Long, Person> qry = new IndexQuery<Long,
Person>(Person.class, "_key_PK")
+ IndexQuery<Long, Person> qry = new IndexQuery<Long,
Person>(Person.class, qryKeyPkIdx)
.setCriteria(lt("_KEY", (long) pivot));
checkPerson(cache.query(qry), 0, pivot);
// Lte.
- secQry = new IndexQuery<Long, SecondPerson>(SecondPerson.class,
"_key_PK")
+ secQry = new IndexQuery<Long, SecondPerson>(SecondPerson.class,
qryKeyPkIdx)
.setCriteria(lte("_KEY", (long) (CNT + pivot)));
checkSecondPerson(cache.query(secQry), CNT, CNT + pivot + 1);
- qry = new IndexQuery<Long, Person>(Person.class, "_key_PK")
+ qry = new IndexQuery<Long, Person>(Person.class, qryKeyPkIdx)
.setCriteria(lte("_KEY", (long) pivot));
checkPerson(cache.query(qry), 0, pivot + 1);
// Gt.
- secQry = new IndexQuery<Long, SecondPerson>(SecondPerson.class,
"_key_PK")
+ secQry = new IndexQuery<Long, SecondPerson>(SecondPerson.class,
qryKeyPkIdx)
.setCriteria(gt("_KEY", (long) (CNT + pivot)));
checkSecondPerson(cache.query(secQry), CNT + pivot + 1, 2 * CNT);
- qry = new IndexQuery<Long, Person>(Person.class, "_key_PK")
+ qry = new IndexQuery<Long, Person>(Person.class, qryKeyPkIdx)
.setCriteria(gt("_KEY", (long) pivot));
checkPerson(cache.query(qry), pivot + 1, CNT);
// Gte.
- secQry = new IndexQuery<Long, SecondPerson>(SecondPerson.class,
"_key_PK")
+ secQry = new IndexQuery<Long, SecondPerson>(SecondPerson.class,
qryKeyPkIdx)
.setCriteria(gte("_KEY", (long) (CNT + pivot)));
checkSecondPerson(cache.query(secQry), CNT + pivot, 2 * CNT);
- qry = new IndexQuery<Long, Person>(Person.class, "_key_PK")
+ qry = new IndexQuery<Long, Person>(Person.class, qryKeyPkIdx)
.setCriteria(gte("_KEY", (long) pivot));
checkPerson(cache.query(qry), pivot, CNT);
diff --git
a/modules/indexing/src/test/java/org/apache/ignite/cache/query/MultifieldIndexQueryTest.java
b/modules/indexing/src/test/java/org/apache/ignite/cache/query/MultifieldIndexQueryTest.java
index 549063c..887704c 100644
---
a/modules/indexing/src/test/java/org/apache/ignite/cache/query/MultifieldIndexQueryTest.java
+++
b/modules/indexing/src/test/java/org/apache/ignite/cache/query/MultifieldIndexQueryTest.java
@@ -66,6 +66,18 @@ public class MultifieldIndexQueryTest extends
GridCommonAbstractTest {
@Parameterized.Parameter()
public int nodesCnt;
+ /** Query index, {@code null} or index name. */
+ @Parameterized.Parameter(1)
+ public String qryIdx;
+
+ /** Query desc index, {@code null} or index name. */
+ @Parameterized.Parameter(2)
+ public String qryDescIdx;
+
+ /** Query key PK index, {@code null} or index name. */
+ @Parameterized.Parameter(3)
+ public String qryKeyPKIdx;
+
/** */
private Ignite ignite;
@@ -73,14 +85,16 @@ public class MultifieldIndexQueryTest extends
GridCommonAbstractTest {
private IgniteCache<Object, Object> cache;
/** */
- @Parameterized.Parameters(name = "nodesCnt={0}")
+ @Parameterized.Parameters(name = "nodesCnt={0} qryIdx={1}")
public static Collection<Object[]> testParams() {
return Arrays.asList(
- new Object[] {1},
- new Object[] {2});
+ new Object[] {1, null, null, null},
+ new Object[] {2, null, null, null},
+ new Object[] {1, INDEX, DESC_INDEX, "_key_PK"},
+ new Object[] {2, INDEX, DESC_INDEX, "_key_PK"});
}
- /** {@inheritDoc} */
+ /** {@inheritDoc} */
@Override protected void beforeTest() throws Exception {
ignite = startGrids(nodesCnt);
@@ -113,7 +127,7 @@ public class MultifieldIndexQueryTest extends
GridCommonAbstractTest {
int pivot = new Random().nextInt(CNT);
- IndexQuery<Long, Person> qry = new IndexQuery<Long,
Person>(Person.class, "_key_PK")
+ IndexQuery<Long, Person> qry = new IndexQuery<Long,
Person>(Person.class, qryKeyPKIdx)
.setCriteria(lt("_KEY", (long) pivot));
checkPerson(cache.query(qry), 0, pivot);
@@ -122,7 +136,7 @@ public class MultifieldIndexQueryTest extends
GridCommonAbstractTest {
/** */
@Test
public void testEmptyCacheQuery() {
- IndexQuery<Long, Person> qry = new IndexQuery<Long,
Person>(Person.class, INDEX)
+ IndexQuery<Long, Person> qry = new IndexQuery<Long,
Person>(Person.class, qryIdx)
.setCriteria(lt("id", Integer.MAX_VALUE), lt("secId",
Integer.MAX_VALUE));
QueryCursor<Cache.Entry<Long, Person>> cursor = cache.query(qry);
@@ -130,7 +144,7 @@ public class MultifieldIndexQueryTest extends
GridCommonAbstractTest {
assertTrue(cursor.getAll().isEmpty());
// Check query with single column only.
- qry = new IndexQuery<Long, Person>(Person.class, INDEX)
+ qry = new IndexQuery<Long, Person>(Person.class, qryIdx)
.setCriteria(lt("id", Integer.MAX_VALUE));
assertTrue(cache.query(qry).getAll().isEmpty());
@@ -143,7 +157,7 @@ public class MultifieldIndexQueryTest extends
GridCommonAbstractTest {
cache.put(2L, new Person(1, 0));
cache.put(3L, new Person(1, 1));
- IndexQuery<Long, Person> qry = new IndexQuery<Long,
Person>(Person.class, INDEX)
+ IndexQuery<Long, Person> qry = new IndexQuery<Long,
Person>(Person.class, qryIdx)
.setCriteria(between("id", 0, 1), eq("secId", 1));
List<Cache.Entry<Long, Person>> result = cache.query(qry).getAll();
@@ -165,24 +179,24 @@ public class MultifieldIndexQueryTest extends
GridCommonAbstractTest {
insertData();
// Should return empty result for ID that less any inserted.
- IndexQuery<Long, Person> qry = new IndexQuery<Long,
Person>(Person.class, INDEX)
+ IndexQuery<Long, Person> qry = new IndexQuery<Long,
Person>(Person.class, qryIdx)
.setCriteria(lt("id", -1));
assertTrue(cache.query(qry).getAll().isEmpty());
// Should return all data for ID that greater any inserted.
- qry = new IndexQuery<Long, Person>(Person.class, INDEX)
+ qry = new IndexQuery<Long, Person>(Person.class, qryIdx)
.setCriteria(lt("id", 1));
checkPerson(cache.query(qry), 0, CNT);
// Checks the same with query for DESC_IDX.
- qry = new IndexQuery<Long, Person>(Person.class, DESC_INDEX)
+ qry = new IndexQuery<Long, Person>(Person.class, qryDescIdx)
.setCriteria(lt("id", -1));
assertTrue(cache.query(qry).getAll().isEmpty());
- qry = new IndexQuery<Long, Person>(Person.class, DESC_INDEX)
+ qry = new IndexQuery<Long, Person>(Person.class, qryDescIdx)
.setCriteria(lt("id", 1));
checkPerson(cache.query(qry), 0, CNT);
@@ -196,25 +210,25 @@ public class MultifieldIndexQueryTest extends
GridCommonAbstractTest {
int pivot = new Random().nextInt(CNT);
// Should return empty result for ID that less any inserted.
- IndexQuery<Long, Person> qry = new IndexQuery<Long,
Person>(Person.class, INDEX)
+ IndexQuery<Long, Person> qry = new IndexQuery<Long,
Person>(Person.class, qryIdx)
.setCriteria(lt("id", -1), lt("secId", pivot));
assertTrue(cache.query(qry).getAll().isEmpty());
// Should return all data for ID and SECID that greater any inserted.
- qry = new IndexQuery<Long, Person>(Person.class, INDEX)
+ qry = new IndexQuery<Long, Person>(Person.class, qryIdx)
.setCriteria(lt("id", 1), lt("secId", CNT));
checkPerson(cache.query(qry), 0, CNT);
// Should return part of data, as ID equals to inserted data ID field.
- qry = new IndexQuery<Long, Person>(Person.class, INDEX)
+ qry = new IndexQuery<Long, Person>(Person.class, qryIdx)
.setCriteria(lt("id", 0), lt("secId", pivot));
assertTrue(cache.query(qry).getAll().isEmpty());
// Should return all data for ID greater any inserted.
- qry = new IndexQuery<Long, Person>(Person.class, INDEX)
+ qry = new IndexQuery<Long, Person>(Person.class, qryIdx)
.setCriteria(lt("id", 1), lt("secId", pivot));
checkPerson(cache.query(qry), 0, pivot);
@@ -228,25 +242,25 @@ public class MultifieldIndexQueryTest extends
GridCommonAbstractTest {
int pivot = new Random().nextInt(CNT);
// Should return empty result for ID that less any inserted.
- IndexQuery<Long, Person> qry = new IndexQuery<Long,
Person>(Person.class, INDEX)
+ IndexQuery<Long, Person> qry = new IndexQuery<Long,
Person>(Person.class, qryIdx)
.setCriteria(lt("secId", pivot), lt("id", -1));
assertTrue(cache.query(qry).getAll().isEmpty());
// Should return all data for ID and SECID that greater any inserted.
- qry = new IndexQuery<Long, Person>(Person.class, INDEX)
+ qry = new IndexQuery<Long, Person>(Person.class, qryIdx)
.setCriteria(lt("secId", CNT), lt("id", 1));
checkPerson(cache.query(qry), 0, CNT);
// Should return part of data, as ID equals to inserted data ID field.
- qry = new IndexQuery<Long, Person>(Person.class, INDEX)
+ qry = new IndexQuery<Long, Person>(Person.class, qryIdx)
.setCriteria(lt("secId", pivot), lt("id", 0));
assertTrue(cache.query(qry).getAll().isEmpty());
// Should return all data for ID greater any inserted.
- qry = new IndexQuery<Long, Person>(Person.class, INDEX)
+ qry = new IndexQuery<Long, Person>(Person.class, qryIdx)
.setCriteria(lt("secId", pivot), lt("id", 1));
checkPerson(cache.query(qry), 0, pivot);
@@ -260,22 +274,22 @@ public class MultifieldIndexQueryTest extends
GridCommonAbstractTest {
int pivot = new Random().nextInt(CNT);
// Eq as first criterion.
- IndexQuery<Long, Person> qry = new IndexQuery<Long,
Person>(Person.class, INDEX)
+ IndexQuery<Long, Person> qry = new IndexQuery<Long,
Person>(Person.class, qryIdx)
.setCriteria(eq("id", 1), lt("secId", pivot));
assertTrue(cache.query(qry).getAll().isEmpty());
- qry = new IndexQuery<Long, Person>(Person.class, INDEX)
+ qry = new IndexQuery<Long, Person>(Person.class, qryIdx)
.setCriteria(eq("id", 0), lte("secId", pivot));
checkPerson(cache.query(qry), 0, pivot + 1);
- qry = new IndexQuery<Long, Person>(Person.class, INDEX)
+ qry = new IndexQuery<Long, Person>(Person.class, qryIdx)
.setCriteria(eq("id", 0), gt("secId", pivot));
checkPerson(cache.query(qry), pivot + 1, CNT);
- qry = new IndexQuery<Long, Person>(Person.class, INDEX)
+ qry = new IndexQuery<Long, Person>(Person.class, qryIdx)
.setCriteria(eq("id", 0), gte("secId", pivot));
checkPerson(cache.query(qry), pivot, CNT);
@@ -283,97 +297,97 @@ public class MultifieldIndexQueryTest extends
GridCommonAbstractTest {
int lower = new Random().nextInt(CNT / 2);
int upper = lower + new Random().nextInt(CNT / 2);
- qry = new IndexQuery<Long, Person>(Person.class, INDEX)
+ qry = new IndexQuery<Long, Person>(Person.class, qryIdx)
.setCriteria(eq("id", 0), between("secId", lower, upper));
checkPerson(cache.query(qry), lower, upper + 1);
// Lt as first criterion.
- qry = new IndexQuery<Long, Person>(Person.class, INDEX)
+ qry = new IndexQuery<Long, Person>(Person.class, qryIdx)
.setCriteria(lt("id", 1), lte("secId", pivot));
checkPerson(cache.query(qry), 0, pivot + 1);
- qry = new IndexQuery<Long, Person>(Person.class, INDEX)
+ qry = new IndexQuery<Long, Person>(Person.class, qryIdx)
.setCriteria(lt("id", 1), eq("secId", pivot));
checkPerson(cache.query(qry), pivot, pivot + 1);
- qry = new IndexQuery<Long, Person>(Person.class, INDEX)
+ qry = new IndexQuery<Long, Person>(Person.class, qryIdx)
.setCriteria(lt("id", 1), between("secId", lower, upper));
checkPerson(cache.query(qry), lower, upper + 1);
// Lte as first criterion.
- qry = new IndexQuery<Long, Person>(Person.class, INDEX)
+ qry = new IndexQuery<Long, Person>(Person.class, qryIdx)
.setCriteria(lte("id", 0), lt("secId", pivot));
checkPerson(cache.query(qry), 0, pivot);
- qry = new IndexQuery<Long, Person>(Person.class, INDEX)
+ qry = new IndexQuery<Long, Person>(Person.class, qryIdx)
.setCriteria(lte("id", 1), between("secId", lower, upper));
checkPerson(cache.query(qry), lower, upper + 1);
- qry = new IndexQuery<Long, Person>(Person.class, INDEX)
+ qry = new IndexQuery<Long, Person>(Person.class, qryIdx)
.setCriteria(lte("id", 0), eq("secId", pivot));
checkPerson(cache.query(qry), pivot, pivot + 1);
// Gt as first criterion.
- qry = new IndexQuery<Long, Person>(Person.class, INDEX)
+ qry = new IndexQuery<Long, Person>(Person.class, qryIdx)
.setCriteria(gt("id", -1), gte("secId", pivot));
checkPerson(cache.query(qry), pivot, CNT);
- qry = new IndexQuery<Long, Person>(Person.class, INDEX)
+ qry = new IndexQuery<Long, Person>(Person.class, qryIdx)
.setCriteria(gt("id", -1), eq("secId", pivot));
checkPerson(cache.query(qry), pivot, pivot + 1);
- qry = new IndexQuery<Long, Person>(Person.class, INDEX)
+ qry = new IndexQuery<Long, Person>(Person.class, qryIdx)
.setCriteria(gt("id", -1), between("secId", lower, upper));
checkPerson(cache.query(qry), lower, upper + 1);
// Gte as first criterion.
- qry = new IndexQuery<Long, Person>(Person.class, INDEX)
+ qry = new IndexQuery<Long, Person>(Person.class, qryIdx)
.setCriteria(gte("id", 0), gt("secId", pivot));
checkPerson(cache.query(qry), pivot + 1, CNT);
- qry = new IndexQuery<Long, Person>(Person.class, INDEX)
+ qry = new IndexQuery<Long, Person>(Person.class, qryIdx)
.setCriteria(gte("id", 0), between("secId", lower, upper));
checkPerson(cache.query(qry), lower, upper + 1);
- qry = new IndexQuery<Long, Person>(Person.class, INDEX)
+ qry = new IndexQuery<Long, Person>(Person.class, qryIdx)
.setCriteria(gte("id", 0), eq("secId", pivot));
checkPerson(cache.query(qry), pivot, pivot + 1);
// Between as first criterion.
- qry = new IndexQuery<Long, Person>(Person.class, INDEX)
+ qry = new IndexQuery<Long, Person>(Person.class, qryIdx)
.setCriteria(between("id", -1, 1), lt("secId", pivot));
checkPerson(cache.query(qry), 0, pivot);
- qry = new IndexQuery<Long, Person>(Person.class, INDEX)
+ qry = new IndexQuery<Long, Person>(Person.class, qryIdx)
.setCriteria(between("id", -1, 1), lte("secId", pivot));
checkPerson(cache.query(qry), 0, pivot + 1);
- qry = new IndexQuery<Long, Person>(Person.class, INDEX)
+ qry = new IndexQuery<Long, Person>(Person.class, qryIdx)
.setCriteria(between("id", -1, 1), gt("secId", pivot));
checkPerson(cache.query(qry), pivot + 1, CNT);
- qry = new IndexQuery<Long, Person>(Person.class, INDEX)
+ qry = new IndexQuery<Long, Person>(Person.class, qryIdx)
.setCriteria(between("id", -1, 1), gte("secId", pivot));
checkPerson(cache.query(qry), pivot, CNT);
- qry = new IndexQuery<Long, Person>(Person.class, INDEX)
+ qry = new IndexQuery<Long, Person>(Person.class, qryIdx)
.setCriteria(between("id", -1, 1), eq("secId", pivot));
checkPerson(cache.query(qry), pivot, pivot + 1);
@@ -389,121 +403,121 @@ public class MultifieldIndexQueryTest extends
GridCommonAbstractTest {
int upper = lower + new Random().nextInt(CNT / 2);
// Eq as first criteria.
- IndexQuery<Long, Person> qry = new IndexQuery<Long,
Person>(Person.class, DESC_INDEX)
+ IndexQuery<Long, Person> qry = new IndexQuery<Long,
Person>(Person.class, qryDescIdx)
.setCriteria(eq("id", 1), lt("descId", pivot));
assertTrue(cache.query(qry).getAll().isEmpty());
- qry = new IndexQuery<Long, Person>(Person.class, DESC_INDEX)
+ qry = new IndexQuery<Long, Person>(Person.class, qryDescIdx)
.setCriteria(eq("id", 0), lt("descId", pivot));
checkPerson(cache.query(qry), 0, pivot);
- qry = new IndexQuery<Long, Person>(Person.class, DESC_INDEX)
+ qry = new IndexQuery<Long, Person>(Person.class, qryDescIdx)
.setCriteria(eq("id", 0), lte("descId", pivot));
checkPerson(cache.query(qry), 0, pivot + 1);
- qry = new IndexQuery<Long, Person>(Person.class, DESC_INDEX)
+ qry = new IndexQuery<Long, Person>(Person.class, qryDescIdx)
.setCriteria(eq("id", 0), gt("descId", pivot));
checkPerson(cache.query(qry), pivot + 1, CNT);
- qry = new IndexQuery<Long, Person>(Person.class, DESC_INDEX)
+ qry = new IndexQuery<Long, Person>(Person.class, qryDescIdx)
.setCriteria(eq("id", 0), gte("descId", pivot));
checkPerson(cache.query(qry), pivot, CNT);
- qry = new IndexQuery<Long, Person>(Person.class, DESC_INDEX)
+ qry = new IndexQuery<Long, Person>(Person.class, qryDescIdx)
.setCriteria(eq("id", 0), between("descId", lower, upper));
checkPerson(cache.query(qry), lower, upper + 1);
// Lt as first criteria.
- qry = new IndexQuery<Long, Person>(Person.class, DESC_INDEX)
+ qry = new IndexQuery<Long, Person>(Person.class, qryDescIdx)
.setCriteria(lt("id", 1), gt("descId", pivot));
checkPerson(cache.query(qry), pivot + 1, CNT);
- qry = new IndexQuery<Long, Person>(Person.class, DESC_INDEX)
+ qry = new IndexQuery<Long, Person>(Person.class, qryDescIdx)
.setCriteria(lt("id", 1), gte("descId", pivot));
checkPerson(cache.query(qry), pivot, CNT);
- qry = new IndexQuery<Long, Person>(Person.class, DESC_INDEX)
+ qry = new IndexQuery<Long, Person>(Person.class, qryDescIdx)
.setCriteria(lt("id", 1), between("descId", lower, upper));
checkPerson(cache.query(qry), lower, upper + 1);
- qry = new IndexQuery<Long, Person>(Person.class, DESC_INDEX)
+ qry = new IndexQuery<Long, Person>(Person.class, qryDescIdx)
.setCriteria(lt("id", 1), eq("descId", pivot));
checkPerson(cache.query(qry), pivot, pivot + 1);
// Lte as first criteria.
- qry = new IndexQuery<Long, Person>(Person.class, DESC_INDEX)
+ qry = new IndexQuery<Long, Person>(Person.class, qryDescIdx)
.setCriteria(lte("id", 0), gt("descId", pivot));
checkPerson(cache.query(qry), pivot + 1, CNT);
- qry = new IndexQuery<Long, Person>(Person.class, DESC_INDEX)
+ qry = new IndexQuery<Long, Person>(Person.class, qryDescIdx)
.setCriteria(lte("id", 0), gte("descId", pivot));
checkPerson(cache.query(qry), pivot, CNT);
- qry = new IndexQuery<Long, Person>(Person.class, DESC_INDEX)
+ qry = new IndexQuery<Long, Person>(Person.class, qryDescIdx)
.setCriteria(lte("id", 0), between("descId", lower, upper));
checkPerson(cache.query(qry), lower, upper + 1);
- qry = new IndexQuery<Long, Person>(Person.class, DESC_INDEX)
+ qry = new IndexQuery<Long, Person>(Person.class, qryDescIdx)
.setCriteria(lte("id", 0), eq("descId", pivot));
checkPerson(cache.query(qry), pivot, pivot + 1);
// Gte as first criteria.
- qry = new IndexQuery<Long, Person>(Person.class, DESC_INDEX)
+ qry = new IndexQuery<Long, Person>(Person.class, qryDescIdx)
.setCriteria(gte("id", 0), lt("descId", pivot));
checkPerson(cache.query(qry), 0, pivot);
- qry = new IndexQuery<Long, Person>(Person.class, DESC_INDEX)
+ qry = new IndexQuery<Long, Person>(Person.class, qryDescIdx)
.setCriteria(gte("id", 0), lte("descId", pivot));
checkPerson(cache.query(qry), 0, pivot + 1);
- qry = new IndexQuery<Long, Person>(Person.class, DESC_INDEX)
+ qry = new IndexQuery<Long, Person>(Person.class, qryDescIdx)
.setCriteria(gte("id", 0), between("descId", lower, upper));
checkPerson(cache.query(qry), lower, upper + 1);
- qry = new IndexQuery<Long, Person>(Person.class, DESC_INDEX)
+ qry = new IndexQuery<Long, Person>(Person.class, qryDescIdx)
.setCriteria(gte("id", 0), eq("descId", pivot));
checkPerson(cache.query(qry), pivot, pivot + 1);
// Between as first criteria.
- qry = new IndexQuery<Long, Person>(Person.class, DESC_INDEX)
+ qry = new IndexQuery<Long, Person>(Person.class, qryDescIdx)
.setCriteria(between("id", -1, 1), lt("descId", pivot));
checkPerson(cache.query(qry), 0, pivot);
- qry = new IndexQuery<Long, Person>(Person.class, DESC_INDEX)
+ qry = new IndexQuery<Long, Person>(Person.class, qryDescIdx)
.setCriteria(between("id", -1, 1), lte("descId", pivot));
checkPerson(cache.query(qry), 0, pivot + 1);
- qry = new IndexQuery<Long, Person>(Person.class, DESC_INDEX)
+ qry = new IndexQuery<Long, Person>(Person.class, qryDescIdx)
.setCriteria(between("id", -1, 1), gt("descId", pivot));
checkPerson(cache.query(qry), pivot + 1, CNT);
- qry = new IndexQuery<Long, Person>(Person.class, DESC_INDEX)
+ qry = new IndexQuery<Long, Person>(Person.class, qryDescIdx)
.setCriteria(between("id", -1, 1), gte("descId", pivot));
checkPerson(cache.query(qry), pivot, CNT);
- qry = new IndexQuery<Long, Person>(Person.class, DESC_INDEX)
+ qry = new IndexQuery<Long, Person>(Person.class, qryDescIdx)
.setCriteria(between("id", -1, 1), eq("descId", pivot));
checkPerson(cache.query(qry), pivot, pivot + 1);
@@ -516,22 +530,22 @@ public class MultifieldIndexQueryTest extends
GridCommonAbstractTest {
int pivot = new Random().nextInt(CNT);
- IndexQuery<Long, Person> qry = new IndexQuery<Long,
Person>(Person.class, INDEX)
+ IndexQuery<Long, Person> qry = new IndexQuery<Long,
Person>(Person.class, qryIdx)
.setCriteria(lt("id", 1), gt("secId", pivot));
checkPerson(cache.query(qry), pivot + 1, CNT);
- qry = new IndexQuery<Long, Person>(Person.class, INDEX)
+ qry = new IndexQuery<Long, Person>(Person.class, qryIdx)
.setCriteria(lt("id", 1), gte("secId", pivot));
checkPerson(cache.query(qry), pivot, CNT);
- qry = new IndexQuery<Long, Person>(Person.class, INDEX)
+ qry = new IndexQuery<Long, Person>(Person.class, qryIdx)
.setCriteria(gt("id", 2), lt("secId", pivot));
assertTrue(cache.query(qry).getAll().isEmpty());
- qry = new IndexQuery<Long, Person>(Person.class, INDEX)
+ qry = new IndexQuery<Long, Person>(Person.class, qryIdx)
.setCriteria(gt("id", 2), eq("secId", pivot));
assertTrue(cache.query(qry).getAll().isEmpty());
@@ -543,7 +557,7 @@ public class MultifieldIndexQueryTest extends
GridCommonAbstractTest {
insertData();
// Use long boundary instead of int.
- IndexQuery<Long, Person> qry = new IndexQuery<Long,
Person>(Person.class, INDEX)
+ IndexQuery<Long, Person> qry = new IndexQuery<Long,
Person>(Person.class, qryIdx)
.setCriteria(lt("id", (long) 0));
GridTestUtils.assertThrows(null,
@@ -560,7 +574,7 @@ public class MultifieldIndexQueryTest extends
GridCommonAbstractTest {
int pivot = new Random().nextInt(CNT);
- IndexQuery<Long, Person> qry = new IndexQuery<Long,
Person>(Person.class, INDEX)
+ IndexQuery<Long, Person> qry = new IndexQuery<Long,
Person>(Person.class, qryIdx)
.setCriteria(eq("id", 0), lt("secId", pivot), lt("_KEY", (long)
pivot));
checkPerson(cache.query(qry), 0, pivot);