From f68744c32b14cd6930db259ad284eef1dc136c50 Mon Sep 17 00:00:00 2001 From: Yonik Seeley Date: Tue, 23 May 2006 15:01:11 +0000 Subject: [PATCH] remove 2GB file limitation from RAMIndexInput and RAMIndexOutput: LUCENE-546 git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@408916 13f79535-47bb-0310-9956-ffa450edef68 --- CHANGES.txt | 6 +++--- src/java/org/apache/lucene/store/RAMInputStream.java | 10 +++++----- src/java/org/apache/lucene/store/RAMOutputStream.java | 8 ++++---- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 191e98854d5..d9ca00ce5ff 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -70,9 +70,9 @@ Bug fixes 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) - +15. LUCENE-546: Removed 2GB file size limitations for RAMDirectory. + (Peter Royal, Michael Chan, Yonik Seeley) + 1.9.1 Bug fixes diff --git a/src/java/org/apache/lucene/store/RAMInputStream.java b/src/java/org/apache/lucene/store/RAMInputStream.java index 7e6f2467e99..48bc187d4b4 100644 --- a/src/java/org/apache/lucene/store/RAMInputStream.java +++ b/src/java/org/apache/lucene/store/RAMInputStream.java @@ -24,7 +24,7 @@ package org.apache.lucene.store; class RAMInputStream extends BufferedIndexInput implements Cloneable { private RAMFile file; - private int pointer = 0; + private long pointer = 0; private long length; public RAMInputStream(RAMFile f) { @@ -34,10 +34,10 @@ class RAMInputStream extends BufferedIndexInput implements Cloneable { public void readInternal(byte[] dest, int destOffset, int len) { int remainder = len; - int start = pointer; + long start = pointer; while (remainder != 0) { - int bufferNumber = start/BUFFER_SIZE; - int bufferOffset = start%BUFFER_SIZE; + int bufferNumber = (int)(start/BUFFER_SIZE); + int bufferOffset = (int)(start%BUFFER_SIZE); int bytesInBuffer = BUFFER_SIZE - bufferOffset; int bytesToCopy = bytesInBuffer >= remainder ? remainder : bytesInBuffer; byte[] buffer = (byte[])file.buffers.elementAt(bufferNumber); @@ -53,7 +53,7 @@ class RAMInputStream extends BufferedIndexInput implements Cloneable { } public void seekInternal(long pos) { - pointer = (int)pos; + pointer = pos; } public long length() { diff --git a/src/java/org/apache/lucene/store/RAMOutputStream.java b/src/java/org/apache/lucene/store/RAMOutputStream.java index 970651a718b..5d63fc7d96e 100644 --- a/src/java/org/apache/lucene/store/RAMOutputStream.java +++ b/src/java/org/apache/lucene/store/RAMOutputStream.java @@ -26,7 +26,7 @@ import java.io.IOException; public class RAMOutputStream extends BufferedIndexOutput { private RAMFile file; - private int pointer = 0; + private long pointer = 0; /** Construct an empty output buffer. */ public RAMOutputStream() { @@ -69,8 +69,8 @@ public class RAMOutputStream extends BufferedIndexOutput { byte[] buffer; int bufferPos = 0; while (bufferPos != len) { - int bufferNumber = pointer/BUFFER_SIZE; - int bufferOffset = pointer%BUFFER_SIZE; + int bufferNumber = (int)(pointer/BUFFER_SIZE); + int bufferOffset = (int)(pointer%BUFFER_SIZE); int bytesInBuffer = BUFFER_SIZE - bufferOffset; int remainInSrcBuffer = len - bufferPos; int bytesToCopy = bytesInBuffer >= remainInSrcBuffer ? remainInSrcBuffer : bytesInBuffer; @@ -99,7 +99,7 @@ public class RAMOutputStream extends BufferedIndexOutput { public void seek(long pos) throws IOException { super.seek(pos); - pointer = (int)pos; + pointer = pos; } public long length() { return file.length;