Skip to content
This repository was archived by the owner on Nov 16, 2018. It is now read-only.

Commit 346d8ef

Browse files
committed
Fix implementation of currentValueHash in FieldDataSource.Bytes.SortedAndUnique.
Close elastic#4330
1 parent 9e4b5ea commit 346d8ef

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/main/java/org/elasticsearch/search/aggregations/bucket/terms/StringTermsAggregator.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ public void collect(int doc, long owningBucketOrdinal) throws IOException {
7979
continue;
8080
}
8181
final int hash = values.currentValueHash();
82+
assert hash == bytes.hashCode();
8283
int bucketOrdinal = bucketOrds.add(bytes, hash);
8384
if (bucketOrdinal < 0) { // already seen
8485
bucketOrdinal = - 1 - bucketOrdinal;

src/main/java/org/elasticsearch/search/aggregations/support/FieldDataSource.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ public int setDocument(int docId) {
166166
bytes.clear();
167167
bytes.reinit();
168168
for (int i = 0; i < numValues; ++i) {
169-
bytes.add(super.nextValue(), super.hashCode());
169+
bytes.add(super.nextValue(), super.currentValueHash());
170170
}
171171
numUniqueValues = bytes.size();
172172
sortedIds = bytes.sort(BytesRef.getUTF8SortedAsUnicodeComparator());
@@ -180,6 +180,11 @@ public BytesRef nextValue() {
180180
return spare;
181181
}
182182

183+
@Override
184+
public int currentValueHash() {
185+
return spare.hashCode();
186+
}
187+
183188
@Override
184189
public Order getOrder() {
185190
return Order.BYTES;

0 commit comments

Comments
 (0)