You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by Karl Wettin <ka...@gmail.com> on 2007/10/25 01:23:25 UTC
Allowing IOExceptions in TermVectorMapper?
How about allowing IOExceptions beeing thrown from the abstract
TermVectorMapper methods?
The use case is that I want a normalized frequency, and I'd like to
do that by loading the factor from an IndexReader in setExpectations.
I could wrap it in a RuntimeException, I could update the values
later. But TermVectorReader.readTermVector already throws
IOException, so using that feels like the optimal solution to me. Or?
--
karl
---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-dev-help@lucene.apache.org
Re: Allowing IOExceptions in TermVectorMapper?
Posted by Karl Wettin <ka...@gmail.com>.
25 okt 2007 kl. 18.03 skrev Grant Ingersoll:
> I suppose we could have a whole fun debate about checked exceptions
> versus unchecked. :-)
I would hate to open yet another can of worms. If Lucene historically
says that checked is the way to go, I'll follow that.
--
karl
---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-dev-help@lucene.apache.org
Re: Allowing IOExceptions in TermVectorMapper?
Posted by Grant Ingersoll <gs...@apache.org>.
Cool use of the TVMs, but...
I think a RuntimeException is better, as TVMs don't generally do IO.
The TermVectorReader.readTermVector is just calling back to the TVM,
so it is appropriate that it throws the IOException since it is where
the IO happens. Implementation exceptions, IMO, are best handled
through RuntimeExceptions, else you are potentially putting
implementation details into the interface. Not sure if an
IOException falls into that category, since it is pretty generic,
but, what do others think?
I suppose we could have a whole fun debate about checked exceptions
versus unchecked. :-)
http://www.javapractices.com/Topic129.cjp
http://java.sun.com/docs/books/tutorial/essential/exceptions/
runtime.html
and on, and on, and on
On Oct 24, 2007, at 7:23 PM, Karl Wettin wrote:
> How about allowing IOExceptions beeing thrown from the abstract
> TermVectorMapper methods?
>
> The use case is that I want a normalized frequency, and I'd like to
> do that by loading the factor from an IndexReader in setExpectations.
>
> I could wrap it in a RuntimeException, I could update the values
> later. But TermVectorReader.readTermVector already throws
> IOException, so using that feels like the optimal solution to me. Or?
>
>
>
> --
> karl
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-dev-help@lucene.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-dev-help@lucene.apache.org
Re: More about the TermVectorMapper
Posted by Grant Ingersoll <gs...@apache.org>.
On Oct 29, 2007, at 8:51 PM, Karl Wettin wrote:
>
> 25 okt 2007 kl. 01.23 skrev Karl Wettin:
>>
>> The use case is that I want a normalized frequency, and I'd like to
>> do that by loading the factor from an IndexReader in setExpectations.
>
> Moving along in this code, how about passing down the current
> document number to the mapper? Perhaps in setExpectations, perhaps
> as a simple setter method.
>
> Really no big deal to handle that my self via an ad hoc setter
> method, but I think it make sense that the mapper is aware of what
> document it is working with, that the mapper is told when it is used
> for a new/different document.
>
Seems reasonable, feel free to submit a patch. Not sure if we need to
worry too much back-compatibility, since it hasn't been released.
---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-dev-help@lucene.apache.org
More about the TermVectorMapper
Posted by Karl Wettin <ka...@gmail.com>.
25 okt 2007 kl. 01.23 skrev Karl Wettin:
>
> The use case is that I want a normalized frequency, and I'd like to
> do that by loading the factor from an IndexReader in setExpectations.
Moving along in this code, how about passing down the current
document number to the mapper? Perhaps in setExpectations, perhaps as
a simple setter method.
Really no big deal to handle that my self via an ad hoc setter
method, but I think it make sense that the mapper is aware of what
document it is working with, that the mapper is told when it is used
for a new/different document.
I reuse a (non thread safe) mapper to go easy on the GC, clearing it
from data between mappings of different documents. It would be great
if all that could be handled by the mapper, keeping the calling layer
of code above that as thin as possible.
--
karl
---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-dev-help@lucene.apache.org