[ https://issues.apache.org/jira/browse/GEODE-2002?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Hitesh Khamesra closed GEODE-2002. ---------------------------------- > The index is not used on a query with a where clause containing a > parameterized key on a map > -------------------------------------------------------------------------------------------- > > Key: GEODE-2002 > URL: https://issues.apache.org/jira/browse/GEODE-2002 > Project: Geode > Issue Type: Bug > Components: querying > Reporter: Barry Oglesby > Fix For: 1.1.0 > > > This is the same as GEM-1026. > If an index is defined like: > {noformat} > <index name="instrumentTLAltIdIndex" from-clause="/instrument i, > i.tradingLines tl" expression="tl.alternateReferences['SEDOL', > 'INHOUSE_SEDOL']"/> > {noformat} > And a query is defined like: > {noformat} > <trace> select i from from /instrument i, i.tradingLines t where > t.alternateReferences[$1]='BFNY8K9' with bind parameter 'SEDOL'. > {noformat} > Then, the {{instrumentTLAltIdIndex}} index won't be used when the query is > executed. > The message logged in the server log looks like (with {{indexesUsed(0)}} > instead of {{indexesUsed(1)}}): > {noformat} > [info 2016/10/14 14:51:03.069 PDT <ServerConnection on port 57074 Thread 2> > tid=0x3e] Query Executed in 3.645424 ms; rowCount = 14; indexesUsed(0) > "<trace> select i from /instrument i, i.tradingLines t where > t.alternateReferences[$1]='BFNY8K9'" > {noformat} > The {{CompiledIndexOperation generateCanonicalizedExpression}} method returns > {{index_iter2.alternateReferences\[$1\]}} instead of > {{index_iter2.alternateReferences\['INHOUSE_SEDOL'\]}}, and the > {{AbstractMapIndex isMatchingWithIndexExpression}} method fails to match the > index. > The {{$1}} is generated by CompiledBindArgument > generateCanonicalizedExpression. > Also, note that the trace logging is incorrect on any query using a map index. > The static query is defined like: > {noformat} > <trace> select i from from /instrument i, i.tradingLines t where > t.alternateReferences['SEDOL']='BFNY8K9' > {noformat} > This logs a message in the server log like: > {noformat} > [info 2016/10/14 14:29:58.145 PDT <ServerConnection on port 56969 Thread 1> > tid=0x3c] Query Executed in 54.36587 ms; rowCount = 16; > indexesUsed(1):instrumentTLAltIdIndex-SEDOL(Results: 0) "<trace> select i > from /instrument i, i.tradingLines t where > t.alternateReferences['SEDOL']='BFNY8K9'" > {noformat} > The {{Results: 0}} part of the message is wrong. It should be {{Results: 16}}. > The {{IndexTrackingQueryObserver beforeIndexLookup}} method saves the > {{IndexInfo}} at {{key=instrumentTLAltIdIndex-SEDOL}}, but the > {{afterIndexLookup}} method attempts to retrieve it using > {{key=instrumentTLAltIdIndex}}. The {{IndexInfo}} is not found, so its > results are not updated. -- This message was sent by Atlassian JIRA (v6.3.15#6346)