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

MultipleTermPositions

public class MultipleTermPositions extends Object implements TermPositions
Describe class MultipleTermPositions here.
author
Anders Nielsen
version
1.0

Fields Summary
private int
_doc
private int
_freq
private TermPositionsQueue
_termPositionsQueue
private IntQueue
_posList
Constructors Summary
public MultipleTermPositions(IndexReader indexReader, Term[] terms)
Creates a new MultipleTermPositions instance.

exception
IOException

    List termPositions = new LinkedList();

    for (int i = 0; i < terms.length; i++)
      termPositions.add(indexReader.termPositions(terms[i]));

    _termPositionsQueue = new TermPositionsQueue(termPositions);
    _posList = new IntQueue();
  
Methods Summary
public final voidclose()

    while (_termPositionsQueue.size() > 0)
      ((TermPositions) _termPositionsQueue.pop()).close();
  
public final intdoc()

    return _doc;
  
public final intfreq()

    return _freq;
  
public final booleannext()

    if (_termPositionsQueue.size() == 0)
      return false;

    _posList.clear();
    _doc = _termPositionsQueue.peek().doc();

    TermPositions tp;
    do {
      tp = _termPositionsQueue.peek();

      for (int i = 0; i < tp.freq(); i++)
        _posList.add(tp.nextPosition());

      if (tp.next())
        _termPositionsQueue.adjustTop();
      else {
        _termPositionsQueue.pop();
        tp.close();
      }
    } while (_termPositionsQueue.size() > 0 && _termPositionsQueue.peek().doc() == _doc);

    _posList.sort();
    _freq = _posList.size();

    return true;
  
public final intnextPosition()

    return _posList.next();
  
public intread(int[] arg0, int[] arg1)
Not implemented.

throws
UnsupportedOperationException

    throw new UnsupportedOperationException();
  
public voidseek(org.apache.lucene.index.Term arg0)
Not implemented.

throws
UnsupportedOperationException

    throw new UnsupportedOperationException();
  
public voidseek(org.apache.lucene.index.TermEnum termEnum)
Not implemented.

throws
UnsupportedOperationException

    throw new UnsupportedOperationException();
  
public final booleanskipTo(int target)

    while (_termPositionsQueue.peek() != null && target > _termPositionsQueue.peek().doc()) {
      TermPositions tp = (TermPositions) _termPositionsQueue.pop();
      if (tp.skipTo(target))
        _termPositionsQueue.put(tp);
      else
        tp.close();
    }
    return next();