public class NativeUnixDirectory extends FSDirectory
Directory
implementation for all Unixes that uses
DIRECT I/O to bypass OS level IO caching during
merging. For all other cases (searching, writing) we delegate
to the provided Directory instance.
See Overview for more details.
To use this you must compile
NativePosixUtil.cpp (exposes Linux-specific APIs through
JNI) for your platform, by running ant
build-native-unix
, and then putting the resulting
libNativePosixUtil.so
(from
lucene/build/native
) onto your dynamic
linker search path.
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 today (only writes
small number of bytes after seek), but that may change.
This directory passes Solr and Lucene tests on Linux and OS X; other Unixes should work but have not been tested! Use at your own risk.
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_MERGE_BUFFER_SIZE
Default buffer size before writing to disk (256 KB);
larger means less IO load but more RAM and direct
buffer storage space consumed during merging.
|
static long |
DEFAULT_MIN_BYTES_DIRECT
Default min expected merge size before direct IO is
used (10 MB):
|
directory
isOpen, lockFactory
Constructor and Description |
---|
NativeUnixDirectory(Path path,
Directory delegate)
Create a new NIOFSDirectory for the named location with
FSLockFactory.getDefault() . |
NativeUnixDirectory(Path path,
int mergeBufferSize,
long minBytesDirect,
LockFactory lockFactory,
Directory delegate)
Create a new NIOFSDirectory for the named location.
|
NativeUnixDirectory(Path path,
LockFactory lockFactory,
Directory delegate)
Create a new NIOFSDirectory for the named location.
|
Modifier and Type | Method and Description |
---|---|
IndexOutput |
createOutput(String name,
IOContext context) |
IndexInput |
openInput(String name,
IOContext context) |
close, createTempOutput, deleteFile, deletePendingFiles, ensureCanRead, fileLength, fsync, getDirectory, getPendingDeletions, listAll, listAll, open, open, rename, sync, syncMetaData, toString
ensureOpen, obtainLock
copyFrom, getTempFileName, openChecksumInput
public static final int DEFAULT_MERGE_BUFFER_SIZE
public static final long DEFAULT_MIN_BYTES_DIRECT
public NativeUnixDirectory(Path path, int mergeBufferSize, long minBytesDirect, LockFactory lockFactory, Directory delegate) throws IOException
path
- the path of the directorylockFactory
- to usemergeBufferSize
- Size of buffer to use for
merging. See DEFAULT_MERGE_BUFFER_SIZE
.minBytesDirect
- Merges, or files to be opened for
reading, smaller than this will
not use direct IO. See DEFAULT_MIN_BYTES_DIRECT
delegate
- fallback Directory for non-mergesIOException
- If there is a low-level I/O errorpublic NativeUnixDirectory(Path path, LockFactory lockFactory, Directory delegate) throws IOException
path
- the path of the directorylockFactory
- the lock factory to usedelegate
- fallback Directory for non-mergesIOException
- If there is a low-level I/O errorpublic NativeUnixDirectory(Path path, Directory delegate) throws IOException
FSLockFactory.getDefault()
.path
- the path of the directorydelegate
- fallback Directory for non-mergesIOException
- If there is a low-level I/O errorpublic IndexInput openInput(String name, IOContext context) throws IOException
openInput
in class Directory
IOException
public IndexOutput createOutput(String name, IOContext context) throws IOException
createOutput
in class FSDirectory
IOException
Copyright © 2000-2021 Apache Software Foundation. All Rights Reserved.