You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by "Uwe Schindler (Commented) (JIRA)" <ji...@apache.org> on 2012/02/14 08:26:59 UTC

[jira] [Commented] (LUCENE-3777) trapping overloaded ctors/setters in Field/NumericField/DocValuesField

    [ https://issues.apache.org/jira/browse/LUCENE-3777?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13207556#comment-13207556 ] 

Uwe Schindler commented on LUCENE-3777:
---------------------------------------

Hi Robert,

that type overloading was exactly the reason why in 3.x we have setXxxValue(). I don't know what was the intention to change this in trunk, but the type overloading on int/long/float/byte is very trappy. We should change this back to what we had in 3.x!

bq. factories like DocValuesField.newIntField()

Thats how NumericRangeQuery looks like (it's exactly to overcome the problem with type overloading).
                
> trapping overloaded ctors/setters in Field/NumericField/DocValuesField
> ----------------------------------------------------------------------
>
>                 Key: LUCENE-3777
>                 URL: https://issues.apache.org/jira/browse/LUCENE-3777
>             Project: Lucene - Java
>          Issue Type: Bug
>    Affects Versions: 4.0
>            Reporter: Robert Muir
>
> In trunk, these apis let you easily create a field, but my concern is this:
> {code}
> public NumericField(String name, int value)
> public NumericField(String name, long value)
> ..
> public Field(String name, int value, FieldType type)
> public Field(String name, long value, FieldType type)
> ..
> public void setValue(int value)
> public void setValue(long value)
> ..
> public DocValuesField(String name, int value, DocValues.Type docValueType)
> public DocValuesField(String name, long value, DocValues.Type docValueType)
> {code}
> I really don't like overloaded ctors/setters where the compiler can type-promote you,
> I think it makes the apis hard to use.
> Instead for the setters I think we sohuld have setIntValue, setLongValue, ...
> For the ctors, I see two other options:
> # factories like DocValuesField.newIntField()
> # subclasses like IntField
> I don't have any patch for this, but I think we should discuss and fix before these apis are released.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org