FileDocCategorySizeDatePackage
SegmentTermEnum.javaAPI DocApache Lucene 2.1.06066Wed Feb 14 10:46:40 GMT 2007org.apache.lucene.index

SegmentTermEnum

public final class SegmentTermEnum extends TermEnum implements Cloneable
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Fields Summary
private IndexInput
input
FieldInfos
fieldInfos
long
size
long
position
private TermBuffer
termBuffer
private TermBuffer
prevBuffer
private TermBuffer
scratch
private TermInfo
termInfo
private int
format
private boolean
isIndex
long
indexPointer
int
indexInterval
int
skipInterval
private int
formatM1SkipInterval
Constructors Summary
SegmentTermEnum(IndexInput i, FieldInfos fis, boolean isi)


       
            
    input = i;
    fieldInfos = fis;
    isIndex = isi;

    int firstInt = input.readInt();
    if (firstInt >= 0) {
      // original-format file, without explicit format version number
      format = 0;
      size = firstInt;

      // back-compatible settings
      indexInterval = 128;
      skipInterval = Integer.MAX_VALUE; // switch off skipTo optimization

    } else {
      // we have a format version number
      format = firstInt;

      // check that it is a format we can understand
      if (format < TermInfosWriter.FORMAT)
        throw new IOException("Unknown format version:" + format);

      size = input.readLong();                    // read the size
      
      if(format == -1){
        if (!isIndex) {
          indexInterval = input.readInt();
          formatM1SkipInterval = input.readInt();
        }
        // switch off skipTo optimization for file format prior to 1.4rc2 in order to avoid a bug in 
        // skipTo implementation of these versions
        skipInterval = Integer.MAX_VALUE;
      }
      else{
        indexInterval = input.readInt();
        skipInterval = input.readInt();
      }
    }

  
Methods Summary
protected java.lang.Objectclone()

    SegmentTermEnum clone = null;
    try {
      clone = (SegmentTermEnum) super.clone();
    } catch (CloneNotSupportedException e) {}

    clone.input = (IndexInput) input.clone();
    clone.termInfo = new TermInfo(termInfo);

    clone.termBuffer = (TermBuffer)termBuffer.clone();
    clone.prevBuffer = (TermBuffer)prevBuffer.clone();
    clone.scratch = null;

    return clone;
  
public final voidclose()
Closes the enumeration to further activity, freeing resources.

    input.close();
  
public final intdocFreq()
Returns the docFreq from the current TermInfo in the enumeration. Initially invalid, valid after next() called for the first time.

    return termInfo.docFreq;
  
final longfreqPointer()

    return termInfo.freqPointer;
  
public final booleannext()
Increments the enumeration to the next element. True if one exists.

    if (position++ >= size - 1) {
      termBuffer.reset();
      return false;
    }

    prevBuffer.set(termBuffer);
    termBuffer.read(input, fieldInfos);

    termInfo.docFreq = input.readVInt();	  // read doc freq
    termInfo.freqPointer += input.readVLong();	  // read freq pointer
    termInfo.proxPointer += input.readVLong();	  // read prox pointer
    
    if(format == -1){
    //  just read skipOffset in order to increment  file pointer; 
    // value is never used since skipTo is switched off
      if (!isIndex) {
        if (termInfo.docFreq > formatM1SkipInterval) {
          termInfo.skipOffset = input.readVInt(); 
        }
      }
    }
    else{
      if (termInfo.docFreq >= skipInterval) 
        termInfo.skipOffset = input.readVInt();
    }
    
    if (isIndex)
      indexPointer += input.readVLong();	  // read index pointer

    return true;
  
final org.apache.lucene.index.Termprev()
Returns the previous Term enumerated. Initially null.

    return prevBuffer.toTerm();
  
final longproxPointer()

    return termInfo.proxPointer;
  
final voidscanTo(org.apache.lucene.index.Term term)
Optimized scan, without allocating new terms.

    if (scratch == null)
      scratch = new TermBuffer();
    scratch.set(term);
    while (scratch.compareTo(termBuffer) > 0 && next()) {}
  
final voidseek(long pointer, int p, org.apache.lucene.index.Term t, org.apache.lucene.index.TermInfo ti)

    input.seek(pointer);
    position = p;
    termBuffer.set(t);
    prevBuffer.reset();
    termInfo.set(ti);
  
public final org.apache.lucene.index.Termterm()
Returns the current Term in the enumeration. Initially invalid, valid after next() called for the first time.

    return termBuffer.toTerm();
  
final org.apache.lucene.index.TermInfotermInfo()
Returns the current TermInfo in the enumeration. Initially invalid, valid after next() called for the first time.

    return new TermInfo(termInfo);
  
final voidtermInfo(org.apache.lucene.index.TermInfo ti)
Sets the argument to the current TermInfo in the enumeration. Initially invalid, valid after next() called for the first time.

    ti.set(termInfo);