org.apache.lucene.store.bytebuffer
Class ByteBufferDirectory
java.lang.Object
org.apache.lucene.store.Directory
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.
Fields inherited from class org.apache.lucene.store.Directory |
isOpen, lockFactory |
Methods inherited from class org.apache.lucene.store.Directory |
clearLock, copy, copy, ensureOpen, getLockFactory, getLockID, makeLock, openInput, setLockFactory, sync, toString |
files
protected final Map<String,ByteBufferFile> files
ByteBufferDirectory
public ByteBufferDirectory()
- Constructs a new directory using
PlainByteBufferAllocator
.
ByteBufferDirectory
public ByteBufferDirectory(ByteBufferAllocator allocator)
- Constructs a new byte buffer directory with a custom allocator.
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.