Lucene.Net  3.0.3
Lucene.Net is a port of the Lucene search engine library, written in C# and targeted at .NET runtime users.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Properties Pages
TermVectorMapper.cs
Go to the documentation of this file.
1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 using System;
19 
20 namespace Lucene.Net.Index
21 {
22 
23  /// <summary> The TermVectorMapper can be used to map Term Vectors into your own
24  /// structure instead of the parallel array structure used by
25  /// <see cref="Lucene.Net.Index.IndexReader.GetTermFreqVector(int,String)" />.
26  /// <p/>
27  /// It is up to the implementation to make sure it is thread-safe.
28  ///
29  ///
30  ///
31  /// </summary>
32  public abstract class TermVectorMapper
33  {
34 
35  private bool ignoringPositions;
36  private bool ignoringOffsets;
37 
38 
39  protected internal TermVectorMapper()
40  {
41  }
42 
43  /// <summary> </summary>
44  /// <param name="ignoringPositions">true if this mapper should tell Lucene to ignore positions even if they are stored
45  /// </param>
46  /// <param name="ignoringOffsets">similar to ignoringPositions
47  /// </param>
48  protected internal TermVectorMapper(bool ignoringPositions, bool ignoringOffsets)
49  {
50  this.ignoringPositions = ignoringPositions;
51  this.ignoringOffsets = ignoringOffsets;
52  }
53 
54  /// <summary> Tell the mapper what to expect in regards to field, number of terms, offset and position storage.
55  /// This method will be called once before retrieving the vector for a field.
56  ///
57  /// This method will be called before <see cref="Map(String,int,TermVectorOffsetInfo[],int[])" />.
58  /// </summary>
59  /// <param name="field">The field the vector is for
60  /// </param>
61  /// <param name="numTerms">The number of terms that need to be mapped
62  /// </param>
63  /// <param name="storeOffsets">true if the mapper should expect offset information
64  /// </param>
65  /// <param name="storePositions">true if the mapper should expect positions info
66  /// </param>
67  public abstract void SetExpectations(System.String field, int numTerms, bool storeOffsets, bool storePositions);
68  /// <summary> Map the Term Vector information into your own structure</summary>
69  /// <param name="term">The term to add to the vector
70  /// </param>
71  /// <param name="frequency">The frequency of the term in the document
72  /// </param>
73  /// <param name="offsets">null if the offset is not specified, otherwise the offset into the field of the term
74  /// </param>
75  /// <param name="positions">null if the position is not specified, otherwise the position in the field of the term
76  /// </param>
77  public abstract void Map(System.String term, int frequency, TermVectorOffsetInfo[] offsets, int[] positions);
78 
79  /// <summary> Indicate to Lucene that even if there are positions stored, this mapper is not interested in them and they
80  /// can be skipped over. Derived classes should set this to true if they want to ignore positions. The default
81  /// is false, meaning positions will be loaded if they are stored.
82  /// </summary>
83  /// <value> false </value>
84  public virtual bool IsIgnoringPositions
85  {
86  get { return ignoringPositions; }
87  }
88 
89  /// <summary> </summary>
90  /// <seealso cref="IsIgnoringPositions()"> Same principal as <see cref="IsIgnoringPositions()" />, but applied to offsets. false by default.
91  /// </seealso>
92  /// <value> false </value>
93  public virtual bool IsIgnoringOffsets
94  {
95  get { return ignoringOffsets; }
96  }
97 
98  /// <summary> Passes down the index of the document whose term vector is currently being mapped,
99  /// once for each top level call to a term vector reader.
100  /// <p/>
101  /// Default implementation IGNORES the document number. Override if your implementation needs the document number.
102  /// <p/>
103  /// NOTE: Document numbers are internal to Lucene and subject to change depending on indexing operations.
104  ///
105  /// </summary>
106  /// <param name="documentNumber">index of document currently being mapped
107  /// </param>
108  public virtual void SetDocumentNumber(int documentNumber)
109  {
110  }
111  }
112 }