Return-Path: Delivered-To: apmail-jakarta-lucene-dev-archive@www.apache.org Received: (qmail 41484 invoked from network); 31 Dec 2004 13:31:07 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 31 Dec 2004 13:31:07 -0000 Received: (qmail 95025 invoked by uid 500); 31 Dec 2004 13:31:03 -0000 Delivered-To: apmail-jakarta-lucene-dev-archive@jakarta.apache.org Received: (qmail 94997 invoked by uid 500); 31 Dec 2004 13:31:03 -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 94980 invoked by uid 99); 31 Dec 2004 13:31:03 -0000 X-ASF-Spam-Status: No, hits=0.1 required=10.0 tests=HTML_40_50,HTML_MESSAGE,HTML_TITLE_EMPTY X-Spam-Check-By: apache.org Received-SPF: neutral (hermes.apache.org: local policy) Received: from p15112568.pureserver.info (HELO p15112568.pureserver.info) (217.160.91.29) by apache.org (qpsmtpd/0.28) with ESMTP; Fri, 31 Dec 2004 05:30:59 -0800 Received: from [192.168.10.103] (ppp-82-135-9-180.mnet-online.de [82.135.9.180]) (using TLSv1 with cipher RC4-MD5 (128/128 bits)) (No client certificate requested) by p15112568.pureserver.info (Postfix) with ESMTP id 96B0314010F for ; Fri, 31 Dec 2004 14:30:55 +0100 (CET) Message-ID: <41D55489.70703@apache.org> Date: Fri, 31 Dec 2004 14:30:49 +0100 From: Bernhard Messer User-Agent: Mozilla Thunderbird 0.8 (X11/20040913) X-Accept-Language: de-DE, de, en-us, en MIME-Version: 1.0 To: Lucene Developers List Subject: Re: CFS file and file formats References: <20041230161754.76557.qmail@web12702.mail.yahoo.com> In-Reply-To: <20041230161754.76557.qmail@web12702.mail.yahoo.com> Content-Type: multipart/alternative; boundary="------------060305010100060901000502" X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N --------------060305010100060901000502 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit >Hello, > >I understand the technical reason for main() there, but logically this >belongs to an external utility class, I think. > > > Otis you are right, i already thought about it. It could be simply moved to a newly created class in org.apache.lucene.util package. But then we have to change the visibility of CompoundFileReader to public. I have no problems with a public CompoundFileReader class. Does anybody see a reason that the visibility of CompoundFileReader should not be changed to public ? Bernhard > >--- Bernhard Messer wrote: > > > >>hi, >> >>i already had a look at Garrett's implementation. I made some smaller >> >>changes to improve the performance when extracting the files from the >> >>compound. All tests work fine and the index is usable after >>extraction. >>The new functionality is added as a public static void main () to >>CompoundFileReader because of the reduced visibility (package) of >>CompoundFileReader itself. It will be committed this afternoon. >> >>Bernhard >> >> >> >>>Doug Cutting wrote: >>> >>> >>> >>>>It would be useful to have a command-line utility (i.e., a static >>>>main(String[]) method somewhere) that lists the files and sizes >>>>contained inside a CFS file, and perhaps even an option to unpack >>>> >>>> >>it. >> >> >>>>Anyone care to contribute this method? >>>> >>>> >>>Here's a diff to add this functionality to CompoundFileReader. >>>Comments are of course welcome, as I'm not that fantastic a Java >>> >>> >>hacker. >> >> >>>-garrett >>> >>> >>> >>------------------------------------------------------------------------ >> >> >>>Index: src/java/org/apache/lucene/index/CompoundFileReader.java >>>=================================================================== >>>RCS file: >>> >>> >/home/cvspublic/jakarta-lucene/src/java/org/apache/lucene/index/CompoundFileReader.java,v > > >>>retrieving revision 1.14 >>>diff -u -r1.14 CompoundFileReader.java >>>--- src/java/org/apache/lucene/index/CompoundFileReader.java 28 Sep >>> >>> >>2004 18:15:52 -0000 1.14 >> >> >>>+++ src/java/org/apache/lucene/index/CompoundFileReader.java 25 Dec >>> >>> >>2004 04:25:11 -0000 >> >> >>>@@ -17,12 +17,14 @@ >>> */ >>> >>>import org.apache.lucene.store.Directory; >>>+import org.apache.lucene.store.FSDirectory; >>>import org.apache.lucene.store.IndexInput; >>>import org.apache.lucene.store.BufferedIndexInput; >>>import org.apache.lucene.store.IndexOutput; >>>import org.apache.lucene.store.Lock; >>>import java.util.HashMap; >>>import java.io.IOException; >>>+import java.io.FileOutputStream; >>> >>> >>>/** >>>@@ -233,5 +235,61 @@ >>> } >>> >>> >>>+ } >>>+ >>>+ public static void main(String [] args) { >>>+ String dirname = null, filename = null; >>>+ boolean extract = false; >>>+ >>>+ for (int i = 0; i < args.length; ++i) { >>>+ if (args[i].equals("-extract")) { >>>+ extract = true; >>>+ } else if (dirname == null) { >>>+ dirname = args[i]; >>>+ } else if (filename == null) { >>>+ filename = args[i]; >>>+ } >>>+ } >>>+ >>>+ if (dirname == null || filename == null) { >>>+ System.out.println("Usage: CompoundFileReader directory >>> >>> >>cfsfile"); >> >> >>>+ System.out.println(""); >>>+ System.out.println("Prints the filename and size of >>> >>> >>each file " >> >> >>>+ + "within cfsfile."); >>>+ System.out.println(""); >>>+ System.out.println("Add the -extract flag to extract >>> >>> >>files to the " >> >> >>>+ + "current working directory."); >>>+ >>>+ return; >>>+ } >>>+ >>>+ try { >>>+ Directory dir = FSDirectory.getDirectory(dirname, >>> >>> >>false); >> >> >>>+ >>>+ CompoundFileReader cfr = new CompoundFileReader(dir, >>> >>> >>filename); >> >> >>>+ >>>+ String [] files = cfr.list(); >>>+ >>>+ for (int i = 0; i < files.length; ++i) { >>>+ long len = cfr.fileLength(files[i]); >>>+ >>>+ System.out.println(files[i] + "\t: " + len + " >>> >>> >>bytes"); >> >> >>>+ >>>+ if (extract) { >>>+ IndexInput ii = cfr.openInput(files[i]); >>>+ >>>+ FileOutputStream f = new >>> >>> >>FileOutputStream(files[i]); >> >> >>>+ >>>+ while (len-- != 0) { >>>+ byte b = ii.readByte(); >>>+ f.write(b); >>>+ } >>>+ >>>+ f.close(); >>>+ } >>>+ } >>>+ } catch (IOException ioe) { >>>+ ioe.printStackTrace(); >>>+ } >>> } >>>} >>> >>> >>> >>> >>> >>------------------------------------------------------------------------ >> >> >>--------------------------------------------------------------------- >> >> >>>To unsubscribe, e-mail: lucene-dev-unsubscribe@jakarta.apache.org >>>For additional commands, e-mail: lucene-dev-help@jakarta.apache.org >>> >>> >>> >> >> > > >--------------------------------------------------------------------- >To unsubscribe, e-mail: lucene-dev-unsubscribe@jakarta.apache.org >For additional commands, e-mail: lucene-dev-help@jakarta.apache.org > > > --------------060305010100060901000502--