gate.creole.annic.apache.lucene.index
Class TermVectorsWriter

java.lang.Object
  extended by gate.creole.annic.apache.lucene.index.TermVectorsWriter

final class TermVectorsWriter
extends Object

Writer works by opening a document and then opening the fields within the document and then writing out the vectors for each field. Rough usage: for each document { writer.openDocument(); for each field on the document { writer.openField(field); for all of the terms { writer.addTerm(...) } writer.closeField } writer.closeDocument() }


Nested Class Summary
private static class TermVectorsWriter.TVField
           
private static class TermVectorsWriter.TVTerm
           
 
Field Summary
private  long currentDocPointer
           
private  TermVectorsWriter.TVField currentField
           
private  FieldInfos fieldInfos
           
private  Vector fields
           
static int FORMAT_SIZE
           
static int FORMAT_VERSION
           
private  Vector terms
           
private  OutputStream tvd
           
static String TVD_EXTENSION
           
private  OutputStream tvf
           
static String TVF_EXTENSION
           
private  OutputStream tvx
           
static String TVX_EXTENSION
           
 
Constructor Summary
TermVectorsWriter(Directory directory, String segment, FieldInfos fieldInfos)
          Create term vectors writer for the specified segment in specified directory.
 
Method Summary
 void addTerm(String termText, int freq)
          Add term to the field's term vector.
 void addTermFreqVector(TermFreqVector vector)
          Add specified vector to the document.
private  void addTermFreqVectorInternal(TermFreqVector vector)
           
private  void addTermInternal(String termText, int freq)
           
 void addVectors(TermFreqVector[] vectors)
          Add specified vectors to the document.
(package private)  void close()
          Close all streams.
 void closeDocument()
           
 void closeField()
          Finished processing current field.
 boolean isDocumentOpen()
           
 boolean isFieldOpen()
          Return true if a field is currently open.
 void openDocument()
           
 void openField(String field)
          Start processing a field.
private  void writeDoc()
           
private  void writeField()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FORMAT_VERSION

public static final int FORMAT_VERSION
See Also:
Constant Field Values

FORMAT_SIZE

public static final int FORMAT_SIZE
See Also:
Constant Field Values

TVX_EXTENSION

public static final String TVX_EXTENSION
See Also:
Constant Field Values

TVD_EXTENSION

public static final String TVD_EXTENSION
See Also:
Constant Field Values

TVF_EXTENSION

public static final String TVF_EXTENSION
See Also:
Constant Field Values

tvx

private OutputStream tvx

tvd

private OutputStream tvd

tvf

private OutputStream tvf

fields

private Vector fields

terms

private Vector terms

fieldInfos

private FieldInfos fieldInfos

currentField

private TermVectorsWriter.TVField currentField

currentDocPointer

private long currentDocPointer
Constructor Detail

TermVectorsWriter

public TermVectorsWriter(Directory directory,
                         String segment,
                         FieldInfos fieldInfos)
                  throws IOException
Create term vectors writer for the specified segment in specified directory. A new TermVectorsWriter should be created for each segment. The parameter maxFields indicates how many total fields are found in this document. Not all of these fields may require termvectors to be stored, so the number of calls to openField is less or equal to this number.

Throws:
IOException
Method Detail

openDocument

public final void openDocument()
                        throws IOException
Throws:
IOException

closeDocument

public final void closeDocument()
                         throws IOException
Throws:
IOException

isDocumentOpen

public final boolean isDocumentOpen()

openField

public final void openField(String field)
                     throws IOException
Start processing a field. This can be followed by a number of calls to addTerm, and a final call to closeField to indicate the end of processing of this field. If a field was previously open, it is closed automatically.

Throws:
IOException

closeField

public final void closeField()
                      throws IOException
Finished processing current field. This should be followed by a call to openField before future calls to addTerm.

Throws:
IOException

isFieldOpen

public final boolean isFieldOpen()
Return true if a field is currently open.


addTerm

public final void addTerm(String termText,
                          int freq)
Add term to the field's term vector. Field must already be open of NullPointerException is thrown. Terms should be added in increasing order of terms, one call per unique termNum. ProxPointer is a pointer into the TermPosition file (prx). Freq is the number of times this term appears in this field, in this document.


addTermInternal

private final void addTermInternal(String termText,
                                   int freq)

addVectors

public final void addVectors(TermFreqVector[] vectors)
                      throws IOException
Add specified vectors to the document.

Throws:
IOException

addTermFreqVector

public final void addTermFreqVector(TermFreqVector vector)
                             throws IOException
Add specified vector to the document. Document must be open but no field should be open or exception is thrown. The same document can have addTerm and addVectors calls mixed, however a given field must either be populated with addTerm or with addVector. *

Throws:
IOException

addTermFreqVectorInternal

private final void addTermFreqVectorInternal(TermFreqVector vector)
                                      throws IOException
Throws:
IOException

close

final void close()
          throws IOException
Close all streams.

Throws:
IOException

writeField

private void writeField()
                 throws IOException
Throws:
IOException

writeDoc

private void writeDoc()
               throws IOException
Throws:
IOException