13
13
import com .tangosol .util .QueryRecord ;
14
14
15
15
import java .util .ArrayList ;
16
- import java .util .HashSet ;
16
+ import java .util .LinkedHashSet ;
17
17
import java .util .List ;
18
18
import java .util .Map ;
19
19
import java .util .Set ;
@@ -57,7 +57,7 @@ public AllFilter(Filter[] afilter)
57
57
*/
58
58
public boolean evaluate (Object o )
59
59
{
60
- Filter [] afilter = m_aFilter ;
60
+ Filter [] afilter = getFilters () ;
61
61
for (int i = 0 , c = afilter .length ; i < c ; i ++)
62
62
{
63
63
if (!afilter [i ].evaluate (o ))
@@ -77,7 +77,7 @@ public int calculateEffectiveness(Map mapIndexes, Set setKeys)
77
77
{
78
78
optimizeFilterOrder (mapIndexes , setKeys );
79
79
80
- Filter [] aFilter = m_aFilter ;
80
+ Filter [] aFilter = getFilters () ;
81
81
int cFilters = aFilter .length ;
82
82
83
83
if (cFilters > 0 )
@@ -102,7 +102,8 @@ public int calculateEffectiveness(Map mapIndexes, Set setKeys)
102
102
protected boolean evaluateEntry (Map .Entry entry , QueryContext ctx ,
103
103
QueryRecord .PartialResult .TraceStep step )
104
104
{
105
- for (Filter filter : m_aFilter )
105
+ Filter <?>[] aFilter = getFilters ();
106
+ for (Filter <?> filter : aFilter )
106
107
{
107
108
if (!evaluateFilter (filter , entry , ctx ,
108
109
step == null ? null : step .ensureStep (filter )))
@@ -114,43 +115,43 @@ protected boolean evaluateEntry(Map.Entry entry, QueryContext ctx,
114
115
}
115
116
116
117
@ Override
117
- protected Set < Filter <?>> simplifyFilters ()
118
+ protected Filter <?>[] simplifyFilters (Filter <?>[] aFilter )
118
119
{
119
- Set <Filter <?>> setFilters = new HashSet <>();
120
- for (Filter <?> filter : m_aFilter )
120
+ Set <Filter <?>> setFilters = new LinkedHashSet <>();
121
+ for (Filter <?> filter : aFilter )
121
122
{
122
- if (filter instanceof AllFilter )
123
+ if (filter instanceof AllFilter && !( filter instanceof BetweenFilter ) )
123
124
{
124
125
// pull nested AND/ALL filters to top level
125
- setFilters .addAll ((( AllFilter ) filter ).simplifyFilters ( ));
126
+ setFilters .addAll (List . of ((( AllFilter ) filter ).getFilters () ));
126
127
}
127
128
else
128
129
{
129
130
// remove duplicates
130
131
setFilters .add (filter );
131
132
}
132
133
}
133
- return setFilters ;
134
+ return setFilters . toArray ( Filter []:: new ) ;
134
135
}
135
136
136
137
@ Override
137
- protected Filter applyIndex (Map mapIndexes , Set setKeys ,
138
+ protected Filter <?> applyIndex (Map mapIndexes , Set setKeys ,
138
139
QueryContext ctx , QueryRecord .PartialResult .TraceStep step )
139
140
{
140
141
optimizeFilterOrder (mapIndexes , setKeys );
141
142
142
- Filter [] aFilter = m_aFilter ;
143
- int cFilters = aFilter .length ;
144
- List listFilter = new ArrayList (cFilters );
143
+ Filter <?> [] aFilter = getFilters () ;
144
+ int cFilters = aFilter .length ;
145
+ List < Filter <?>> listFilter = new ArrayList <> (cFilters );
145
146
146
147
// listFilter is an array of filters that will have to be re-applied
147
148
148
149
for (int i = 0 ; i < cFilters ; i ++)
149
150
{
150
- Filter filter = aFilter [i ];
151
+ Filter <?> filter = aFilter [i ];
151
152
if (filter instanceof IndexAwareFilter )
152
153
{
153
- Filter filterNew = applyFilter (filter , i , mapIndexes , setKeys , ctx , step );
154
+ Filter <?> filterNew = applyFilter (filter , i , mapIndexes , setKeys , ctx , step );
154
155
155
156
if (setKeys .isEmpty ())
156
157
{
@@ -175,21 +176,20 @@ else if (filter != null)
175
176
}
176
177
else if (cFilters == 1 )
177
178
{
178
- return ( Filter ) listFilter .get (0 );
179
+ return listFilter .get (0 );
179
180
}
180
181
else
181
182
{
182
- return new AllFilter ((Filter [])
183
- listFilter .toArray (new Filter [cFilters ]));
183
+ return new AllFilter (listFilter .toArray (new Filter [cFilters ]));
184
184
}
185
185
}
186
186
187
187
protected String getName ()
188
188
{
189
- switch (m_aFilter .length )
189
+ switch (getFilters () .length )
190
190
{
191
191
case 1 :
192
- return m_aFilter [0 ].getClass ().getSimpleName ();
192
+ return getFilters () [0 ].getClass ().getSimpleName ();
193
193
case 2 :
194
194
return "AndFilter" ;
195
195
default :
0 commit comments