Skip to content

Commit

Permalink
Remove hppc uses from histogram field mapper (#84849)
Browse files Browse the repository at this point in the history
The histogram field parses values and counts from document. Parsing the
document should not be the bottleneck in index, so using hppc classes
here appears unnecessary, especially given all the other overhead of I/O
for parsing a document. This commit converts these two uses to
ArrayList.

relates #84735
  • Loading branch information
rjernst authored Mar 10, 2022
1 parent 4814da7 commit 85b3476
Showing 1 changed file with 5 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@
*/
package org.elasticsearch.xpack.analytics.mapper;

import com.carrotsearch.hppc.DoubleArrayList;
import com.carrotsearch.hppc.IntArrayList;

import org.apache.lucene.document.BinaryDocValuesField;
import org.apache.lucene.document.Field;
import org.apache.lucene.index.BinaryDocValues;
Expand Down Expand Up @@ -50,6 +47,7 @@
import org.elasticsearch.xpack.analytics.aggregations.support.AnalyticsValuesSourceType;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.function.Supplier;
Expand Down Expand Up @@ -283,8 +281,8 @@ public void parse(DocumentParserContext context) throws IOException {
context.path().remove();
return;
}
DoubleArrayList values = null;
IntArrayList counts = null;
ArrayList<Double> values = null;
ArrayList<Integer> counts = null;
// should be an object
ensureExpectedToken(XContentParser.Token.START_OBJECT, token, context.parser());
subParser = new XContentSubParser(context.parser());
Expand All @@ -297,7 +295,7 @@ public void parse(DocumentParserContext context) throws IOException {
token = subParser.nextToken();
// should be an array
ensureExpectedToken(XContentParser.Token.START_ARRAY, token, subParser);
values = new DoubleArrayList();
values = new ArrayList<>();
token = subParser.nextToken();
double previousVal = -Double.MAX_VALUE;
while (token != XContentParser.Token.END_ARRAY) {
Expand Down Expand Up @@ -326,7 +324,7 @@ public void parse(DocumentParserContext context) throws IOException {
token = subParser.nextToken();
// should be an array
ensureExpectedToken(XContentParser.Token.START_ARRAY, token, subParser);
counts = new IntArrayList();
counts = new ArrayList<>();
token = subParser.nextToken();
while (token != XContentParser.Token.END_ARRAY) {
// should be a number
Expand Down

0 comments on commit 85b3476

Please sign in to comment.