Clover Coverage Report
Coverage timestamp: Fri May 9 2008 10:54:27 EST
../../../img/srcFileCovDistChart0.png 86% of files have more coverage
27   76   5   13.5
4   46   0.19   2
2     2.5  
1    
 
  IndexTest       Line # 26 27 5 0% 0.0
 
No Tests
 
1    package org.apache.lucene;
2   
3    /**
4    * Copyright 2004 The Apache Software Foundation
5    *
6    * Licensed under the Apache License, Version 2.0 (the "License");
7    * you may not use this file except in compliance with the License.
8    * You may obtain a copy of the License at
9    *
10    * http://www.apache.org/licenses/LICENSE-2.0
11    *
12    * Unless required by applicable law or agreed to in writing, software
13    * distributed under the License is distributed on an "AS IS" BASIS,
14    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15    * See the License for the specific language governing permissions and
16    * limitations under the License.
17    */
18   
19    import org.apache.lucene.analysis.SimpleAnalyzer;
20    import org.apache.lucene.index.IndexWriter;
21    import org.apache.lucene.demo.FileDocument;
22   
23    import java.io.File;
24    import java.util.Date;
25   
 
26    class IndexTest {
 
27  0 toggle public static void main(String[] args) {
28  0 try {
29  0 Date start = new Date();
30  0 IndexWriter writer = new IndexWriter(File.createTempFile("luceneTest", "idx"),
31    new SimpleAnalyzer(), true);
32   
33  0 writer.setMergeFactor(20);
34   
35  0 indexDocs(writer, new File("/tmp"));
36   
37  0 writer.optimize();
38  0 writer.close();
39   
40  0 Date end = new Date();
41   
42  0 System.out.print(end.getTime() - start.getTime());
43  0 System.out.println(" total milliseconds");
44   
45  0 Runtime runtime = Runtime.getRuntime();
46   
47  0 System.out.print(runtime.freeMemory());
48  0 System.out.println(" free memory before gc");
49  0 System.out.print(runtime.totalMemory());
50  0 System.out.println(" total memory before gc");
51   
52  0 runtime.gc();
53   
54  0 System.out.print(runtime.freeMemory());
55  0 System.out.println(" free memory after gc");
56  0 System.out.print(runtime.totalMemory());
57  0 System.out.println(" total memory after gc");
58   
59    } catch (Exception e) {
60  0 System.out.println(" caught a " + e.getClass() +
61    "\n with message: " + e.getMessage());
62    }
63    }
64   
 
65  0 toggle public static void indexDocs(IndexWriter writer, File file)
66    throws Exception {
67  0 if (file.isDirectory()) {
68  0 String[] files = file.list();
69  0 for (int i = 0; i < files.length; i++)
70  0 indexDocs(writer, new File(file, files[i]));
71    } else {
72  0 System.out.println("adding " + file);
73  0 writer.addDocument(FileDocument.Document(file));
74    }
75    }
76    }