public class

FileSwitchDirectory

extends Directory
java.lang.Object
   ↳ org.apache.lucene.store.Directory
     ↳ org.apache.lucene.store.FileSwitchDirectory

Class Overview

Expert: A Directory instance that switches files between two other Directory instances.

Files with the specified extensions are placed in the primary directory; others are placed in the secondary directory. The provided Set must not change once passed to this class, and must allow multiple threads to call contains at once.

NOTE: this API is new and experimental and is subject to suddenly change in the next release.

Summary

[Expand]
Inherited Fields
From class org.apache.lucene.store.Directory
Public Constructors
FileSwitchDirectory(Set<String> primaryExtensions, Directory primaryDir, Directory secondaryDir, boolean doClose)
Public Methods
void close()
Closes the store.
IndexOutput createOutput(String name)
Creates a new, empty file in the directory with the given name.
void deleteFile(String name)
Removes an existing file in the directory.
boolean fileExists(String name)
Returns true iff a file with the given name exists.
long fileLength(String name)
Returns the length of a file in the directory.
long fileModified(String name)
Returns the time the named file was last modified.
static String getExtension(String name)
Utility method to return a file's extension.
Directory getPrimaryDir()
Return the primary directory
Directory getSecondaryDir()
Return the secondary directory
String[] listAll()
Returns an array of strings, one for each file in the directory.
IndexInput openInput(String name)
Returns a stream reading an existing file.
void sync(String name)
Ensure that any writes to this file are moved to stable storage.
void touchFile(String name)
Set the modified time of an existing file to now.
[Expand]
Inherited Methods
From class org.apache.lucene.store.Directory
From class java.lang.Object
From interface java.io.Closeable

Public Constructors

public FileSwitchDirectory (Set<String> primaryExtensions, Directory primaryDir, Directory secondaryDir, boolean doClose)

Public Methods

public void close ()

Closes the store.

Throws
IOException

public IndexOutput createOutput (String name)

Creates a new, empty file in the directory with the given name. Returns a stream writing this file.

Throws
IOException

public void deleteFile (String name)

Removes an existing file in the directory.

Throws
IOException

public boolean fileExists (String name)

Returns true iff a file with the given name exists.

Throws
IOException

public long fileLength (String name)

Returns the length of a file in the directory.

Throws
IOException

public long fileModified (String name)

Returns the time the named file was last modified.

Throws
IOException

public static String getExtension (String name)

Utility method to return a file's extension.

public Directory getPrimaryDir ()

Return the primary directory

public Directory getSecondaryDir ()

Return the secondary directory

public String[] listAll ()

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

Throws
IOException

public IndexInput openInput (String name)

Returns a stream reading an existing file.

Throws
IOException

public void sync (String name)

Ensure that any writes to this file are moved to stable storage. Lucene uses this to properly commit changes to the index, to prevent a machine/OS crash from corrupting the index.

Throws
IOException

public void touchFile (String name)

Set the modified time of an existing file to now.

Throws
IOException