Return-Path: Delivered-To: apmail-lucene-java-dev-archive@www.apache.org Received: (qmail 25501 invoked from network); 1 Mar 2010 08:56:55 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 1 Mar 2010 08:56:55 -0000 Received: (qmail 73893 invoked by uid 500); 28 Feb 2010 16:48:54 -0000 Delivered-To: apmail-lucene-java-dev-archive@lucene.apache.org Received: (qmail 73856 invoked by uid 500); 28 Feb 2010 16:48:54 -0000 Mailing-List: contact java-dev-help@lucene.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: java-dev@lucene.apache.org Delivered-To: mailing list java-dev@lucene.apache.org Received: (qmail 73849 invoked by uid 99); 28 Feb 2010 16:48:54 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 28 Feb 2010 16:48:54 +0000 X-ASF-Spam-Status: No, hits=1.2 required=10.0 tests=SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (nike.apache.org: local policy) Received: from [209.85.160.176] (HELO mail-gy0-f176.google.com) (209.85.160.176) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 28 Feb 2010 16:48:43 +0000 Received: by gyb13 with SMTP id 13so762775gyb.35 for ; Sun, 28 Feb 2010 08:48:21 -0800 (PST) MIME-Version: 1.0 Received: by 10.150.4.7 with SMTP id 7mr4409730ybd.241.1267375700798; Sun, 28 Feb 2010 08:48:20 -0800 (PST) In-Reply-To: <786fde51002280741n139bec69i42f75fb5eabfe462@mail.gmail.com> References: <786fde51002280333w484971abx6ebd63ca5cee4bbc@mail.gmail.com> <786fde51002280420j4772fb04x2ce7abcaaa658043@mail.gmail.com> <000301cab871$199c2840$4cd478c0$@de> <786fde51002280437o774c6cabmed16d0333ca55832@mail.gmail.com> <001601cab874$71f18050$55d480f0$@de> <786fde51002280504x5e002af7ofd43b81d47f74abe@mail.gmail.com> <000301cab878$05e3c540$11ab4fc0$@de> <786fde51002280522i54a5befaje4092ed4d39be2bc@mail.gmail.com> <001801cab87e$f5e3fd70$e1abf850$@de> <786fde51002280741n139bec69i42f75fb5eabfe462@mail.gmail.com> Date: Sun, 28 Feb 2010 11:48:20 -0500 Message-ID: <9ac0c6aa1002280848m9bff732se1cbc86c91008e7d@mail.gmail.com> Subject: Re: SegmentInfos extends Vector From: Michael McCandless To: java-dev@lucene.apache.org Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable X-Virus-Checked: Checked by ClamAV on apache.org This class is @lucene.experimental, so we are free to break it. +1 to not "extends Vector". I don't think we should change to @lucene.internal.... since the thinking is apps outside Lucene should be able to introspect and see segment structure in the index. Ie we made this API public so people outside could call it, but it's experimental so we are free to break things. Mike On Sun, Feb 28, 2010 at 10:41 AM, Shai Erera wrote: > Ok agreed. I'll do some code investigation and then open an issue. I thin= k > that back-compat with this class should not be a (big) problem ... but th= en > - I always think that :). > Shai > > On Sun, Feb 28, 2010 at 4:04 PM, Uwe Schindler wrote: >> >> Hi Shai, >> >> >> >> I am only the Generics Police but not the Generics Homeland Security and >> also not the Backwards Homeland Security J I think if we break backwards= , >> lets break it complete and remove the =93extends Vector=94. And then let= =92s make >> the Iterator/Iterable/Collection unmodifiable. That would get a big +1 f= rom >> my side. >> >> >> >> ----- >> >> Uwe Schindler >> >> H.-H.-Meier-Allee 63, D-28213 Bremen >> >> http://www.thetaphi.de >> >> eMail: uwe@thetaphi.de >> >> >> >> From: Shai Erera [mailto:serera@gmail.com] >> Sent: Sunday, February 28, 2010 2:22 PM >> >> To: java-dev@lucene.apache.org >> Subject: Re: SegmentInfos extends Vector >> >> >> >> Ok so just that I'm cleared - unmodifiable you mean for iteration only >> right? >> >> And .. do you agree then to refactor the class, or prefer to keep it lik= e >> that? If you agree, then we need to think if we do that by introducing a= new >> class, or modify the existing one breaking back-compat. A new class is >> problematic since that will lead to a series of deprecations throughout = the >> code. So I prefer modifying the current one. >> >> DM - I've traced Vector.remove all the way back to 1.3, and AbstractList >> exists since 1.2 (so it's javadocs states), so I think remove has been >> around always. >> >> Shai >> >> On Sun, Feb 28, 2010 at 3:14 PM, Uwe Schindler wrote: >> >> I meant it was supported by the API, but if you called the modification >> methods of SegmentInfos you may have corrupted the contents. So implemen= ting >> List or Collection just throwing UOE is fine, as modifying in >> Collections can disabled by that exception, the docs state that. >> >> >> >> But you are right, it does not make real sense. With backwards >> compatibility I think of plug-in compatibility, not behavior compatibili= ty. >> If we want to keep behavior compatibility, we must extend Vector J and a= llow >> all modifications. >> >> >> >> So implementing a non-modifiable Collection/List may be the best. But >> that=92s only my opinion. >> >> >> >> ----- >> >> Uwe Schindler >> >> H.-H.-Meier-Allee 63, D-28213 Bremen >> >> http://www.thetaphi.de >> >> eMail: uwe@thetaphi.de >> >> >> >> From: Shai Erera [mailto:serera@gmail.com] >> Sent: Sunday, February 28, 2010 2:04 PM >> >> To: java-dev@lucene.apache.org >> Subject: Re: SegmentInfos extends Vector >> >> >> >> Why do you say remove was unsupported before? I don't see it in the >> class's impl. It just inherits from Vector and so remove is supported by >> inheritance. Since the class is public, someone may have called it. >> >> Even if we change the class to impl List, period, we'll break back-compa= t, >> just because of the synchronization Vector offers. If anyone out there >> relies on that, it's a problem. >> >> On one hand, the best way would be is to impl Collection, as then someon= e >> will be able to use Collections.synchronizedCollection if one needs it, = or >> call toArray etc. But Collection does not have a get(index) method, whic= h >> might be required and useful ... >> >> All in all, I don't feel like SegmentInfos is a true collection (even >> though its Javadoc starts with "a collection ...". It adds lots of segme= nts >> related methods. The collection's ones are really get and iterator? So m= aybe >> we should just impl Iterable and expose whatever API we feel is necessar= y? >> Back-compat wise, if we change anything in this class's extension/implem= ents >> details, we break it. >> >> Unless the folks here don't think we should go to great lengths w/ this >> class, and do whatever changes we dim are necessary, even at the cost of >> breaking back-compat. And I'd vote that whether with this class or the n= ew >> one, we mark it as @lucene.internal. >> >> Shai >> >> On Sun, Feb 28, 2010 at 2:49 PM, Uwe Schindler wrote: >> >> Hi Shai, >> >> >> >> I forgot to mention: Iterable is always a good idea. E.g. during my 3.0 >> generification, I made =93BooleanQuery implements Iterable=94 and >> so on. That makes look the code nice J. Also other classes got this >> interface in Lucene. Also adding j.io.Closeable everywhere was a good id= ea. >> >> >> >> Uwe >> >> >> >> ----- >> >> Uwe Schindler >> >> H.-H.-Meier-Allee 63, D-28213 Bremen >> >> http://www.thetaphi.de >> >> eMail: uwe@thetaphi.de >> >> >> >> From: Shai Erera [mailto:serera@gmail.com] >> Sent: Sunday, February 28, 2010 1:38 PM >> >> To: java-dev@lucene.apache.org >> Subject: Re: SegmentInfos extends Vector >> >> >> >> I would rather avoid implementing List .. we should implement Iterable f= or >> sure, but I'd like to keep the API open either iterating in-order or get= ting >> a particular SegmentInfo. Another thing, I haven't seen anywhere that re= move >> is called. In general I don't like to impl an interface just to throw UO= E >> everywhere ... >> >> I will open an issue. I usually investigate the code first before I open >> an issue. Also, what about back-compat? Are we even allowed to change th= at >> class? If not, then we can deprecate it and introduce a new one ... >> >> Shai >> >> On Sun, Feb 28, 2010 at 2:25 PM, Uwe Schindler wrote: >> >> I think you should open an issue! I like this refactoring, maybe we can >> still let it implement List but only deprecated and most >> methods should throw UOE. Just keep get() and so on. >> >> >> >> ----- >> >> Uwe Schindler >> >> H.-H.-Meier-Allee 63, D-28213 Bremen >> >> http://www.thetaphi.de >> >> eMail: uwe@thetaphi.de >> >> >> >> From: Shai Erera [mailto:serera@gmail.com] >> Sent: Sunday, February 28, 2010 1:20 PM >> >> To: java-dev@lucene.apache.org >> >> Subject: Re: SegmentInfos extends Vector >> >> >> >> Yes that's what I've been thinking as well - SegmentInfos should have a >> segments-related API, not a List related. Whether the infos inside are k= ept >> in a Map, List, Collection or array is an implementation detail. In fact= , I >> have a code which uses the API and could really benefit from a Map-like >> interface, but perhaps other code needs things ordered (which is why we = can >> keep a TreeMap inside, or LinkedHahsMap). That's a great example to why = it >> should have its own API. >> >> The Lucene code usually calls SegmentInfos.info(int), but some places ca= ll >> get(int) (which is inherited from Vector). That's bad. >> >> SegmentInfos is public, though it's tagged with @lucene.experimental. I >> think it should be tagged with @lucene.internal as there's nothing >> experimental about it? >> >> I don't mind doing the refactoring. Not sure how this will affect >> back-compat (is it acceptable for this classs?). I've touched SegmentInf= os >> in LUCENE-2289, so I'll wait for someone to pick it up first, so that I >> don't work on it in parallel. >> >> Thanks, >> Shai >> >> On Sun, Feb 28, 2010 at 1:37 PM, Uwe Schindler wrote: >> >> I think this is historically. I have seen this in my big 3.0 >> generification patches, too. But I did not wanted to change it as Vector= has >> other allocation schema than ArrayList. But maybe we should simply chang= e >> it, it=92s a package-private class, right? >> >> >> >> But in general subclassing those implementations is not the best thing y= ou >> can do. In general the class should extend Object or something else and = just >> have final field of type List<=85>. Exposing the whole API of List to th= e >> outside is bad. >> >> >> >> +1 to refactor this class (and don=92t let it extend a Collections class= ). >> >> >> >> ----- >> >> Uwe Schindler >> >> H.-H.-Meier-Allee 63, D-28213 Bremen >> >> http://www.thetaphi.de >> >> eMail: uwe@thetaphi.de >> >> >> >> From: Shai Erera [mailto:serera@gmail.com] >> Sent: Sunday, February 28, 2010 12:33 PM >> To: java-dev@lucene.apache.org >> Subject: SegmentInfos extends Vector >> >> >> >> Hi >> >> What's the reason SegmentInfos extends Vector rather than say ArrayList? >> Do we need the synchronization around it which Vector provides? >> >> Shai >> >> >> >> >> >> >> >> > --------------------------------------------------------------------- To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org For additional commands, e-mail: java-dev-help@lucene.apache.org