Thumbnail file hits. Based on a patch from D Bera
[beagle.git] / beagled / Lucene.Net / Index / SegmentTermPositions.cs
blob5d6a5f99afcb077a20e13f36d394facbd69a9574
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.
16 using System;
17 using InputStream = Lucene.Net.Store.InputStream;
18 namespace Lucene.Net.Index
21 sealed class SegmentTermPositions : SegmentTermDocs, TermPositions
23 private InputStream proxStream;
24 private int proxCount;
25 private int position;
27 internal SegmentTermPositions(SegmentReader p):base(p)
29 this.proxStream = (InputStream) parent.proxStream.Clone();
32 internal override void Seek(TermInfo ti)
34 base.Seek(ti);
35 if (ti != null)
36 proxStream.Seek(ti.proxPointer);
37 proxCount = 0;
40 public override void Close()
42 base.Close();
43 proxStream.Close();
46 public int NextPosition()
48 proxCount--;
49 return position += proxStream.ReadVInt();
52 protected internal override void SkippingDoc()
54 for (int f = freq; f > 0; f--)
55 // skip all positions
56 proxStream.ReadVInt();
59 public override bool Next()
61 for (int f = proxCount; f > 0; f--)
62 // skip unread positions
63 proxStream.ReadVInt();
65 if (base.Next())
67 // run super
68 proxCount = freq; // note frequency
69 position = 0; // reset position
70 return true;
72 return false;
75 public override int Read(int[] docs, int[] freqs)
77 throw new System.NotSupportedException("TermPositions does not support processing multiple documents in one call. Use TermDocs instead.");
81 /// <summary>Called by base.SkipTo(). </summary>
82 protected internal override void SkipProx(long proxPointer)
84 proxStream.Seek(proxPointer);
85 proxCount = 0;