Chris Hostetter wrote:
>
>
> : i suggest it could be defined a (e.g.) NOT_FOUND_FLOAT_VALUE,
> modifiable,
> : so it does not necessarily have to be 0. And used for initialise the
> array
> : of floats before processing (or do it on the loop if better performance
> can
> : be reached).
> : I have set it to Float.NEGATIVE_INFINITY
>
> this sounds like a generally usable feature ... although we wouldn't want
> it to be a single for hte whole field cache because then code expecting
> the defaults to be Float.NEGATIVE_INFINITY could be suprised if other code
> (perhaps even dealing with different fields) populated the cache first.
>
> the ideal way to do this might be to add a "getDefault()" method to the
> IntParser and FloatParser interfaces ... but thta wouldn't be backwards
> compatible.
>
>
The default should be 0 to keep being backwards compatible. Then just
provide a means to change that setting. So for my code I just could add:
setInitialValue(Float.NEGATIVE_INFINITY); for example.
Being the INITIAL_VALUE thingy set initially to 0. That would be backwards
compatible.
Chris Hostetter wrote:
>
> one (kludgy) possibility would be to use a single call to
> FloatParser.parseFloat(null) to determine what value to use -- if it
> throws an exception use "0.0", otherwise use whatever it returns, what are
> the odds that an existing FloatParser that doesn't balk on null isn't
> going to return something that makes sense as a default?
>
The parser is not used in those cases that there is no field. My first
approach on all this, before looking at the code, was to create a new
FloatParser that returns NEGATIVE_INFINITY in those cases it throws an
exception. When I saw there was no difference with the default
implementation (which just uses Float.parseFloat(String s) ) then I began
diving into the code.
I am for the previous solution though. The setInitialFloatValue(Float)
thingy. And same for Ints! :)
Cheers
--
View this message in context:
http://www.nabble.com/Re%3A-FieldCacheImpl-mistake--tf3228736.html#a8982670
Sent from the Lucene - Java Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]