|
[
Permlink
| « Hide
]
Shai Erera added a comment - 13/Aug/08 02:00 PM
The very trivial patch
Shai, Thanks for creating this issue and patch!
I noticed you also modified the private reusableSD to be protected. This field is just for avoiding creating a new object at each insert to the priority queue. I am wondering if the right thing to do is to (1) leave that field private, or (2) make it protected but then make TopFieldDocCollector use it too. What do you think? Others? IMO, TopFieldDocCollector should be changed to use reusableSD. FieldDoc extends ScoreDoc. That's the reason I modified it to protected - for extensions of TopDocCollector who maintain in PQ ScoreDoc types (either ScoreDoc or extensions).
I don't see any advantage in marking it private, nor any disadvantage if any extension to TopDocCollector will maintain its own ScoreDoc instance. It's just that we have TopDocCollector, TopFieldDocCollector and my extension to TDC which insert ScoreDoc instances into PQ, so it made sense to me to change it to protected. Re-thinking this - resuableSD should remain private to both TDC and TFDC. The reason is the two classes use it differently and don't share any implementation which involves this member (unlike totalHits and hq).
I was in the middle of adding javadoc to the protected members and constructor (which accepts numHits and PQ) when I noticed that numHits is completely ignored by this constructor --> TopDocCollector(int numHits, PriortityQueue hq). What bothers me with this constructor is that it may falsely lead users of the API to think that it limits their PQ with a maximum number of hits. I think we should remove that parameter and expose two constructors: If you agree, I'll reflect that in the 2nd patch I want to create (which adds javadoc). You're right, this is confusing indeed.
Although it is not public or protected there may users code (residing in same package) relying on this method so it can't just be removed but rather just deprecated.
Yes thanks! Marked the constructor as deprecated, created another one (protected) which accepts PQ only and modified TopFieldDocCollector to use the new c'tor instead of the deprecated one.
Also added javadoc. Doron is this one ready to go in?
It is, applies cleanly and seems correct.
Will commit as soon as tests complete. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||