You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucenenet.apache.org by ni...@apache.org on 2017/07/13 18:35:56 UTC
[1/9] lucenenet git commit:
Lucene.Net.Search.ConstantScoreAutoRewrite: Fixed broken doc comment
references
Repository: lucenenet
Updated Branches:
refs/heads/master e8e1b5a9c -> 9c5085c4b
Lucene.Net.Search.ConstantScoreAutoRewrite: Fixed broken doc comment references
Project: http://git-wip-us.apache.org/repos/asf/lucenenet/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucenenet/commit/bfcb8958
Tree: http://git-wip-us.apache.org/repos/asf/lucenenet/tree/bfcb8958
Diff: http://git-wip-us.apache.org/repos/asf/lucenenet/diff/bfcb8958
Branch: refs/heads/master
Commit: bfcb8958954cc96a9f18a47ea1a8536d5417f300
Parents: e8e1b5a
Author: Shad Storhaug <sh...@shadstorhaug.com>
Authored: Thu Jul 13 17:24:36 2017 +0700
Committer: Shad Storhaug <sh...@shadstorhaug.com>
Committed: Thu Jul 13 17:24:36 2017 +0700
----------------------------------------------------------------------
src/Lucene.Net/Search/ConstantScoreAutoRewrite.cs | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/bfcb8958/src/Lucene.Net/Search/ConstantScoreAutoRewrite.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net/Search/ConstantScoreAutoRewrite.cs b/src/Lucene.Net/Search/ConstantScoreAutoRewrite.cs
index aa741b9..16155d9 100644
--- a/src/Lucene.Net/Search/ConstantScoreAutoRewrite.cs
+++ b/src/Lucene.Net/Search/ConstantScoreAutoRewrite.cs
@@ -37,8 +37,8 @@ namespace Lucene.Net.Search
/// constant-score rewrite method based on term and
/// document counts from the query. If both the number of
/// terms and documents is small enough, then
- /// <see cref="CONSTANT_SCORE_BOOLEAN_QUERY_REWRITE"/> is used.
- /// Otherwise, <see cref="CONSTANT_SCORE_FILTER_REWRITE"/> is
+ /// <see cref="MultiTermQuery.CONSTANT_SCORE_BOOLEAN_QUERY_REWRITE"/> is used.
+ /// Otherwise, <see cref="MultiTermQuery.CONSTANT_SCORE_FILTER_REWRITE"/> is
/// used.
/// </summary>
// LUCENENET specific: made this class public. In Lucene there was a derived class
[3/9] lucenenet git commit: API:
Lucene.Net.Store.Directory.IndexInputSlicer: Removed unnecessary constructor
and private variable that were not in use.
Posted by ni...@apache.org.
API: Lucene.Net.Store.Directory.IndexInputSlicer: Removed unnecessary constructor and private variable that were not in use.
Project: http://git-wip-us.apache.org/repos/asf/lucenenet/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucenenet/commit/de62e957
Tree: http://git-wip-us.apache.org/repos/asf/lucenenet/tree/de62e957
Diff: http://git-wip-us.apache.org/repos/asf/lucenenet/diff/de62e957
Branch: refs/heads/master
Commit: de62e95746f23d6026412e22c6f724fed03b5fa7
Parents: c0e7a25
Author: Shad Storhaug <sh...@shadstorhaug.com>
Authored: Thu Jul 13 23:53:55 2017 +0700
Committer: Shad Storhaug <sh...@shadstorhaug.com>
Committed: Thu Jul 13 23:53:55 2017 +0700
----------------------------------------------------------------------
src/Lucene.Net.TestFramework/Store/MockDirectoryWrapper.cs | 1 -
src/Lucene.Net/Store/CompoundFileDirectory.cs | 1 -
src/Lucene.Net/Store/Directory.cs | 8 --------
src/Lucene.Net/Store/MMapDirectory.cs | 1 -
src/Lucene.Net/Store/NIOFSDirectory.cs | 5 ++---
src/Lucene.Net/Store/SimpleFSDirectory.cs | 5 ++---
6 files changed, 4 insertions(+), 17 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/de62e957/src/Lucene.Net.TestFramework/Store/MockDirectoryWrapper.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.TestFramework/Store/MockDirectoryWrapper.cs b/src/Lucene.Net.TestFramework/Store/MockDirectoryWrapper.cs
index a333d93..6011990 100644
--- a/src/Lucene.Net.TestFramework/Store/MockDirectoryWrapper.cs
+++ b/src/Lucene.Net.TestFramework/Store/MockDirectoryWrapper.cs
@@ -1345,7 +1345,6 @@ namespace Lucene.Net.Store
private IndexInputSlicer DelegateHandle;
public IndexInputSlicerAnonymousInnerClassHelper(MockDirectoryWrapper outerInstance, string name, IndexInputSlicer delegateHandle)
- : base(outerInstance)
{
this.OuterInstance = outerInstance;
this.Name = name;
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/de62e957/src/Lucene.Net/Store/CompoundFileDirectory.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net/Store/CompoundFileDirectory.cs b/src/Lucene.Net/Store/CompoundFileDirectory.cs
index 53682b2..0b53e9b 100644
--- a/src/Lucene.Net/Store/CompoundFileDirectory.cs
+++ b/src/Lucene.Net/Store/CompoundFileDirectory.cs
@@ -442,7 +442,6 @@ namespace Lucene.Net.Store
private FileEntry entry;
public IndexInputSlicerAnonymousInnerClassHelper(CompoundFileDirectory outerInstance, FileEntry entry)
- : base(outerInstance)
{
this.outerInstance = outerInstance;
this.entry = entry;
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/de62e957/src/Lucene.Net/Store/Directory.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net/Store/Directory.cs b/src/Lucene.Net/Store/Directory.cs
index 7ca06b3..24b7bb8 100644
--- a/src/Lucene.Net/Store/Directory.cs
+++ b/src/Lucene.Net/Store/Directory.cs
@@ -263,7 +263,6 @@ namespace Lucene.Net.Store
private IOContext context;
public IndexInputSlicerAnonymousInnerClassHelper(Directory outerInstance, string name, IOContext context)
- : base(outerInstance)
{
this.outerInstance = outerInstance;
this.name = name;
@@ -311,13 +310,6 @@ namespace Lucene.Net.Store
#endif
public abstract class IndexInputSlicer : IDisposable
{
- private readonly Directory outerInstance;
-
- public IndexInputSlicer(Directory outerInstance)
- {
- this.outerInstance = outerInstance;
- }
-
/// <summary>
/// Returns an <see cref="IndexInput"/> slice starting at the given offset with the given length.
/// </summary>
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/de62e957/src/Lucene.Net/Store/MMapDirectory.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net/Store/MMapDirectory.cs b/src/Lucene.Net/Store/MMapDirectory.cs
index 68eebf6..b116b90 100644
--- a/src/Lucene.Net/Store/MMapDirectory.cs
+++ b/src/Lucene.Net/Store/MMapDirectory.cs
@@ -240,7 +240,6 @@ namespace Lucene.Net.Store
private MMapIndexInput full;
public IndexInputSlicerAnonymousInnerClassHelper(MMapDirectory outerInstance, MMapIndexInput full)
- : base(outerInstance)
{
this.outerInstance = outerInstance;
this.full = full;
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/de62e957/src/Lucene.Net/Store/NIOFSDirectory.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net/Store/NIOFSDirectory.cs b/src/Lucene.Net/Store/NIOFSDirectory.cs
index 5ce4d81..74adff4 100644
--- a/src/Lucene.Net/Store/NIOFSDirectory.cs
+++ b/src/Lucene.Net/Store/NIOFSDirectory.cs
@@ -116,7 +116,7 @@ namespace Lucene.Net.Store
EnsureOpen();
var path = new FileInfo(Path.Combine(Directory.FullName, name));
var fc = new FileStream(path.FullName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite | FileShare.Delete);
- return new IndexInputSlicerAnonymousInnerClassHelper(this, context, path, fc);
+ return new IndexInputSlicerAnonymousInnerClassHelper(context, path, fc);
}
#if FEATURE_SERIALIZABLE
@@ -128,8 +128,7 @@ namespace Lucene.Net.Store
private readonly FileInfo path;
private readonly FileStream descriptor;
- public IndexInputSlicerAnonymousInnerClassHelper(NIOFSDirectory outerInstance, IOContext context, FileInfo path, FileStream descriptor)
- : base(outerInstance)
+ public IndexInputSlicerAnonymousInnerClassHelper(IOContext context, FileInfo path, FileStream descriptor)
{
this.context = context;
this.path = path;
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/de62e957/src/Lucene.Net/Store/SimpleFSDirectory.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net/Store/SimpleFSDirectory.cs b/src/Lucene.Net/Store/SimpleFSDirectory.cs
index 28d5e51..2d5b8ac 100644
--- a/src/Lucene.Net/Store/SimpleFSDirectory.cs
+++ b/src/Lucene.Net/Store/SimpleFSDirectory.cs
@@ -94,7 +94,7 @@ namespace Lucene.Net.Store
EnsureOpen();
var file = new FileInfo(Path.Combine(Directory.FullName, name));
var descriptor = new FileStream(file.FullName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
- return new IndexInputSlicerAnonymousInnerClassHelper(this, context, file, descriptor);
+ return new IndexInputSlicerAnonymousInnerClassHelper(context, file, descriptor);
}
private class IndexInputSlicerAnonymousInnerClassHelper : IndexInputSlicer
@@ -103,8 +103,7 @@ namespace Lucene.Net.Store
private readonly FileInfo file;
private readonly FileStream descriptor;
- public IndexInputSlicerAnonymousInnerClassHelper(SimpleFSDirectory outerInstance, IOContext context, FileInfo file, FileStream descriptor)
- : base(outerInstance)
+ public IndexInputSlicerAnonymousInnerClassHelper(IOContext context, FileInfo file, FileStream descriptor)
{
this.context = context;
this.file = file;
[9/9] lucenenet git commit: API: Lucene.Net.Support.Document: Added
extension methods to make casting to the correct field type simpler.
Posted by ni...@apache.org.
API: Lucene.Net.Support.Document: Added extension methods to make casting to the correct field type simpler.
Project: http://git-wip-us.apache.org/repos/asf/lucenenet/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucenenet/commit/9c5085c4
Tree: http://git-wip-us.apache.org/repos/asf/lucenenet/tree/9c5085c4
Diff: http://git-wip-us.apache.org/repos/asf/lucenenet/diff/9c5085c4
Branch: refs/heads/master
Commit: 9c5085c4b6c6e16aaa10eb79ac645789af5b2b6c
Parents: 2fedc57
Author: Shad Storhaug <sh...@shadstorhaug.com>
Authored: Fri Jul 14 01:34:03 2017 +0700
Committer: Shad Storhaug <sh...@shadstorhaug.com>
Committed: Fri Jul 14 01:34:03 2017 +0700
----------------------------------------------------------------------
src/Lucene.Net/Document/Document.cs | 2 +-
src/Lucene.Net/Lucene.Net.csproj | 1 +
.../Support/Document/DocumentExtensions.cs | 39 ++++++++++++++++++++
3 files changed, 41 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/9c5085c4/src/Lucene.Net/Document/Document.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net/Document/Document.cs b/src/Lucene.Net/Document/Document.cs
index d19f874..e67946f 100644
--- a/src/Lucene.Net/Document/Document.cs
+++ b/src/Lucene.Net/Document/Document.cs
@@ -192,7 +192,7 @@ namespace Lucene.Net.Documents
/// <summary>
/// Returns an array of <see cref="IIndexableField"/>s with the given name.
- /// this method returns an empty array when there are no
+ /// This method returns an empty array when there are no
/// matching fields. It never returns <c>null</c>.
/// </summary>
/// <param name="name"> the name of the field </param>
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/9c5085c4/src/Lucene.Net/Lucene.Net.csproj
----------------------------------------------------------------------
diff --git a/src/Lucene.Net/Lucene.Net.csproj b/src/Lucene.Net/Lucene.Net.csproj
index ff96872..d2b8e6e 100644
--- a/src/Lucene.Net/Lucene.Net.csproj
+++ b/src/Lucene.Net/Lucene.Net.csproj
@@ -394,6 +394,7 @@
<Compile Include="Index\TwoStoredFieldsConsumers.cs" />
<Compile Include="Index\UpgradeIndexMergePolicy.cs" />
<Compile Include="LucenePackage.cs" />
+ <Compile Include="Support\Document\DocumentExtensions.cs" />
<Compile Include="Support\IO\Compression\LZOCompressor.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Search\AutomatonQuery.cs" />
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/9c5085c4/src/Lucene.Net/Support/Document/DocumentExtensions.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net/Support/Document/DocumentExtensions.cs b/src/Lucene.Net/Support/Document/DocumentExtensions.cs
new file mode 100644
index 0000000..c04dc21
--- /dev/null
+++ b/src/Lucene.Net/Support/Document/DocumentExtensions.cs
@@ -0,0 +1,39 @@
+using Lucene.Net.Index;
+using System.Linq;
+
+namespace Lucene.Net.Documents
+{
+ /// <summary>
+ /// Extension methods to the <see cref="Document"/> class.
+ /// </summary>
+ public static class DocumentExtensions
+ {
+ /// <summary>
+ /// Returns a field with the given name if any exist in this document cast to type <typeparam name="T"/>, or
+ /// <c>null</c>. If multiple fields exists with this name, this method returns the
+ /// first value added.
+ /// <para/>
+ /// LUCENENET specific
+ /// </summary>
+ /// <exception cref="InvalidCastException">If the field type cannot be cast to <typeparam name="T"/>.</exception>
+ public static T GetField<T>(this Document document, string name) where T : IIndexableField
+ {
+ return (T)document.GetField(name);
+ }
+
+ /// <summary>
+ /// Returns an array of <see cref="IIndexableField"/>s with the given name, cast to type <typeparam name="T"/>.
+ /// This method returns an empty array when there are no
+ /// matching fields. It never returns <c>null</c>.
+ /// <para/>
+ /// LUCENENET specific
+ /// </summary>
+ /// <param name="name"> the name of the field </param>
+ /// <returns> a <see cref="T:IndexableField[]"/> array </returns>
+ /// <exception cref="InvalidCastException">If the field type cannot be cast to <typeparam name="T"/>.</exception>
+ public static T[] GetFields<T>(this Document document, string name) where T : IIndexableField
+ {
+ return document.GetFields(name).Cast<T>().ToArray();
+ }
+ }
+}
[8/9] lucenenet git commit:
Lucene.Net.Support.Search.ReferenceManagerExtensions: Renamed
AcquireContext() to GetContext()
Posted by ni...@apache.org.
Lucene.Net.Support.Search.ReferenceManagerExtensions: Renamed AcquireContext() to GetContext()
Project: http://git-wip-us.apache.org/repos/asf/lucenenet/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucenenet/commit/2fedc574
Tree: http://git-wip-us.apache.org/repos/asf/lucenenet/tree/2fedc574
Diff: http://git-wip-us.apache.org/repos/asf/lucenenet/diff/2fedc574
Branch: refs/heads/master
Commit: 2fedc5747838f3aa66e3e1b6e60f2600e0a4f46c
Parents: 6f51ab5
Author: Shad Storhaug <sh...@shadstorhaug.com>
Authored: Fri Jul 14 01:21:11 2017 +0700
Committer: Shad Storhaug <sh...@shadstorhaug.com>
Committed: Fri Jul 14 01:21:11 2017 +0700
----------------------------------------------------------------------
src/Lucene.Net/Support/Search/ReferenceManagerExtensions.cs | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/2fedc574/src/Lucene.Net/Support/Search/ReferenceManagerExtensions.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net/Support/Search/ReferenceManagerExtensions.cs b/src/Lucene.Net/Support/Search/ReferenceManagerExtensions.cs
index 2629398..b8bde10 100644
--- a/src/Lucene.Net/Support/Search/ReferenceManagerExtensions.cs
+++ b/src/Lucene.Net/Support/Search/ReferenceManagerExtensions.cs
@@ -28,7 +28,7 @@
/// <para/>
/// <code>
/// var searcherManager = new SearcherManager(indexWriter, true, null);
- /// using (var context = searcherManager.AcquireContext())
+ /// using (var context = searcherManager.GetContext())
/// {
/// IndexSearcher searcher = context.Reference;
///
@@ -38,8 +38,10 @@
/// </summary>
/// <typeparam name="T">The reference type</typeparam>
/// <param name="referenceManager">this <see cref="ReferenceManager{G}"/></param>
- /// <returns>A <see cref="ReferenceContext{T}"/> instance that holds the <see cref="ReferenceContext{T}.Reference"/> and ensures it is released properly when <see cref="ReferenceContext{T}.Dispose()"/> is called.</returns>
- public static ReferenceContext<T> AcquireContext<T>(this ReferenceManager<T> referenceManager) where T : class
+ /// <returns>A <see cref="ReferenceContext{T}"/> instance that holds the
+ /// <see cref="ReferenceContext{T}.Reference"/> and ensures it is released properly
+ /// when <see cref="ReferenceContext{T}.Dispose()"/> is called.</returns>
+ public static ReferenceContext<T> GetContext<T>(this ReferenceManager<T> referenceManager) where T : class
{
return new ReferenceContext<T>(referenceManager);
}
[6/9] lucenenet git commit: LUCENENET-521: Added regression test to
confirm this issue is fixed with the new MMapDirectory implementation.
Posted by ni...@apache.org.
LUCENENET-521: Added regression test to confirm this issue is fixed with the new MMapDirectory implementation.
Project: http://git-wip-us.apache.org/repos/asf/lucenenet/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucenenet/commit/39e63160
Tree: http://git-wip-us.apache.org/repos/asf/lucenenet/tree/39e63160
Diff: http://git-wip-us.apache.org/repos/asf/lucenenet/diff/39e63160
Branch: refs/heads/master
Commit: 39e63160efd6709c591862a7cf6c8e3a1e44b126
Parents: 3944108
Author: Shad Storhaug <sh...@shadstorhaug.com>
Authored: Fri Jul 14 00:46:07 2017 +0700
Committer: Shad Storhaug <sh...@shadstorhaug.com>
Committed: Fri Jul 14 00:46:07 2017 +0700
----------------------------------------------------------------------
src/Lucene.Net.Tests/Lucene.Net.Tests.csproj | 1 +
src/Lucene.Net.Tests/Store/LUCENENET521.zip | Bin 0 -> 8186 bytes
src/Lucene.Net.Tests/Store/TestDirectory.cs | 44 ++++++++++++++++++++++
src/Lucene.Net.Tests/project.json | 1 +
4 files changed, 46 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/39e63160/src/Lucene.Net.Tests/Lucene.Net.Tests.csproj
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/Lucene.Net.Tests.csproj b/src/Lucene.Net.Tests/Lucene.Net.Tests.csproj
index a913b37..de94c52 100644
--- a/src/Lucene.Net.Tests/Lucene.Net.Tests.csproj
+++ b/src/Lucene.Net.Tests/Lucene.Net.Tests.csproj
@@ -117,6 +117,7 @@
<EmbeddedResource Include="Index\taxo.48.w-binary-doc-values.zip" />
<None Include="Lucene.Net.snk" />
<None Include="Lucene.Net.Tests.project.json" />
+ <EmbeddedResource Include="Store\LUCENENET521.zip" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Lucene.Net.Analysis.Common\Lucene.Net.Analysis.Common.csproj">
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/39e63160/src/Lucene.Net.Tests/Store/LUCENENET521.zip
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/Store/LUCENENET521.zip b/src/Lucene.Net.Tests/Store/LUCENENET521.zip
new file mode 100644
index 0000000..ee12368
Binary files /dev/null and b/src/Lucene.Net.Tests/Store/LUCENENET521.zip differ
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/39e63160/src/Lucene.Net.Tests/Store/TestDirectory.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/Store/TestDirectory.cs b/src/Lucene.Net.Tests/Store/TestDirectory.cs
index bbcfbc9..2d22ae1 100644
--- a/src/Lucene.Net.Tests/Store/TestDirectory.cs
+++ b/src/Lucene.Net.Tests/Store/TestDirectory.cs
@@ -6,6 +6,7 @@ using Lucene.Net.Util;
using NUnit.Framework;
using System;
using System.IO;
+using System.Reflection;
using System.Threading;
namespace Lucene.Net.Store
@@ -477,5 +478,48 @@ namespace Lucene.Net.Store
}
}
}
+
+ [Test]
+ [LuceneNetSpecific]
+ public void TestLUCENENET521()
+ {
+ var newDirectoryInfo = CreateTempDir("LUCENENET521");
+ using (var zipFileStream = this.GetType().GetTypeInfo().Assembly.FindAndGetManifestResourceStream(this.GetType(), "LUCENENET521.zip"))
+ {
+ TestUtil.Unzip(zipFileStream, newDirectoryInfo);
+ }
+
+ var newDirectory = new MMapDirectory(newDirectoryInfo);
+ var conf = new Index.IndexWriterConfig(LuceneVersion.LUCENE_30, new Analysis.Standard.StandardAnalyzer(LuceneVersion.LUCENE_30));
+ var indexWriter = new Index.IndexWriter(newDirectory, conf);
+ indexWriter.Dispose();
+
+ var sharedReader = Index.IndexReader.Open(newDirectory /*, true*/);
+ const int times = 10;
+ const int concurrentTaskCount = 10;
+ var task = new System.Threading.Tasks.Task[concurrentTaskCount];
+ for (int i = 0; i < concurrentTaskCount; i++)
+ {
+ task[i] = new System.Threading.Tasks.Task(() => Search(sharedReader, times));
+ task[i].Start();
+ }
+
+ System.Threading.Tasks.Task.WaitAll(task);
+ return;
+ }
+
+ private static void Search(Index.IndexReader r, int times)
+ {
+ var searcher = new Search.IndexSearcher(r);
+ var docs = new System.Collections.Generic.List<Documents.Document>(10000);
+ for (int i = 0; i < times; i++)
+ {
+ var q = new Search.TermQuery(new Index.Term("title", "volume"));
+ foreach (var scoreDoc in searcher.Search(q, 100).ScoreDocs)
+ {
+ docs.Add(searcher.Doc(scoreDoc.Doc));
+ }
+ }
+ }
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/39e63160/src/Lucene.Net.Tests/project.json
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/project.json b/src/Lucene.Net.Tests/project.json
index 117862c..f1ff4ed 100644
--- a/src/Lucene.Net.Tests/project.json
+++ b/src/Lucene.Net.Tests/project.json
@@ -50,6 +50,7 @@
"Index/unsupported.24.nocfs.zip",
"Index/unsupported.29.cfs.zip",
"Index/unsupported.29.nocfs.zip",
+ "Store/LUCENENET521.zip",
"Support/IO/ReadFully.txt"
]
}
[2/9] lucenenet git commit: BUG: Lucene.Net.Store: Fixed
MMapDirectory and FSDirectory concurrency using solution suggested by Vincent
Van Den Berghe http://apache.markmail.org/message/hafnuhq2ydhfjmi2. Fixes
LUCENENET-521 and closes LUCENENET-530.
Posted by ni...@apache.org.
BUG: Lucene.Net.Store: Fixed MMapDirectory and FSDirectory concurrency using solution suggested by Vincent Van Den Berghe http://apache.markmail.org/message/hafnuhq2ydhfjmi2. Fixes LUCENENET-521 and closes LUCENENET-530.
Project: http://git-wip-us.apache.org/repos/asf/lucenenet/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucenenet/commit/c0e7a25c
Tree: http://git-wip-us.apache.org/repos/asf/lucenenet/tree/c0e7a25c
Diff: http://git-wip-us.apache.org/repos/asf/lucenenet/diff/c0e7a25c
Branch: refs/heads/master
Commit: c0e7a25c4a5901a4b6bea4f92088b5135c1f550a
Parents: bfcb895
Author: Shad Storhaug <sh...@shadstorhaug.com>
Authored: Thu Jul 13 23:45:23 2017 +0700
Committer: Shad Storhaug <sh...@shadstorhaug.com>
Committed: Thu Jul 13 23:45:23 2017 +0700
----------------------------------------------------------------------
src/Lucene.Net/Store/FSDirectory.cs | 18 +++--
src/Lucene.Net/Store/MMapDirectory.cs | 101 +++++++++--------------------
2 files changed, 43 insertions(+), 76 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/c0e7a25c/src/Lucene.Net/Store/FSDirectory.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net/Store/FSDirectory.cs b/src/Lucene.Net/Store/FSDirectory.cs
index 36cac51..19f8e14 100644
--- a/src/Lucene.Net/Store/FSDirectory.cs
+++ b/src/Lucene.Net/Store/FSDirectory.cs
@@ -362,10 +362,12 @@ namespace Lucene.Net.Store
ISet<string> toSync = new HashSet<string>(names);
toSync.IntersectWith(m_staleFiles);
- foreach (var name in toSync)
- {
- Fsync(name);
- }
+ // LUCENENET specific: Fsync breaks concurrency here.
+ // Part of a solution suggested by Vincent Van Den Berghe: http://apache.markmail.org/message/hafnuhq2ydhfjmi2
+ //foreach (var name in toSync)
+ //{
+ // Fsync(name);
+ //}
// fsync the directory itsself, but only if there was any file fsynced before
// (otherwise it can happen that the directory does not yet exist)!
@@ -487,6 +489,14 @@ namespace Lucene.Net.Store
//Debug.Assert(size == 0);
}
+ // LUCENENET specific - file.Flush(flushToDisk: true) required in .NET for concurrency
+ // Part of a solution suggested by Vincent Van Den Berghe: http://apache.markmail.org/message/hafnuhq2ydhfjmi2
+ public override void Flush()
+ {
+ base.Flush();
+ file.Flush(flushToDisk: true);
+ }
+
protected override void Dispose(bool disposing)
{
if (disposing)
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/c0e7a25c/src/Lucene.Net/Store/MMapDirectory.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net/Store/MMapDirectory.cs b/src/Lucene.Net/Store/MMapDirectory.cs
index 349b926..68eebf6 100644
--- a/src/Lucene.Net/Store/MMapDirectory.cs
+++ b/src/Lucene.Net/Store/MMapDirectory.cs
@@ -174,21 +174,7 @@ namespace Lucene.Net.Store
// indeed "release all resources".
public static readonly bool UNMAP_SUPPORTED = true;
- //static MMapDirectory()
- //{
- // bool v;
- // try
- // {
- // Type.GetType("sun.misc.Cleaner");
- // Type.GetType("java.nio.DirectByteBuffer").GetMethod("cleaner");
- // v = true;
- // }
- // catch (Exception)
- // {
- // v = false;
- // }
- // UNMAP_SUPPORTED = v;
- //}
+ // LUCENENET specific: No need for static constructor, since unmap is always supported
/// <summary>
/// This property enables the workaround for unmapping the buffers
@@ -235,7 +221,7 @@ namespace Lucene.Net.Store
EnsureOpen();
var file = new FileInfo(Path.Combine(Directory.FullName, name));
- var c = new FileStream(file.FullName, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite);
+ var c = new FileStream(file.FullName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
return new MMapIndexInput(this, "MMapIndexInput(path=\"" + file + "\")", c);
}
@@ -317,52 +303,14 @@ namespace Lucene.Net.Store
/// </summary>
protected override void FreeBuffer(ByteBuffer buffer)
{
- // .NET port: this should free the memory mapped view accessor
+ // LUCENENET specific: this should free the memory mapped view accessor
var mmfbb = buffer as MemoryMappedFileByteBuffer;
if (mmfbb != null)
mmfbb.Dispose();
- //if (UseUnmapHack)
- //{
- // try
- // {
- // AccessController.doPrivileged(new PrivilegedExceptionActionAnonymousInnerClassHelper(this, buffer));
- // }
- // catch (PrivilegedActionException e)
- // {
- // System.IO.IOException ioe = new System.IO.IOException("unable to unmap the mapped buffer");
- // ioe.initCause(e.InnerException);
- // throw ioe;
- // }
- //}
+ // LUCENENET specific: no need for UnmapHack
}
-
-
- //private class PrivilegedExceptionActionAnonymousInnerClassHelper : PrivilegedExceptionAction<Void>
- //{
- // private readonly MMapIndexInput OuterInstance;
-
- // private ByteBuffer Buffer;
-
- // public PrivilegedExceptionActionAnonymousInnerClassHelper(MMapIndexInput outerInstance, ByteBuffer buffer)
- // {
- // this.OuterInstance = outerInstance;
- // this.Buffer = buffer;
- // }
-
- // public override void Run()
- // {
- // Method getCleanerMethod = Buffer.GetType().GetMethod("cleaner");
- // getCleanerMethod.Accessible = true;
- // object cleaner = getCleanerMethod.invoke(Buffer);
- // if (cleaner != null)
- // {
- // cleaner.GetType().GetMethod("clean").invoke(cleaner);
- // }
- // //return null;
- // }
- //}
}
/// <summary>
@@ -372,6 +320,13 @@ namespace Lucene.Net.Store
if (Number.URShift(length, chunkSizePower) >= int.MaxValue)
throw new ArgumentException("RandomAccessFile too big for chunk size: " + fc.ToString());
+ // LUCENENET specific: Return empty buffer if length is 0, rather than attempting to create a MemoryMappedFile.
+ // Part of a solution provided by Vincent Van Den Berghe: http://apache.markmail.org/message/hafnuhq2ydhfjmi2
+ if (length == 0)
+ {
+ return new[] { ByteBuffer.Allocate(0).AsReadOnlyBuffer() };
+ }
+
long chunkSize = 1L << chunkSizePower;
// we always allocate one more buffer, the last one may be a 0 byte one
@@ -379,21 +334,18 @@ namespace Lucene.Net.Store
ByteBuffer[] buffers = new ByteBuffer[nrBuffers];
- /*
- public static MemoryMappedFile CreateFromFile(FileStream fileStream, String mapName, Int64 capacity,
- MemoryMappedFileAccess access, MemoryMappedFileSecurity memoryMappedFileSecurity,
- HandleInheritability inheritability, bool leaveOpen)
- */
-
- long fileCapacity = length == 0 ? ushort.MaxValue : length;
-
if (input.memoryMappedFile == null)
{
-#if NETSTANDARD
- input.memoryMappedFile = MemoryMappedFile.CreateFromFile(fc, null, fileCapacity, MemoryMappedFileAccess.ReadWrite, HandleInheritability.Inheritable, false);
-#else
- input.memoryMappedFile = MemoryMappedFile.CreateFromFile(fc, null, fileCapacity, MemoryMappedFileAccess.ReadWrite, null, HandleInheritability.Inheritable, false);
+ input.memoryMappedFile = MemoryMappedFile.CreateFromFile(
+ fileStream: fc,
+ mapName: null,
+ capacity: length,
+ access: MemoryMappedFileAccess.Read,
+#if !NETSTANDARD
+ memoryMappedFileSecurity: null,
#endif
+ inheritability: HandleInheritability.Inheritable,
+ leaveOpen: false);
}
long bufferStart = 0L;
@@ -401,16 +353,21 @@ namespace Lucene.Net.Store
{
int bufSize = (int)((length > (bufferStart + chunkSize)) ? chunkSize : (length - bufferStart));
- // LUCENENET: We get a file access exception if we create a 0 byte file at the end of the range.
- // We can fix this by moving back 1 byte if the bufSize is 0.
+ // LUCENENET: We get an UnauthorizedAccessException if we create a 0 byte file at the end of the range.
+ // See: https://stackoverflow.com/a/5501331
+ // We can fix this by moving back 1 byte on the offset if the bufSize is 0.
int adjust = 0;
if (bufSize == 0 && bufNr == (nrBuffers - 1) && (offset + bufferStart) > 0)
{
adjust = 1;
}
- //buffers[bufNr] = new MemoryMappedFileByteBuffer(input.memoryMappedFile.CreateViewAccessor((offset + bufferStart) - adjust, bufSize, MemoryMappedFileAccess.Read), -1, 0, bufSize, bufSize);
- buffers[bufNr] = new MemoryMappedFileByteBuffer(input.memoryMappedFile.CreateViewAccessor((offset + bufferStart) - adjust, bufSize, MemoryMappedFileAccess.Read), bufSize);
+ buffers[bufNr] = new MemoryMappedFileByteBuffer(
+ input.memoryMappedFile.CreateViewAccessor(
+ offset: (offset + bufferStart) - adjust,
+ size: bufSize,
+ access: MemoryMappedFileAccess.Read),
+ bufSize);
bufferStart += bufSize;
}
[5/9] lucenenet git commit: build\build.ps1: For now,
removing the lucene-cli and tests from the build (until a solution
can be found for restore, which isn't working)
Posted by ni...@apache.org.
build\build.ps1: For now, removing the lucene-cli and tests from the build (until a solution can be found for restore, which isn't working)
Project: http://git-wip-us.apache.org/repos/asf/lucenenet/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucenenet/commit/39441082
Tree: http://git-wip-us.apache.org/repos/asf/lucenenet/tree/39441082
Diff: http://git-wip-us.apache.org/repos/asf/lucenenet/diff/39441082
Branch: refs/heads/master
Commit: 3944108241a8046be74b926ff461dec39af92178
Parents: d6e8d69
Author: Shad Storhaug <sh...@shadstorhaug.com>
Authored: Fri Jul 14 00:11:13 2017 +0700
Committer: Shad Storhaug <sh...@shadstorhaug.com>
Committed: Fri Jul 14 00:11:13 2017 +0700
----------------------------------------------------------------------
build/build.ps1 | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/39441082/build/build.ps1
----------------------------------------------------------------------
diff --git a/build/build.ps1 b/build/build.ps1
index 578c216..565f6aa 100644
--- a/build/build.ps1
+++ b/build/build.ps1
@@ -113,7 +113,7 @@ task Restore -description "This task restores the dependencies" {
task Compile -depends Clean, Init -description "This task compiles the solution" {
try {
pushd $base_directory
- $projects = Get-ChildItem -Path "project.json" -Recurse
+ $projects = Get-ChildItem -Path "project.json" -Recurse | ? { !$_.Directory.Name.Contains(".Cli") -and !$_.Directory.Name.Contains("lucene-cli") }
popd
Backup-Files $projects
[7/9] lucenenet git commit: API: Added
ReferenceManager.AcquireContext(),
which is similar to ReferenceManager.Acquire() but can be used in a using
block to implicitly dereference instead of having to do it explicitly in a
finally block.
Posted by ni...@apache.org.
API: Added ReferenceManager<G>.AcquireContext(), which is similar to ReferenceManager<G>.Acquire() but can be used in a using block to implicitly dereference instead of having to do it explicitly in a finally block.
Project: http://git-wip-us.apache.org/repos/asf/lucenenet/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucenenet/commit/6f51ab54
Tree: http://git-wip-us.apache.org/repos/asf/lucenenet/tree/6f51ab54
Diff: http://git-wip-us.apache.org/repos/asf/lucenenet/diff/6f51ab54
Branch: refs/heads/master
Commit: 6f51ab547cd00f3280d69b37d17c86d45f587c00
Parents: 39e6316
Author: Shad Storhaug <sh...@shadstorhaug.com>
Authored: Thu May 11 13:44:46 2017 +0700
Committer: Shad Storhaug <sh...@shadstorhaug.com>
Committed: Fri Jul 14 01:15:57 2017 +0700
----------------------------------------------------------------------
src/Lucene.Net/Lucene.Net.csproj | 2 +
.../Support/Search/ReferenceContext.cs | 64 ++++++++++++++++++++
.../Search/ReferenceManagerExtensions.cs | 47 ++++++++++++++
3 files changed, 113 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/6f51ab54/src/Lucene.Net/Lucene.Net.csproj
----------------------------------------------------------------------
diff --git a/src/Lucene.Net/Lucene.Net.csproj b/src/Lucene.Net/Lucene.Net.csproj
index c0c02d3..ff96872 100644
--- a/src/Lucene.Net/Lucene.Net.csproj
+++ b/src/Lucene.Net/Lucene.Net.csproj
@@ -652,6 +652,8 @@
<Compile Include="Support\ICallable.cs" />
<Compile Include="Support\ICharSequence.cs" />
<Compile Include="Support\RectangularArrays.cs" />
+ <Compile Include="Support\Search\ReferenceContext.cs" />
+ <Compile Include="Support\Search\ReferenceManagerExtensions.cs" />
<Compile Include="Support\Threading\ICompletionService.cs" />
<Compile Include="Support\IO\IDataInput.cs" />
<Compile Include="Support\IO\IDataOutput.cs" />
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/6f51ab54/src/Lucene.Net/Support/Search/ReferenceContext.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net/Support/Search/ReferenceContext.cs b/src/Lucene.Net/Support/Search/ReferenceContext.cs
new file mode 100644
index 0000000..c72e3f4
--- /dev/null
+++ b/src/Lucene.Net/Support/Search/ReferenceContext.cs
@@ -0,0 +1,64 @@
+using System;
+
+namespace Lucene.Net.Search
+{
+ /*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+ /// <summary>
+ /// <see cref="ReferenceContext{T}"/> holds a reference instance and
+ /// ensures it is properly de-referenced from its corresponding <see cref="ReferenceManager{G}"/>
+ /// when <see cref="Dispose()"/> is called. This class is primarily intended
+ /// to be used with a using block.
+ /// <para/>
+ /// LUCENENET specific
+ /// </summary>
+ /// <typeparam name="T">The reference type</typeparam>
+ public class ReferenceContext<T> : IDisposable
+ where T : class
+ {
+ private readonly ReferenceManager<T> referenceManager;
+ private T reference;
+
+ internal ReferenceContext(ReferenceManager<T> referenceManager)
+ {
+ this.referenceManager = referenceManager;
+ this.reference = referenceManager.Acquire();
+ }
+
+ /// <summary>
+ /// The reference acquired from the <see cref="ReferenceManager{G}"/>.
+ /// </summary>
+ public T Reference
+ {
+ get { return reference; }
+ }
+
+ /// <summary>
+ /// Ensures the reference is properly de-referenced from its <see cref="ReferenceManager{G}"/>.
+ /// After this call, <see cref="Reference"/> will be <c>null</c>.
+ /// </summary>
+ public void Dispose()
+ {
+ if (this.reference != null)
+ {
+ this.referenceManager.Release(this.reference);
+ this.reference = null;
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/6f51ab54/src/Lucene.Net/Support/Search/ReferenceManagerExtensions.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net/Support/Search/ReferenceManagerExtensions.cs b/src/Lucene.Net/Support/Search/ReferenceManagerExtensions.cs
new file mode 100644
index 0000000..2629398
--- /dev/null
+++ b/src/Lucene.Net/Support/Search/ReferenceManagerExtensions.cs
@@ -0,0 +1,47 @@
+namespace Lucene.Net.Search
+{
+ /*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+ public static class ReferenceManagerExtensions
+ {
+ /// <summary>
+ /// Obtain the current reference.
+ /// <para/>
+ /// Like <see cref="ReferenceManager{G}.Acquire()"/>, but intended for use in a using
+ /// block so calling <see cref="ReferenceManager{G}.Release(G)"/> happens implicitly.
+ /// For example:
+ /// <para/>
+ /// <code>
+ /// var searcherManager = new SearcherManager(indexWriter, true, null);
+ /// using (var context = searcherManager.AcquireContext())
+ /// {
+ /// IndexSearcher searcher = context.Reference;
+ ///
+ /// // use searcher...
+ /// }
+ /// </code>
+ /// </summary>
+ /// <typeparam name="T">The reference type</typeparam>
+ /// <param name="referenceManager">this <see cref="ReferenceManager{G}"/></param>
+ /// <returns>A <see cref="ReferenceContext{T}"/> instance that holds the <see cref="ReferenceContext{T}.Reference"/> and ensures it is released properly when <see cref="ReferenceContext{T}.Dispose()"/> is called.</returns>
+ public static ReferenceContext<T> AcquireContext<T>(this ReferenceManager<T> referenceManager) where T : class
+ {
+ return new ReferenceContext<T>(referenceManager);
+ }
+ }
+}
[4/9] lucenenet git commit: Lucene.Net.Search.DocIdSet: Fixed broken
reference in doc comment
Posted by ni...@apache.org.
Lucene.Net.Search.DocIdSet: Fixed broken reference in doc comment
Project: http://git-wip-us.apache.org/repos/asf/lucenenet/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucenenet/commit/d6e8d698
Tree: http://git-wip-us.apache.org/repos/asf/lucenenet/tree/d6e8d698
Diff: http://git-wip-us.apache.org/repos/asf/lucenenet/diff/d6e8d698
Branch: refs/heads/master
Commit: d6e8d69899bfcf3d624d5680b609c7c799bf60f4
Parents: de62e95
Author: Shad Storhaug <sh...@shadstorhaug.com>
Authored: Fri Jul 14 00:10:15 2017 +0700
Committer: Shad Storhaug <sh...@shadstorhaug.com>
Committed: Fri Jul 14 00:10:15 2017 +0700
----------------------------------------------------------------------
src/Lucene.Net/Search/DocIdSet.cs | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/d6e8d698/src/Lucene.Net/Search/DocIdSet.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net/Search/DocIdSet.cs b/src/Lucene.Net/Search/DocIdSet.cs
index 8f0cc23..1de4b61 100644
--- a/src/Lucene.Net/Search/DocIdSet.cs
+++ b/src/Lucene.Net/Search/DocIdSet.cs
@@ -137,8 +137,8 @@ namespace Lucene.Net.Search
/// <summary>
/// Creates a new instance with the ability to specify the body of the <see cref="GetIterator()"/>
- /// method through the <paramref name="getIterator"/> parameter and the body of the <see cref="Bits"/>
- /// property through the <paramref name="bits"/> parameter.
+ /// method through the <paramref name="getIterator"/> parameter and the body of the <see cref="IsCacheable"/>
+ /// property through the <paramref name="isCacheable"/> parameter.
/// Simple example:
/// <code>
/// var docIdSet = DocIdSet.NewAnonymous(getIterator: () =>