Apache Solr open-source search software
fix RAMDirectory(Directory) 2GB size limitation: LUCENE-546
Yonik Seeley45712c518f6e
diff --git a/CHANGES.txt b/CHANGES.txtindex 5c35a9eadaf..191e98854d5 100644--- a/CHANGES.txt+++ b/CHANGES.txt@@ -69,6 +69,9 @@ Bug fixes14. LUCENE-556: Added empty extractTerms() implementation to MatchAllDocsQuery andConstantScoreQuery in order to allow their use with a MultiSearcher.(Yonik Seeley)++15. LUCENE-546: Creating a RAMDirectory from a Directory truncated files over 2GB.+ (Peter Royal via Yonik Seeley)1.9.1diff --git a/src/java/org/apache/lucene/store/RAMDirectory.java b/src/java/org/apache/lucene/store/RAMDirectory.javaindex a18abe45d42..c3282f0a079 100644--- a/src/java/org/apache/lucene/store/RAMDirectory.java+++ b/src/java/org/apache/lucene/store/RAMDirectory.java@@ -60,10 +60,10 @@ public final class RAMDirectory extends Directory {// read current fileIndexInput is = dir.openInput(files[i]);// and copy to ram disk- int len = (int) is.length();- int readCount = 0;+ long len = is.length();+ long readCount = 0;while (readCount < len) {- int toRead = readCount + BufferedIndexOutput.BUFFER_SIZE > len ? len - readCount : BufferedIndexOutput.BUFFER_SIZE;+ int toRead = readCount + BufferedIndexOutput.BUFFER_SIZE > len ? (int)(len - readCount) : BufferedIndexOutput.BUFFER_SIZE;is.readBytes(buf, 0, toRead);os.writeBytes(buf, toRead);readCount += toRead;