Return-Path: Delivered-To: apmail-lucene-java-commits-archive@www.apache.org Received: (qmail 56109 invoked from network); 25 Apr 2007 08:46:38 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 25 Apr 2007 08:46:38 -0000 Received: (qmail 63728 invoked by uid 500); 25 Apr 2007 08:46:44 -0000 Delivered-To: apmail-lucene-java-commits-archive@lucene.apache.org Received: (qmail 63706 invoked by uid 500); 25 Apr 2007 08:46:44 -0000 Mailing-List: contact java-commits-help@lucene.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: java-dev@lucene.apache.org Delivered-To: mailing list java-commits@lucene.apache.org Received: (qmail 63695 invoked by uid 99); 25 Apr 2007 08:46:44 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 25 Apr 2007 01:46:44 -0700 X-ASF-Spam-Status: No, hits=-99.5 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 25 Apr 2007 01:46:37 -0700 Received: by eris.apache.org (Postfix, from userid 65534) id 9EB341A9838; Wed, 25 Apr 2007 01:46:15 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r532259 - in /lucene/java/trunk: CHANGES.txt src/java/org/apache/lucene/store/FSDirectory.java src/test/org/apache/lucene/store/_TestHelper.java Date: Wed, 25 Apr 2007 08:46:15 -0000 To: java-commits@lucene.apache.org From: buschmi@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20070425084615.9EB341A9838@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: buschmi Date: Wed Apr 25 01:46:14 2007 New Revision: 532259 URL: http://svn.apache.org/viewvc?view=rev&rev=532259 Log: LUCENE-869: Changed FSIndexInput and FSIndexOutput to inner classes of FSDirectory to enable extensibility of these classes. Modified: lucene/java/trunk/CHANGES.txt lucene/java/trunk/src/java/org/apache/lucene/store/FSDirectory.java lucene/java/trunk/src/test/org/apache/lucene/store/_TestHelper.java Modified: lucene/java/trunk/CHANGES.txt URL: http://svn.apache.org/viewvc/lucene/java/trunk/CHANGES.txt?view=diff&rev=532259&r1=532258&r2=532259 ============================================================================== --- lucene/java/trunk/CHANGES.txt (original) +++ lucene/java/trunk/CHANGES.txt Wed Apr 25 01:46:14 2007 @@ -46,6 +46,9 @@ combination when caching is desired. (Chris Hostetter, Otis Gospodnetic) + 8. LUCENE-869: Changed FSIndexInput and FSIndexOutput to inner classes of FSDirectory + to enable extensibility of these classes. + Bug fixes 1. LUCENE-804: Fixed build.xml to pack a fully compilable src dist. (Doron Cohen) Modified: lucene/java/trunk/src/java/org/apache/lucene/store/FSDirectory.java URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/store/FSDirectory.java?view=diff&rev=532259&r1=532258&r2=532259 ============================================================================== --- lucene/java/trunk/src/java/org/apache/lucene/store/FSDirectory.java (original) +++ lucene/java/trunk/src/java/org/apache/lucene/store/FSDirectory.java Wed Apr 25 01:46:14 2007 @@ -487,126 +487,124 @@ public String toString() { return this.getClass().getName() + "@" + directory; } -} + protected static class FSIndexInput extends BufferedIndexInput { + + private static class Descriptor extends RandomAccessFile { + // remember if the file is open, so that we don't try to close it + // more than once + private boolean isOpen; + long position; + final long length; + + public Descriptor(File file, String mode) throws IOException { + super(file, mode); + isOpen=true; + length=length(); + } + + public void close() throws IOException { + if (isOpen) { + isOpen=false; + super.close(); + } + } + + protected void finalize() throws Throwable { + try { + close(); + } finally { + super.finalize(); + } + } + } + + private final Descriptor file; + boolean isClone; + + public FSIndexInput(File path) throws IOException { + file = new Descriptor(path, "r"); + } + + /** IndexInput methods */ + protected void readInternal(byte[] b, int offset, int len) + throws IOException { + synchronized (file) { + long position = getFilePointer(); + if (position != file.position) { + file.seek(position); + file.position = position; + } + int total = 0; + do { + int i = file.read(b, offset+total, len-total); + if (i == -1) + throw new IOException("read past EOF"); + file.position += i; + total += i; + } while (total < len); + } + } + + public void close() throws IOException { + // only close the file if this is not a clone + if (!isClone) file.close(); + } + + protected void seekInternal(long position) { + } + + public long length() { + return file.length; + } + + public Object clone() { + FSIndexInput clone = (FSIndexInput)super.clone(); + clone.isClone = true; + return clone; + } + + /** Method used for testing. Returns true if the underlying + * file descriptor is valid. + */ + boolean isFDValid() throws IOException { + return file.getFD().valid(); + } + } -class FSIndexInput extends BufferedIndexInput { - - private static class Descriptor extends RandomAccessFile { + protected static class FSIndexOutput extends BufferedIndexOutput { + RandomAccessFile file = null; + // remember if the file is open, so that we don't try to close it // more than once private boolean isOpen; - long position; - final long length; - - public Descriptor(File file, String mode) throws IOException { - super(file, mode); - isOpen=true; - length=length(); + + public FSIndexOutput(File path) throws IOException { + file = new RandomAccessFile(path, "rw"); + isOpen = true; + } + + /** output methods: */ + public void flushBuffer(byte[] b, int offset, int size) throws IOException { + file.write(b, offset, size); } - public void close() throws IOException { + // only close the file if it has not been closed yet if (isOpen) { - isOpen=false; super.close(); + file.close(); + isOpen = false; } } - - protected void finalize() throws Throwable { - try { - close(); - } finally { - super.finalize(); - } - } - } - - private final Descriptor file; - boolean isClone; - - public FSIndexInput(File path) throws IOException { - file = new Descriptor(path, "r"); - } - - /** IndexInput methods */ - protected void readInternal(byte[] b, int offset, int len) - throws IOException { - synchronized (file) { - long position = getFilePointer(); - if (position != file.position) { - file.seek(position); - file.position = position; - } - int total = 0; - do { - int i = file.read(b, offset+total, len-total); - if (i == -1) - throw new IOException("read past EOF"); - file.position += i; - total += i; - } while (total < len); + + /** Random-access methods */ + public void seek(long pos) throws IOException { + super.seek(pos); + file.seek(pos); } - } - - public void close() throws IOException { - // only close the file if this is not a clone - if (!isClone) file.close(); - } - - protected void seekInternal(long position) { - } - - public long length() { - return file.length; - } - - public Object clone() { - FSIndexInput clone = (FSIndexInput)super.clone(); - clone.isClone = true; - return clone; - } - - /** Method used for testing. Returns true if the underlying - * file descriptor is valid. - */ - boolean isFDValid() throws IOException { - return file.getFD().valid(); - } -} - - -class FSIndexOutput extends BufferedIndexOutput { - RandomAccessFile file = null; - - // remember if the file is open, so that we don't try to close it - // more than once - private boolean isOpen; - - public FSIndexOutput(File path) throws IOException { - file = new RandomAccessFile(path, "rw"); - isOpen = true; - } - - /** output methods: */ - public void flushBuffer(byte[] b, int offset, int size) throws IOException { - file.write(b, offset, size); - } - public void close() throws IOException { - // only close the file if it has not been closed yet - if (isOpen) { - super.close(); - file.close(); - isOpen = false; + public long length() throws IOException { + return file.length(); } + } - - /** Random-access methods */ - public void seek(long pos) throws IOException { - super.seek(pos); - file.seek(pos); - } - public long length() throws IOException { - return file.length(); - } - } Modified: lucene/java/trunk/src/test/org/apache/lucene/store/_TestHelper.java URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/store/_TestHelper.java?view=diff&rev=532259&r1=532258&r2=532259 ============================================================================== --- lucene/java/trunk/src/test/org/apache/lucene/store/_TestHelper.java (original) +++ lucene/java/trunk/src/test/org/apache/lucene/store/_TestHelper.java Wed Apr 25 01:46:14 2007 @@ -2,6 +2,8 @@ import java.io.IOException; +import org.apache.lucene.store.FSDirectory.FSIndexInput; + /** This class provides access to package-level features defined in the * store package. It is used for testing only. */