mirror of https://github.com/apache/lucene.git
- Cosmetics
git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@485884 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
f4d9f44828
commit
00250552f8
|
@ -69,8 +69,7 @@ public class LengthNormModifier {
|
||||||
LengthNormModifier lnm = new LengthNormModifier(d, s);
|
LengthNormModifier lnm = new LengthNormModifier(d, s);
|
||||||
|
|
||||||
for (int i = 2; i < args.length; i++) {
|
for (int i = 2; i < args.length; i++) {
|
||||||
System.out.print("Updating field: " + args[i] + " " +
|
System.out.print("Updating field: " + args[i] + " " + (new Date()).toString() + " ... ");
|
||||||
(new Date()).toString() + " ... ");
|
|
||||||
lnm.reSetNorms(args[i]);
|
lnm.reSetNorms(args[i]);
|
||||||
System.out.println(new Date().toString());
|
System.out.println(new Date().toString());
|
||||||
}
|
}
|
||||||
|
@ -83,7 +82,7 @@ public class LengthNormModifier {
|
||||||
private Similarity sim;
|
private Similarity sim;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor for code that wishes to use this class progromaticaly
|
* Constructor for code that wishes to use this class progaomatically.
|
||||||
*
|
*
|
||||||
* @param d The Directory to modify
|
* @param d The Directory to modify
|
||||||
* @param s The Similarity to use in <code>reSetNorms</code>
|
* @param s The Similarity to use in <code>reSetNorms</code>
|
||||||
|
@ -94,7 +93,7 @@ public class LengthNormModifier {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Re-Set the norms for the specified field.
|
* Resets the norms for the specified field.
|
||||||
*
|
*
|
||||||
* <p>
|
* <p>
|
||||||
* Opens a new IndexReader on the Directory given to this instance,
|
* Opens a new IndexReader on the Directory given to this instance,
|
||||||
|
@ -102,7 +101,7 @@ public class LengthNormModifier {
|
||||||
* and closes the IndexReader.
|
* and closes the IndexReader.
|
||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
* @param field the field whose norms
|
* @param field the field whose norms should be reset
|
||||||
*/
|
*/
|
||||||
public void reSetNorms(String field) throws IOException {
|
public void reSetNorms(String field) throws IOException {
|
||||||
String fieldName = field.intern();
|
String fieldName = field.intern();
|
||||||
|
@ -127,7 +126,6 @@ public class LengthNormModifier {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} while (termEnum.next());
|
} while (termEnum.next());
|
||||||
|
|
||||||
} finally {
|
} finally {
|
||||||
if (null != termDocs) termDocs.close();
|
if (null != termDocs) termDocs.close();
|
||||||
}
|
}
|
||||||
|
@ -142,12 +140,10 @@ public class LengthNormModifier {
|
||||||
reader = IndexReader.open(dir);
|
reader = IndexReader.open(dir);
|
||||||
for (int d = 0; d < termCounts.length; d++) {
|
for (int d = 0; d < termCounts.length; d++) {
|
||||||
if (! reader.isDeleted(d)) {
|
if (! reader.isDeleted(d)) {
|
||||||
byte norm = sim.encodeNorm
|
byte norm = sim.encodeNorm(sim.lengthNorm(fieldName, termCounts[d]));
|
||||||
(sim.lengthNorm(fieldName, termCounts[d]));
|
|
||||||
reader.setNorm(d, fieldName, norm);
|
reader.setNorm(d, fieldName, norm);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} finally {
|
} finally {
|
||||||
if (null != reader) reader.close();
|
if (null != reader) reader.close();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue