[
http://issues.apache.org/jira/browse/LUCENE-762?page=comments#action_12461382 ]
Grant Ingersoll commented on LUCENE-762:
----------------------------------------
Hi Chuck,
I haven't applied this yet, but it looks good. My only hesitation, and this is
no reflection on how you have implemented it, but the if-then-else structure
around line 104 is starting to get ugly. I can imagine it growing and growing
as more cases are handled. I was wondering if maybe we should convert to a map
lookup approach. In Java 1.5 the map would be something like:
Map<FieldSelectorResult, FieldSelectorFunctor>
where the Functor does the work of what is in the clause of each of the
different cases
then, the if-else structure could be replaced by
FieldSelectorFunctor functor = map.get(FieldSelectorResult);
if (functor != null)
{
functor.apply(doc, fi, binary, compressed, tokenize);
}
else
{
skipField(binary, compressed)
}
The constructor/static would be responsible for instantiating the Map. The
Functors could be implemented as inner classes (although this can lead to a
bunch of inner classes too)
What do you think?
> [PATCH] Efficiently retrieve sizes of field values
> --------------------------------------------------
>
> Key: LUCENE-762
> URL: http://issues.apache.org/jira/browse/LUCENE-762
> Project: Lucene - Java
> Issue Type: New Feature
> Components: Store
> Affects Versions: 2.1
> Reporter: Chuck Williams
> Attachments: SizeFieldSelector.patch
>
>
> Sometimes an application would like to know how large a document is before
> retrieving it. This can be important for memory management or choosing
> between algorithms, especially in cases where documents might be very large.
> This patch extends the existing FieldSelector mechanism with two new
> FieldSelectorResults: SIZE and SIZE_AND_BREAK. SIZE creates fields on the
> retrieved document that store field sizes instead of actual values.
> SIZE_AND_BREAK is especially efficient if one field comprises the bulk of the
> document size (e.g., the body field) and can thus be used as a reasonable
> size approximation.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]