org.apache.lucene.store.bytebuffer
Class ByteBufferDirectory

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

public class ByteBufferDirectory
extends org.apache.lucene.store.Directory

A memory based directory that uses ByteBuffer in order to store the directory content.

The benefit of using ByteBuffer is the fact that it can be stored in "native" memory outside of the JVM heap, thus not incurring the GC overhead of large in memory index.

Each "file" is segmented into one or more byte buffers.

If constructed with ByteBufferAllocator, it allows to control the allocation and release of byte buffer. For example, custom implementations can include caching of byte buffers.


Field Summary
protected  Map<String,ByteBufferFile> files
           
 
Fields inherited from class org.apache.lucene.store.Directory
isOpen, lockFactory
 
Constructor Summary
ByteBufferDirectory()
          Constructs a new directory using PlainByteBufferAllocator.
ByteBufferDirectory(ByteBufferAllocator allocator)
          Constructs a new byte buffer directory with a custom allocator.
 
Method Summary
 void close()
           
 org.apache.lucene.store.IndexOutput createOutput(String name)
           
 void deleteFile(String name)
           
 boolean fileExists(String name)
           
 long fileLength(String name)
           
 long fileModified(String name)
           
 String[] listAll()
           
 org.apache.lucene.store.IndexInput openInput(String name)
           
 long sizeInBytes()
          Returns the size in bytes of the directory, chunk by buffer size.
 void sync(Collection<String> names)
           
 void touchFile(String name)
           
 
Methods inherited from class org.apache.lucene.store.Directory
clearLock, copy, copy, ensureOpen, getLockFactory, getLockID, makeLock, openInput, setLockFactory, sync, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

files

protected final Map<String,ByteBufferFile> files
Constructor Detail

ByteBufferDirectory

public ByteBufferDirectory()
Constructs a new directory using PlainByteBufferAllocator.


ByteBufferDirectory

public ByteBufferDirectory(ByteBufferAllocator allocator)
Constructs a new byte buffer directory with a custom allocator.

Method Detail

sizeInBytes

public long sizeInBytes()
Returns the size in bytes of the directory, chunk by buffer size.


sync

public void sync(Collection<String> names)
          throws IOException
Overrides:
sync in class org.apache.lucene.store.Directory
Throws:
IOException

listAll

public String[] listAll()
                 throws IOException
Specified by:
listAll in class org.apache.lucene.store.Directory
Throws:
IOException

fileExists

public boolean fileExists(String name)
                   throws IOException
Specified by:
fileExists in class org.apache.lucene.store.Directory
Throws:
IOException

fileModified

public long fileModified(String name)
                  throws IOException
Specified by:
fileModified in class org.apache.lucene.store.Directory
Throws:
IOException

touchFile

public void touchFile(String name)
               throws IOException
Specified by:
touchFile in class org.apache.lucene.store.Directory
Throws:
IOException

deleteFile

public void deleteFile(String name)
                throws IOException
Specified by:
deleteFile in class org.apache.lucene.store.Directory
Throws:
IOException

fileLength

public long fileLength(String name)
                throws IOException
Specified by:
fileLength in class org.apache.lucene.store.Directory
Throws:
IOException

createOutput

public org.apache.lucene.store.IndexOutput createOutput(String name)
                                                 throws IOException
Specified by:
createOutput in class org.apache.lucene.store.Directory
Throws:
IOException

openInput

public org.apache.lucene.store.IndexInput openInput(String name)
                                             throws IOException
Specified by:
openInput in class org.apache.lucene.store.Directory
Throws:
IOException

close

public void close()
           throws IOException
Specified by:
close in interface Closeable
Specified by:
close in class org.apache.lucene.store.Directory
Throws:
IOException


Copyright © 2009-2012. All Rights Reserved.