Return-Path: Delivered-To: apmail-lucene-java-dev-archive@www.apache.org Received: (qmail 77932 invoked from network); 13 Apr 2010 15:56:55 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 13 Apr 2010 15:56:55 -0000 Received: (qmail 98702 invoked by uid 500); 13 Apr 2010 15:56:54 -0000 Delivered-To: apmail-lucene-java-dev-archive@lucene.apache.org Received: (qmail 98664 invoked by uid 500); 13 Apr 2010 15:56: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 98657 invoked by uid 99); 13 Apr 2010 15:56:54 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 13 Apr 2010 15:56:54 +0000 X-ASF-Spam-Status: No, hits=-0.9 required=10.0 tests=AWL,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_PASS,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of williamstw@gmail.com designates 209.85.160.176 as permitted sender) Received: from [209.85.160.176] (HELO mail-gy0-f176.google.com) (209.85.160.176) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 13 Apr 2010 15:56:48 +0000 Received: by gyf1 with SMTP id 1so3428343gyf.35 for ; Tue, 13 Apr 2010 08:56:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:received:message-id:subject:from:to:content-type; bh=5L8Ci9NPyi2LrmV7iC6lHzJtdS5T/aRqJhdFND2RAcg=; b=AIzQNfEgN3C5XXrXXVviuu/mCL6m6D+6iennARbdsm13XM6PD9I/aj23+/Fd4ZpoJk mZixHfEN4rlqqRNwU1uFFIraTfJCLePQKNbmM7xQmloFH+2uN5sTf0rwKdgYZKrM7Uvu 2nSm5S4AUmCs8JgcrOYhMK69YLHZhiMc5kkW4= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=ZfQy+JT3RdxxP2fu3Ob4vekbjAaVqJr+9aQ/jdHDFJAB/rRxJCL81hGBdJSwu+2liz 65pKAFGmxSqN3H+5av0dcYhrOlFZpwTUxCTQPSdOB2H46fS1307q2rDpOCnMcUkKZkm3 OgYozRv6YXMeqW+g5lFLv86zwa43+lM1hc/eQ= MIME-Version: 1.0 Received: by 10.151.99.2 with HTTP; Tue, 13 Apr 2010 08:56:26 -0700 (PDT) In-Reply-To: References: Date: Tue, 13 Apr 2010 11:56:26 -0400 Received: by 10.151.128.7 with SMTP id f7mr5218657ybn.65.1271174187035; Tue, 13 Apr 2010 08:56:27 -0700 (PDT) Message-ID: Subject: Re: Proposal about Version API "relaxation" From: Tim Williams To: java-dev@lucene.apache.org Content-Type: text/plain; charset=ISO-8859-1 On Tue, Apr 13, 2010 at 11:27 AM, Shai Erera wrote: > Hi > > I'd like to propose a relaxation on the Version API. Uwe, please read the > entire email before you reply :). > > I was thinking, following a question on the user list, that the > Version-based API may not be very intuitive to users, especially those who > don't care about versioning, as well as very inconvenient. So there are two > issues here: > 1) How should one use Version smartly so that he keeps backwards > compatibility. I think we all know the answer, but a Wiki page with some > "best practices" tips would really help users use it. > 2) How can one write sane code, which doesn't pass versions all over the > place if: (1) he doesn't care about versions, or (2) he cares, and sets the > Version to the same value in his app, in all places. > > Also, I think that today we offer a flexibility to users, to set different > Versions on different objects in the life span of their application - which > is a good flexibility but can also lead people to shoot themselves in the > legs if they're not careful -- e.g. upgrading Version across their app, but > failing to do so for one or two places ... > > So the change I'd like to propose is to mostly alleviate (2) and better > protect users - I DO NOT PROPOSE TO GET RID OF Version :). > > I was thinking that we can add on Version a DEFAULT version, which the > caller can set. So Version.setDefault and Version.getDefault will be added, > as static members (more on the static-ness of it later). We then change the > API which requires Version to also expose an API which doesn't require it, > and that API will call Version.getDefault(). People can use it if they want > to ... > > Few points: > 1) As a default DEFAULT Version is controversial, I don't want to propose > it, even though I think Lucene can define the DEFAULT to be the latest. > Instead, I propose that Version.getDefault throw a > DefaultVersionNotSetException if it wasn't set, while an API which relies on > the default Version is called (I don't want to return null, not sure how > safe it is). > 2) That DEFAULT Version is static, which means it will affect all indexing > code running inside the JVM. Which is fine: > 2.1) Perhaps all the indexing code should use the same Version > 2.2) If you know that's not the case, then pass Version to the API which > requires it - you cannot use the 'default Version' API -- nothing changes > for you. > One case is missing -- you might not know if your code is the only indexing > code which runs in the JVM ... I don't have a solution to that, but I think > it'll be revealed pretty quickly, and you can change your code then ... > > So to summarize - the current Version API will remain and people can still > use it. The DEFAULT Version API is meant for convenience for those who don't > want to pass Version everywhere, for the reasons I outlined above. This will > also clean our test code significantly, as the tests will set the DEFAULT > version to TEST_VERSION_CURRENT at start ... > > The changes to the Version class will be very simple. > > If people think that's acceptable, I can open an issue and work on it. >From the peanut gallery, I say *please*. This Version idiom has taken an otherwise beautiful api and nearly boosted it to the likes of DOM and InputStream;) --tim --------------------------------------------------------------------- To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org For additional commands, e-mail: java-dev-help@lucene.apache.org