Lucene - Directory


Advertisements


Introduction

This class represents the storage location of the indexes and generally it is a list of files. These files are called index files. Index files are normally created once and then used for read operation or can be deleted.

Class declaration

Following is the declaration for org.apache.lucene.store.Directory class:

public abstract class Directory
   extends Object
      implements Closeable

Field

Following are the fields for org.apache.lucene.store.Directory class:

  • protected boolean isOpen

  • protected LockFactory lockFactory -- Holds the LockFactory instance (implements locking for this Directory instance).

Class constructors

S.N.Constructor & Description
1

Directory()

Class methods

S.N.Method & Description
1

void clearLock(String name)

Attempt to clear (forcefully unlock and remove) the specified lock.

2

abstract void close()

Closes the store.

3

static void copy(Directory src, Directory dest, boolean closeDirSrc)

Deprecated. Should be replaced with calls to copy(Directory, String, String) for every file that needs copying. You can use the following code:

 IndexFileNameFilter filter = IndexFileNameFilter.getFilter();
 for (String file : src.listAll()) {
   if (filter.accept(null, file)) {
     src.copy(dest, file, file);
   }
 }
4

void copy(Directory to, String src, String dest)

Copies the file src to Directory to under the new file name dest.

5

abstract IndexOutput createOutput(String name)

Creates a new, empty file in the directory with the given name.

6

abstract void deleteFile(String name)

Removes an existing file in the directory.

7

protected void ensureOpen() =

8

abstract boolean fileExists(String name)

Returns true iff a file with the given name exists.

9

abstract long fileLength(String name)

Returns the length of a file in the directory.

10

abstract long fileModified(String name)

Deprecated.

11

LockFactory getLockFactory()

Get the LockFactory that this Directory instance is using for its locking implementation.

12

String getLockID()

Return a string identifier that uniquely differentiates this Directory instance from other Directory instances.

13

abstract String[] listAll()

Returns an array of strings, one for each file in the directory.

14

Lock makeLock(String name)

Construct a Lock.

15

abstract IndexInput openInput(String name)

Returns a stream reading an existing file.

16

IndexInput openInput(String name, int bufferSize)

Returns a stream reading an existing file, with the specified read buffer size.

17

void setLockFactory(LockFactory lockFactory)

Set the LockFactory that this Directory instance should use for its locking implementation.

18

void sync(Collection<String> names)

Ensure that any writes to these files are moved to stable storage.

19

void sync(String name)

Deprecated. use sync(Collection) instead. For easy migration you can change your code to call sync(Collections.singleton(name))

20

String toString()

21

abstract void touchFile(String name)

Deprecated. Lucene never uses this API; it will be removed in 4.0.

Methods inherited

This class inherits methods from the following classes:

  • java.lang.Object


lucene_indexing_classes.htm

Advertisements