You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucenenet.apache.org by sy...@apache.org on 2015/05/02 19:37:23 UTC
[1/3] lucenenet git commit: open with read/write sharing instead of
read
Repository: lucenenet
Updated Branches:
refs/heads/master 27be98ab3 -> ef7a7ad88
open with read/write sharing instead of read
Project: http://git-wip-us.apache.org/repos/asf/lucenenet/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucenenet/commit/19f506cd
Tree: http://git-wip-us.apache.org/repos/asf/lucenenet/tree/19f506cd
Diff: http://git-wip-us.apache.org/repos/asf/lucenenet/diff/19f506cd
Branch: refs/heads/master
Commit: 19f506cd6a2fe4c84f4b1df2d51e48e24757c11c
Parents: 27be98a
Author: Laimonas Simutis <la...@gmail.com>
Authored: Fri May 1 20:28:28 2015 -0400
Committer: Laimonas Simutis <la...@gmail.com>
Committed: Fri May 1 20:28:28 2015 -0400
----------------------------------------------------------------------
src/Lucene.Net.Core/Store/FSDirectory.cs | 2 +-
src/Lucene.Net.Core/Store/SimpleFSDirectory.cs | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/19f506cd/src/Lucene.Net.Core/Store/FSDirectory.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Store/FSDirectory.cs b/src/Lucene.Net.Core/Store/FSDirectory.cs
index 660cc4e..1a60cdf 100644
--- a/src/Lucene.Net.Core/Store/FSDirectory.cs
+++ b/src/Lucene.Net.Core/Store/FSDirectory.cs
@@ -477,7 +477,7 @@ namespace Lucene.Net.Store
{
this.Parent = parent;
this.Name = name;
- File = new FileStream(Path.Combine(parent.directory.FullName, name), FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.Read);
+ File = new FileStream(Path.Combine(parent.directory.FullName, name), FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite);
IsOpen = true;
}
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/19f506cd/src/Lucene.Net.Core/Store/SimpleFSDirectory.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Store/SimpleFSDirectory.cs b/src/Lucene.Net.Core/Store/SimpleFSDirectory.cs
index 186913d..e18a3bd 100644
--- a/src/Lucene.Net.Core/Store/SimpleFSDirectory.cs
+++ b/src/Lucene.Net.Core/Store/SimpleFSDirectory.cs
@@ -59,7 +59,7 @@ namespace Lucene.Net.Store
{
EnsureOpen();
var path = new FileInfo(Path.Combine(Directory.FullName, name));
- var raf = new FileStream(path.FullName, FileMode.Open, FileAccess.Read, FileShare.Read);
+ var raf = new FileStream(path.FullName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
return new SimpleFSIndexInput("SimpleFSIndexInput(path=\"" + path.FullName + "\")", raf, context);
}
@@ -67,7 +67,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.Read);
+ var descriptor = new FileStream(file.FullName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
return new IndexInputSlicerAnonymousInnerClassHelper(this, context, file, descriptor);
}
[3/3] lucenenet git commit: use appropriate filestream share mode
Posted by sy...@apache.org.
use appropriate filestream share mode
Project: http://git-wip-us.apache.org/repos/asf/lucenenet/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucenenet/commit/ef7a7ad8
Tree: http://git-wip-us.apache.org/repos/asf/lucenenet/tree/ef7a7ad8
Diff: http://git-wip-us.apache.org/repos/asf/lucenenet/diff/ef7a7ad8
Branch: refs/heads/master
Commit: ef7a7ad88668ef87a880aed2d1f9e4bff6ccae21
Parents: ff6f242
Author: Laimonas Simutis <la...@gmail.com>
Authored: Fri May 1 21:26:14 2015 -0400
Committer: Laimonas Simutis <la...@gmail.com>
Committed: Fri May 1 21:26:14 2015 -0400
----------------------------------------------------------------------
src/Lucene.Net.Core/Store/MMapDirectory.cs | 18 ++++++------------
src/Lucene.Net.Core/Store/NIOFSDirectory.cs | 4 ++--
2 files changed, 8 insertions(+), 14 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/ef7a7ad8/src/Lucene.Net.Core/Store/MMapDirectory.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Store/MMapDirectory.cs b/src/Lucene.Net.Core/Store/MMapDirectory.cs
index 2e2d8ab..b59ad88 100644
--- a/src/Lucene.Net.Core/Store/MMapDirectory.cs
+++ b/src/Lucene.Net.Core/Store/MMapDirectory.cs
@@ -198,23 +198,17 @@ namespace Lucene.Net.Store
public override IndexInput OpenInput(string name, IOContext context)
{
EnsureOpen();
- FileInfo file = new FileInfo(Path.Combine(Directory.FullName, name));
+ var file = new FileInfo(Path.Combine(Directory.FullName, name));
- FileStream c = new FileStream(file.FullName, FileMode.Open, FileAccess.Read, FileShare.Read);
+ var c = new FileStream(file.FullName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite | FileShare.Delete);
- return new MMapIndexInput(this, "MMapIndexInput(path=\"" + file.ToString() + "\")", c);
+ return new MMapIndexInput(this, "MMapIndexInput(path=\"" + file + "\")", c);
}
public override IndexInputSlicer CreateSlicer(string name, IOContext context)
{
- EnsureOpen();
- FileInfo file = new FileInfo(Path.Combine(Directory.FullName, name));
-
- FileStream c = new FileStream(file.FullName, FileMode.Open, FileAccess.Read, FileShare.Read);
-
- var full = new MMapIndexInput(this, "MMapIndexInputSlicer(path=\"" + file.ToString() + "\")", c);
+ var full = (MMapIndexInput)OpenInput(name, context);
- //MMapIndexInput full = (MMapIndexInput)OpenInput(name, context);
return new IndexInputSlicerAnonymousInnerClassHelper(this, full);
}
@@ -222,9 +216,9 @@ namespace Lucene.Net.Store
{
private readonly MMapDirectory OuterInstance;
- private Lucene.Net.Store.MMapDirectory.MMapIndexInput Full;
+ private MMapIndexInput Full;
- public IndexInputSlicerAnonymousInnerClassHelper(MMapDirectory outerInstance, Lucene.Net.Store.MMapDirectory.MMapIndexInput full)
+ public IndexInputSlicerAnonymousInnerClassHelper(MMapDirectory outerInstance, MMapIndexInput full)
: base(outerInstance)
{
this.OuterInstance = outerInstance;
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/ef7a7ad8/src/Lucene.Net.Core/Store/NIOFSDirectory.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Store/NIOFSDirectory.cs b/src/Lucene.Net.Core/Store/NIOFSDirectory.cs
index 682c8a8..42fa5e6 100644
--- a/src/Lucene.Net.Core/Store/NIOFSDirectory.cs
+++ b/src/Lucene.Net.Core/Store/NIOFSDirectory.cs
@@ -80,7 +80,7 @@ namespace Lucene.Net.Store
//File path = new File(Directory, name);
FileInfo path = new FileInfo(Path.Combine(Directory.FullName, name));
//path.Create();
- FileStream fc = new FileStream(path.FullName, FileMode.Open, FileAccess.Read, FileShare.Read);//FileChannel.open(path.toPath(), StandardOpenOption.READ);
+ FileStream fc = new FileStream(path.FullName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite | FileShare.Delete);//FileChannel.open(path.toPath(), StandardOpenOption.READ);
return new NIOFSIndexInput("NIOFSIndexInput(path=\"" + path + "\")", fc, context);
//return new NIOFSIndexInput(new FileInfo(Path.Combine(Directory.FullName, name)), context, ReadChunkSize);
}
@@ -91,7 +91,7 @@ namespace Lucene.Net.Store
//File path = new File(Directory, name);
//FileStream descriptor = FileChannel.open(path.toPath(), StandardOpenOption.READ);
FileInfo path = new FileInfo(Path.Combine(Directory.FullName, name));
- FileStream fc = new FileStream(path.FullName, FileMode.Open, FileAccess.Read, FileShare.Read);
+ FileStream fc = new FileStream(path.FullName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite | FileShare.Delete);
return new IndexInputSlicerAnonymousInnerClassHelper(this, context, path, fc);
}
[2/3] lucenenet git commit: put back the test to match what Lucene is
doing
Posted by sy...@apache.org.
put back the test to match what Lucene is doing
Project: http://git-wip-us.apache.org/repos/asf/lucenenet/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucenenet/commit/ff6f2426
Tree: http://git-wip-us.apache.org/repos/asf/lucenenet/tree/ff6f2426
Diff: http://git-wip-us.apache.org/repos/asf/lucenenet/diff/ff6f2426
Branch: refs/heads/master
Commit: ff6f2426cb96a74f5573350ee0e1b56bcc9dbcd9
Parents: 19f506c
Author: Laimonas Simutis <la...@gmail.com>
Authored: Fri May 1 20:30:59 2015 -0400
Committer: Laimonas Simutis <la...@gmail.com>
Committed: Fri May 1 20:30:59 2015 -0400
----------------------------------------------------------------------
.../core/Store/TestBufferedIndexInput.cs | 98 +++++++++++---------
1 file changed, 52 insertions(+), 46 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/ff6f2426/src/Lucene.Net.Tests/core/Store/TestBufferedIndexInput.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/core/Store/TestBufferedIndexInput.cs b/src/Lucene.Net.Tests/core/Store/TestBufferedIndexInput.cs
index 731bcc5..86335f0 100644
--- a/src/Lucene.Net.Tests/core/Store/TestBufferedIndexInput.cs
+++ b/src/Lucene.Net.Tests/core/Store/TestBufferedIndexInput.cs
@@ -269,55 +269,61 @@ namespace Lucene.Net.Store
public virtual void TestSetBufferSize()
{
var indexDir = CreateTempDir("testSetBufferSize");
- using (var dir = new MockFSDirectory(indexDir, Random()))
+ var dir = new MockFSDirectory(indexDir, Random());
+ try
{
- using (var writer = new IndexWriter(dir,
- (new IndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(Random()))).SetOpenMode(
- IndexWriterConfig.OpenMode_e.CREATE).SetMergePolicy(NewLogMergePolicy(false))))
+ var writer = new IndexWriter(
+ dir,
+ new IndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(Random()))
+ .SetOpenMode(IndexWriterConfig.OpenMode_e.CREATE)
+ .SetMergePolicy(NewLogMergePolicy(false)));
+
+ for (int i = 0; i < 37; i++)
{
- for (int i = 0; i < 37; i++)
- {
- var doc = new Document();
- doc.Add(NewTextField("content", "aaa bbb ccc ddd" + i, Field.Store.YES));
- doc.Add(NewTextField("id", "" + i, Field.Store.YES));
- writer.AddDocument(doc);
- }
-
- dir.AllIndexInputs.Clear();
- dir.TweakBufferSizes();
- writer.DeleteDocuments(new Term("id", "0"));
-
- var aaa = new Term("content", "aaa");
- var bbb = new Term("content", "bbb");
-
- IndexSearcher searcher;
- ScoreDoc[] hits;
- using (var reader = DirectoryReader.Open(writer, true))
- {
- searcher = NewSearcher(reader);
- hits = searcher.Search(new TermQuery(bbb), null, 1000).ScoreDocs;
- dir.TweakBufferSizes();
- Assert.AreEqual(36, hits.Length);
- }
-
- dir.TweakBufferSizes();
- writer.DeleteDocuments(new Term("id", "4"));
- using (var reader = DirectoryReader.Open(writer, true))
- {
- searcher = NewSearcher(reader);
-
- hits = searcher.Search(new TermQuery(bbb), null, 1000).ScoreDocs;
- dir.TweakBufferSizes();
- Assert.AreEqual(35, hits.Length);
- dir.TweakBufferSizes();
- hits = searcher.Search(new TermQuery(new Term("id", "33")), null, 1000).ScoreDocs;
- dir.TweakBufferSizes();
- Assert.AreEqual(1, hits.Length);
- hits = searcher.Search(new TermQuery(aaa), null, 1000).ScoreDocs;
- dir.TweakBufferSizes();
- Assert.AreEqual(35, hits.Length);
- }
+ var doc = new Document();
+ doc.Add(NewTextField("content", "aaa bbb ccc ddd" + i, Field.Store.YES));
+ doc.Add(NewTextField("id", "" + i, Field.Store.YES));
+ writer.AddDocument(doc);
}
+
+ dir.AllIndexInputs.Clear();
+
+ IndexReader reader = DirectoryReader.Open(writer, true);
+ var aaa = new Term("content", "aaa");
+ var bbb = new Term("content", "bbb");
+ reader.Dispose();
+
+ dir.TweakBufferSizes();
+ writer.DeleteDocuments(new Term("id", "0"));
+ reader = DirectoryReader.Open(writer, true);
+ var searcher = NewSearcher(reader);
+ var hits = searcher.Search(new TermQuery(bbb), null, 1000).ScoreDocs;
+ dir.TweakBufferSizes();
+ Assert.AreEqual(36, hits.Length);
+
+ reader.Dispose();
+
+ dir.TweakBufferSizes();
+ writer.DeleteDocuments(new Term("id", "4"));
+ reader = DirectoryReader.Open(writer, true);
+ searcher = NewSearcher(reader);
+
+ hits = searcher.Search(new TermQuery(bbb), null, 1000).ScoreDocs;
+ dir.TweakBufferSizes();
+ Assert.AreEqual(35, hits.Length);
+ dir.TweakBufferSizes();
+ hits = searcher.Search(new TermQuery(new Term("id", "33")), null, 1000).ScoreDocs;
+ dir.TweakBufferSizes();
+ Assert.AreEqual(1, hits.Length);
+ hits = searcher.Search(new TermQuery(aaa), null, 1000).ScoreDocs;
+ dir.TweakBufferSizes();
+ Assert.AreEqual(35, hits.Length);
+ writer.Dispose();
+ reader.Dispose();
+ }
+ finally
+ {
+ indexDir.Delete(true);
}
}