lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Doug Cutting <DCutt...@grandcentral.com>
Subject RE: existing or not existing
Date Wed, 05 Dec 2001 17:21:56 GMT
> 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:   <mailto:lucene-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:lucene-user-help@jakarta.apache.org>


Mime
View raw message