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

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

Commit 884d399d58912864d36161e06a47c8d8af93a641 in geode's branch 
refs/heads/develop from Alberto Gomez
[ https://gitbox.apache.org/repos/asf?p=geode.git;h=884d399 ]

GEODE-9004: Align results of queries with and without map indexes (#6279)

* GEODE-9004: Align results of queries with and without map indexes

Queries in which map fields are involved
in the condition, sometimes do not return the same entries
if map indexes are used, compared to when map indexes
are not used.

Differences were found when the condition on the
map field was of type '!=' and also when the condition
on the map field was comparing the value with null.

Example1:
Running a query with the following condition:
positions['SUN'] = null

in a region with the following entries:
entry1.positions=null
entry2.positions={'a'=>'b'}
entry3.positions={'SUN'=>null}

- will return entry1 and entry3 if there are no
  indexes defined.
- will return no entries if the following index is defined:
  positions['SUN','c']
- will return entry3 if the following index is defined:
  positions[*]

Example2:
Running a query with the following condition:
positions['SUN'] != '3'

in a region with the following entries:
entry1.positions=null
entry2.positions={'a'=>'b'}
entry3.positions={'SUN'=>'4'}
entry4.positions={'SUN'=>'3'}
entry5.positions={'SUN'=>null}

- will return all entries except for entry4 if:
  there are no indexes defined.
- will return entry3 if the following index is defined:
  positions['SUN','c']
- will return entry3 and entry5 if the following index is defined:
  positions[*]

In order to have the same results for these
queries no matter if indexes are used,
the following changes have been made:

- When using compact map indexes or map indexes
an index entry will be created for every entry
added to the region even if the entry does not
contain the indexed map (the map is null) or
it does not contain any of the indexed keys.
The above will not apply to indexes of type
"allkeys" (e.g. positions[*]).

- As a consequence of the statement above
about indexes of type "allkeys", when the index
configured is of "allkeys" type and the query
is of type "!=" (e.g. positions['SUN'] != "3"
or the query is comparing against a null value
(e.g. positions['SUN'] = null) the index will
not be used.
This is a limitation of this solution
as allowing the index to be used in this case
would require bigger and more complex changes that
have not been considered in this solution.

* GEODE-9004: Fix stats for number of keys in compact map indexes

* GEODE-9004: Fix failing test cases polluted by other test cases changing a 
System Property

* GEODE-9004: Changes after review and some refactorings

* GEODE-9004: Add documentation changes

* GEODE-9004: Small change in doc. after review

> Issues with queries targeting a map field
> -----------------------------------------
>
>                 Key: GEODE-9004
>                 URL: https://issues.apache.org/jira/browse/GEODE-9004
>             Project: Geode
>          Issue Type: Bug
>          Components: querying
>            Reporter: Alberto Gomez
>            Assignee: Alberto Gomez
>            Priority: Major
>              Labels: pull-request-available
>
> When defining indexes on a map field several issues have been found:
>  * If the index is defined for one specific key in the map, e.g. 
> positions['SUN'], then an index entry is created for every entry, no matter 
> if the entry contains the 'SUN' key in its map or not. This makes the index 
> take a lot of memory (unnecessarily?).
>  * If the index is specified for more than one key in the map or for all 
> ('*'), then queries in which the "where" contains a != condition for the map, 
> e.g. "p.positions['SUN'] != '3'" return less values than those returned when 
> the query is run without the index.
>  * If the index is specified for more than one key in the map or for all 
> ('*'), then queries in which the "where" contains a "= null" condition for 
> the map, e.g. "p.positions['SUN'] = null" return less values than those 
> returned when the query is run without the index.
>  * If the index is defined for one specific key in the map, e.g. 
> positions['SUN'], queries in which the "where" contains a "!=" condition for 
> the map or a " = null" condition sometimes return less values than those 
> returned when the query is run without the index.
> Apart from the above, looking at the indexes documentation, it seems that Map 
> indexes are only those indexes for which more than one key or '*' is 
> specified for the Map. But if just one key is specified for the Map in the 
> index, then the index is not a Map index but a range index. This should be 
> clarified.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to