From a35399734de463a3fcc67ab82cac2de1d19dfcf0 Mon Sep 17 00:00:00 2001 From: Christoph Goller Date: Fri, 16 Apr 2004 10:15:20 +0000 Subject: [PATCH] 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 --- .../org/apache/lucene/index/DocumentWriter.java | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/java/org/apache/lucene/index/DocumentWriter.java b/src/java/org/apache/lucene/index/DocumentWriter.java index 4ea68330ab8..bdfc3cb1e48 100644 --- a/src/java/org/apache/lucene/index/DocumentWriter.java +++ b/src/java/org/apache/lucene/index/DocumentWriter.java @@ -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));