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
9 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 package org.apache.lucene.index;
19 import org.apache.lucene.util.AttributeSource;
22 * This class tracks the number and position / offset parameters of terms
23 * being added to the index. The information collected in this class is
24 * also used to calculate the normalization factor for a field.
26 * @lucene.experimental
28 public final class FieldInvertState {
36 AttributeSource attributeSource;
38 public FieldInvertState() {
41 public FieldInvertState(int position, int length, int numOverlap, int offset, float boost) {
42 this.position = position;
44 this.numOverlap = numOverlap;
50 * Re-initialize the state, using this boost value.
51 * @param docBoost boost value to use.
53 void reset(float docBoost) {
61 attributeSource = null;
65 * Get the last processed term position.
66 * @return the position
68 public int getPosition() {
73 * Get total number of terms in this field.
76 public int getLength() {
80 public void setLength(int length) {
85 * Get the number of terms with <code>positionIncrement == 0</code>.
86 * @return the numOverlap
88 public int getNumOverlap() {
92 public void setNumOverlap(int numOverlap) {
93 this.numOverlap = numOverlap;
97 * Get end offset of the last processed term.
100 public int getOffset() {
105 * Get boost value. This is the cumulative product of
106 * document boost and field boost for all field instances
107 * sharing the same field name.
110 public float getBoost() {
114 public void setBoost(float boost) {
119 * Get the maximum term-frequency encountered for any term in the field. A
120 * field containing "the quick brown fox jumps over the lazy dog" would have
121 * a value of 2, because "the" appears twice.
123 public int getMaxTermFrequency() {
124 return maxTermFrequency;
128 * Return the number of unique terms encountered in this field.
130 public int getUniqueTermCount() {
131 return uniqueTermCount;
134 public AttributeSource getAttributeSource() {
135 return attributeSource;