LUCENE-1582: enable FieldCache.Parser to stop early

git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@762684 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael McCandless 2009-04-07 10:59:22 +00:00
parent c7fe3c5cb0
commit b86ded6fae
3 changed files with 18 additions and 0 deletions

View File

@ -73,6 +73,7 @@ class ExtendedFieldCacheImpl extends FieldCacheImpl implements ExtendedFieldCach
retArray[termDocs.doc()] = termval;
}
} while (termEnum.next());
} catch (StopFillCacheException stop) {
} finally {
termDocs.close();
termEnum.close();
@ -113,6 +114,7 @@ class ExtendedFieldCacheImpl extends FieldCacheImpl implements ExtendedFieldCach
retArray[termDocs.doc()] = termval;
}
} while (termEnum.next());
} catch (StopFillCacheException stop) {
} finally {
termDocs.close();
termEnum.close();

View File

@ -82,6 +82,18 @@ public interface FieldCache {
public interface Parser {
}
/**
* Expert: when thrown from a custom Parser, this stops
* processing terms and returns the current FieldCache
* array.
*
* <p><b>NOTE</b>: This API is experimental and likely to
* change in incompatible ways, or be removed entirely, in
* the next release.
*/
public static class StopFillCacheException extends RuntimeException {
}
/** Interface to parse bytes from document fields.
* @see FieldCache#getBytes(IndexReader, String, FieldCache.ByteParser)
*/

View File

@ -196,6 +196,7 @@ implements FieldCache {
retArray[termDocs.doc()] = termval;
}
} while (termEnum.next());
} catch (StopFillCacheException stop) {
} finally {
termDocs.close();
termEnum.close();
@ -235,6 +236,7 @@ implements FieldCache {
retArray[termDocs.doc()] = termval;
}
} while (termEnum.next());
} catch (StopFillCacheException stop) {
} finally {
termDocs.close();
termEnum.close();
@ -274,6 +276,7 @@ implements FieldCache {
retArray[termDocs.doc()] = termval;
}
} while (termEnum.next());
} catch (StopFillCacheException stop) {
} finally {
termDocs.close();
termEnum.close();
@ -315,6 +318,7 @@ implements FieldCache {
retArray[termDocs.doc()] = termval;
}
} while (termEnum.next());
} catch (StopFillCacheException stop) {
} finally {
termDocs.close();
termEnum.close();