FileDocCategorySizeDatePackage
FieldsReader.javaAPI DocApache Lucene 1.4.32256Tue Mar 30 00:48:02 BST 2004org.apache.lucene.index

FieldsReader

public final class FieldsReader extends Object
Class responsible for access to stored document fields. It uses <segment>.fdt and <segment>.fdx; files.
version
$Id: FieldsReader.java,v 1.7 2004/03/29 22:48:02 cutting Exp $

Fields Summary
private FieldInfos
fieldInfos
private org.apache.lucene.store.InputStream
fieldsStream
private org.apache.lucene.store.InputStream
indexStream
private int
size
Constructors Summary
FieldsReader(Directory d, String segment, FieldInfos fn)

    fieldInfos = fn;

    fieldsStream = d.openFile(segment + ".fdt");
    indexStream = d.openFile(segment + ".fdx");

    size = (int)(indexStream.length() / 8);
  
Methods Summary
final voidclose()

    fieldsStream.close();
    indexStream.close();
  
final org.apache.lucene.document.Documentdoc(int n)

    indexStream.seek(n * 8L);
    long position = indexStream.readLong();
    fieldsStream.seek(position);

    Document doc = new Document();
    int numFields = fieldsStream.readVInt();
    for (int i = 0; i < numFields; i++) {
      int fieldNumber = fieldsStream.readVInt();
      FieldInfo fi = fieldInfos.fieldInfo(fieldNumber);

      byte bits = fieldsStream.readByte();

      doc.add(new Field(fi.name,		  // name
			fieldsStream.readString(), // read value
			true,			  // stored
			fi.isIndexed,		  // indexed
			(bits & 1) != 0, fi.storeTermVector)); // vector
    }

    return doc;
  
final intsize()

    return size;