Class WindowsDirectory

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable

    public class WindowsDirectory
    extends FSDirectory
    Native Directory implementation for Microsoft Windows.

    Steps:

    1. Compile the source code to create libLuceneNativeIO.dll: ./gradlew build
    2. Put the resulting libLuceneNativeIO.dll (from lucene/misc/native/build/lib/release/platform/) into some directory in your windows PATH
    3. Open indexes with WindowsDirectory and use it.
    • Constructor Detail

      • WindowsDirectory

        public WindowsDirectory​(java.nio.file.Path path,
                                LockFactory lockFactory)
                         throws java.io.IOException
        Create a new WindowsDirectory for the named location.
        Parameters:
        path - the path of the directory
        lockFactory - the lock factory to use
        Throws:
        java.io.IOException - If there is a low-level I/O error
      • WindowsDirectory

        public WindowsDirectory​(java.nio.file.Path path)
                         throws java.io.IOException
        Create a new WindowsDirectory for the named location and FSLockFactory.getDefault().
        Parameters:
        path - the path of the directory
        Throws:
        java.io.IOException - If there is a low-level I/O error
    • Method Detail

      • openInput

        public IndexInput openInput​(java.lang.String name,
                                    IOContext context)
                             throws java.io.IOException
        Description copied from class: Directory
        Opens a stream for reading an existing file.

        This method must throw either NoSuchFileException or FileNotFoundException if name points to a non-existing file.

        Specified by:
        openInput in class Directory
        Parameters:
        name - the name of an existing file.
        Throws:
        java.io.IOException - in case of I/O error
      • open

        private static long open​(java.lang.String filename)
                          throws java.io.IOException
        Opens a handle to a file.
        Throws:
        java.io.IOException
      • read

        private static int read​(long fd,
                                byte[] bytes,
                                int offset,
                                int length,
                                long pos)
                         throws java.io.IOException
        Reads data from a file at pos into bytes
        Throws:
        java.io.IOException
      • close

        private static void close​(long fd)
                           throws java.io.IOException
        Closes a handle to a file
        Throws:
        java.io.IOException
      • length

        private static long length​(long fd)
                            throws java.io.IOException
        Returns the length of a file
        Throws:
        java.io.IOException