lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Earwin Burrfoot <ear...@gmail.com>
Subject Re: Lucene 2.9 and deprecated IR.open() methods
Date Mon, 05 Oct 2009 08:25:14 GMT
On Mon, Oct 5, 2009 at 12:01, Uwe Schindler <uwe@thetaphi.de> wrote:
> Hi Marvin,
>
>> > Property names are always String, values any type (therefore
>> Map<String,?>).
>> > With Java 5, integer props and so on are no "bad syntax" problem because
>> of
>> > autoboxing (no need to pass new Integer() or Integer.valueOf()).
>>
>> Argument validation gets to be a headache when you pass around complex
>> data
>> structures.  It's doable, but messy and hard to grok.  Going through
>> dedicated
>> methods is cleaner and safer.
>>
>> > Another good thing is, that implementors of e.g. XML config files like
>> in
>> > Solr, can simple pass all elements in config to this map.
>>
>> I go back and forth on this.  At some point, the volume of data becomes
>> overwhelming and it becomes easier to swap in the name of a class where
>> most
>> of the data can reside in nice, reliable, structured code.
>
> See my second mail. The recently introduced Attributes and AttributeSource
> would solve this. Each component just defines its attribute interface and
> impl class and you pass in an AttributeSource as configuration. Then you can
> do:
>
> AttributeSource cfg = new AttributeSource();
>
> ComponentAttribute compCfg = cfg.addAttribute(ComponentAttribute.class);
> compCfg.setMergeScheduler(FooScheduler.class);
>
> MergeBarAttribute mergeCfg = cfg.addAttribute(MergeBarAttribute.class);
> mergeCfg.setWhateverProp(1234);
> ...
> IndexWriter iw = new IndexWriter(dir, cfg);
>
> (this is just brainstorming not yet thoroughly thought about).

This approach suggests IW creates its components, and while doing so
provides them your AS instance.
I personally prefer creating all these components myself, configuring
them (at the moment of creation) and passing them to IW in one way or
another.
This requires way less code, you don't have to invent elaborate
schemes of passing through your custom per-component settings and
selecting which exact component types IW should use, you don't risk
construct/postConstruct/postpostConstruct-style things.

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

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


Mime
View raw message