org.compass.needle.terracotta
Class TerracottaDirectory

java.lang.Object
  extended by org.apache.lucene.store.Directory
      extended by org.compass.needle.terracotta.TerracottaDirectory

public class TerracottaDirectory
extends Directory

A Terracota based directory based on Lucene RAM directory improved to support better concurrency.

Basically, the direcotry stores TerracottaFile which are broken into one or more byte arrays. The size of the byte array can be configured but should not be changed once the index created.

Author:
kimchy

Field Summary
static int DEFAULT_BUFFER_SIZE
           
static int DEFAULT_FLUSH_RATE
           
 
Fields inherited from class org.apache.lucene.store.Directory
lockFactory
 
Constructor Summary
TerracottaDirectory()
           
TerracottaDirectory(Directory dir)
           
TerracottaDirectory(File dir)
           
TerracottaDirectory(int bufferSize, int flushRate)
          Constructs an empty Directory.
TerracottaDirectory(String dir)
           
 
Method Summary
(package private)  void addFile(String name, TerracottaFile file)
           
 void close()
          Closes the store to future operations, releasing associated memory.
 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 the named file exists in this directory.
 long fileLength(String name)
          Returns the length in bytes of a file in the directory.
 long fileModified(String name)
          Returns the time the named file was last modified.
(package private)  int getBufferSize()
           
(package private)  int getFlushRate()
           
(package private)  Map<String,Boolean> getOnGoingIndexOutputs()
           
 String[] list()
          Returns an array of strings, one for each file in the directory.
 IndexInput openInput(String name)
          Returns a stream reading an existing file.
 void renameFile(String from, String to)
          Deprecated.  
 void touchFile(String name)
          Set the modified time of an existing file to now.
 
Methods inherited from class org.apache.lucene.store.Directory
clearLock, copy, getLockFactory, getLockID, makeLock, openInput, setLockFactory
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_BUFFER_SIZE

public static final transient int DEFAULT_BUFFER_SIZE
See Also:
Constant Field Values

DEFAULT_FLUSH_RATE

public static final transient int DEFAULT_FLUSH_RATE
See Also:
Constant Field Values
Constructor Detail

TerracottaDirectory

public TerracottaDirectory()

TerracottaDirectory

public TerracottaDirectory(int bufferSize,
                           int flushRate)
Constructs an empty Directory.


TerracottaDirectory

public TerracottaDirectory(Directory dir)
                    throws IOException
Throws:
IOException

TerracottaDirectory

public TerracottaDirectory(File dir)
                    throws IOException
Throws:
IOException

TerracottaDirectory

public TerracottaDirectory(String dir)
                    throws IOException
Throws:
IOException
Method Detail

list

public final String[] list()
Returns an array of strings, one for each file in the directory.

Specified by:
list in class Directory

fileExists

public final boolean fileExists(String name)
Returns true iff the named file exists in this directory.

Specified by:
fileExists in class Directory

fileModified

public final long fileModified(String name)
                        throws IOException
Returns the time the named file was last modified.

Specified by:
fileModified in class Directory
Throws:
IOException - if the file does not exist

touchFile

public void touchFile(String name)
               throws IOException
Set the modified time of an existing file to now.

Specified by:
touchFile in class Directory
Throws:
IOException - if the file does not exist

fileLength

public final long fileLength(String name)
                      throws IOException
Returns the length in bytes of a file in the directory.

Specified by:
fileLength in class Directory
Throws:
IOException - if the file does not exist

deleteFile

public void deleteFile(String name)
                throws IOException
Removes an existing file in the directory.

Specified by:
deleteFile in class Directory
Throws:
IOException - if the file does not exist

renameFile

public final void renameFile(String from,
                             String to)
                      throws IOException
Deprecated. 

Renames an existing file in the directory.

Specified by:
renameFile in class Directory
Throws:
FileNotFoundException - if from does not exist
IOException

createOutput

public IndexOutput createOutput(String name)
                         throws IOException
Creates a new, empty file in the directory with the given name. Returns a stream writing this file.

Specified by:
createOutput in class Directory
Throws:
IOException

openInput

public IndexInput openInput(String name)
                     throws IOException
Returns a stream reading an existing file.

Specified by:
openInput in class Directory
Throws:
IOException

addFile

void addFile(String name,
             TerracottaFile file)

getBufferSize

int getBufferSize()

getFlushRate

int getFlushRate()

getOnGoingIndexOutputs

Map<String,Boolean> getOnGoingIndexOutputs()

close

public void close()
Closes the store to future operations, releasing associated memory.

Specified by:
close in class Directory


Copyright (c) 2004-2008 The Compass Project.