geode-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF subversion and git services (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (GEODE-3708) Use of 3 iterators resulted in redundant entries to be present in the result of two joins conditions separated by an OR
Date Wed, 18 Oct 2017 21:18:00 GMT

    [ https://issues.apache.org/jira/browse/GEODE-3708?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16210060#comment-16210060
] 

ASF subversion and git services commented on GEODE-3708:
--------------------------------------------------------

Commit 2e710e5d8ab11695c12f381f107398f2122f43ec in geode's branch refs/heads/develop from
[~nnag]
[ https://gitbox.apache.org/repos/asf?p=geode.git;h=2e710e5 ]

GEODE-3708: Added a separate iterator for MemoryIndexStore which doesn't iterate over the
values in the Map.

	* The new iterator MemoryIndexStoreKeyIterator will only iterate over the keys
	* This is different from the previous iterator which iterates over the values too and sending
out IndexStoreEntry pairs of the key and iterated value entry
	* This resulted in duplicate results in join queries with OR clause as the same key was being
repeatedly sent if the value associated with the key is a collection.


> 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
>
> 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)

Mime
View raw message