- Reverted back to the previous revision (1.1).

git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@149858 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Otis Gospodnetic 2002-09-20 02:21:31 +00:00
parent 2ae2c8682f
commit 474d9de985
1 changed files with 37 additions and 52 deletions

View File

@ -63,66 +63,51 @@ import org.apache.lucene.store.InputStream;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
/**
* FIXME: Describe class <code>FieldsReader</code> here.
*
* @version $Id$
*/
final class FieldsReader
{
private FieldInfos fieldInfos;
private InputStream fieldsStream;
private InputStream indexStream;
private int size;
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");
// TODO: document the magic number 8
size = (int)indexStream.length() / 8;
}
size = (int)indexStream.length() / 8;
}
final void close()
throws IOException
{
fieldsStream.close();
indexStream.close();
}
final void close() throws IOException {
fieldsStream.close();
indexStream.close();
}
final int size()
{
return size;
}
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);
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);
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();
byte bits = fieldsStream.readByte();
doc.add(new Field(fi.name, // name
doc.add(new Field(fi.name, // name
fieldsStream.readString(), // read value
true, // stored
fi.isIndexed, // indexed
(bits & 1) != 0)); // tokenized
}
return doc;
true, // stored
fi.isIndexed, // indexed
(bits & 1) != 0)); // tokenized
}
return doc;
}
}