You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@geode.apache.org by "nabarun (JIRA)" <ji...@apache.org> on 2017/10/20 18:22:00 UTC
[jira] [Resolved] (GEODE-3708) Use of 3 iterators resulted in
redundant entries to be present in the result of two joins conditions
separated by an OR
[ https://issues.apache.org/jira/browse/GEODE-3708?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
nabarun resolved GEODE-3708.
----------------------------
Resolution: Fixed
Fix Version/s: 1.4.0
> Use of 3 iterators resulted in redundant entries to be present in the result of two joins conditions separated by an OR
> -----------------------------------------------------------------------------------------------------------------------
>
> Key: GEODE-3708
> URL: https://issues.apache.org/jira/browse/GEODE-3708
> Project: Geode
> Issue Type: Bug
> Components: querying
> Affects Versions: 1.3.0
> Reporter: nabarun
> Fix For: 1.4.0
>
>
> Code fix hint : in method queryEquijoinCondition we end up using the same iterator again while calling populateListForEquiJoin. We should clean up populateListForEquiJoin to not use that iterator again.
> Acceptance : The below test case must pass. The result size is verified to be 22 and should be same with and with indexes.
> {code: title = }
> @Category(IntegrationTest.class)
> @RunWith(JUnitParamsRunner.class)
> public class JoinQueriesIntegrationTest {
> public static class Customer implements Serializable {
> public int pkid;
> public int id;
> public int joinId;
> public String name;
> public Customer(int pkid, int id) {
> this.pkid = pkid;
> this.id = id;
> this.joinId = id;
> this.name = "name" + pkid;
> }
> public Customer(int pkid, int id, int joinId) {
> this.pkid = pkid;
> this.id = id;
> this.joinId = joinId;
> this.name = "name" + pkid;
> }
> public String toString() {
> return "Customer pkid = " + pkid + ", id: " + id + " name:" + name + " joinId: " + joinId;
> }
> }
> private static Object[] getQueryStrings() {
> return new Object[] {
> new Object[] {"<trace>select STA.id as STACID, STA.pkid as STAacctNum, STC.id as STCCID, STC.pkid as STCacctNum from /region1 STA, /region2 STC where STA.pkid = 1 AND STA.joinId = STC.joinId OR STA.id = STC.id", 22}
> };
> }
> @Test
> @Parameters(method = "getQueryStrings")
> public void testJoinTwoRegions(String queryString, int expectedResultSize) throws Exception {
> Cache cache = CacheUtils.getCache();
> try {
> Region region1 =
> cache.createRegionFactory().setDataPolicy(DataPolicy.REPLICATE).create("region1");
> Region region2 =
> cache.createRegionFactory().setDataPolicy(DataPolicy.REPLICATE).create("region2");
> populateRegionWithData(region1, region2);
> QueryService queryService = cache.getQueryService();
> SelectResults results = (SelectResults) queryService.newQuery(queryString).execute();
> int resultsWithoutIndex = results.size();
> assertEquals(expectedResultSize, resultsWithoutIndex);
> queryService.createIndex("pkidregion1", "p.pkid", "/region1 p");
> queryService.createIndex("pkidregion2", "p.pkid", "/region2 p");
> queryService.createIndex("indexIDRegion2", "p.id", "/region2 p");
> queryService.createIndex("indexIDRegion1", "p.id", "/region1 p");
> queryService.createIndex("joinIdregion1", "p.joinId", "/region1 p");
> queryService.createIndex("joinIdregion2", "p.joinId", "/region2 p");
> queryService.createIndex("nameIndex", "p.name", "/region2 p");
> results = (SelectResults) queryService.newQuery(queryString).execute();
> int resultsSizeWithIndex = results.size();
> assertEquals(expectedResultSize, resultsWithoutIndex);
> assertEquals(resultsSizeWithIndex, resultsWithoutIndex);
> } finally {
> cache.getRegion("region1").destroyRegion();
> cache.getRegion("region2").destroyRegion();
> }
> }
> private void populateRegionWithData(Region region1, Region region2) {
> for (int i = 1; i < 11; i++) {
> if (i == 1 || i == 3 || i == 8 || i == 2 || i == 5) {
> region1.put(i, new Customer(1, 1, 1));
> } else {
> region1.put(i, new Customer(i, i, i));
> }
> if (i == 1 || i == 4 || i == 7 || i == 10) {
> region2.put(i, new Customer(1, 1, 1));
> } else {
> region2.put(i, new Customer(i % 5, i, i % 3));
> }
> }
> }
> }
> {code}
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)