Removed constrait that a sort field must have some terms indexed: LUCENE-374

git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@377502 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Yonik Seeley 2006-02-13 21:46:13 +00:00
parent 93657ca63a
commit 8a3cae2dd8
2 changed files with 100 additions and 121 deletions

View File

@ -337,6 +337,9 @@ Bug fixes
"[1/16/2000 TO 1/18/2000]". This query did not include the documents "[1/16/2000 TO 1/18/2000]". This query did not include the documents
of 1/18/2000, i.e. the last day was not included. (Daniel Naber) of 1/18/2000, i.e. the last day was not included. (Daniel Naber)
24. Removed sorting constraint that threw an exception if there were
not yet any values for the sort field (Yonik Seeley, LUCENE-374)
Optimizations Optimizations
1. Disk usage (peak requirements during indexing and optimization) 1. Disk usage (peak requirements during indexing and optimization)

View File

@ -154,16 +154,12 @@ implements FieldCache {
Object ret = lookup (reader, field, parser); Object ret = lookup (reader, field, parser);
if (ret == null) { if (ret == null) {
final int[] retArray = new int[reader.maxDoc()]; final int[] retArray = new int[reader.maxDoc()];
if (retArray.length > 0) {
TermDocs termDocs = reader.termDocs(); TermDocs termDocs = reader.termDocs();
TermEnum termEnum = reader.terms (new Term (field, "")); TermEnum termEnum = reader.terms (new Term (field, ""));
try { try {
if (termEnum.term() == null) {
throw new RuntimeException ("no terms in field " + field);
}
do { do {
Term term = termEnum.term(); Term term = termEnum.term();
if (term.field() != field) break; if (term==null || term.field() != field) break;
int termval = parser.parseInt(term.text()); int termval = parser.parseInt(term.text());
termDocs.seek (termEnum); termDocs.seek (termEnum);
while (termDocs.next()) { while (termDocs.next()) {
@ -174,7 +170,6 @@ implements FieldCache {
termDocs.close(); termDocs.close();
termEnum.close(); termEnum.close();
} }
}
store (reader, field, parser, retArray); store (reader, field, parser, retArray);
return retArray; return retArray;
} }
@ -194,16 +189,12 @@ implements FieldCache {
Object ret = lookup (reader, field, parser); Object ret = lookup (reader, field, parser);
if (ret == null) { if (ret == null) {
final float[] retArray = new float[reader.maxDoc()]; final float[] retArray = new float[reader.maxDoc()];
if (retArray.length > 0) {
TermDocs termDocs = reader.termDocs(); TermDocs termDocs = reader.termDocs();
TermEnum termEnum = reader.terms (new Term (field, "")); TermEnum termEnum = reader.terms (new Term (field, ""));
try { try {
if (termEnum.term() == null) {
throw new RuntimeException ("no terms in field " + field);
}
do { do {
Term term = termEnum.term(); Term term = termEnum.term();
if (term.field() != field) break; if (term==null || term.field() != field) break;
float termval = parser.parseFloat(term.text()); float termval = parser.parseFloat(term.text());
termDocs.seek (termEnum); termDocs.seek (termEnum);
while (termDocs.next()) { while (termDocs.next()) {
@ -214,7 +205,6 @@ implements FieldCache {
termDocs.close(); termDocs.close();
termEnum.close(); termEnum.close();
} }
}
store (reader, field, parser, retArray); store (reader, field, parser, retArray);
return retArray; return retArray;
} }
@ -228,16 +218,12 @@ implements FieldCache {
Object ret = lookup (reader, field, SortField.STRING); Object ret = lookup (reader, field, SortField.STRING);
if (ret == null) { if (ret == null) {
final String[] retArray = new String[reader.maxDoc()]; final String[] retArray = new String[reader.maxDoc()];
if (retArray.length > 0) {
TermDocs termDocs = reader.termDocs(); TermDocs termDocs = reader.termDocs();
TermEnum termEnum = reader.terms (new Term (field, "")); TermEnum termEnum = reader.terms (new Term (field, ""));
try { try {
if (termEnum.term() == null) {
throw new RuntimeException ("no terms in field " + field);
}
do { do {
Term term = termEnum.term(); Term term = termEnum.term();
if (term.field() != field) break; if (term==null || term.field() != field) break;
String termval = term.text(); String termval = term.text();
termDocs.seek (termEnum); termDocs.seek (termEnum);
while (termDocs.next()) { while (termDocs.next()) {
@ -248,7 +234,6 @@ implements FieldCache {
termDocs.close(); termDocs.close();
termEnum.close(); termEnum.close();
} }
}
store (reader, field, SortField.STRING, retArray); store (reader, field, SortField.STRING, retArray);
return retArray; return retArray;
} }
@ -263,7 +248,6 @@ implements FieldCache {
if (ret == null) { if (ret == null) {
final int[] retArray = new int[reader.maxDoc()]; final int[] retArray = new int[reader.maxDoc()];
String[] mterms = new String[reader.maxDoc()+1]; String[] mterms = new String[reader.maxDoc()+1];
if (retArray.length > 0) {
TermDocs termDocs = reader.termDocs(); TermDocs termDocs = reader.termDocs();
TermEnum termEnum = reader.terms (new Term (field, "")); TermEnum termEnum = reader.terms (new Term (field, ""));
int t = 0; // current term number int t = 0; // current term number
@ -275,12 +259,9 @@ implements FieldCache {
mterms[t++] = null; mterms[t++] = null;
try { try {
if (termEnum.term() == null) {
throw new RuntimeException ("no terms in field " + field);
}
do { do {
Term term = termEnum.term(); Term term = termEnum.term();
if (term.field() != field) break; if (term==null || term.field() != field) break;
// store term text // store term text
// we expect that there is at most one term per document // we expect that there is at most one term per document
@ -312,7 +293,7 @@ implements FieldCache {
System.arraycopy (mterms, 0, terms, 0, t); System.arraycopy (mterms, 0, terms, 0, t);
mterms = terms; mterms = terms;
} }
}
StringIndex value = new StringIndex (retArray, mterms); StringIndex value = new StringIndex (retArray, mterms);
store (reader, field, STRING_INDEX, value); store (reader, field, STRING_INDEX, value);
return value; return value;
@ -389,16 +370,12 @@ implements FieldCache {
Object ret = lookup (reader, field, comparator); Object ret = lookup (reader, field, comparator);
if (ret == null) { if (ret == null) {
final Comparable[] retArray = new Comparable[reader.maxDoc()]; final Comparable[] retArray = new Comparable[reader.maxDoc()];
if (retArray.length > 0) {
TermDocs termDocs = reader.termDocs(); TermDocs termDocs = reader.termDocs();
TermEnum termEnum = reader.terms (new Term (field, "")); TermEnum termEnum = reader.terms (new Term (field, ""));
try { try {
if (termEnum.term() == null) {
throw new RuntimeException ("no terms in field " + field);
}
do { do {
Term term = termEnum.term(); Term term = termEnum.term();
if (term.field() != field) break; if (term==null || term.field() != field) break;
Comparable termval = comparator.getComparable (term.text()); Comparable termval = comparator.getComparable (term.text());
termDocs.seek (termEnum); termDocs.seek (termEnum);
while (termDocs.next()) { while (termDocs.next()) {
@ -409,7 +386,6 @@ implements FieldCache {
termDocs.close(); termDocs.close();
termEnum.close(); termEnum.close();
} }
}
store (reader, field, comparator, retArray); store (reader, field, comparator, retArray);
return retArray; return retArray;
} }