return;
}
System.out.println("Loading date index to RAM at "+this.getClass().getSimpleName()+" class.");
timestamps=new long[reader.maxDoc()];
TermEnum enumerator = reader.terms(new Term(fieldName, ""));
try {
if (enumerator.term()==null) {
throw new IOException("No term found.");
}
TermDocs termDocs = reader.termDocs();
try {
do {
Term term = enumerator.term();
if (term!=null && term.field().equals(fieldName)) {
termDocs.seek(enumerator.term());
while (termDocs.next()) {
// sanity check - validate if timestamp is already assigned to this document
if (timestamps[termDocs.doc()]!=0) {
throw new IOException("Timestamp already assigned.");
}
// sanity check - validate if docid is smaller than the max docid
if (termDocs.doc()>=reader.maxDoc()) {
throw new IOException("Timestamp with invalid docid "+termDocs.doc()+", since max docid is "+reader.maxDoc()+".");
}
timestamps[termDocs.doc()]=Long.parseLong(enumerator.term().text());
if (timestamps[termDocs.doc()]<minTimestamp) {
minTimestamp=timestamps[termDocs.doc()];
}
if (timestamps[termDocs.doc()]>maxTimestamp) {
maxTimestamp=timestamps[termDocs.doc()];
}
}
}
else {
break;
}
}
while (enumerator.next());
}
finally {
termDocs.close();
}
}
finally {
enumerator.close();
}
// sanity check - validate if all documents have timestamps assigned
for (int i=0;i<timestamps.length;i++) {
if (timestamps[i]==0) {