Post

3 followers Follow
0
Avatar

Using index on a Set field

I cannot force an index to work on a HashSet field.

Using GemFire version: Pivotal_GemFire_820_b17919_Linux

I have a region /targets with the following entities:
public class Target {
...
private HashSet<Long> groupMembers;
...
}

I have created the following index:
create index --name=idx_groupMembers --expression=m --region='/targets t, t.groupMembers m'

gfsh>list indexes
Member Name | Member ID | Region Path | Name | Type | Indexed Expression | From Clause
------------------------ | --------------------------------------------------- | ------------- | ------------------ | ----- | ------------------ | ----------------------------
...-server-1-14548 | ...( ...-server-1-14548:21627)<v1>:33651 | /targets | idx_groupMembers | RANGE | m | /targets t, t.groupMembers m

But for some reason it is not used in the following query:
gfsh>query --query="<trace> SELECT DISTINCT * FROM /targets t WHERE 111111 IN t.groupMembers"

Result : true
startCount : 0
endCount : 20
Rows : 1
Query Trace : Query Executed in 0.45673 ms; indexesUsed(0)

id | operatorId | type | prefLanguage | roamingRestricted | holidayRestricted | weekendRestricted | enabled | typeID | externalId | tag | groupMembers | groupOwners | groupIds | groupTags | allowedNotifyOwnerList | properties
------ | ---------- | ---- | ------------ | ----------------- | ----------------- | ----------------- | ------- | ------ | ---------- | ---- | ----------------------- | ----------------------- | ----------------------- | ----------------------- | ----------------------- | -----------------------
111110 | 0 | 1 | 0 | false | false | false | true | 9 | sub1 | sub1 | class java.util.HashSet | class java.util.HashSet | class java.util.HashSet | class java.util.HashMap | class java.util.HashSet | class java.util.HashMap

NEXT_STEP_NAME : END

Could someone help me, please?

Dmitriy Parkhonin Answered

Please sign in to leave a comment.

1 comment

1
Avatar

Try the following query instead:
<trace> SELECT DISTINCT * FROM /targets t, t.groupMembers m WHERE m IN SET(111111)
This way the from clause matches your region expression for the index and the query now indicates that we are trying to look for groupMembers that are in a set of values (in this case just 111111).

Jason Huynh 1 vote