lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chris Hostetter <hossman_luc...@fucit.org>
Subject Re: [jira] Created: (LUCENE-1439) Inconsistent API
Date Wed, 12 Nov 2008 23:00:36 GMT
: > There are a lot of containers which don't implement an interface which indicates this
fact
: > (for pre-java-1.5 Lucene it could be Collection, for post-ajva-1.5 Lucene it could
be more general Iterable)
: > 
: > Example:
: >  IndexSearcher: "int maxDoc()" and "doc(int i)"
: 
: This is not as simple as it sounds, I think. Like you said yourself, before
: Java 1.5, the "Iterable" interface did not exist. The Collection interface
: (of Java 1.4) is way too broad to be used in this context, because it has
: *writing* methods like add(), clear() - what are these supposed to do in the
: IndexReader class, for example? And what about the contains() method?
: remove()? toArray()? No, I would not like to see IndexReader (for example)
: implement Collection.
: 
: That being said, I would personally like to see Lucene move to Java 1.5

Just to clarify; even when we start using Java 1.5, it would make almost 
no sense what so ever for IndexSearcher to implement Interable.

just becuase there is a "thing" which may allow you to iterate over 
something, doesn't mean it should implement the Iterable interface.  A 
Reader essentially lets you iterate over characters, but it doesn't 
implement Iterable; an InputStream lets you iterate over bytes, but it 
isn't "Iterable"

You *could* iterate over every doc in an IndexSearcher -- but 
IndexSearcher doesn't have an iterator() method because it doesn't, for 
lack of less judgemental phrase "make any sense" ... it's not waht it's 
for, and it implies usage that it wasn't designed for.

There are better ways to use an IndexSearcher then by iterating over every 
doc, just as there are better ways to use a Reader then by poping a single 
character off at a time.

The Iterable interface describes it's utility quite well, and quite 
succinctly...

	Implementing this interface allows an object to be the target 
	of the "foreach" statement.

Suggesting that people might want to "foreach" over an IndexSearcher 
wouldn't help make the Lucene APIs any easier to understand.


-Hoss


---------------------------------------------------------------------
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