remove n^2 ram accounting

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/branches/lucene4547@1439915 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Robert Muir 2013-01-29 14:47:04 +00:00
parent 6bfac8590b
commit fa35092734
2 changed files with 4 additions and 7 deletions

View File

@ -55,7 +55,7 @@ class NumericDocValuesWriter extends DocValuesWriter {
pending.add(value);
updateBytesUsed(); // nocommit: O(n^2)!!!!!!!!!!!!
updateBytesUsed();
}
private void updateBytesUsed() {

View File

@ -33,6 +33,7 @@ public class AppendingLongBuffer {
private long[] minValues;
private PackedInts.Reader[] values;
private long valuesBytes;
private int valuesOff;
private long[] pending;
private int pendingOff;
@ -85,6 +86,7 @@ public class AppendingLongBuffer {
i += mutable.set(i, pending, i, pendingOff - i);
}
values[valuesOff] = mutable;
valuesBytes += mutable.ramBytesUsed();
}
++valuesOff;
@ -166,12 +168,7 @@ public class AppendingLongBuffer {
+ RamUsageEstimator.sizeOf(minValues)
+ RamUsageEstimator.alignObjectSize(RamUsageEstimator.NUM_BYTES_ARRAY_HEADER + (long) RamUsageEstimator.NUM_BYTES_OBJECT_REF * values.length); // values
for (int i = 0; i < valuesOff; ++i) {
if (values[i] != null) {
bytesUsed += values[i].ramBytesUsed();
}
}
return bytesUsed;
return bytesUsed + valuesBytes;
}
}