com.sun.labs.minion.indexer.dictionary
Class DiskDictionary.DiskDictionaryIterator

java.lang.Object
  extended by com.sun.labs.minion.indexer.dictionary.DiskDictionary.DiskDictionaryIterator
All Implemented Interfaces:
DictionaryIterator, java.lang.Comparable, java.util.Iterator<QueryEntry>
Enclosing class:
DiskDictionary

public class DiskDictionary.DiskDictionaryIterator
extends java.lang.Object
implements DictionaryIterator, java.lang.Comparable

A class that can be used as an iterator for this block.


Field Summary
protected  boolean actualOnly
          A flag indicating whether we should try to ignore entries whose names have not actually occurred in the indexed material.
protected  PostingsInput[] buffChans
          Buffered channels for reading postings.
protected  boolean casedEntries
          Whether our entries are cased.
protected  Entry curr
          The current entry.
protected  int estSize
          The estimated size of the results set for this iterator.
protected  DiskDictionary.LookupState lus
          Our lookup state.
protected  int pos
          The position in the dictionary.
protected  java.lang.Object prevName
          The name of the previous entry.
protected  boolean returnCurr
           
protected  int startPos
          The position to start iterating from
protected  int stopPos
          The position to stop iterating at
 
Constructor Summary
DiskDictionary.DiskDictionaryIterator(int begin, int end)
          Gets an iterator for the dictionary that starts and stops at the given indices in the dictionary.
DiskDictionary.DiskDictionaryIterator(java.lang.Object startEntry, boolean includeStart, java.lang.Object stopEntry, boolean includeStop)
          Creates a DictionaryIterator that iterates over a range of entries.
 
Method Summary
 int compareTo(java.lang.Object o)
           
 int estimateSize()
          Estimates the size of the document set that would be returned for all the entries that this iterator would produce.
 QueryEntry get(int id)
          Gets an entry for a specific ID from the dictionary that this iterator is iterating through.
 QueryEntry get(java.lang.Object name)
          Gets an entry for a specific name from the dictionary that this iterator is iterating through.
 int getNEntries()
          Gets the number of entries that will be returned by this iterator.
 boolean hasNext()
           
 QueryEntry next()
           
 void remove()
           
 void setActualOnly(boolean actualOnly)
          Modifies the iterator so that it only returns entries whose names have actually occurred in the indexed material.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

estSize

protected int estSize
The estimated size of the results set for this iterator.


pos

protected int pos
The position in the dictionary.


lus

protected DiskDictionary.LookupState lus
Our lookup state.


prevName

protected java.lang.Object prevName
The name of the previous entry.


curr

protected Entry curr
The current entry.


startPos

protected int startPos
The position to start iterating from


stopPos

protected int stopPos
The position to stop iterating at


buffChans

protected PostingsInput[] buffChans
Buffered channels for reading postings.


actualOnly

protected boolean actualOnly
A flag indicating whether we should try to ignore entries whose names have not actually occurred in the indexed material. This will allow us to iterate through the entries in a dictionary where the names are strings and the entries are cased and only show entry names that actually occurred in the indexed material.


casedEntries

protected boolean casedEntries
Whether our entries are cased.


returnCurr

protected boolean returnCurr
Constructor Detail

DiskDictionary.DiskDictionaryIterator

public DiskDictionary.DiskDictionaryIterator(java.lang.Object startEntry,
                                             boolean includeStart,
                                             java.lang.Object stopEntry,
                                             boolean includeStop)
Creates a DictionaryIterator that iterates over a range of entries.

Parameters:
startEntry - the name of the entry to start iterating at, or null to start at the first entry
includeStart - if true and startEntry is non-null, then the iterator will return startEntry, if it is in the dictionary.
stopEntry - the name of the entry to stop iterating at, or null to stop after the last entry.
includeStop - if true and stopEntry is non-null, then the iterator will return stopEntry, if it is in the dictionary.

DiskDictionary.DiskDictionaryIterator

public DiskDictionary.DiskDictionaryIterator(int begin,
                                             int end)
Gets an iterator for the dictionary that starts and stops at the given indices in the dictionary. This can be used when we want to process pieces of a dictionary in different threads.

Parameters:
begin - the beginning index in the dictionary, counting from 0. If this value is less than zero it will be clamped to zero.
end - the ending index in the dictionary, counting from 0. If this value is greater than the number of entries in the dictionary, it will be limited to that number.
Method Detail

setActualOnly

public void setActualOnly(boolean actualOnly)
Modifies the iterator so that it only returns entries whose names have actually occurred in the indexed material. So, for example, if the word Dog occurs in the indexed material, and is the only occurrence of that word, then the entry dog in a cased dictionary would not be returned if this method is called with a value of true.

Note that this option really only makes sense for dictionaries that use cased entries.

Specified by:
setActualOnly in interface DictionaryIterator
Parameters:
actualOnly - if true only entries with names that actually occurred in the indexed material will be returned. If false all entries will be returned.

hasNext

public boolean hasNext()
Specified by:
hasNext in interface java.util.Iterator<QueryEntry>

next

public QueryEntry next()
                throws java.util.NoSuchElementException
Specified by:
next in interface java.util.Iterator<QueryEntry>
Throws:
java.util.NoSuchElementException

remove

public void remove()
Specified by:
remove in interface java.util.Iterator<QueryEntry>

compareTo

public int compareTo(java.lang.Object o)
Specified by:
compareTo in interface java.lang.Comparable

estimateSize

public int estimateSize()
Estimates the size of the document set that would be returned for all the entries that this iterator would produce. This is a gross hack!

Specified by:
estimateSize in interface DictionaryIterator

getNEntries

public int getNEntries()
Description copied from interface: DictionaryIterator
Gets the number of entries that will be returned by this iterator.

Specified by:
getNEntries in interface DictionaryIterator

get

public QueryEntry get(int id)
Description copied from interface: DictionaryIterator
Gets an entry for a specific ID from the dictionary that this iterator is iterating through. This is an atypical iterator method, but it may be a lot faster, especially if the implementation keeps a local copy of dictionary data for faster uncontended access.

Specified by:
get in interface DictionaryIterator

get

public QueryEntry get(java.lang.Object name)
Description copied from interface: DictionaryIterator
Gets an entry for a specific name from the dictionary that this iterator is iterating through. This is an atypical iterator method, but it may be a lot faster, especially if the implementation keeps a local copy of dictionary data for faster uncontended access.

Specified by:
get in interface DictionaryIterator