API: Lucene.Net.Store (MMapDirectory + NIOFSDirectory + SimpleFSDirectory): Added overloads to allow passing the path as string rather than always requiring a DirectoryInfo instance from the user.
Project: http://git-wip-us.apache.org/repos/asf/lucenenet/repo Commit: http://git-wip-us.apache.org/repos/asf/lucenenet/commit/93203d88 Tree: http://git-wip-us.apache.org/repos/asf/lucenenet/tree/93203d88 Diff: http://git-wip-us.apache.org/repos/asf/lucenenet/diff/93203d88 Branch: refs/heads/master Commit: 93203d88ee6a1610950776eacf83d2c7bacd9a56 Parents: 8eaf47e Author: Shad Storhaug <[email protected]> Authored: Sun May 14 05:10:23 2017 +0700 Committer: Shad Storhaug <[email protected]> Committed: Tue May 16 19:17:13 2017 +0700 ---------------------------------------------------------------------- src/Lucene.Net/Store/MMapDirectory.cs | 57 +++++++++++++++++++++++++- src/Lucene.Net/Store/NIOFSDirectory.cs | 26 ++++++++++++ src/Lucene.Net/Store/SimpleFSDirectory.cs | 26 ++++++++++++ 3 files changed, 107 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/lucenenet/blob/93203d88/src/Lucene.Net/Store/MMapDirectory.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net/Store/MMapDirectory.cs b/src/Lucene.Net/Store/MMapDirectory.cs index ee1ac8c..349b926 100644 --- a/src/Lucene.Net/Store/MMapDirectory.cs +++ b/src/Lucene.Net/Store/MMapDirectory.cs @@ -65,7 +65,7 @@ namespace Lucene.Net.Store /// </summary> /// <param name="path"> the path of the directory </param> /// <param name="lockFactory"> the lock factory to use, or null for the default - /// (<seealso cref="NativeFSLockFactory"/>); </param> + /// (<see cref="NativeFSLockFactory"/>); </param> /// <exception cref="IOException"> if there is a low-level I/O error </exception> public MMapDirectory(DirectoryInfo path, LockFactory lockFactory) : this(path, lockFactory, DEFAULT_MAX_BUFF) @@ -88,7 +88,7 @@ namespace Lucene.Net.Store /// </summary> /// <param name="path"> the path of the directory </param> /// <param name="lockFactory"> the lock factory to use, or <c>null</c> for the default - /// (<seealso cref="NativeFSLockFactory"/>); </param> + /// (<see cref="NativeFSLockFactory"/>); </param> /// <param name="maxChunkSize"> maximum chunk size (default is 1 GiBytes for /// 64 bit runtimes and 256 MiBytes for 32 bit runtimes) used for memory mapping. /// <para/> @@ -114,6 +114,59 @@ namespace Lucene.Net.Store } /// <summary> + /// Create a new <see cref="MMapDirectory"/> for the named location. + /// <para/> + /// LUCENENET specific overload for convenience using string instead of <see cref="DirectoryInfo"/>. + /// </summary> + /// <param name="path"> the path of the directory </param> + /// <param name="lockFactory"> the lock factory to use, or null for the default + /// (<see cref="NativeFSLockFactory"/>); </param> + /// <exception cref="IOException"> if there is a low-level I/O error </exception> + public MMapDirectory(string path, LockFactory lockFactory) + : this(path, lockFactory, DEFAULT_MAX_BUFF) + { + } + + /// <summary> + /// Create a new <see cref="MMapDirectory"/> for the named location and <see cref="NativeFSLockFactory"/>. + /// <para/> + /// LUCENENET specific overload for convenience using string instead of <see cref="DirectoryInfo"/>. + /// </summary> + /// <param name="path"> the path of the directory </param> + /// <exception cref="IOException"> if there is a low-level I/O error </exception> + public MMapDirectory(string path) + : this(path, null) + { + } + + /// <summary> + /// Create a new <see cref="MMapDirectory"/> for the named location, specifying the + /// maximum chunk size used for memory mapping. + /// <para/> + /// LUCENENET specific overload for convenience using string instead of <see cref="DirectoryInfo"/>. + /// </summary> + /// <param name="path"> the path of the directory </param> + /// <param name="lockFactory"> the lock factory to use, or <c>null</c> for the default + /// (<see cref="NativeFSLockFactory"/>); </param> + /// <param name="maxChunkSize"> maximum chunk size (default is 1 GiBytes for + /// 64 bit runtimes and 256 MiBytes for 32 bit runtimes) used for memory mapping. + /// <para/> + /// Especially on 32 bit platform, the address space can be very fragmented, + /// so large index files cannot be mapped. Using a lower chunk size makes + /// the directory implementation a little bit slower (as the correct chunk + /// may be resolved on lots of seeks) but the chance is higher that mmap + /// does not fail. On 64 bit platforms, this parameter should always + /// be <c>1 << 30</c>, as the address space is big enough. + /// <para/> + /// <b>Please note:</b> The chunk size is always rounded down to a power of 2. + /// </param> + /// <exception cref="IOException"> if there is a low-level I/O error </exception> + public MMapDirectory(string path, LockFactory lockFactory, int maxChunkSize) + : this(new DirectoryInfo(path), lockFactory, maxChunkSize) + { + } + + /// <summary> /// <c>true</c>, if this platform supports unmapping mmapped files. /// </summary> // LUCENENET NOTE: Some JREs had a bug that didn't allow them to unmap. http://git-wip-us.apache.org/repos/asf/lucenenet/blob/93203d88/src/Lucene.Net/Store/NIOFSDirectory.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net/Store/NIOFSDirectory.cs b/src/Lucene.Net/Store/NIOFSDirectory.cs index 1649401..5ce4d81 100644 --- a/src/Lucene.Net/Store/NIOFSDirectory.cs +++ b/src/Lucene.Net/Store/NIOFSDirectory.cs @@ -76,6 +76,32 @@ namespace Lucene.Net.Store } /// <summary> + /// Create a new <see cref="NIOFSDirectory"/> for the named location. + /// <para/> + /// LUCENENET specific overload for convenience using string instead of <see cref="DirectoryInfo"/>. + /// </summary> + /// <param name="path"> the path of the directory </param> + /// <param name="lockFactory"> the lock factory to use, or null for the default + /// (<see cref="NativeFSLockFactory"/>); </param> + /// <exception cref="IOException"> if there is a low-level I/O error </exception> + public NIOFSDirectory(string path, LockFactory lockFactory) + : this(new DirectoryInfo(path), lockFactory) + { + } + + /// <summary> + /// Create a new <see cref="NIOFSDirectory"/> for the named location and <see cref="NativeFSLockFactory"/>. + /// <para/> + /// LUCENENET specific overload for convenience using string instead of <see cref="DirectoryInfo"/>. + /// </summary> + /// <param name="path"> the path of the directory </param> + /// <exception cref="IOException"> if there is a low-level I/O error </exception> + public NIOFSDirectory(string path) + : this(path, null) + { + } + + /// <summary> /// Creates an <see cref="IndexInput"/> for the file with the given name. </summary> public override IndexInput OpenInput(string name, IOContext context) { http://git-wip-us.apache.org/repos/asf/lucenenet/blob/93203d88/src/Lucene.Net/Store/SimpleFSDirectory.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net/Store/SimpleFSDirectory.cs b/src/Lucene.Net/Store/SimpleFSDirectory.cs index ce76a84..28d5e51 100644 --- a/src/Lucene.Net/Store/SimpleFSDirectory.cs +++ b/src/Lucene.Net/Store/SimpleFSDirectory.cs @@ -54,6 +54,32 @@ namespace Lucene.Net.Store } /// <summary> + /// Create a new <see cref="SimpleFSDirectory"/> for the named location. + /// <para/> + /// LUCENENET specific overload for convenience using string instead of <see cref="DirectoryInfo"/>. + /// </summary> + /// <param name="path"> the path of the directory </param> + /// <param name="lockFactory"> the lock factory to use, or null for the default + /// (<see cref="NativeFSLockFactory"/>); </param> + /// <exception cref="IOException"> if there is a low-level I/O error </exception> + public SimpleFSDirectory(string path, LockFactory lockFactory) + : this(new DirectoryInfo(path), lockFactory) + { + } + + /// <summary> + /// Create a new <see cref="SimpleFSDirectory"/> for the named location and <see cref="NativeFSLockFactory"/>. + /// <para/> + /// LUCENENET specific overload for convenience using string instead of <see cref="DirectoryInfo"/>. + /// </summary> + /// <param name="path"> the path of the directory </param> + /// <exception cref="IOException"> if there is a low-level I/O error </exception> + public SimpleFSDirectory(string path) + : this(path, null) + { + } + + /// <summary> /// Creates an <see cref="IndexInput"/> for the file with the given name. </summary> public override IndexInput OpenInput(string name, IOContext context) {
