Fix AppendingLongBuffer/Iterator.hasNext.

This method failed to return the right result when the total number of values was a multiple of MAX_PENDING_COUNT = 1024.


git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/branches/lucene4547@1439530 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Adrien Grand 2013-01-28 17:58:59 +00:00
parent e42d057f81
commit 955aef17b6

View File

@ -124,7 +124,7 @@ public class AppendingLongBuffer {
} else if (values[vOff] == null) { } else if (values[vOff] == null) {
Arrays.fill(currentValues, minValues[vOff]); Arrays.fill(currentValues, minValues[vOff]);
} else { } else {
for (int k = 0; k < MAX_PENDING_COUNT; ++k) { for (int k = 0; k < MAX_PENDING_COUNT; ) {
k += values[vOff].get(k, currentValues, k, MAX_PENDING_COUNT - k); k += values[vOff].get(k, currentValues, k, MAX_PENDING_COUNT - k);
} }
for (int k = 0; k < MAX_PENDING_COUNT; ++k) { for (int k = 0; k < MAX_PENDING_COUNT; ++k) {
@ -135,7 +135,7 @@ public class AppendingLongBuffer {
/** Whether or not there are remaining values. */ /** Whether or not there are remaining values. */
public boolean hasNext() { public boolean hasNext() {
return vOff < valuesOff || pOff < pendingOff; return vOff < valuesOff || (vOff == valuesOff && pOff < pendingOff);
} }
/** Return the next long in the buffer. */ /** Return the next long in the buffer. */