cvsimport
[beagle.git] / beagled / Lucene.Net / Index / SegmentTermPositions.cs
blob0c39d4459e1a8afd1864e6915add7861c92cfd88
1 /*
2 * Copyright 2004 The Apache Software Foundation
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 using System;
18 using IndexInput = Lucene.Net.Store.IndexInput;
20 namespace Lucene.Net.Index
23 sealed class SegmentTermPositions : SegmentTermDocs, TermPositions
25 private IndexInput proxStream;
26 private int proxCount;
27 private int position;
29 internal SegmentTermPositions(SegmentReader p) : base(p)
31 this.proxStream = (IndexInput) parent.proxStream.Clone();
34 internal override void Seek(TermInfo ti)
36 base.Seek(ti);
37 if (ti != null)
38 proxStream.Seek(ti.proxPointer);
39 proxCount = 0;
42 public override void Close()
44 base.Close();
45 proxStream.Close();
48 public int NextPosition()
50 proxCount--;
51 return position += proxStream.ReadVInt();
54 protected internal override void SkippingDoc()
56 for (int f = freq; f > 0; f--)
57 // skip all positions
58 proxStream.ReadVInt();
61 public override bool Next()
63 for (int f = proxCount; f > 0; f--)
64 // skip unread positions
65 proxStream.ReadVInt();
67 if (base.Next())
69 // run super
70 proxCount = freq; // note frequency
71 position = 0; // reset position
72 return true;
74 return false;
77 public override int Read(int[] docs, int[] freqs)
79 throw new System.NotSupportedException("TermPositions does not support processing multiple documents in one call. Use TermDocs instead.");
83 /// <summary>Called by super.skipTo(). </summary>
84 protected internal override void SkipProx(long proxPointer)
86 proxStream.Seek(proxPointer);
87 proxCount = 0;