>> Builder pattern allows you to switch concrete implementations as you
>> please, taking parameters into account or not.
>
> We could also achieve this w/ static "factory" method.  EG
> IndexReader.open(IndexReader.Config) could switch between concrete
> impls (it already does today).
Yes, the choice of 'IW.create(IWSettings, Directory)' VS
'IWSettings.create(Directory)' is purely syntactical (with latter
being more concise, imo), but I was comparing to 'new IW(Settings,
Directory)'.

>>> Call me old fashioned, but I like how the non constructor params are set
>>> now.
>> And what happens when you index some docs, change these params, index
>> more docs, change params, commit? Let's throw in some threads?
>> You either end up writing really hairy state control code, or just
>> leave it broken, with "Don't change parameters after you start pumping
>> docs through it!" plea covering your back somewhere in JavaDocs.
>> If nothing else, having stuff 'final' keeps JIT really happy.
>
> This is a good point: are you allowed to change config settings after
> creating your IndexWriter/Reader?
>
> Today it's ad hoc.
>
> EG IW does not allow you to swap out your deletion policy, because
> it'd be a nightmare to implement.  You also can't swap the analyzer.
> But it does let you change your RAM buffer size, CFS or not, merge
> factor, etc.  We can remove that flexibility (I'm not sure it's
> compelling), so we can make things final.  You can't change read-only
> after opening your IndexReader.  I think it'd make sense to move away
> from changing settings after construction...
I've just remembered some horrible things:

public void setMergeFactor(int mergeFactor) {
  getLogMergePolicy().setMergeFactor(mergeFactor);
}

Let's remove this "flexibility" too?

> But: the "do we disallow changing config settings after construction?"
> question is really orthogonal to the "what syntax do we use for
> construction?" (builder vs config vs zillions-of-ctors).
There's better syntax for both mutable and immutable approach, so it's
not like these two questions are completely orthogonal.

-- 
Kirill Zakharenko/Кирилл Захаренко (ear...@gmail.com)
Home / Mobile: +7 (495) 683-567-4 / +7 (903) 5-888-423
ICQ: 104465785

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

Reply via email to