File tree Expand file tree Collapse file tree 1 file changed +3
-22
lines changed
modules/elasticsearch/src/main/java/org/elasticsearch/search/facet/histogram Expand file tree Collapse file tree 1 file changed +3
-22
lines changed Original file line number Diff line number Diff line change @@ -66,38 +66,19 @@ public static enum ComparatorType {
66
66
KEY ((byte ) 0 , "key" , new Comparator <Entry >() {
67
67
68
68
@ Override public int compare (Entry o1 , Entry o2 ) {
69
- // really, there should not be two entries with the same value
70
- int i = (int ) (o1 .key () - o2 .key ());
71
- if (i == 0 ) {
72
- i = System .identityHashCode (o1 ) - System .identityHashCode (o2 );
73
- }
74
- return i ;
69
+ return (o1 .key () < o2 .key () ? -1 : (o1 .key () == o2 .key () ? 0 : 1 ));
75
70
}
76
71
}),
77
72
COUNT ((byte ) 1 , "count" , new Comparator <Entry >() {
78
73
79
74
@ Override public int compare (Entry o1 , Entry o2 ) {
80
- int i = (int ) (o2 .count () - o1 .count ());
81
- if (i == 0 ) {
82
- i = (int ) (o2 .total () - o1 .total ());
83
- if (i == 0 ) {
84
- i = System .identityHashCode (o2 ) - System .identityHashCode (o1 );
85
- }
86
- }
87
- return i ;
75
+ return (o1 .count () < o2 .count () ? -1 : (o1 .count () == o2 .count () ? 0 : 1 ));
88
76
}
89
77
}),
90
78
TOTAL ((byte ) 2 , "total" , new Comparator <Entry >() {
91
79
92
80
@ Override public int compare (Entry o1 , Entry o2 ) {
93
- int i = (int ) (o2 .total () - o1 .total ());
94
- if (i == 0 ) {
95
- i = (int ) (o2 .count () - o1 .count ());
96
- if (i == 0 ) {
97
- i = System .identityHashCode (o2 ) - System .identityHashCode (o1 );
98
- }
99
- }
100
- return i ;
81
+ return (o1 .total () < o2 .total () ? -1 : (o1 .total () == o2 .total () ? 0 : 1 ));
101
82
}
102
83
});
103
84
You can’t perform that action at this time.
0 commit comments