Fix implementation of currentValueHash in FieldDataSource.Bytes.SortedAndUnique.

Close #4330
This commit is contained in:
Adrien Grand 2013-12-04 00:23:18 +01:00
parent 9e4b5ea242
commit 346d8efeb5
2 changed files with 7 additions and 1 deletions

View File

@ -79,6 +79,7 @@ public class StringTermsAggregator extends BucketsAggregator {
continue;
}
final int hash = values.currentValueHash();
assert hash == bytes.hashCode();
int bucketOrdinal = bucketOrds.add(bytes, hash);
if (bucketOrdinal < 0) { // already seen
bucketOrdinal = - 1 - bucketOrdinal;

View File

@ -166,7 +166,7 @@ public abstract class FieldDataSource {
bytes.clear();
bytes.reinit();
for (int i = 0; i < numValues; ++i) {
bytes.add(super.nextValue(), super.hashCode());
bytes.add(super.nextValue(), super.currentValueHash());
}
numUniqueValues = bytes.size();
sortedIds = bytes.sort(BytesRef.getUTF8SortedAsUnicodeComparator());
@ -180,6 +180,11 @@ public abstract class FieldDataSource {
return spare;
}
@Override
public int currentValueHash() {
return spare.hashCode();
}
@Override
public Order getOrder() {
return Order.BYTES;