Clover Coverage Report
Coverage timestamp: Fri May 9 2008 10:54:27 EST
../../../../img/srcFileCovDistChart9.png 37% of files have more coverage
55   194   32   2.89
22   120   0.58   6.33
19     1.68  
3    
 
  MultipleTermPositions       Line # 33 35 20 83.6% 0.8360656
  MultipleTermPositions.TermPositionsQueue       Line # 35 8 5 93.3% 0.93333334
  MultipleTermPositions.IntQueue       Line # 56 12 7 65% 0.65
 
  (8)
 
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 java.io.IOException;
20    import java.util.Arrays;
21    import java.util.Iterator;
22    import java.util.LinkedList;
23    import java.util.List;
24   
25    import org.apache.lucene.util.PriorityQueue;
26   
27    /**
28    * Describe class <code>MultipleTermPositions</code> here.
29    *
30    * @author Anders Nielsen
31    * @version 1.0
32    */
 
33    public class MultipleTermPositions implements TermPositions {
34   
 
35    private static final class TermPositionsQueue extends PriorityQueue {
 
36  47 toggle TermPositionsQueue(List termPositions) throws IOException {
37  47 initialize(termPositions.size());
38   
39  47 Iterator i = termPositions.iterator();
40  153 while (i.hasNext()) {
41  106 TermPositions tp = (TermPositions) i.next();
42  106 if (tp.next())
43  106 put(tp);
44    }
45    }
46   
 
47  783 toggle final TermPositions peek() {
48  783 return (TermPositions) top();
49    }
50   
 
51  323 toggle public final boolean lessThan(Object a, Object b) {
52  323 return ((TermPositions) a).doc() < ((TermPositions) b).doc();
53    }
54    }
55   
 
56    private static final class IntQueue {
57    private int _arraySize = 16;
58    private int _index = 0;
59    private int _lastIndex = 0;
60    private int[] _array = new int[_arraySize];
61   
 
62  325 toggle final void add(int i) {
63  325 if (_lastIndex == _arraySize)
64  0 growArray();
65   
66  325 _array[_lastIndex++] = i;
67    }
68   
 
69  230 toggle final int next() {
70  230 return _array[_index++];
71    }
72   
 
73  148 toggle final void sort() {
74  148 Arrays.sort(_array, _index, _lastIndex);
75    }
76   
 
77  148 toggle final void clear() {
78  148 _index = 0;
79  148 _lastIndex = 0;
80    }
81   
 
82  148 toggle final int size() {
83  148 return (_lastIndex - _index);
84    }
85   
 
86  0 toggle private void growArray() {
87  0 int[] newArray = new int[_arraySize * 2];
88  0 System.arraycopy(_array, 0, newArray, 0, _arraySize);
89  0 _array = newArray;
90  0 _arraySize *= 2;
91    }
92    }
93   
94    private int _doc;
95    private int _freq;
96    private TermPositionsQueue _termPositionsQueue;
97    private IntQueue _posList;
98   
99    /**
100    * Creates a new <code>MultipleTermPositions</code> instance.
101    *
102    * @exception IOException
103    */
 
104  47 toggle public MultipleTermPositions(IndexReader indexReader, Term[] terms) throws IOException {
105  47 List termPositions = new LinkedList();
106   
107  153 for (int i = 0; i < terms.length; i++)
108  106 termPositions.add(indexReader.termPositions(terms[i]));
109   
110  47 _termPositionsQueue = new TermPositionsQueue(termPositions);
111  47