org.apache.lucene.store
Class DirectIOLinuxDirectory

java.lang.Object
  extended by org.apache.lucene.store.Directory
      extended by org.apache.lucene.store.FSDirectory
          extended by org.apache.lucene.store.DirectIOLinuxDirectory
All Implemented Interfaces:
Closeable

public class DirectIOLinuxDirectory
extends FSDirectory

An Directory implementation that uses the Linux-specific O_DIRECT flag to bypass all OS level caching. To use this you must compile NativePosixUtil.cpp (exposes Linux-specific APIs through JNI) for your platform.

WARNING: this code is very new and quite easily could contain horrible bugs. For example, here's one known issue: if you use seek in IndexOutput, and then write more than one buffer's worth of bytes, then the file will be wrong. Lucene does not do this (only writes small number of bytes after seek).

WARNING: This API is experimental and might change in incompatible ways in the next release.

Nested Class Summary
 
Nested classes/interfaces inherited from class org.apache.lucene.store.FSDirectory
FSDirectory.FSIndexOutput
 
Field Summary
 
Fields inherited from class org.apache.lucene.store.FSDirectory
DEFAULT_READ_CHUNK_SIZE, directory, staleFiles
 
Fields inherited from class org.apache.lucene.store.Directory
isOpen, lockFactory
 
Constructor Summary
DirectIOLinuxDirectory(File path, LockFactory lockFactory, int forcedBufferSize)
          Create a new NIOFSDirectory for the named location.
 
Method Summary
 IndexOutput createOutput(String name)
          Creates an IndexOutput for the file with the given name.
 IndexInput openInput(String name, int bufferSize)
          Returns a stream reading an existing file, with the specified read buffer size.
 
Methods inherited from class org.apache.lucene.store.FSDirectory
close, deleteFile, ensureCanWrite, fileExists, fileLength, fileModified, fileModified, fsync, getDirectory, getFile, getLockID, getReadChunkSize, listAll, listAll, onIndexOutputClosed, open, open, openInput, setLockFactory, setReadChunkSize, sync, sync, toString, touchFile
 
Methods inherited from class org.apache.lucene.store.Directory
clearLock, copy, copy, ensureOpen, getLockFactory, makeLock
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DirectIOLinuxDirectory

public DirectIOLinuxDirectory(File path,
                              LockFactory lockFactory,
                              int forcedBufferSize)
                       throws IOException
Create a new NIOFSDirectory for the named location.

Parameters:
path - the path of the directory
lockFactory - the lock factory to use, or null for the default (NativeFSLockFactory);
forcedBufferSize - if this is 0, just use Lucene's default buffer size; else, force this buffer size. For best performance, force the buffer size to something fairly large (eg 1 MB), but note that this will eat up the JRE's direct buffer storage space
Throws:
IOException
Method Detail

openInput

public IndexInput openInput(String name,
                            int bufferSize)
                     throws IOException
Description copied from class: Directory
Returns a stream reading an existing file, with the specified read buffer size. The particular Directory implementation may ignore the buffer size. Currently the only Directory implementations that respect this parameter are FSDirectory and CompoundFileReader.

Overrides:
openInput in class Directory
Throws:
IOException

createOutput

public IndexOutput createOutput(String name)
                         throws IOException
Description copied from class: FSDirectory
Creates an IndexOutput for the file with the given name.

Overrides:
createOutput in class FSDirectory
Throws:
IOException


Copyright © 2000-2011 Apache Software Foundation. All Rights Reserved.