iterating over fieldInfos instead of document fields seems

more natural and more efficient for writeNorms


git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@150288 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Christoph Goller 2004-04-16 10:15:20 +00:00
parent 34b8f647fe
commit a35399734d
1 changed files with 5 additions and 9 deletions

View File

@ -316,15 +316,11 @@ final class DocumentWriter {
}
}
private final void writeNorms(Document doc, String segment)
throws IOException {
Enumeration fields = doc.fields();
while (fields.hasMoreElements()) {
Field field = (Field) fields.nextElement();
if (field.isIndexed()) {
int n = fieldInfos.fieldNumber(field.name());
float norm =
fieldBoosts[n] * similarity.lengthNorm(field.name(), fieldLengths[n]);
private final void writeNorms(Document doc, String segment) throws IOException {
for(int n = 0; n < fieldInfos.size(); n++){
FieldInfo fi = fieldInfos.fieldInfo(n);
if(fi.isIndexed){
float norm = fieldBoosts[n] * similarity.lengthNorm(fi.name, fieldLengths[n]);
OutputStream norms = directory.createFile(segment + ".f" + n);
try {
norms.writeByte(similarity.encodeNorm(norm));