@@ -70,7 +70,7 @@ public FastTaxonomyFacetCounts(
70
70
countAll (reader );
71
71
}
72
72
73
- private final void count (List <MatchingDocs > matchingDocs ) throws IOException {
73
+ private void count (List <MatchingDocs > matchingDocs ) throws IOException {
74
74
for (MatchingDocs hits : matchingDocs ) {
75
75
SortedNumericDocValues multiValued =
76
76
FacetUtils .loadOrdinalValues (hits .context .reader (), indexFieldName );
@@ -85,13 +85,27 @@ private final void count(List<MatchingDocs> matchingDocs) throws IOException {
85
85
ConjunctionUtils .intersectIterators (Arrays .asList (hits .bits .iterator (), valuesIt ));
86
86
87
87
if (singleValued != null ) {
88
- while (it .nextDoc () != DocIdSetIterator .NO_MORE_DOCS ) {
89
- increment ((int ) singleValued .longValue ());
88
+ if (values != null ) {
89
+ while (it .nextDoc () != DocIdSetIterator .NO_MORE_DOCS ) {
90
+ values [(int ) singleValued .longValue ()]++;
91
+ }
92
+ } else {
93
+ while (it .nextDoc () != DocIdSetIterator .NO_MORE_DOCS ) {
94
+ sparseValues .addTo ((int ) singleValued .longValue (), 1 );
95
+ }
90
96
}
91
97
} else {
92
- while (it .nextDoc () != DocIdSetIterator .NO_MORE_DOCS ) {
93
- for (int i = 0 ; i < multiValued .docValueCount (); i ++) {
94
- increment ((int ) multiValued .nextValue ());
98
+ if (values != null ) {
99
+ while (it .nextDoc () != DocIdSetIterator .NO_MORE_DOCS ) {
100
+ for (int i = 0 ; i < multiValued .docValueCount (); i ++) {
101
+ values [(int ) multiValued .nextValue ()]++;
102
+ }
103
+ }
104
+ } else {
105
+ while (it .nextDoc () != DocIdSetIterator .NO_MORE_DOCS ) {
106
+ for (int i = 0 ; i < multiValued .docValueCount (); i ++) {
107
+ sparseValues .addTo ((int ) multiValued .nextValue (), 1 );
108
+ }
95
109
}
96
110
}
97
111
}
@@ -100,7 +114,8 @@ private final void count(List<MatchingDocs> matchingDocs) throws IOException {
100
114
rollup ();
101
115
}
102
116
103
- private final void countAll (IndexReader reader ) throws IOException {
117
+ private void countAll (IndexReader reader ) throws IOException {
118
+ assert values != null ;
104
119
for (LeafReaderContext context : reader .leaves ()) {
105
120
SortedNumericDocValues multiValued =
106
121
FacetUtils .loadOrdinalValues (context .reader (), indexFieldName );
@@ -118,7 +133,7 @@ private final void countAll(IndexReader reader) throws IOException {
118
133
if (liveDocs != null && liveDocs .get (doc ) == false ) {
119
134
continue ;
120
135
}
121
- increment (( int ) singleValued .longValue ()) ;
136
+ values [( int ) singleValued .longValue ()]++ ;
122
137
}
123
138
} else {
124
139
for (int doc = multiValued .nextDoc ();
@@ -128,7 +143,7 @@ private final void countAll(IndexReader reader) throws IOException {
128
143
continue ;
129
144
}
130
145
for (int i = 0 ; i < multiValued .docValueCount (); i ++) {
131
- increment (( int ) multiValued .nextValue ()) ;
146
+ values [( int ) multiValued .nextValue ()]++ ;
132
147
}
133
148
}
134
149
}
0 commit comments