Return-Path: Delivered-To: apmail-jakarta-lucene-dev-archive@apache.org Received: (qmail 53993 invoked from network); 21 Feb 2002 21:40:05 -0000 Received: from unknown (HELO nagoya.betaversion.org) (192.18.49.131) by daedalus.apache.org with SMTP; 21 Feb 2002 21:40:05 -0000 Received: (qmail 23166 invoked by uid 97); 21 Feb 2002 21:40:09 -0000 Delivered-To: qmlist-jakarta-archive-lucene-dev@jakarta.apache.org Received: (qmail 23150 invoked by uid 97); 21 Feb 2002 21:40:09 -0000 Mailing-List: contact lucene-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Lucene Developers List" Reply-To: "Lucene Developers List" Delivered-To: mailing list lucene-dev@jakarta.apache.org Received: (qmail 23139 invoked from network); 21 Feb 2002 21:40:08 -0000 X-MimeOLE: Produced By Microsoft Exchange V6.0.4712.0 content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Subject: Converting a FSDirectory (on disk index) to a RAMDirectory Date: Thu, 21 Feb 2002 13:40:07 -0800 Message-ID: <728DA21B8941A843A7C496F1ACF48518012CF7AA@gleam.lumos.com> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: Converting a FSDirectory (on disk index) to a RAMDirectory Thread-Index: AcG7IFS+vRLyB2qLTLygvxgGprSwJQ== From: "Spencer, Dave" To: X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N Inspired by the talk on slashdot recently about google using solid state ("ram") disks I wanted to play around w/ Lucene runnning purely out of memory. Could anyone glance at this and verify that this code is correct. Goal is to convert an existing, on-disk, index to a RAMDirectory, which presumably is purely in memory. If the code is correct I'd suggest someone w/ CVS powers adding it to the source base - maybe a static method in RAMDirectory itself. public static RAMDirectory convert( String path) throws IOException { final RAMDirectory ram =3D new RAMDirectory(); final Directory d =3D FSDirectory.getDirectory( path, false); final String[] ar =3D d.list(); for ( int i =3D 0; i< ar.length; i++) { // make place on ram disk OutputStream os =3D ram.createFile( ar[ i]); // read current file InputStream is =3D d.openFile( ar[ i]); // and copy to ram disk int len =3D (int) is.length(); =20 byte[] buf =3D new byte[ len]; is.readBytes( buf, 0, len); os.writeBytes( buf, len); // graceful cleanup is.close(); os.close(); } return ram; } -- To unsubscribe, e-mail: For additional commands, e-mail: