Hi Mike,

> Let's remove the .empty(), and let's switch to this "normal iterator"
> semantics -- I think I had originally added that back when TermsEnum
> didn't have a .term() method, ie, you had to keep the result returned
> from calling .next() or .seek().  But that proved too much of hassle
> (lots of places where we pass a TermsEnum down and the callee needs to
> figure out what term it's on), so I've since added .term().

+1

> Actually TermEnum (the current API) already behaves like a normal
> iterator, right?  It's only FilteredTermEnum (and, FilteredTermsEnum)
> that pre-next's itself on construction.  So we should fix
> FilteredTermsEnum to not pre-next, and to remove its empty() method?

Not really, if you get the unitialized TermEnum from IR.terms(), it is like
an iterator, but if you get it with IR.terms(Term), it is already placed on
the first term. You have to then check, if it the current term is null (e.g.
exhausted if you take the last term). You see this type of code everywhere
in lucene, like in MTQ. In my opinion, it would be better here to always
call next() first (and this was often done by users, then missing the first
term). The new API does not have this problem, as you only get an terms
iterator for a specific field that is per default always uninitialized and
you have to call seek. But with trunk, that is not the case.


> Uwe do you want to take a stab at it?  Or, I can... let me know.

I think, you know the code better, but I could find out what to do.

I would like to have an IllegalStateException if you call docFreq() or
term(), too. I think this would help people migrating from old to new code
(and rewriting their do-while code to while(next)).

Uwe


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