You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by eks dev <ek...@yahoo.co.uk> on 2008/03/05 10:00:53 UTC

Ideas to refactor Filed

I have noticed the two potential enhancements in Field, and I am not sure if I read it correctly, so better to ask before crating Jira issue :)

1.. Field uses two methods to determine type of fieldsData, sometimes with boolean isBinary; and sometimes with instanceof byt[]
The proposal is to reduce it to one method, ether by removing  isBinary and using instance of byte[] or to replace one instanceof with isBinary. I do not know which one should be faster? 

2. Second enhancement would be to add length of char[]/byte[], to setValue(...) methods e.g. 
public void setValue(byte[] value, int length)  //maybe offset as well? 
This would enable users to save some allocations 







      ___________________________________________________________ 
Rise to the challenge for Sport Relief with Yahoo! For Good  

http://uk.promotions.yahoo.com/forgood/


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


Re: Ideas to refactor Filed

Posted by Michael McCandless <lu...@mikemccandless.com>.
Good morning!

eks dev wrote:

> I have noticed the two potential enhancements in Field, and I am  
> not sure if I read it correctly, so better to ask before crating  
> Jira issue :)
>
> 1.. Field uses two methods to determine type of fieldsData,  
> sometimes with boolean isBinary; and sometimes with instanceof byt[]
> The proposal is to reduce it to one method, ether by removing   
> isBinary and using instance of byte[] or to replace one instanceof  
> with isBinary. I do not know which one should be faster?

This makes sense.  Is this for the binaryValue() method?  I would  
expect the explicit isBinary would be fastest.

> 2. Second enhancement would be to add length of char[]/byte[], to  
> setValue(...) methods e.g.
> public void setValue(byte[] value, int length)  //maybe offset as  
> well?
> This would enable users to save some allocations

This also makes sense.  I think adding offset and length makes sense.

Mike

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