use of gate.creole.annic.apache.lucene.index.TermEnum in project gate-core by GateNLP.
the class FieldCacheImpl method getFloats.
// inherit javadocs
@Override
public float[] getFloats(IndexReader reader, String field) throws IOException {
field = field.intern();
Object ret = lookup(reader, field, SortField.FLOAT);
if (ret == null) {
final float[] retArray = new float[reader.maxDoc()];
if (retArray.length > 0) {
TermDocs termDocs = reader.termDocs();
TermEnum termEnum = reader.terms(new Term(field, ""));
try {
if (termEnum.term() == null) {
throw new RuntimeException("no terms in field " + field);
}
do {
Term term = termEnum.term();
if (term.field() != field)
break;
float termval = Float.parseFloat(term.text());
termDocs.seek(termEnum);
while (termDocs.next()) {
retArray[termDocs.doc()] = termval;
}
} while (termEnum.next());
} finally {
termDocs.close();
termEnum.close();
}
}
store(reader, field, SortField.FLOAT, retArray);
return retArray;
}
return (float[]) ret;
}
use of gate.creole.annic.apache.lucene.index.TermEnum in project gate-core by GateNLP.
the class FieldCacheImpl method getStrings.
// inherit javadocs
@Override
public String[] getStrings(IndexReader reader, String field) throws IOException {
field = field.intern();
Object ret = lookup(reader, field, SortField.STRING);
if (ret == null) {
final String[] retArray = new String[reader.maxDoc()];
if (retArray.length > 0) {
TermDocs termDocs = reader.termDocs();
TermEnum termEnum = reader.terms(new Term(field, ""));
try {
if (termEnum.term() == null) {
throw new RuntimeException("no terms in field " + field);
}
do {
Term term = termEnum.term();
if (term.field() != field)
break;
String termval = term.text();
termDocs.seek(termEnum);
while (termDocs.next()) {
retArray[termDocs.doc()] = termval;
}
} while (termEnum.next());
} finally {
termDocs.close();
termEnum.close();
}
}
store(reader, field, SortField.STRING, retArray);
return retArray;
}
return (String[]) ret;
}
Aggregations