You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by GitBox <gi...@apache.org> on 2021/09/14 09:27:27 UTC
[GitHub] [ignite] timoninmaxim opened a new pull request #9407: IGNITE-15391 Add support for creating IndexQuery without index name
timoninmaxim opened a new pull request #9407:
URL: https://github.com/apache/ignite/pull/9407
Thank you for submitting the pull request to the Apache Ignite.
In order to streamline the review of the contribution
we ask you to ensure the following steps have been taken:
### The Contribution Checklist
- [ ] There is a single JIRA ticket related to the pull request.
- [ ] The web-link to the pull request is attached to the JIRA ticket.
- [ ] The JIRA ticket has the _Patch Available_ state.
- [ ] The pull request body describes changes that have been made.
The description explains _WHAT_ and _WHY_ was made instead of _HOW_.
- [ ] The pull request title is treated as the final commit message.
The following pattern must be used: `IGNITE-XXXX Change summary` where `XXXX` - number of JIRA issue.
- [ ] A reviewer has been mentioned through the JIRA comments
(see [the Maintainers list](https://cwiki.apache.org/confluence/display/IGNITE/How+to+Contribute#HowtoContribute-ReviewProcessandMaintainers))
- [ ] The pull request has been checked by the Teamcity Bot and
the `green visa` attached to the JIRA ticket (see [TC.Bot: Check PR](https://mtcga.gridgain.com/prs.html))
### Notes
- [How to Contribute](https://cwiki.apache.org/confluence/display/IGNITE/How+to+Contribute)
- [Coding abbreviation rules](https://cwiki.apache.org/confluence/display/IGNITE/Abbreviation+Rules)
- [Coding Guidelines](https://cwiki.apache.org/confluence/display/IGNITE/Coding+Guidelines)
- [Apache Ignite Teamcity Bot](https://cwiki.apache.org/confluence/display/IGNITE/Apache+Ignite+Teamcity+Bot)
If you need any help, please email dev@ignite.apache.org or ask anу advice on http://asf.slack.com _#ignite_ channel.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [ignite] anton-vinogradov merged pull request #9407: IGNITE-15391 Add support for creating IndexQuery without index name
Posted by GitBox <gi...@apache.org>.
anton-vinogradov merged pull request #9407:
URL: https://github.com/apache/ignite/pull/9407
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [ignite] timoninmaxim commented on a change in pull request #9407: IGNITE-15391 Add support for creating IndexQuery without index name
Posted by GitBox <gi...@apache.org>.
timoninmaxim commented on a change in pull request #9407:
URL: https://github.com/apache/ignite/pull/9407#discussion_r715564925
##########
File path: modules/indexing/src/test/java/org/apache/ignite/cache/query/IndexQueryRangeTest.java
##########
@@ -253,8 +253,8 @@ public void checkRangeQueries() {
/** */
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));
Review comment:
This is a misprint in test. The method tests DESC_IDX, but before this change it checks IDX instead. So I fix this mistake
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [ignite] anton-vinogradov commented on a change in pull request #9407: IGNITE-15391 Add support for creating IndexQuery without index name
Posted by GitBox <gi...@apache.org>.
anton-vinogradov commented on a change in pull request #9407:
URL: https://github.com/apache/ignite/pull/9407#discussion_r714954416
##########
File path: modules/indexing/src/test/java/org/apache/ignite/cache/query/IndexQueryAliasTest.java
##########
@@ -53,6 +56,23 @@
/** */
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}")
Review comment:
looks like the second param is also important :)
##########
File path: modules/core/src/main/java/org/apache/ignite/internal/cache/query/index/IndexQueryProcessor.java
##########
@@ -148,6 +161,55 @@ private Index indexByName(GridCacheContext<?, ?> cctx, IndexQueryDesc idxQryDesc
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 i: idxs) {
Review comment:
idx
##########
File path: modules/indexing/src/test/java/org/apache/ignite/cache/query/IndexQueryQueryEntityTest.java
##########
@@ -61,6 +62,23 @@
/** */
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}")
Review comment:
looks like the second param is also important :)
##########
File path: modules/indexing/src/test/java/org/apache/ignite/cache/query/IndexQueryQueryEntityTest.java
##########
@@ -113,44 +131,46 @@
/** */
@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));
+ if (qryIdx != null) {
Review comment:
any reason for this `if`?
##########
File path: modules/indexing/src/test/java/org/apache/ignite/cache/query/IndexQuerySqlIndexTest.java
##########
@@ -57,6 +62,16 @@
/** */
private static final int CNT = 10_000;
+ /** Query index, {@code null} of index name. */
+ @Parameterized.Parameter()
+ public String qryIdxName;
Review comment:
should this be qryDescIdx?
##########
File path: modules/indexing/src/test/java/org/apache/ignite/cache/query/IndexQueryRangeTest.java
##########
@@ -253,8 +253,8 @@ public void checkRangeQueries() {
/** */
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));
Review comment:
any reason for this change?
##########
File path: modules/indexing/src/test/java/org/apache/ignite/cache/query/IndexQueryQueryEntityTest.java
##########
@@ -38,6 +38,7 @@
import org.apache.ignite.testframework.GridTestUtils;
import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
import org.junit.Test;
+import org.junit.runners.Parameterized;
Review comment:
@RunWith(Parameterized.class) missed
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [ignite] timoninmaxim commented on a change in pull request #9407: IGNITE-15391 Add support for creating IndexQuery without index name
Posted by GitBox <gi...@apache.org>.
timoninmaxim commented on a change in pull request #9407:
URL: https://github.com/apache/ignite/pull/9407#discussion_r715564366
##########
File path: modules/indexing/src/test/java/org/apache/ignite/cache/query/IndexQueryQueryEntityTest.java
##########
@@ -113,44 +131,46 @@
/** */
@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));
+ if (qryIdx != null) {
Review comment:
This test checks if index name is specified (DESC_IDX) and wrong field (id) is provided and Ignite will not start a query on wrong index. If `idxName == null` Ignite will find a correct index by field (IDX), and exception will not be thrown
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [ignite] anton-vinogradov commented on a change in pull request #9407: IGNITE-15391 Add support for creating IndexQuery without index name
Posted by GitBox <gi...@apache.org>.
anton-vinogradov commented on a change in pull request #9407:
URL: https://github.com/apache/ignite/pull/9407#discussion_r716637066
##########
File path: modules/indexing/src/test/java/org/apache/ignite/cache/query/IndexQueryQueryEntityTest.java
##########
@@ -113,44 +131,46 @@
/** */
@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));
+ if (qryIdx != null) {
Review comment:
It works like a charm after `if` removal :)
Could you recheck this?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org