Clover Coverage Report
Coverage timestamp: Fri May 9 2008 10:54:27 EST
../../../../img/srcFileCovDistChart6.png 74% of files have more coverage
139   395   84   3.02
84   271   0.6   11.5
46     1.83  
4    
 
  ParallelReader       Line # 55 87 48 51.5% 0.5151515
  ParallelReader.ParallelTermEnum       Line # 262 31 18 59.6% 0.5964912
  ParallelReader.ParallelTermDocs       Line # 330 17 14 56.8% 0.5675676
  ParallelReader.ParallelTermPositions       Line # 376 4 4 0% 0.0
 
  (5)
 
1    package org.apache.lucene.index;
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.document.Document;
20    import org.apache.lucene.document.Fieldable;
21    import org.apache.lucene.document.FieldSelector;
22    import org.apache.lucene.document.FieldSelectorResult;
23   
24    import java.io.IOException;
25    import java.util.SortedMap;
26    import java.util.ArrayList;
27    import java.util.List;
28    import java.util.HashMap;
29    import java.util.Map;
30    import java.util.TreeMap;
31    import java.util.Collection;
32    import java.util.Iterator;
33    import java.util.Enumeration;
34    import java.util.Set;
35    import java.util.HashSet;
36   
37   
38    /** An IndexReader which reads multiple, parallel indexes. Each index added
39    * must have the same number of documents, but typically each contains
40    * different fields. Each document contains the union of the fields of all
41    * documents with the same document number. When searching, matches for a
42    * query term are from the first index added that has the field.
43    *
44    * <p>This is useful, e.g., with collections that have large fields which
45    * change rarely and small fields that change more frequently. The smaller
46    * fields may be re-indexed in a new index and both indexes may be searched
47    * together.
48    *
49    * <p><strong>Warning:</strong> It is up to you to make sure all indexes
50    * are created and modified the same way. For example, if you add
51    * documents to one index, you need to add the same documents in the
52    * same order to the other indexes. <em>Failure to do so will result in
53    * undefined behavior</em>.
54    */
 
55    public class ParallelReader extends IndexReader {
56    private List readers = new ArrayList();
57    private SortedMap fieldToReader = new TreeMap();
58    private Map readerToFields = new HashMap();
59    private List storedFieldReaders = new ArrayList();
60   
61    private int maxDoc;
62    private int numDocs;
63    private boolean hasDeletions;
64   
65    /** Construct a ParallelReader. */
 
66  8 toggle public ParallelReader() throws IOException { super(null); }
67   
68    /** Add an IndexReader. */
 
69  16 toggle public void add(IndexReader reader) throws IOException {
70  16 add(reader, false);
71    }