71
71
import org .apache .solr .core .SolrCore ;
72
72
import org .apache .solr .request .SolrQueryRequest ;
73
73
import org .apache .solr .schema .FieldType ;
74
- import org .apache .solr .schema .NumberType ;
75
74
import org .apache .solr .schema .SchemaField ;
76
75
import org .apache .solr .schema .StrField ;
77
76
import org .apache .solr .search .CollapsingQParserPlugin ;
@@ -214,7 +213,6 @@ public void process(ResponseBuilder rb) throws IOException {
214
213
FieldType fieldType = schemaField .getType ();
215
214
216
215
SortedDocValues values = null ;
217
- long nullValue = 0L ;
218
216
219
217
if (fieldType instanceof StrField ) {
220
218
//Get The Top Level SortedDocValues
@@ -225,28 +223,7 @@ public void process(ResponseBuilder rb) throws IOException {
225
223
} else {
226
224
values = DocValues .getSorted (reader , field );
227
225
}
228
- } else if (fieldType .getNumberType () != null ) {
229
- //Get the nullValue for the numeric collapse field
230
- String defaultValue = searcher .getSchema ().getField (field ).getDefaultValue ();
231
-
232
- final NumberType numType = fieldType .getNumberType ();
233
-
234
- // Since the expand component depends on the operation of the collapse component,
235
- // which validates that numeric field types are 32-bit,
236
- // we don't need to handle invalid 64-bit field types here.
237
- // FIXME: what happens when expand.field specified?
238
- // how would this work for date field?
239
- // SOLR-10400: before this, long and double were explicitly handled
240
- if (defaultValue != null ) {
241
- if (numType == NumberType .INTEGER ) {
242
- nullValue = Long .parseLong (defaultValue );
243
- } else if (numType == NumberType .FLOAT ) {
244
- nullValue = Float .floatToIntBits (Float .parseFloat (defaultValue ));
245
- }
246
- } else if (NumberType .FLOAT .equals (numType )) { // Integer case already handled by nullValue defaulting to 0
247
- nullValue = Float .floatToIntBits (0.0f );
248
- }
249
- } else {
226
+ } else if (fieldType .getNumberType () == null ) {
250
227
// possible if directly expand.field is specified
251
228
throw new SolrException (SolrException .ErrorCode .BAD_REQUEST ,
252
229
"Expand not supported for fieldType:'" + fieldType .getTypeName () +"'" );
@@ -358,13 +335,8 @@ public void process(ResponseBuilder rb) throws IOException {
358
335
if (valueDocID < contextDoc ) {
359
336
valueDocID = collapseValues .advance (contextDoc );
360
337
}
361
- long value ;
362
338
if (valueDocID == contextDoc ) {
363
- value = collapseValues .longValue ();
364
- } else {
365
- value = 0 ;
366
- }
367
- if (value != nullValue ) {
339
+ final long value = collapseValues .longValue ();
368
340
groupSet .add (value );
369
341
collapsedSet .add (globalDoc );
370
342
}
@@ -399,7 +371,7 @@ public void process(ResponseBuilder rb) throws IOException {
399
371
400
372
groupExpandCollector = new GroupExpandCollector (values , groupBits , collapsedSet , limit , sort );
401
373
} else {
402
- groupExpandCollector = new NumericGroupExpandCollector (field , nullValue , groupSet , collapsedSet , limit , sort );
374
+ groupExpandCollector = new NumericGroupExpandCollector (field , groupSet , collapsedSet , limit , sort );
403
375
}
404
376
405
377
if (groupQuery != null ) {
@@ -628,11 +600,9 @@ private static class NumericGroupExpandCollector implements Collector, GroupColl
628
600
private LongObjectHashMap <Collector > groups ;
629
601
630
602
private IntHashSet collapsedSet ;
631
- private long nullValue ;
632
603
633
- public NumericGroupExpandCollector (String field , long nullValue , LongHashSet groupSet , IntHashSet collapsedSet , int limit , Sort sort ) throws IOException {
604
+ public NumericGroupExpandCollector (String field , LongHashSet groupSet , IntHashSet collapsedSet , int limit , Sort sort ) throws IOException {
634
605
int numGroups = collapsedSet .size ();
635
- this .nullValue = nullValue ;
636
606
groups = new LongObjectHashMap <>(numGroups );
637
607
for (LongCursor cursor : groupSet ) {
638
608
groups .put (cursor .value , getCollector (limit , sort ));
@@ -663,17 +633,12 @@ public void setScorer(Scorable scorer) throws IOException {
663
633
664
634
@ Override
665
635
public void collect (int docId ) throws IOException {
666
- long value ;
667
636
if (docValues .advanceExact (docId )) {
668
- value = docValues .longValue ();
669
- } else {
670
- value = 0 ;
671
- }
672
- final int index ;
673
- if (value != nullValue &&
674
- (index = leafCollectors .indexOf (value )) >= 0 &&
675
- !collapsedSet .contains (docId + docBase )) {
676
- leafCollectors .indexGet (index ).collect (docId );
637
+ final long value = docValues .longValue ();
638
+ final int index = leafCollectors .indexOf (value );
639
+ if (index >= 0 && !collapsedSet .contains (docId + docBase )) {
640
+ leafCollectors .indexGet (index ).collect (docId );
641
+ }
677
642
}
678
643
}
679
644
};
0 commit comments