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 2014/12/31 20:55:24 UTC
lucenenet git commit: Remove faulty ConcurrentList implementation
from Support classes
Repository: lucenenet
Updated Branches:
refs/heads/master 48c00dbd4 -> 7bcff5395
Remove faulty ConcurrentList implementation from Support classes
Project: http://git-wip-us.apache.org/repos/asf/lucenenet/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucenenet/commit/7bcff539
Tree: http://git-wip-us.apache.org/repos/asf/lucenenet/tree/7bcff539
Diff: http://git-wip-us.apache.org/repos/asf/lucenenet/diff/7bcff539
Branch: refs/heads/master
Commit: 7bcff5395bd241890b73903a0252631446f9b393
Parents: 48c00db
Author: Itamar Syn-Hershko <it...@code972.com>
Authored: Wed Dec 31 21:55:11 2014 +0200
Committer: Itamar Syn-Hershko <it...@code972.com>
Committed: Wed Dec 31 21:55:11 2014 +0200
----------------------------------------------------------------------
src/Lucene.Net.Core/Lucene.Net.csproj | 1 -
src/Lucene.Net.Core/Support/ConcurrentList.cs | 191 -------------------
.../ThreadedIndexingAndSearchingTestCase.cs | 5 +-
.../Lucene.Net.TestFramework.csproj | 1 +
src/Lucene.Net.Tests/Lucene.Net.Tests.csproj | 1 +
.../core/Index/TestDirectoryReaderReopen.cs | 2 +-
.../Index/TestDocumentsWriterStallControl.cs | 6 +-
.../core/Index/TestIndexWriterReader.cs | 10 +-
.../core/Search/TestLiveFieldValues.cs | 2 +-
.../core/Search/TestSortRandom.cs | 16 +-
10 files changed, 23 insertions(+), 212 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/7bcff539/src/Lucene.Net.Core/Lucene.Net.csproj
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Lucene.Net.csproj b/src/Lucene.Net.Core/Lucene.Net.csproj
index 844d8ce..fec1b4f 100644
--- a/src/Lucene.Net.Core/Lucene.Net.csproj
+++ b/src/Lucene.Net.Core/Lucene.Net.csproj
@@ -622,7 +622,6 @@
<Compile Include="Support\ConcurrentHashMap.cs" />
<Compile Include="Support\ConcurrentHashMapWrapper.cs" />
<Compile Include="Support\ConcurrentHashSet.cs" />
- <Compile Include="Support\ConcurrentList.cs" />
<Compile Include="Support\FileStreamExtensions.cs" />
<Compile Include="Support\HashCodeMerge.cs" />
<Compile Include="Support\ICallable.cs" />
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/7bcff539/src/Lucene.Net.Core/Support/ConcurrentList.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Support/ConcurrentList.cs b/src/Lucene.Net.Core/Support/ConcurrentList.cs
deleted file mode 100644
index ec51908..0000000
--- a/src/Lucene.Net.Core/Support/ConcurrentList.cs
+++ /dev/null
@@ -1,191 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Threading;
-
-namespace Lucene.Net.Support
-{
- public class ConcurrentList<T> : IList<T>
- {
- private IList<T> _list;
- private readonly ReaderWriterLockSlim _lock = new ReaderWriterLockSlim(LockRecursionPolicy.SupportsRecursion);
-
- public ConcurrentList(IEnumerable<T> enumerable)
- {
- _list = new List<T>(enumerable);
- }
-
- public void Add(T value)
- {
- _lock.EnterWriteLock();
- try
- {
- _list.Add(value);
- }
- finally
- {
- _lock.ExitWriteLock();
- }
- }
-
- public void Clear()
- {
- _lock.EnterWriteLock();
- try
- {
- _list.Clear();
- }
- finally
- {
- _lock.ExitWriteLock();
- }
- }
-
- public bool Contains(T value)
- {
- _lock.EnterReadLock();
- try
- {
- return _list.Contains(value);
- }
- finally
- {
- _lock.ExitReadLock();
- }
- }
-
- public int Count
- {
- get
- {
- _lock.EnterReadLock();
- try
- {
- return _list.Count;
- }
- finally
- {
- _lock.ExitReadLock();
- }
- }
- }
-
- public void CopyTo(T[] arr, int i)
- {
- _lock.EnterReadLock();
- try
- {
- _list.CopyTo(arr, i);
- }
- finally
- {
- _lock.ExitWriteLock();
- }
- }
-
- public bool IsReadOnly
- {
- get
- {
- _lock.EnterReadLock();
- try
- {
- return _list.IsReadOnly;
- }
- finally
- {
- _lock.ExitReadLock();
- }
- }
- }
-
- public bool Remove(T value)
- {
- _lock.EnterWriteLock();
- try
- {
- return _list.Remove(value);
- }
- finally
- {
- _lock.ExitWriteLock();
- }
- }
-
- public int IndexOf(T value)
- {
- _lock.EnterReadLock();
- try
- {
- return _list.IndexOf(value);
- }
- finally
- {
- _lock.ExitReadLock();
- }
- }
-
- public void Insert(int i, T value)
- {
- _lock.EnterWriteLock();
- try
- {
- _list.Insert(i, value);
- }
- finally
- {
- _lock.ExitWriteLock();
- }
- }
-
- public void RemoveAt(int i)
- {
- _lock.EnterWriteLock();
- try
- {
- _list.RemoveAt(i);
- }
- finally
- {
- _lock.ExitWriteLock();
- }
- }
-
- public T this[int i]
- {
- get
- {
- _lock.EnterReadLock();
- try
- {
- return _list[i];
- }
- finally
- {
- _lock.ExitReadLock();
- }
- }
- set
- {
- _lock.EnterWriteLock();
- try
- {
- _list[i] = value;
- }
- finally
- {
- _lock.ExitWriteLock();
- }
- }
- }
-
- System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
- {
- throw new NotSupportedException();
- }
-
- public IEnumerator<T> GetEnumerator()
- {
- throw new NotSupportedException();
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/7bcff539/src/Lucene.Net.TestFramework/Index/ThreadedIndexingAndSearchingTestCase.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.TestFramework/Index/ThreadedIndexingAndSearchingTestCase.cs b/src/Lucene.Net.TestFramework/Index/ThreadedIndexingAndSearchingTestCase.cs
index b21d8ce..f329dfd 100644
--- a/src/Lucene.Net.TestFramework/Index/ThreadedIndexingAndSearchingTestCase.cs
+++ b/src/Lucene.Net.TestFramework/Index/ThreadedIndexingAndSearchingTestCase.cs
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
+using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Lucene.Net.Documents;
@@ -601,7 +602,7 @@ namespace Lucene.Net.Index
ISet<string> delIDs = new ConcurrentHashSet<string>(new HashSet<string>());
ISet<string> delPackIDs = new ConcurrentHashSet<string>(new HashSet<string>());
- IList<SubDocs> allSubDocs = new ConcurrentList<SubDocs>(new List<SubDocs>());
+ IList<SubDocs> allSubDocs = new SynchronizedCollection<SubDocs>();
DateTime stopTime = DateTime.UtcNow.AddSeconds(RUN_TIME_SEC);
@@ -665,7 +666,7 @@ namespace Lucene.Net.Index
}
// Verify: make sure each group of sub-docs are still in docID order:
- foreach (SubDocs subDocs in allSubDocs)
+ foreach (SubDocs subDocs in allSubDocs.ToList())
{
TopDocs hits = s.Search(new TermQuery(new Term("packID", subDocs.PackID)), 20);
if (!subDocs.Deleted)
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/7bcff539/src/Lucene.Net.TestFramework/Lucene.Net.TestFramework.csproj
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.TestFramework/Lucene.Net.TestFramework.csproj b/src/Lucene.Net.TestFramework/Lucene.Net.TestFramework.csproj
index 7680987..d86aae8 100644
--- a/src/Lucene.Net.TestFramework/Lucene.Net.TestFramework.csproj
+++ b/src/Lucene.Net.TestFramework/Lucene.Net.TestFramework.csproj
@@ -58,6 +58,7 @@
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Numerics" />
+ <Reference Include="System.ServiceModel" />
</ItemGroup>
<ItemGroup>
<Compile Include="Analysis\BaseTokenStreamTestCase.cs">
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/7bcff539/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 da4ef05..6be5a97 100644
--- a/src/Lucene.Net.Tests/Lucene.Net.Tests.csproj
+++ b/src/Lucene.Net.Tests/Lucene.Net.Tests.csproj
@@ -56,6 +56,7 @@
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Management" />
<Reference Include="System.Numerics" />
+ <Reference Include="System.ServiceModel" />
<Reference Include="System.Xml" />
<Reference Include="System.Xml.Linq" />
</ItemGroup>
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/7bcff539/src/Lucene.Net.Tests/core/Index/TestDirectoryReaderReopen.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/core/Index/TestDirectoryReaderReopen.cs b/src/Lucene.Net.Tests/core/Index/TestDirectoryReaderReopen.cs
index 524047b..5a21c47 100644
--- a/src/Lucene.Net.Tests/core/Index/TestDirectoryReaderReopen.cs
+++ b/src/Lucene.Net.Tests/core/Index/TestDirectoryReaderReopen.cs
@@ -247,7 +247,7 @@ namespace Lucene.Net.Index
TestReopen test = new TestReopenAnonymousInnerClassHelper3(this, dir, n);
- IList<ReaderCouple> readers = new ConcurrentList<ReaderCouple>(new List<ReaderCouple>());
+ IList<ReaderCouple> readers = new SynchronizedCollection<ReaderCouple>();
DirectoryReader firstReader = DirectoryReader.Open(dir);
DirectoryReader reader = firstReader;
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/7bcff539/src/Lucene.Net.Tests/core/Index/TestDocumentsWriterStallControl.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/core/Index/TestDocumentsWriterStallControl.cs b/src/Lucene.Net.Tests/core/Index/TestDocumentsWriterStallControl.cs
index d735ac6..2fc66be 100644
--- a/src/Lucene.Net.Tests/core/Index/TestDocumentsWriterStallControl.cs
+++ b/src/Lucene.Net.Tests/core/Index/TestDocumentsWriterStallControl.cs
@@ -131,9 +131,9 @@ namespace Lucene.Net.Index
int numStallers = AtLeast(1);
int numReleasers = AtLeast(1);
int numWaiters = AtLeast(1);
- Synchronizer sync = new Synchronizer(numStallers + numReleasers, numStallers + numReleasers + numWaiters);
- ThreadClass[] threads = new ThreadClass[numReleasers + numStallers + numWaiters];
- IList<Exception> exceptions = new ConcurrentList<Exception>(new List<Exception>());
+ var sync = new Synchronizer(numStallers + numReleasers, numStallers + numReleasers + numWaiters);
+ var threads = new ThreadClass[numReleasers + numStallers + numWaiters];
+ IList<Exception> exceptions = new SynchronizedCollection<Exception>();
for (int i = 0; i < numReleasers; i++)
{
threads[i] = new Updater(stop, checkPoint, ctrl, sync, true, exceptions);
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/7bcff539/src/Lucene.Net.Tests/core/Index/TestIndexWriterReader.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/core/Index/TestIndexWriterReader.cs b/src/Lucene.Net.Tests/core/Index/TestIndexWriterReader.cs
index 709b129..70e7cd6 100644
--- a/src/Lucene.Net.Tests/core/Index/TestIndexWriterReader.cs
+++ b/src/Lucene.Net.Tests/core/Index/TestIndexWriterReader.cs
@@ -864,11 +864,11 @@ namespace Lucene.Net.Index
const float SECONDS = 0.5f;
long endTime = (long)(DateTime.Now.Millisecond + 1000.0 * SECONDS);
- IList<Exception> excs = new ConcurrentList<Exception>(new List<Exception>());
+ IList<Exception> excs = new SynchronizedCollection<Exception>();
// Only one thread can addIndexes at a time, because
// IndexWriter acquires a write lock in each directory:
- ThreadClass[] threads = new ThreadClass[1];
+ var threads = new ThreadClass[1];
for (int i = 0; i < threads.Length; i++)
{
threads[i] = new ThreadAnonymousInnerClassHelper(this, writer, dirs, endTime, excs);
@@ -971,7 +971,7 @@ namespace Lucene.Net.Index
public virtual void TestDuringAddDelete()
{
Directory dir1 = NewDirectory();
- IndexWriter writer = new IndexWriter(dir1, NewIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(Random())).SetMergePolicy(NewLogMergePolicy(2)));
+ var writer = new IndexWriter(dir1, NewIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(Random())).SetMergePolicy(NewLogMergePolicy(2)));
// create the index
CreateIndexNoClose(false, "test", writer);
@@ -982,9 +982,9 @@ namespace Lucene.Net.Index
const float SECONDS = 0.5f;
long endTime = (long)(DateTime.Now.Millisecond + 1000.0 * SECONDS);
- IList<Exception> excs = new ConcurrentList<Exception>(new List<Exception>());
+ IList<Exception> excs = new SynchronizedCollection<Exception>();
- ThreadClass[] threads = new ThreadClass[NumThreads];
+ var threads = new ThreadClass[NumThreads];
for (int i = 0; i < NumThreads; i++)
{
threads[i] = new ThreadAnonymousInnerClassHelper2(this, writer, r, endTime, excs);
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/7bcff539/src/Lucene.Net.Tests/core/Search/TestLiveFieldValues.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/core/Search/TestLiveFieldValues.cs b/src/Lucene.Net.Tests/core/Search/TestLiveFieldValues.cs
index 6abc4e2..b0b6e0d 100644
--- a/src/Lucene.Net.Tests/core/Search/TestLiveFieldValues.cs
+++ b/src/Lucene.Net.Tests/core/Search/TestLiveFieldValues.cs
@@ -179,7 +179,7 @@ namespace Lucene.Net.Search
try
{
IDictionary<string, int?> values = new Dictionary<string, int?>();
- IList<string> allIDs = new ConcurrentList<string>(new List<string>());
+ IList<string> allIDs = new SynchronizedCollection<string>();
StartingGun.@await();
for (int iter = 0; iter < Iters; iter++)
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/7bcff539/src/Lucene.Net.Tests/core/Search/TestSortRandom.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/core/Search/TestSortRandom.cs b/src/Lucene.Net.Tests/core/Search/TestSortRandom.cs
index 37c24cd..f48e716 100644
--- a/src/Lucene.Net.Tests/core/Search/TestSortRandom.cs
+++ b/src/Lucene.Net.Tests/core/Search/TestSortRandom.cs
@@ -216,13 +216,13 @@ namespace Lucene.Net.Search
}
// Compute expected results:
- ((List<BytesRef>)f.MatchValues).Sort(new ComparatorAnonymousInnerClassHelper(this, sortMissingLast));
-
+ var expected = f.MatchValues.ToList();
+ expected.Sort(new ComparatorAnonymousInnerClassHelper(this, sortMissingLast));
if (reverse)
{
- f.MatchValues.Reverse();
+ expected.Reverse();
}
- IList<BytesRef> expected = f.MatchValues;
+
if (VERBOSE)
{
Console.WriteLine(" expected:");
@@ -330,10 +330,10 @@ namespace Lucene.Net.Search
private class RandomFilter : Filter
{
- internal readonly Random Random;
- internal float Density;
- internal readonly IList<BytesRef> DocValues;
- public readonly IList<BytesRef> MatchValues = new ConcurrentList<BytesRef>(new List<BytesRef>());
+ private readonly Random Random;
+ private readonly float Density;
+ private readonly IList<BytesRef> DocValues;
+ public readonly IList<BytesRef> MatchValues = new SynchronizedCollection<BytesRef>();
// density should be 0.0 ... 1.0
public RandomFilter(Random random, float density, IList<BytesRef> docValues)