Return-Path: Delivered-To: apmail-lucene-java-user-archive@www.apache.org Received: (qmail 48337 invoked from network); 4 Aug 2009 17:01:01 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 4 Aug 2009 17:01:01 -0000 Received: (qmail 99697 invoked by uid 500); 4 Aug 2009 17:01:04 -0000 Delivered-To: apmail-lucene-java-user-archive@lucene.apache.org Received: (qmail 99607 invoked by uid 500); 4 Aug 2009 17:01:04 -0000 Mailing-List: contact java-user-help@lucene.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: java-user@lucene.apache.org Delivered-To: mailing list java-user@lucene.apache.org Received: (qmail 99597 invoked by uid 99); 4 Aug 2009 17:01:04 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 04 Aug 2009 17:01:04 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of ian.lea@gmail.com designates 72.14.220.152 as permitted sender) Received: from [72.14.220.152] (HELO fg-out-1718.google.com) (72.14.220.152) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 04 Aug 2009 17:00:56 +0000 Received: by fg-out-1718.google.com with SMTP id l26so1219994fgb.4 for ; Tue, 04 Aug 2009 10:00:34 -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 :from:date:message-id:subject:to:content-type :content-transfer-encoding; bh=JABs4zWp9G6X1F3GmKPdsgVfyXzr61qkDYHo0N1ZI9o=; b=x/7MPW+RqumBdeJBD5FKQkH6HLa0po0s4gRU3ShaMEhTL+h3Dhw5wJqZPd8Ddu6kYw SkvruISyhVP415ZCv2hi9LEPar4cNj7J5CaWgqkBbRWe0wprfOTVa+C01GYXsbnhL/xL 9YQOuxhtUrdaXFvf2OV0MZbWjd1zAsSmjH6NQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type:content-transfer-encoding; b=nbyzNw8lpsBkMK/ENlvdOoQsnx6lZWjiCOWOIQDPfgJ+7ijaysSAuM8/i710IKtgXa rmd91Re4QjISlPeUxtOuSQdZ+RWy84Uq7A4QPE6xCoNnbMBhIdHWy5BYSfwh4RSOfOab dRmTGF2Abory3J8w//3g2hY/0uUmFT5OoTCAM= MIME-Version: 1.0 Received: by 10.86.35.18 with SMTP id i18mr2932346fgi.8.1249405234749; Tue, 04 Aug 2009 10:00:34 -0700 (PDT) In-Reply-To: <20090804120814.6IX2T.4705.imail@eastrmwml31> References: <20090804120316.GBI2D.4626.imail@eastrmwml31> <20090804120814.6IX2T.4705.imail@eastrmwml31> From: Ian Lea Date: Tue, 4 Aug 2009 18:00:14 +0100 Message-ID: <8c4e68610908041000j41105d16n7b9cf42900fdf50f@mail.gmail.com> Subject: Re: Slightly Off-topic: How to decide whether or not to add a document? To: java-user@lucene.apache.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Virus-Checked: Checked by ClamAV on apache.org Jim The sleep is simply try { Thread.sleep(millis); } catch (InterruptedException ie) { } No threading issues that I'm aware of, despite the method living in the Thread class. But you're right about it possibly impacting performance, if you've got to sleep for a reasonable amount of time for each doc, if you've got loads of docs. You can improve it by getting a list of possible files + size + lastmod + whatever, sleeping, then checking them all again i.e. only sleep once for each pass rather than once per file. Yet another option is to forget about sleeping and check the lastmod timestamp and only index the doc if was finished some time ago. And yet another ... make the producer write to /a/b/c and have a standalone non-lucene job that reads /a/b/c doing whatever checks you like, moving files to your input directory. That's more than enough options from me. -- Ian. On Tue, Aug 4, 2009 at 5:08 PM, wrote: > Ian, > > One question about the 4th alternative: =A0I was wondering how you implem= ented the sleep() in Java, esp. in such a way as not to mess up any of the = Lucene stuff (in case there's threading)? > > Right now, my indexer/inserter app doesn't explicitly do any threading st= uff. > > Thanks, > Jim > > > ---- ohaya@cox.net wrote: >> Hi Ian, >> >> Thanks for the quick response. >> >> I forgot to mention, but in our case, the "producers" is part of a comme= rcial package, so we don't have a way to get them to change anything, so I = think the 1st 3 suggestions are not feasible for us. >> >> I have considered something like the 4th suggestion (check file size, ti= meout, and check file size again). =A0I'm worried that it would impact the = overall index insertion process, but that unless there's something better, = that may be our best option :(... >> >> Thanks again, >> Jim >> >> >> ---- Ian Lea wrote: >> > A few suggestions: >> > >> > . Queue the docs once they are complete using something like JMS. >> > >> > . Get the document producers to write to e.g. xxx.tmp and rename to >> > e.g. xxx.txt at the end >> > >> > . Get the document producers to write to a tmp folder and move to e.g. >> > input/ when done >> > >> > . Find a file, store size, sleep for a while, check size and if change= d, skip >> > >> > I've used all these at one time or another for assorted, mainly >> > non-lucene, apps, and they are all workable. >> > >> > >> > -- >> > Ian. >> > >> > >> > On Tue, Aug 4, 2009 at 4:40 PM, wrote: >> > > Hi, >> > > >> > > I have an app to initially create a Lucene index, and to populate it= with documents. =A0I'm now working on that app to insert new documents int= o that Lucene index. >> > > >> > > In general, this new app, which is based loosely on the demo apps (e= .g., IndexFiles.java), is working, i.e., I can run it with a "create" param= eter, and it creates a good/valid index from the documents, and then I can = run it with an "insert" parameter, and it inserts new documents into the in= dex. >> > > >> > > [As I mentioned in an earlier thread, we only have a requirement to = insert new documents into the index, no requirements for deleting documents= or updating documents that have already been indexed). >> > > >> > > Ok, as I said, that works so far. >> > > >> > > However, in our case, the processes that are creating the documents = that we are indexing are fairly long-lived, and write fairly large document= s, and I'm worried that when an insert operation is run, some of the potent= ial documents may still be being written to, and we wouldn't want the index= er to insert the document into the Lucene index until the document is "comp= lete". >> > > >> > > As you know, the way that the demos such as IndexFiles work is that = they call a method called IndexDocs(). =A0IndexDocs() then recursively walk= s the directory tree, and calling the writer to add to the index. >> > > >> > > In this loop, IndexDocs() does a few checks (isDirectory(), canRead)= , and I think that it would "pick up" (find) some documents that are still = "in progress" (being written to, and not closed) in our case. >> > > >> > > I was wondering if anyone here has a situation similar to this (havi= ng to index large documents that may be "in progress/being written to"), an= d how you handle this situation? >> > > >> > > FYI, this is on Redhat Linux (and on Windows in my test environment)= . >> > > >> > > Thanks! >> > > >> > > Jim >> > > >> > > >> > > --------------------------------------------------------------------= - >> > > To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org >> > > For additional commands, e-mail: java-user-help@lucene.apache.org >> > > >> > > >> > >> > --------------------------------------------------------------------- >> > To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org >> > For additional commands, e-mail: java-user-help@lucene.apache.org >> > >> >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org >> For additional commands, e-mail: java-user-help@lucene.apache.org >> > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org > For additional commands, e-mail: java-user-help@lucene.apache.org > > --------------------------------------------------------------------- To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org For additional commands, e-mail: java-user-help@lucene.apache.org