Skip to content

armgit / solr

Public Imported from GitHub
0

Apache Solr open-source search software

LUCENE-5836: when prefix-coding variable length terms, preallocate lastTerm to the correct size

Robert Muir387ee2a6d301
diff --git a/lucene/core/src/java/org/apache/lucene/codecs/lucene49/Lucene49DocValuesConsumer.java b/lucene/core/src/java/org/apache/lucene/codecs/lucene49/Lucene49DocValuesConsumer.java
index 23ed1c5e2d4..40c0dc54e4e 100644
--- a/lucene/core/src/java/org/apache/lucene/codecs/lucene49/Lucene49DocValuesConsumer.java
+++ b/lucene/core/src/java/org/apache/lucene/codecs/lucene49/Lucene49DocValuesConsumer.java
@@ -324,7 +324,7 @@ class Lucene49DocValuesConsumer extends DocValuesConsumer implements Closeable {
// we could avoid this, but its not much and less overall RAM than the previous approach!
RAMOutputStream addressBuffer = new RAMOutputStream();
MonotonicBlockPackedWriter termAddresses = new MonotonicBlockPackedWriter(addressBuffer, BLOCK_SIZE);
- BytesRef lastTerm = new BytesRef();
+ BytesRef lastTerm = new BytesRef(Math.max(0, maxLength));
long count = 0;
for (BytesRef v : values) {
if (count % ADDRESS_INTERVAL == 0) {