fix RAMDirectory(Directory) 2GB size limitation: LUCENE-546

git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@408114 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Yonik Seeley 2006-05-21 01:01:42 +00:00
parent 2c5bc593b8
commit 45712c518f
2 changed files with 6 additions and 3 deletions

View File

@ -69,6 +69,9 @@ Bug fixes
14. LUCENE-556: Added empty extractTerms() implementation to MatchAllDocsQuery and
ConstantScoreQuery 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.1

View File

@ -60,10 +60,10 @@ public final class RAMDirectory extends Directory {
// read current file
IndexInput 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;