- Added FIXME/TODO tags about things to document.

git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@149848 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Otis Gospodnetic 2002-09-19 02:11:42 +00:00
parent 9b9965017e
commit 846da57000
1 changed files with 57 additions and 42 deletions

View File

@ -63,51 +63,66 @@ import org.apache.lucene.store.InputStream;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
final class FieldsReader {
private FieldInfos fieldInfos;
private InputStream fieldsStream;
private InputStream indexStream;
private int size;
/**
* FIXME: Describe class <code>FieldsReader</code> here.
*
* @version $Id$
*/
final class FieldsReader
{
private FieldInfos fieldInfos;
private InputStream fieldsStream;
private InputStream indexStream;
private int size;
FieldsReader(Directory d, String segment, FieldInfos fn)
throws IOException {
fieldInfos = fn;
FieldsReader(Directory d, String segment, FieldInfos fn)
throws IOException
{
fieldInfos = fn;
fieldsStream = d.openFile(segment + ".fdt");
indexStream = d.openFile(segment + ".fdx");
fieldsStream = d.openFile(segment + ".fdt");
indexStream = d.openFile(segment + ".fdx");
size = (int)indexStream.length() / 8;
}
final void close() throws IOException {
fieldsStream.close();
indexStream.close();
}
final int size() {
return size;
}
final Document doc(int n) throws IOException {
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)); // tokenized
// TODO: document the magic number 8
size = (int)indexStream.length() / 8;
}
return doc;
}
final void close()
throws IOException
{
fieldsStream.close();
indexStream.close();
}
final int size()
{
return size;
}
final Document doc(int n)
throws IOException
{
// TODO: document the magic number 8L
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)); // tokenized
}
return doc;
}
}