You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by Otis Gospodnetic <ot...@yahoo.com> on 2001/12/25 20:18:55 UTC

RE: existing or not existing

Here is a Christmas present from me.
I've added those 5 methods listed towards the bottom to IndexReader.

Otis

--- Doug Cutting <DC...@grandcentral.com> wrote:
> > From: Otis Gospodnetic [mailto:otis_gospodnetic@yahoo.com]
> > 
> > You could try looking for a segments file in the index directory.
> > If it exists, the index exists, else it does not.
> > 
> > Is there a better way?
> 
> I think that's currently the best way.  But it's not great, because
> it
> requires applications to know something about the internal structure
> of the
> index.
> 
> Going forward, I'm hesitant to change the semantics of the 'create'
> flag.
> I'm also hesitant to add another flag or constructor method.
> 
> Perhaps the addition of the following IndexReader methods would
> suffice:
> 
>   /** Returns true iff an index exists in the named directory. */
>   public static boolean indexExists(String directory);
>   public static boolean indexExists(File directory);
>   public static boolean indexExists(Directory directory);
> 
> These are analogous to the 'lastModified' methods. Internally these
> would
> just check for the existence of the segments file.
> 
> Does that sound like a good plan?
> 
> Another place that currently requires application knowledge of index
> structure is failure recovery.  Currently if an indexing application
> crashes
> it may leave .lock files in the directory which must be removed
> before the
> index can be altered again.  Perhaps this can be resolved similarly
> by
> adding methods like:
> 
>   /** Returns true iff the index in the named directory is currently
> locked.*/
>   public static boolean isLocked(Directory directory);
> 
>   /** Forcibly unlocks the index in the named directory. 
>    * Caution: this should only be used by failure recovery code,
>    * when it is known that no other process or thread is in fact
>    * currently accessing this index.
>    */
>   public static void unlock(Directory directory);
> 
> We could also have String and File versions for convenience.
> 
> Would folks use something like this?  If so, more fodder for the TODO
> list!
> 
> Doug
> 
> --
> To unsubscribe, e-mail:  
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> 


__________________________________________________
Do You Yahoo!?
Send your FREE holiday greetings online!
http://greetings.yahoo.com

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>