Skip to content
Browse files

Added signed version of Lucene.Net compiled for .NET 1.1

NHibernate.Search ported to .NET 1.1, compiles but can't compile/run tests due to strange compiler/VS errors
Code passes tests under .NET 2.0.

SVN: branches/1.2.x@3143
  • Loading branch information...
1 parent 1233902 commit 4220ddace3ad981558ee8a17c6ba6c4dd14d9935 @phatcher phatcher committed
Showing with 7,404 additions and 98 deletions.
  1. BIN lib/net/1.1/Lucene.Net.dll
  2. BIN lib/net/1.1/Lucene.Net.pdb
  3. +6,740 −0 lib/net/1.1/Lucene.Net.xml
  4. +19 −0 src/NHibernate.Everything-1.1.sln
  5. +29 −21 src/NHibernate.Search.Tests/Bridge/Cloud.cs
  6. +4 −0 src/NHibernate.Search.Tests/Bridge/TruncateFieldBridge.cs
  7. +4 −0 src/NHibernate.Search.Tests/DirectoryProvider/FSSlaveAndMasterDPTest.cs
  8. +19 −0 src/NHibernate.Search.Tests/DirectoryProvider/MultiplySessionFactoriesTestCase.cs
  9. +2 −0 src/NHibernate.Search.Tests/FileHleperTestCase.cs
  10. +5 −5 src/NHibernate.Search.Tests/NHibernate.Search.Tests-2.0.csproj
  11. +1 −1 src/NHibernate.Search/AttributeUtil.cs
  12. +0 −1 src/NHibernate.Search/Attributes/Indexed.cs
  13. +0 −1 src/NHibernate.Search/Attributes/IndexedEmbedded.cs
  14. +11 −0 src/NHibernate.Search/Backend/IBackendQueueProcessorFactory.cs
  15. +18 −0 src/NHibernate.Search/Backend/IQueueingProcessor.cs
  16. +18 −1 src/NHibernate.Search/Backend/Impl/BatchedQueueingProcessor.cs
  17. +30 −2 src/NHibernate.Search/Backend/Impl/Lucene/LuceneBackendQueueProcessor.cs
  18. +10 −0 src/NHibernate.Search/Backend/Impl/Lucene/LuceneBackendQueueProcessorFactory.cs
  19. +0 −1 src/NHibernate.Search/Backend/OptimizeLuceneWork.cs
  20. +0 −1 src/NHibernate.Search/Backend/PurgeAllLuceneWork.cs
  21. +28 −3 src/NHibernate.Search/Backend/Workspace.cs
  22. +30 −10 src/NHibernate.Search/Bridge/BridgeFactory.cs
  23. +22 −0 src/NHibernate.Search/Bridge/Builtin/BoolBridge.cs
  24. +22 −0 src/NHibernate.Search/Bridge/Builtin/DoubleBridge.cs
  25. +22 −0 src/NHibernate.Search/Bridge/Builtin/FloatBridge.cs
  26. +22 −0 src/NHibernate.Search/Bridge/Builtin/IntBridge.cs
  27. +22 −0 src/NHibernate.Search/Bridge/Builtin/LongBridge.cs
  28. +22 −0 src/NHibernate.Search/Bridge/Builtin/ShortBridge.cs
  29. +5 −1 src/NHibernate.Search/Bridge/IFieldBridge.cs
  30. +6 −1 src/NHibernate.Search/Bridge/ITwoWayFieldBridge.cs
  31. +7 −2 src/NHibernate.Search/Bridge/String2FieldBridgeAdaptor.cs
  32. +4 −0 src/NHibernate.Search/Bridge/TwoWayString2FieldBridgeAdaptor.cs
  33. +16 −1 src/NHibernate.Search/DirectoryProviderHelper.cs
  34. +103 −22 src/NHibernate.Search/Engine/DocumentBuilder.cs
  35. +16 −4 src/NHibernate.Search/Engine/SearchFactory.cs
  36. +4 −0 src/NHibernate.Search/IFullTextSession.cs
  37. +6 −0 src/NHibernate.Search/Impl/FullTextSessionImpl.cs
  38. +16 −5 src/NHibernate.Search/Impl/SearchInterceptor.cs
  39. +14 −2 src/NHibernate.Search/LuceneQueryExpression.cs
  40. +15 −3 src/NHibernate.Search/Query/FullTextQueryImpl.cs
  41. +34 −2 src/NHibernate.Search/Query/FullTextSearchHelper.cs
  42. +11 −2 src/NHibernate.Search/Store/DirectoryProviderFactory.cs
  43. +12 −0 src/NHibernate.Search/Store/FSMasterDirectoryProvider.cs
  44. +20 −1 src/NHibernate.Search/Store/FSSlaveDirectoryProvider.cs
  45. +11 −1 src/NHibernate.Search/Store/FileHelper.cs
  46. +4 −4 src/NHibernate.Test.Performance/NHibernate.Test.Performance-1.1.csproj
View
BIN lib/net/1.1/Lucene.Net.dll
Binary file not shown.
View
BIN lib/net/1.1/Lucene.Net.pdb
Binary file not shown.
View
6,740 lib/net/1.1/Lucene.Net.xml
6,740 additions, 0 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
View
19 src/NHibernate.Everything-1.1.sln
@@ -95,11 +95,22 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NHibernate.Caches.MemCache.
ProjectSection(ProjectDependencies) = postProject
EndProjectSection
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NHibernate.Search-1.1", "NHibernate.Search\NHibernate.Search-1.1.csproj", "{F6CDD71A-FDCA-43F1-A5FF-B2941224A66F}"
+ ProjectSection(ProjectDependencies) = postProject
+ EndProjectSection
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NHibernate.Search.Tests-1.1", "NHibernate.Search.Tests\NHibernate.Search.Tests-1.1.csproj", "{F6CDD71A-FDCA-43F1-A5FF-B2941224A66F}"
+ ProjectSection(ProjectDependencies) = postProject
+ {F6CDD71A-FDCA-43F1-A5FF-B2941224A66F} = {F6CDD71A-FDCA-43F1-A5FF-B2941224A66F}
+ EndProjectSection
+EndProject
Global
GlobalSection(SolutionConfiguration) = preSolution
Debug = Debug
Release = Release
EndGlobalSection
+ GlobalSection(ProjectDependencies) = postSolution
+ EndGlobalSection
GlobalSection(ProjectConfiguration) = postSolution
{0D8B57B0-1310-4EF0-B50C-DD22F37310C7}.Debug.ActiveCfg = Debug|.NET
{0D8B57B0-1310-4EF0-B50C-DD22F37310C7}.Debug.Build.0 = Debug|.NET
@@ -197,6 +208,14 @@ Global
{94E1F299-E404-4DDE-BFCE-A3E4F5AD3D41}.Debug.Build.0 = Debug|.NET
{94E1F299-E404-4DDE-BFCE-A3E4F5AD3D41}.Release.ActiveCfg = Release|.NET
{94E1F299-E404-4DDE-BFCE-A3E4F5AD3D41}.Release.Build.0 = Release|.NET
+ {F6CDD71A-FDCA-43F1-A5FF-B2941224A66F}.Debug.ActiveCfg = Debug|.NET
+ {F6CDD71A-FDCA-43F1-A5FF-B2941224A66F}.Debug.Build.0 = Debug|.NET
+ {F6CDD71A-FDCA-43F1-A5FF-B2941224A66F}.Release.ActiveCfg = Release|.NET
+ {F6CDD71A-FDCA-43F1-A5FF-B2941224A66F}.Release.Build.0 = Release|.NET
+ {F6CDD71A-FDCA-43F1-A5FF-B2941224A66F}.Debug.ActiveCfg = Debug|.NET
+ {F6CDD71A-FDCA-43F1-A5FF-B2941224A66F}.Debug.Build.0 = Debug|.NET
+ {F6CDD71A-FDCA-43F1-A5FF-B2941224A66F}.Release.ActiveCfg = Release|.NET
+ {F6CDD71A-FDCA-43F1-A5FF-B2941224A66F}.Release.Build.0 = Release|.NET
EndGlobalSection
GlobalSection(SolutionItems) = postSolution
..\NHibernateSolution.build = ..\NHibernateSolution.build
View
50 src/NHibernate.Search.Tests/Bridge/Cloud.cs
@@ -7,15 +7,18 @@ namespace NHibernate.Search.Tests.Bridge
public class Cloud
{
private int id;
+#if NET_2_0
private long? long1;
- private long long2;
private int? int1;
- private int int2;
private double? double1;
- private double double2;
private float? float1;
+#endif
+ private long long2;
+ private double double2;
private float float2;
+ private int int2;
private string string1;
+#if NET_2_0
private DateTime? dateTime;
private DateTime? dateTimeYear;
private DateTime? dateTimeMonth;
@@ -24,6 +27,7 @@ public class Cloud
private DateTime? dateTimeMinute;
private DateTime? dateTimeSecond;
private DateTime? dateTimeMillisecond;
+#endif
private String customFieldBridge;
private String customStringBridge;
private CloudType type;
@@ -52,6 +56,7 @@ public virtual int Id
set { this.id = value; }
}
+#if NET_2_0
[Field(Index.UnTokenized, Store = Store.Yes)]
public virtual long? Long1
{
@@ -60,45 +65,46 @@ public virtual int Id
}
[Field(Index.UnTokenized, Store = Store.Yes)]
- public virtual long Long2
+ public virtual int? Int1
{
- get { return long2; }
- set { this.long2 = value; }
+ get { return int1; }
+ set { this.int1 = value; }
}
[Field(Index.UnTokenized, Store = Store.Yes)]
- public virtual int? Int1
+ public virtual double? Double1
{
- get { return int1; }
- set { this.int1 = value; }
+ get { return double1; }
+ set { this.double1 = value; }
}
[Field(Index.UnTokenized, Store = Store.Yes)]
- public virtual int Int2
+ public virtual float? Float1
{
- get { return int2; }
- set { this.int2 = value; }
+ get { return float1; }
+ set { this.float1 = value; }
}
+#endif
[Field(Index.UnTokenized, Store = Store.Yes)]
- public virtual double? Double1
+ public virtual long Long2
{
- get { return double1; }
- set { this.double1 = value; }
+ get { return long2; }
+ set { this.long2 = value; }
}
[Field(Index.UnTokenized, Store = Store.Yes)]
- public virtual double Double2
+ public virtual int Int2
{
- get { return double2; }
- set { this.double2 = value; }
+ get { return int2; }
+ set { this.int2 = value; }
}
[Field(Index.UnTokenized, Store = Store.Yes)]
- public virtual float? Float1
+ public virtual double Double2
{
- get { return float1; }
- set { this.float1 = value; }
+ get { return double2; }
+ set { this.double2 = value; }
}
[Field(Index.UnTokenized, Store = Store.Yes)]
@@ -115,6 +121,7 @@ public virtual string String1
set { this.string1 = value; }
}
+#if NET_2_0
[Field(Index.UnTokenized, Store = Store.Yes)]
public virtual DateTime? DateTime
{
@@ -183,6 +190,7 @@ public virtual string String1
get { return dateTimeMillisecond; }
set { this.dateTimeMillisecond = value; }
}
+#endif
[Field(Index.Tokenized)]
public virtual CloudType Type
View
4 src/NHibernate.Search.Tests/Bridge/TruncateFieldBridge.cs
@@ -14,7 +14,11 @@ public Object Get(String name, Document document)
return field.StringValue();
}
+#if NET_2_0
public void Set(String name, Object value, Document document, Field.Store store, Field.Index index, float? boost)
+#else
+ public void Set(String name, Object value, Document document, Field.Store store, Field.Index index, float boost)
+#endif
{
String indexedString = (String) value;
//Do not add fields on empty strings, seems a sensible default in most situations
View
4 src/NHibernate.Search.Tests/DirectoryProvider/FSSlaveAndMasterDPTest.cs
@@ -106,7 +106,11 @@ protected void TearDown()
Directory.Delete("./lucenedirs/",true);
}
+#if NET_2_0
protected override void Configure(IList<Configuration> cfg)
+#else
+ protected override void Configure(IList cfg)
+#endif
{
//master
cfg[0].SetProperty("hibernate.search.default.sourceBase", "./lucenedirs/master/copy");
View
19 src/NHibernate.Search.Tests/DirectoryProvider/MultiplySessionFactoriesTestCase.cs
@@ -1,5 +1,7 @@
using System.Collections;
+#if NET_2_0
using System.Collections.Generic;
+#endif
using System.Reflection;
using NHibernate.Cfg;
using NHibernate.Tool.hbm2ddl;
@@ -9,12 +11,21 @@ namespace NHibernate.Search.Tests.DirectoryProvider
{
public abstract class MultiplySessionFactoriesTestCase
{
+#if NET_2_0
private List<ISessionFactory> sessionFactories = new List<ISessionFactory>();
private List<Configuration> configurations;
+#else
+ private IList sessionFactories = new ArrayList();
+ private IList configurations;
+#endif
protected abstract int NumberOfSessionFactories { get; }
+#if NET_2_0
protected IList<ISessionFactory> SessionFactories
+#else
+ protected IList SessionFactories
+#endif
{
get { return sessionFactories; }
}
@@ -47,7 +58,11 @@ public void BuildSessionFactories()
private void Configure()
{
+#if NET_2_0
configurations = new List<Configuration>();
+#else
+ configurations = new ArrayList();
+#endif
for (int i = 0; i < NumberOfSessionFactories; i++)
{
configurations.Add(CreateConfiguration());
@@ -67,7 +82,11 @@ private Configuration CreateConfiguration()
return cfg;
}
+#if NET_2_0
protected abstract void Configure(IList<Configuration> cfg);
+#else
+ protected abstract void Configure(IList cfg);
+#endif
protected abstract IList Mappings
{
View
2 src/NHibernate.Search.Tests/FileHleperTestCase.cs
@@ -1,5 +1,7 @@
using System;
+#if NET_2_0
using System.Collections.Generic;
+#endif
using System.IO;
using System.Text;
using System.Threading;
View
10 src/NHibernate.Search.Tests/NHibernate.Search.Tests-2.0.csproj
@@ -15,7 +15,7 @@
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug-2.0\</OutputPath>
- <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <DefineConstants>TRACE;DEBUG;NET_2_0</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
@@ -66,6 +66,10 @@
<Compile Include="Worker\WorkerTestCase.cs" />
</ItemGroup>
<ItemGroup>
+ <ProjectReference Include="..\NHibernate.Search\NHibernate.Search-2.0.csproj">
+ <Project>{CC25D767-990D-4CE0-9F64-3426E244403B}</Project>
+ <Name>NHibernate.Search-2.0</Name>
+ </ProjectReference>
<ProjectReference Include="..\NHibernate.Test\NHibernate.Test-2.0.csproj">
<Project>{7AEE5B37-C552-4E59-9B6F-88755BCB5070}</Project>
<Name>NHibernate.Test-2.0</Name>
@@ -74,10 +78,6 @@
<Project>{5909BFE7-93CF-4E5F-BE22-6293368AF01D}</Project>
<Name>NHibernate-2.0</Name>
</ProjectReference>
- <ProjectReference Include="..\NHibernate.Search\NHibernate.Search-2.0.csproj">
- <Project>{CC25D767-990D-4CE0-9F64-3426E244403B}</Project>
- <Name>NHibernate.Search</Name>
- </ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
View
2 src/NHibernate.Search/AttributeUtil.cs
@@ -37,7 +37,7 @@ public static DocumentIdAttribute GetDocumentId(MemberInfo member)
documentIdAttribute.Name = documentIdAttribute.Name ?? member.Name;
#else
if (documentIdAttribute.Name == null)
- docuementIdAttribute.Name = member.Name;
+ documentIdAttribute.Name = member.Name;
#endif
return documentIdAttribute;
}
View
1 src/NHibernate.Search/Attributes/Indexed.cs
@@ -1,5 +1,4 @@
using System;
-using System.Collections.Generic;
using System.Text;
namespace NHibernate.Search.Attributes
View
1 src/NHibernate.Search/Attributes/IndexedEmbedded.cs
@@ -1,5 +1,4 @@
using System;
-using System.Collections.Generic;
using System.Text;
namespace NHibernate.Search.Attributes
View
11 src/NHibernate.Search/Backend/IBackendQueueProcessorFactory.cs
@@ -1,5 +1,7 @@
using System.Collections;
+#if NET_2_0
using System.Collections.Generic;
+#endif
using System.Threading;
namespace NHibernate.Search.Backend
@@ -13,11 +15,20 @@ public interface IBackendQueueProcessorFactory
{
void Initialize(IDictionary props, SearchFactory searchFactory);
+#if NET_2_0
/// <summary>
/// Return a runnable implementation responsible for processing the queue to a given backend
/// </summary>
/// <param name="queue"></param>
/// <returns></returns>
WaitCallback GetProcessor(List<LuceneWork> queue);
+#else
+ /// <summary>
+ /// Return a runnable implementation responsible for processing the queue to a given backend
+ /// </summary>
+ /// <param name="queue"></param>
+ /// <returns></returns>
+ WaitCallback GetProcessor(IList queue);
+#endif
}
}
View
18 src/NHibernate.Search/Backend/IQueueingProcessor.cs
@@ -1,4 +1,8 @@
+#if NET_2_0
using System.Collections.Generic;
+#else
+using System.Collections;
+#endif
namespace NHibernate.Search.Backend
{
@@ -9,6 +13,7 @@ namespace NHibernate.Search.Backend
/// </summary>
public interface IQueueingProcessor
{
+#if NET_2_0
/// <summary>
/// Performs all the work in the queue
/// </summary>
@@ -20,5 +25,18 @@ public interface IQueueingProcessor
/// </summary>
/// <param name="queue"></param>
void CancelWork(List<LuceneWork> queue);
+#else
+ /// <summary>
+ /// Performs all the work in the queue
+ /// </summary>
+ /// <param name="queue">The queue.</param>
+ void PerformWork(IList queue);
+
+ /// <summary>
+ /// Rollback
+ /// </summary>
+ /// <param name="queue"></param>
+ void CancelWork(IList queue);
+#endif
}
}
View
19 src/NHibernate.Search/Backend/Impl/BatchedQueueingProcessor.cs
@@ -1,6 +1,8 @@
using System;
using System.Collections;
+#if NET_2_0
using System.Collections.Generic;
+#endif
using System.Threading;
using NHibernate.Search.Backend.Impl.Lucene;
using NHibernate.Search.Impl;
@@ -23,12 +25,19 @@ public class BatchedQueueingProcessor : IQueueingProcessor
{
this.searchFactory = searchFactory;
//default to sync if none defined
+#if NET_2_0
sync =
!"async".Equals((string) properties[Environment.WorkerExecution],
StringComparison.InvariantCultureIgnoreCase);
- String backend = (string) properties[Environment.WorkerBackend];
+ string backend = (string) properties[Environment.WorkerBackend];
if (StringHelper.IsEmpty(backend) || "lucene".Equals(backend, StringComparison.InvariantCultureIgnoreCase))
+#else
+ sync = !"async".Equals(((string) properties[Environment.WorkerExecution]).ToLower());
+
+ string backend = (string) properties[Environment.WorkerBackend];
+ if (StringHelper.IsEmpty(backend) || "lucene".Equals(backend.ToLower()))
+#endif
{
backendQueueProcessorFactory = new LuceneBackendQueueProcessorFactory();
}
@@ -51,7 +60,11 @@ public class BatchedQueueingProcessor : IQueueingProcessor
//TODO implements parallel batchWorkers (one per Directory)
+#if NET_2_0
public void PerformWork(List<LuceneWork> luceneQueue)
+#else
+ public void PerformWork(IList luceneQueue)
+#endif
{
WaitCallback processor = backendQueueProcessorFactory.GetProcessor(luceneQueue);
if (sync)
@@ -64,7 +77,11 @@ public void PerformWork(List<LuceneWork> luceneQueue)
}
}
+#if NET_2_0
public void CancelWork(List<LuceneWork> queue)
+#else
+ public void CancelWork(IList queue)
+#endif
{
queue.Clear();
}
View
32 src/NHibernate.Search/Backend/Impl/Lucene/LuceneBackendQueueProcessor.cs
@@ -1,4 +1,9 @@
+using System;
+#if NET_2_0
using System.Collections.Generic;
+#else
+using System.Collections;
+#endif
using NHibernate.Search.Impl;
namespace NHibernate.Search.Backend.Impl.Lucene
@@ -8,8 +13,10 @@ namespace NHibernate.Search.Backend.Impl.Lucene
/// </summary>
public class LuceneBackendQueueProcessor
{
+ private readonly SearchFactory searchFactory;
+
+#if NET_2_0
private readonly List<LuceneWork> queue;
- private readonly SearchFactory searchFactory;
public LuceneBackendQueueProcessor(List<LuceneWork> queue, SearchFactory searchFactory)
{
@@ -37,6 +44,27 @@ private static void SortQueueToAvoidDeadLocks(List<LuceneWork> queue, Workspace
else return 1;
});
}
+#else
+ private readonly IList queue;
+
+ public LuceneBackendQueueProcessor(IList queue, SearchFactory searchFactory)
+ {
+ this.queue = queue;
+ this.searchFactory = searchFactory;
+ }
+
+ /// <summary>
+ /// one must lock the directory providers in the exact same order to avoid
+ /// dead lock between concurrent threads or processes
+ /// To achieve that, the work will be done per directory provider
+ /// We rely on the both the DocumentBuilder.GetHashCode() and the GetWorkHashCode() to
+ /// sort them by predictive order at all times, and to put deletes before adds
+ /// </summary>
+ private static void SortQueueToAvoidDeadLocks(IList queue, Workspace luceneWorkspace)
+ {
+ throw new NotImplementedException("Need to sort this");
+ }
+#endif
private static long GetWorkHashCode(LuceneWork luceneWork, Workspace luceneWorkspace)
{
@@ -49,7 +77,7 @@ private static long GetWorkHashCode(LuceneWork luceneWork, Workspace luceneWorks
/// <summary>
///
/// </summary>
- /// <param name="ignore">Ignored, used to keep the delegate signature that WaitWithCallback requires</param>
+ /// <param name="ignore">Ignored, used to keep the delegate signature that WaitCallback requires</param>
public void Run(object ignore)
{
Workspace workspace = new Workspace(searchFactory);
View
10 src/NHibernate.Search/Backend/Impl/Lucene/LuceneBackendQueueProcessorFactory.cs
@@ -1,5 +1,7 @@
using System.Collections;
+#if NET_2_0
using System.Collections.Generic;
+#endif
using System.Threading;
namespace NHibernate.Search.Backend.Impl.Lucene
@@ -13,9 +15,17 @@ public void Initialize(IDictionary props, SearchFactory searchFactory)
this.searchFactory = searchFactory;
}
+#if NET_2_0
public WaitCallback GetProcessor(List<LuceneWork> queue)
{
return new LuceneBackendQueueProcessor(queue, searchFactory).Run;
}
+#else
+ public WaitCallback GetProcessor(IList queue)
+ {
+ LuceneBackendQueueProcessor proc = new LuceneBackendQueueProcessor(queue, searchFactory);
+ return new WaitCallback(proc.Run);
+ }
+#endif
}
}
View
1 src/NHibernate.Search/Backend/OptimizeLuceneWork.cs
@@ -1,5 +1,4 @@
using System;
-using System.Collections.Generic;
using System.Text;
namespace NHibernate.Search.Backend
View
1 src/NHibernate.Search/Backend/PurgeAllLuceneWork.cs
@@ -1,5 +1,4 @@
using System;
-using System.Collections.Generic;
using System.Text;
namespace NHibernate.Search.Backend
View
31 src/NHibernate.Search/Backend/Workspace.cs
@@ -1,5 +1,9 @@
using System;
+#if NET_2_0
using System.Collections.Generic;
+#else
+using System.Collections;
+#endif
using System.IO;
using System.Threading;
using log4net;
@@ -22,9 +26,15 @@ namespace NHibernate.Search.Impl
public class Workspace : IDisposable
{
private static ILog log = LogManager.GetLogger(typeof(Workspace));
+#if NET_2_0
private Dictionary<IDirectoryProvider, IndexReader> readers = new Dictionary<IDirectoryProvider, IndexReader>();
private Dictionary<IDirectoryProvider, IndexWriter> writers = new Dictionary<IDirectoryProvider, IndexWriter>();
private List<IDirectoryProvider> lockedProviders = new List<IDirectoryProvider>();
+#else
+ private Hashtable readers = new Hashtable();
+ private Hashtable writers = new Hashtable();
+ private IList lockedProviders = new ArrayList();
+#endif
private SearchFactory searchFactory;
public Workspace(SearchFactory searchFactory)
@@ -45,8 +55,13 @@ public IndexReader GetIndexReader(System.Type entity)
//one cannot access a reader for update after a writer has been accessed
if (writers.ContainsKey(provider))
throw new AssertionFailure("Tries to read for update a index while a writer is accessed" + entity);
- IndexReader reader;
+ IndexReader reader = null;
+#if NET_2_0
readers.TryGetValue(provider, out reader);
+#else
+ if (readers.ContainsKey(provider))
+ reader = (IndexReader) readers[provider];
+#endif
if (reader != null) return reader;
LockProvider(provider);
try
@@ -65,8 +80,13 @@ public IndexWriter GetIndexWriter(System.Type entity)
{
IDirectoryProvider provider = searchFactory.GetDirectoryProvider(entity);
//one has to close a reader for update before a writer is accessed
- IndexReader reader;
+ IndexReader reader = null;
+#if NET_2_0
readers.TryGetValue(provider, out reader);
+#else
+ if (readers.ContainsKey(provider))
+ reader = (IndexReader) readers[provider];
+#endif
if (reader != null)
{
try
@@ -79,8 +99,13 @@ public IndexWriter GetIndexWriter(System.Type entity)
}
readers.Remove(provider);
}
- IndexWriter writer;
+ IndexWriter writer = null;
+#if NET_2_0
writers.TryGetValue(provider, out writer);
+#else
+ if (writers.ContainsKey(provider))
+ writer = (IndexWriter) writers[provider];
+#endif
if (writer != null) return writer;
LockProvider(provider);
try
View
40 src/NHibernate.Search/Bridge/BridgeFactory.cs
@@ -1,5 +1,9 @@
using System;
+#if NET_2_0
using System.Collections.Generic;
+#else
+using System.Collections;
+#endif
using System.Reflection;
using Lucene.Net.Documents;
using NHibernate.Search.Attributes;
@@ -7,7 +11,11 @@
namespace NHibernate.Search.Bridge
{
- public class BridgeFactory
+#if NET_2_0
+#else
+ [CLSCompliant(false)]
+#endif
+ public class BridgeFactory
{
#if NET_2_0
private static readonly Dictionary<String, IFieldBridge> builtInBridges = new Dictionary<String, IFieldBridge>();
@@ -19,19 +27,22 @@ private BridgeFactory()
{
}
+#if NET_2_0
public static readonly ITwoWayFieldBridge DOUBLE = new TwoWayString2FieldBridgeAdaptor(new ValueTypeBridge<double>());
-
public static readonly ITwoWayFieldBridge FLOAT = new TwoWayString2FieldBridgeAdaptor(new ValueTypeBridge<float>());
-
public static readonly ITwoWayFieldBridge SHORT = new TwoWayString2FieldBridgeAdaptor(new ValueTypeBridge<short>());
-
public static readonly ITwoWayFieldBridge INTEGER = new TwoWayString2FieldBridgeAdaptor(new ValueTypeBridge<int>());
-
public static readonly ITwoWayFieldBridge LONG = new TwoWayString2FieldBridgeAdaptor(new ValueTypeBridge<long>());
-
- public static readonly ITwoWayFieldBridge STRING = new TwoWayString2FieldBridgeAdaptor(new StringBridge());
-
public static readonly ITwoWayFieldBridge BOOLEAN = new TwoWayString2FieldBridgeAdaptor(new ValueTypeBridge<bool>());
+#else
+ public static readonly ITwoWayFieldBridge DOUBLE = new TwoWayString2FieldBridgeAdaptor(new DoubleBridge());
+ public static readonly ITwoWayFieldBridge FLOAT = new TwoWayString2FieldBridgeAdaptor(new FloatBridge());
+ public static readonly ITwoWayFieldBridge SHORT = new TwoWayString2FieldBridgeAdaptor(new ShortBridge());
+ public static readonly ITwoWayFieldBridge INTEGER = new TwoWayString2FieldBridgeAdaptor(new IntBridge());
+ public static readonly ITwoWayFieldBridge LONG = new TwoWayString2FieldBridgeAdaptor(new LongBridge());
+ public static readonly ITwoWayFieldBridge BOOLEAN = new TwoWayString2FieldBridgeAdaptor(new BoolBridge());
+#endif
+ public static readonly ITwoWayFieldBridge STRING = new TwoWayString2FieldBridgeAdaptor(new StringBridge());
public static readonly IFieldBridge DATE_YEAR = new String2FieldBridgeAdaptor(DateBridge.DATE_YEAR);
public static readonly IFieldBridge DATE_MONTH = new String2FieldBridgeAdaptor(DateBridge.DATE_MONTH);
@@ -79,7 +90,7 @@ public static IFieldBridge GuessType(MemberInfo member)
{
bridge = new String2FieldBridgeAdaptor((StringBridge) instance);
}
- if (bridgeAnn.Parameters.Length > 0 && typeof (IParameterizedBridge).IsAssignableFrom(impl))
+ if (bridgeAnn.Parameters.Length > 0 && typeof(IParameterizedBridge).IsAssignableFrom(impl))
{
((IParameterizedBridge) instance).SetParameterValues(bridgeAnn.Parameters);
}
@@ -100,9 +111,13 @@ public static IFieldBridge GuessType(MemberInfo member)
{
//find in built-ins
System.Type returnType = GetMemberType(member);
+#if NET_2_0
if (IsNullable(returnType))
returnType = returnType.GetGenericArguments()[0];
builtInBridges.TryGetValue(returnType.Name, out bridge);
+#else
+ bridge = (IFieldBridge) (builtInBridges.ContainsKey(returnType.Name) ? builtInBridges[returnType.Name] : null);
+#endif
if (bridge == null && returnType.IsEnum)
{
bridge = new TwoWayString2FieldBridgeAdaptor(
@@ -117,7 +132,12 @@ public static IFieldBridge GuessType(MemberInfo member)
private static bool IsNullable(System.Type returnType)
{
- return returnType.IsGenericType && typeof (Nullable<>) == returnType.GetGenericTypeDefinition();
+#if NET_2_0
+ return returnType.IsGenericType && typeof(Nullable<>) == returnType.GetGenericTypeDefinition();
+#else
+ // TODO: Work out if this is adequate
+ return returnType.IsClass;
+#endif
}
private static System.Type GetMemberType(MemberInfo member)
View
22 src/NHibernate.Search/Bridge/Builtin/BoolBridge.cs
@@ -0,0 +1,22 @@
+using System;
+
+namespace NHibernate.Search.Bridge.Builtin
+{
+ /// <summary>
+ /// Bridge class for boolean.
+ /// </summary>
+ public class BoolBridge : SimpleBridge
+ {
+ public override object StringToObject(string stringValue)
+ {
+ try
+ {
+ return bool.Parse(stringValue);
+ }
+ catch (Exception ex)
+ {
+ return false;
+ }
+ }
+ }
+}
View
22 src/NHibernate.Search/Bridge/Builtin/DoubleBridge.cs
@@ -0,0 +1,22 @@
+using System;
+
+namespace NHibernate.Search.Bridge.Builtin
+{
+ /// <summary>
+ /// Bridge class for doubles.
+ /// </summary>
+ public class DoubleBridge : SimpleBridge
+ {
+ public override object StringToObject(string stringValue)
+ {
+ try
+ {
+ return short.Parse(stringValue);
+ }
+ catch (Exception ex)
+ {
+ return 0.0D;
+ }
+ }
+ }
+}
View
22 src/NHibernate.Search/Bridge/Builtin/FloatBridge.cs
@@ -0,0 +1,22 @@
+using System;
+
+namespace NHibernate.Search.Bridge.Builtin
+{
+ /// <summary>
+ /// Bridge class for float.
+ /// </summary>
+ public class FloatBridge : SimpleBridge
+ {
+ public override object StringToObject(string stringValue)
+ {
+ try
+ {
+ return float.Parse(stringValue);
+ }
+ catch (Exception ex)
+ {
+ return 0.0F;
+ }
+ }
+ }
+}
View
22 src/NHibernate.Search/Bridge/Builtin/IntBridge.cs
@@ -0,0 +1,22 @@
+using System;
+
+namespace NHibernate.Search.Bridge.Builtin
+{
+ /// <summary>
+ /// Bridge class for integers.
+ /// </summary>
+ public class IntBridge : SimpleBridge
+ {
+ public override object StringToObject(string stringValue)
+ {
+ try
+ {
+ return int.Parse(stringValue);
+ }
+ catch (Exception ex)
+ {
+ return 0;
+ }
+ }
+ }
+}
View
22 src/NHibernate.Search/Bridge/Builtin/LongBridge.cs
@@ -0,0 +1,22 @@
+using System;
+
+namespace NHibernate.Search.Bridge.Builtin
+{
+ /// <summary>
+ /// Bridge class for long.
+ /// </summary>
+ public class LongBridge : SimpleBridge
+ {
+ public override object StringToObject(string stringValue)
+ {
+ try
+ {
+ return short.Parse(stringValue);
+ }
+ catch (Exception ex)
+ {
+ return 0L;
+ }
+ }
+ }
+}
View
22 src/NHibernate.Search/Bridge/Builtin/ShortBridge.cs
@@ -0,0 +1,22 @@
+using System;
+
+namespace NHibernate.Search.Bridge.Builtin
+{
+ /// <summary>
+ /// Bridge class for short
+ /// </summary>
+ public class ShortBridge : SimpleBridge
+ {
+ public override object StringToObject(string stringValue)
+ {
+ try
+ {
+ return short.Parse(stringValue);
+ }
+ catch (Exception ex)
+ {
+ return 0.0m;
+ }
+ }
+ }
+}
View
6 src/NHibernate.Search/Bridge/IFieldBridge.cs
@@ -7,7 +7,11 @@ namespace NHibernate.Search.Bridge
/// <summary>
/// Put an object inside the document.
/// </summary>
- public interface IFieldBridge
+#if NET_2_0
+#else
+ [CLSCompliant(false)]
+#endif
+ public interface IFieldBridge
{
#if NET_2_0
void Set(string idKeywordName, object id, Document doc, Field.Store store, Field.Index index, float? boost);
View
7 src/NHibernate.Search/Bridge/ITwoWayFieldBridge.cs
@@ -1,9 +1,14 @@
+using System;
using Lucene.Net.Documents;
using NHibernate.Search.Bridge;
namespace NHibernate.Search.Bridge
{
- public interface ITwoWayFieldBridge : IFieldBridge
+#if NET_2_0
+#else
+ [CLSCompliant(false)]
+#endif
+ public interface ITwoWayFieldBridge : IFieldBridge
{
object Get(string value, Document document);
string ObjectToString(object obj);
View
9 src/NHibernate.Search/Bridge/String2FieldBridgeAdaptor.cs
@@ -5,6 +5,10 @@
namespace NHibernate.Search.Bridge
{
+#if NET_2_0
+#else
+ [CLSCompliant(false)]
+#endif
public class String2FieldBridgeAdaptor : IFieldBridge
{
private readonly IStringBridge stringBridge;
@@ -27,11 +31,12 @@ public void Set(String name, Object value, Document document, Field.Store store,
Field field = new Field(name, indexedString, store, index);
#if NET_2_0
if (boost != null)
+ field.SetBoost(boost.Value);
#else
if (boost != 0F)
+ field.SetBoost(boost);
#endif
- field.SetBoost(boost.Value);
- document.Add(field);
+ document.Add(field);
}
}
}
View
4 src/NHibernate.Search/Bridge/TwoWayString2FieldBridgeAdaptor.cs
@@ -3,6 +3,10 @@
namespace NHibernate.Search.Bridge
{
+#if NET_2_0
+#else
+ [CLSCompliant(false)]
+#endif
public class TwoWayString2FieldBridgeAdaptor : String2FieldBridgeAdaptor, ITwoWayFieldBridge
{
private readonly ITwoWayStringBridge stringBridge;
View
17 src/NHibernate.Search/DirectoryProviderHelper.cs
@@ -1,7 +1,9 @@
using System;
using System.Collections;
using System.IO;
+#if NET_2_0
using System.Security.AccessControl;
+#endif
using log4net;
using NHibernate.Search.Impl;
using NHibernate.Util;
@@ -68,10 +70,23 @@ public class DirectoryProviderHelper
public static DirectoryInfo DetermineIndexDir(String directoryProviderName, IDictionary properties)
{
- String indexBase = (string) properties["indexBase"] ?? ".";
bool createIfMissing;
+#if NET_2_0
+ string indexBase = (string) properties["indexBase"] ?? ".";
string shouldCreate = (string)properties["indexBase.create"] ?? "false";
bool.TryParse(shouldCreate, out createIfMissing);
+#else
+ string indexBase = (string) properties["indexBase"] != null ? (string) properties["indexBase"] : ".";
+ string shouldCreate = (string) properties["indexBase.create"] != null ? (string) properties["indexBase.create"] : "false";
+ try
+ {
+ createIfMissing = bool.Parse(shouldCreate);
+ }
+ catch
+ {
+ createIfMissing = false;
+ }
+#endif
//We need this to allow using the search from the web, where the "." directory is
//somewhere in the system root.
indexBase = indexBase.Replace("~", AppDomain.CurrentDomain.BaseDirectory);
View
125 src/NHibernate.Search/Engine/DocumentBuilder.cs
@@ -1,7 +1,12 @@
using System;
-using System.Collections.Generic;
using System.Reflection;
+#if NET_2_0
+using System.Collections.Generic;
using Iesi.Collections.Generic;
+#else
+using System.Collections;
+using Iesi.Collections;
+#endif
using log4net;
using Lucene.Net.Analysis;
using Lucene.Net.Documents;
@@ -20,6 +25,10 @@ namespace NHibernate.Search.Engine
/// <summary>
/// Set up and provide a manager for indexes classes
/// </summary>
+#if NET_2_0
+#else
+ [CLSCompliant(false)]
+#endif
public class DocumentBuilder
{
private static readonly ILog log = LogManager.GetLogger(typeof(DocumentBuilder));
@@ -55,7 +64,11 @@ public DocumentBuilder(System.Type clazz, Analyzer analyzer, IDirectoryProvider
if (clazz == null) throw new AssertionFailure("Unable to build a DocumemntBuilder with a null class");
rootPropertiesMetadata.boost = GetBoost(clazz);
+#if NET_2_0
Set<System.Type> processedClasses = new HashedSet<System.Type>();
+#else
+ ISet processedClasses = new HashedSet();
+#endif
processedClasses.Add(clazz);
InitializeMembers(clazz, rootPropertiesMetadata, true, "", processedClasses);
//processedClasses.remove( clazz ); for the sake of completness
@@ -73,7 +86,7 @@ public DocumentBuilder(System.Type clazz, Analyzer analyzer, IDirectoryProvider
#else
private void InitializeMembers(
System.Type clazz, PropertiesMetadata propertiesMetadata, bool isRoot, String prefix,
- Set processedClasses)
+ ISet processedClasses)
#endif
{
PropertyInfo[] propertyInfos = clazz.GetProperties();
@@ -201,7 +214,7 @@ private static object GetMemberValue(Object instnace, MemberInfo getter)
#if NET_2_0
public void AddToWorkQueue(object entity, object id, WorkType workType, List<LuceneWork> queue, SearchFactory searchFactory)
#else
- public void AddToWorkQueue(object entity, object id, WorkType workType, List queue, SearchFactory searchFactory)
+ public void AddToWorkQueue(object entity, object id, WorkType workType, IList queue, SearchFactory searchFactory)
#endif
{
System.Type entityClass = NHibernateUtil.GetClass(entity);
@@ -267,7 +280,7 @@ not supported
#if NET_2_0
private void ProcessContainedInValue(object value, List<LuceneWork> queue, System.Type valueClass, DocumentBuilder builder, SearchFactory searchFactory)
#else
- private void ProcessContainedInValue(object value, List queue, System.Type valueClass, DocumentBuilder builder, SearchFactory searchFactory)
+ private void ProcessContainedInValue(object value, IList queue, System.Type valueClass, DocumentBuilder builder, SearchFactory searchFactory)
#endif
{
object id = DocumentBuilder.GetMemberValue(value, builder.idGetter);
@@ -278,10 +291,16 @@ public Document GetDocument(object instance, object id)
{
Document doc = new Document();
System.Type instanceClass = instance.GetType();
+#if NET_2_0
if (rootPropertiesMetadata.boost != null)
{
doc.SetBoost(rootPropertiesMetadata.boost.Value);
}
+#else
+ if (rootPropertiesMetadata.boost != 0)
+ doc.SetBoost(rootPropertiesMetadata.boost);
+#endif
+ // TODO: Check if that should be an else?
{
Field classField =
new Field(CLASS_FIELDNAME, instanceClass.AssemblyQualifiedName, Field.Store.YES, Field.Index.UN_TOKENIZED);
@@ -296,6 +315,7 @@ private static void BuildDocumentFields(Object instance, Document doc, Propertie
{
if (instance == null) return;
+#if NET_2_0
for (int i = 0; i < propertiesMetadata.keywordNames.Count; i++)
{
MemberInfo member = propertiesMetadata.keywordGetters[i];
@@ -340,6 +360,63 @@ private static void BuildDocumentFields(Object instance, Document doc, Propertie
//TODO handle boost at embedded level: already stored in propertiesMedatada.boost
BuildDocumentFields(value, doc, propertiesMetadata.embeddedPropertiesMetadata[i]);
}
+#else
+ for (int i = 0; i < propertiesMetadata.keywordNames.Count; i++)
+ {
+ MemberInfo member = (MemberInfo) propertiesMetadata.keywordGetters[i];
+ IFieldBridge bridge = (IFieldBridge) propertiesMetadata.keywordBridges[i];
+
+ Object value = GetMemberValue(instance, member);
+
+ bridge.Set(
+ (string) propertiesMetadata.keywordNames[i], value, doc, Field.Store.YES,
+ Field.Index.UN_TOKENIZED, GetBoost(member)
+ );
+ }
+ for (int i = 0; i < propertiesMetadata.textNames.Count; i++)
+ {
+ MemberInfo member = (MemberInfo) propertiesMetadata.textGetters[i];
+ IFieldBridge bridge = (IFieldBridge) propertiesMetadata.textBridges[i];
+
+ Object value = GetMemberValue(instance, member);
+ bridge.Set(
+ (string) propertiesMetadata.textNames[i], value, doc, Field.Store.YES,
+ Field.Index.TOKENIZED, GetBoost(member)
+ );
+ }
+ for (int i = 0; i < propertiesMetadata.unstoredNames.Count; i++)
+ {
+ MemberInfo member = (MemberInfo) propertiesMetadata.unstoredGetters[i];
+ IFieldBridge bridge = (IFieldBridge) propertiesMetadata.unstoredBridges[i];
+
+ Object value = GetMemberValue(instance, member);
+ bridge.Set(
+ (string) propertiesMetadata.unstoredNames[i], value, doc, Field.Store.NO,
+ Field.Index.TOKENIZED, GetBoost(member)
+ );
+ }
+ for (int i = 0; i < propertiesMetadata.fieldNames.Count; i++)
+ {
+ MemberInfo member = (MemberInfo) propertiesMetadata.fieldGetters[i];
+ IFieldBridge bridge = (IFieldBridge) propertiesMetadata.fieldBridges[i];
+
+ Object value = GetMemberValue(instance, member);
+ bridge.Set(
+ (string) propertiesMetadata.fieldNames[i], value, doc, (Field.Store) propertiesMetadata.fieldStore[i],
+ (Field.Index) propertiesMetadata.fieldIndex[i], GetBoost(member)
+ );
+ }
+ for (int i = 0; i < propertiesMetadata.embeddedGetters.Count; i++)
+ {
+ MemberInfo member = (MemberInfo) propertiesMetadata.embeddedGetters[i];
+ PropertiesMetadata md = (PropertiesMetadata) propertiesMetadata.embeddedPropertiesMetadata[i];
+
+ Object value = GetMemberValue(instance, member);
+ //if ( ! Hibernate.isInitialized( value ) ) continue; //this sounds like a bad idea
+ //TODO handle boost at embedded level: already stored in propertiesMedatada.boost
+ BuildDocumentFields(value, doc, md);
+ }
+#endif
}
public Term GetTerm(object id)
@@ -384,7 +461,7 @@ public static System.Type GetDocumentClass(Document document)
public static object GetDocumentId(SearchFactory searchFactory, Document document)
{
System.Type clazz = GetDocumentClass(document);
- DocumentBuilder builder = searchFactory.DocumentBuilders[clazz];
+ DocumentBuilder builder = (DocumentBuilder) searchFactory.DocumentBuilders[clazz];
if (builder == null) throw new SearchException("No Lucene configuration set up for: " + clazz.Name);
return builder.IdBridge.Get(builder.getIdKeywordName(), document);
}
@@ -437,7 +514,11 @@ public void PostInitialize(ISet indexedClasses)
{
//this method does not requires synchronization
System.Type plainClass = beanClass;
+#if NET_2_0
ISet tempMappedSubclasses = new HashedSet<System.Type>();
+#else
+ ISet tempMappedSubclasses = new HashedSet();
+#endif
//together with the caller this creates a o(2), but I think it's still faster than create the up hierarchy for each class
foreach (System.Type currentClass in indexedClasses)
{
@@ -455,23 +536,23 @@ public ISet MappedSubclasses
private class PropertiesMetadata
{
public float boost = 0;
- public readonly List keywordGetters = new List();
- public readonly List keywordNames = new List();
- public readonly List keywordBridges = new List();
- public readonly List unstoredGetters = new List();
- public readonly List unstoredNames = new List();
- public readonly List unstoredBridges = new List();
- public readonly List textGetters = new List();
- public readonly List textNames = new List();
- public readonly List textBridges = new List();
- public readonly List fieldNames = new List();
- public readonly List fieldGetters = new List();
- public readonly List fieldBridges = new List();
- public readonly List fieldStore = new List();
- public readonly List fieldIndex = new List();
- public readonly List embeddedGetters = new List();
- public readonly List embeddedPropertiesMetadata = new List();
- public readonly List containedInGetters = new List();
+ public readonly IList keywordGetters = new ArrayList();
+ public readonly IList keywordNames = new ArrayList();
+ public readonly IList keywordBridges = new ArrayList();
+ public readonly IList unstoredGetters = new ArrayList();
+ public readonly IList unstoredNames = new ArrayList();
+ public readonly IList unstoredBridges = new ArrayList();
+ public readonly IList textGetters = new ArrayList();
+ public readonly IList textNames = new ArrayList();
+ public readonly IList textBridges = new ArrayList();
+ public readonly IList fieldNames = new ArrayList();
+ public readonly IList fieldGetters = new ArrayList();
+ public readonly IList fieldBridges = new ArrayList();
+ public readonly IList fieldStore = new ArrayList();
+ public readonly IList fieldIndex = new ArrayList();
+ public readonly IList embeddedGetters = new ArrayList();
+ public readonly IList embeddedPropertiesMetadata = new ArrayList();
+ public readonly IList containedInGetters = new ArrayList();
}
#endif
}
View
20 src/NHibernate.Search/Engine/SearchFactory.cs
@@ -1,7 +1,11 @@
using System;
-using System.Collections;
+#if NET_2_0
using System.Collections.Generic;
using Iesi.Collections.Generic;
+#else
+using System.Collections;
+using Iesi.Collections;
+#endif
using Lucene.Net.Analysis;
using Lucene.Net.Analysis.Standard;
using NHibernate.Cfg;
@@ -16,6 +20,10 @@
namespace NHibernate.Search
{
+#if NET_2_0
+#else
+ [CLSCompliant(false)]
+#endif
public class SearchFactory
{
private static readonly WeakHashtable sessionFactory2SearchFactory = new WeakHashtable();
@@ -141,7 +149,7 @@ private SearchFactory(Configuration cfg)
#if NET_2_0
public void ExecuteQueue(List<LuceneWork> luceneWork, ISession session)
#else
- public void ExecuteQueue(List luceneWork, ISession session)
+ public void ExecuteQueue(IList luceneWork, ISession session)
#endif
{
if (session.Transaction.IsActive)
@@ -158,7 +166,7 @@ public void ExecuteQueue(List luceneWork, ISession session)
#if NET_2_0
public void ExecuteQueueImmediate(List<LuceneWork> luceneWork)
#else
- public void ExecuteQueueImmediate(List luceneWork)
+ public void ExecuteQueueImmediate(IList luceneWork)
#endif
{
queueingProcessor.PerformWork(luceneWork);
@@ -172,9 +180,13 @@ public DocumentBuilder GetDocumentBuilder(object entity)
public DocumentBuilder GetDocumentBuilder(System.Type type)
{
+#if NET_2_0
DocumentBuilder builder;
DocumentBuilders.TryGetValue(type, out builder);
return builder;
+#else
+ return (DocumentBuilder) (DocumentBuilders.ContainsKey(type.Name) ? DocumentBuilders[type.Name] : null);
+#endif
}
public IDirectoryProvider GetDirectoryProvider(System.Type entity)
@@ -195,7 +207,7 @@ public void PerformWork(object entity, object id, ISession session, WorkType wor
#if NET_2_0
List<LuceneWork> queue = new List<LuceneWork>();
#else
- List queue = new List();
+ IList queue = new ArrayList();
#endif
documentBuilder.AddToWorkQueue(entity, id, workType, queue, this);
ExecuteQueue(queue, session);
View
4 src/NHibernate.Search/IFullTextSession.cs
@@ -3,6 +3,10 @@
namespace NHibernate.Search
{
+#if NET_2_0
+#else
+ [CLSCompliant(false)]
+#endif
public interface IFullTextSession : ISession
{
#if NET_2_0
View
6 src/NHibernate.Search/Impl/FullTextSessionImpl.cs
@@ -1,6 +1,8 @@
using System;
using System.Collections;
+#if NET_2_0
using System.Collections.Generic;
+#endif
using System.Data;
using System.Text;
using Lucene.Net.Analysis.Standard;
@@ -12,6 +14,10 @@
namespace NHibernate.Search.Impl
{
+#if NET_2_0
+#else
+ [CLSCompliant(false)]
+#endif
public class FullTextSessionImpl : IFullTextSession
{
private readonly ISession session;
View
21 src/NHibernate.Search/Impl/SearchInterceptor.cs
@@ -1,6 +1,8 @@
using System;
using System.Collections;
+#if NET_2_0
using System.Collections.Generic;
+#endif
using NHibernate.Search.Backend;
using NHibernate.Type;
@@ -13,7 +15,7 @@ public class SearchInterceptor : EmptyInterceptor
private readonly List<object> entitiesToAddOnPostFlush = new List<object>();
#else
private readonly Hashtable syncronizations = new Hashtable();
- private readonly List entitiesToAddOnPostFlush = new List();
+ private readonly IList entitiesToAddOnPostFlush = new ArrayList();
#endif
private ISession session;
private SearchFactory searchFactory;
@@ -97,24 +99,33 @@ private void RegisterIndexing(object entity, object id, WorkType workType)
#if NET_2_0
public void RegisterSyncronization(ITransaction transaction, List<LuceneWork> work)
#else
- public void RegisterSyncronization(ITransaction transaction, List work)
+ public void RegisterSyncronization(ITransaction transaction, IList work)
#endif
{
- if (syncronizations.ContainsKey(transaction) == false)
#if NET_2_0
+ if (syncronizations.ContainsKey(transaction) == false)
syncronizations.Add(transaction, new List<LuceneWork>());
+ syncronizations[transaction].AddRange(work);
#else
- syncronizations.Add(transaction, new List());
+ if (syncronizations.ContainsKey(transaction) == false)
+ syncronizations.Add(transaction, new ArrayList());
+
+ ((ArrayList) syncronizations[transaction]).AddRange(work);
#endif
- syncronizations[transaction].AddRange(work);
}
public override void AfterTransactionCompletion(ITransaction tx)
{
base.AfterTransactionCompletion(tx);
+#if NET_2_0
List<LuceneWork> queue;
if (syncronizations.TryGetValue(tx, out queue) == false)
return;
+#else
+ IList queue = (IList) (syncronizations.ContainsKey(tx) ? syncronizations[tx] : null);
+ if (queue == null)
+ return;
+#endif
if (tx.WasCommitted)
{
SearchFactory.GetSearchFactory(session)
View
16 src/NHibernate.Search/LuceneQueryExpression.cs
@@ -1,6 +1,11 @@
using System;
+#if NET_2_0
using System.Collections.Generic;
using Iesi.Collections.Generic;
+#else
+using System.Collections;
+using Iesi.Collections;
+#endif
using Lucene.Net.Search;
using NHibernate.Expression;
using NHibernate.Impl;
@@ -22,15 +27,22 @@ public LuceneQueryExpression(Query luceneQuery)
public override NHibernate.SqlCommand.SqlString ToSqlString(ICriteria criteria, ICriteriaQuery criteriaQuery, System.Collections.IDictionary enabledFilters)
{
+#if NET_2_0
+ ISet<System.Type> types;
+ List<object> ids = new List<object>();
+#else
+ ISet types;
+ ArrayList ids = new ArrayList();
+#endif
+
System.Type type = GetCriteriaClass(criteria);
SearchFactory searchFactory = SearchFactory.GetSearchFactory(GetSession(criteria));
- ISet<System.Type> types;
Searcher searcher = FullTextSearchHelper.BuildSearcher(searchFactory, out types, type);
if (searcher == null)
throw new SearchException("Could not find a searcher for class: " + type.FullName);
Query query = FullTextSearchHelper.FilterQueryByClasses(types, luceneQuery);
Hits hits = searcher.Search(query);
- List<object> ids = new List<object>();
+
for (int i = 0; i < hits.Length(); i++)
{
object id = DocumentBuilder.GetDocumentId(searchFactory,hits.Doc(i));
View
18 src/NHibernate.Search/Query/FullTextQueryImpl.cs
@@ -1,7 +1,12 @@
using System;
+using System.Collections;
+#if NET_2_0
using System.Collections.Generic;
-using System.IO;
using Iesi.Collections.Generic;
+#else
+using Iesi.Collections;
+#endif
+using System.IO;
using log4net;
using Lucene.Net.Documents;
using Lucene.Net.Index;
@@ -9,13 +14,16 @@
using NHibernate.Engine;
using NHibernate.Expression;
using NHibernate.Impl;
-using System.Collections;
using NHibernate.Search.Engine;
using NHibernate.Search.Impl;
using Directory = Lucene.Net.Store.Directory;
namespace NHibernate.Search.Impl
{
+#if NET_2_0
+#else
+ [CLSCompliant(false)]
+#endif
public class FullTextQueryImpl : AbstractQueryImpl
{
private static ILog log = LogManager.GetLogger(typeof (FullTextQueryImpl));
@@ -128,9 +136,13 @@ public override IList<T> List<T>()
List(arrayList);
return (T[]) arrayList.ToArray(typeof (T));
}
+#else
+ public override IEnumerable Enumerable()
+ {
+ throw new NotImplementedException("Enumerator not implemented");
+ }
#endif
-
public override IList List()
{
ArrayList arrayList = new ArrayList();
View
36 src/NHibernate.Search/Query/FullTextSearchHelper.cs
@@ -1,6 +1,11 @@
-using System.Collections.Generic;
using System.IO;
+#if NET_2_0
+using System.Collections.Generic;
using Iesi.Collections.Generic;
+#else
+using System.Collections;
+using Iesi.Collections;
+#endif
using Lucene.Net.Index;
using Lucene.Net.Search;
using NHibernate.Search.Engine;
@@ -8,9 +13,13 @@
namespace NHibernate.Search
{
- public static class FullTextSearchHelper
+ public class FullTextSearchHelper
{
+#if NET_2_0
public static Query FilterQueryByClasses(ISet<System.Type> classesAndSubclasses, Query luceneQuery)
+#else
+ public static Query FilterQueryByClasses(ISet classesAndSubclasses, Query luceneQuery)
+#endif
{
//A query filter is more practical than a manual class filtering post query (esp on scrollable resultsets)
//it also probably minimise the memory footprint
@@ -36,10 +45,17 @@ public static Query FilterQueryByClasses(ISet<System.Type> classesAndSubclasses,
}
}
+#if NET_2_0
public static Searcher BuildSearcher(SearchFactory searchFactory, out ISet<System.Type> classesAndSubclasses, params System.Type[] classes)
{
Dictionary<System.Type, DocumentBuilder> builders = searchFactory.DocumentBuilders;
ISet<Directory> directories = new HashedSet<Directory>();
+#else
+ public static Searcher BuildSearcher(SearchFactory searchFactory, out ISet classesAndSubclasses, params System.Type[] classes)
+ {
+ Hashtable builders = searchFactory.DocumentBuilders;
+ ISet directories = new HashedSet();
+#endif
if (classes == null || classes.Length == 0)
{
//no class means all classes
@@ -51,18 +67,30 @@ public static Searcher BuildSearcher(SearchFactory searchFactory, out ISet<Syste
}
else
{
+#if NET_2_0
ISet<System.Type> involvedClasses = new HashedSet<System.Type>();
+#else
+ ISet involvedClasses = new HashedSet();
+#endif
involvedClasses.AddAll(classes);
foreach (System.Type clazz in classes)
{
DocumentBuilder builder;
+#if NET_2_0
builders.TryGetValue(clazz, out builder);
+#else
+ builder = (DocumentBuilder) (builders.ContainsKey(clazz.Name) ? builders[clazz.Name] : null);
+#endif
if (builder != null) involvedClasses.AddAll(builder.MappedSubclasses);
}
foreach (System.Type clazz in involvedClasses)
{
DocumentBuilder builder;
+#if NET_2_0
builders.TryGetValue(clazz, out builder);
+#else
+ builder = (DocumentBuilder) (builders.ContainsKey(clazz.Name) ? builders[clazz.Name] : null);
+#endif
//TODO should we rather choose a polymorphic path and allow non mapped entities
if (builder == null) throw new HibernateException("Not a mapped entity: " + clazz);
directories.Add(builder.DirectoryProvider.Directory);
@@ -73,7 +101,11 @@ public static Searcher BuildSearcher(SearchFactory searchFactory, out ISet<Syste
return GetSearcher(directories);
}
+#if NET_2_0
public static Searcher GetSearcher(ISet<Directory> directories)
+#else
+ public static Searcher GetSearcher(ISet directories)
+#endif
{
if (directories.Count == 0)
return null;
View
13 src/NHibernate.Search/Store/DirectoryProviderFactory.cs
@@ -1,6 +1,11 @@
using System;
using System.Collections;
+#if NET_2_0
using System.Collections.Generic;
+using Iesi.Collections.Generic;
+#else
+using Iesi.Collections;
+#endif
using NHibernate.Cfg;
using NHibernate.Mapping;
using NHibernate.Search.Attributes;
@@ -17,7 +22,7 @@ public class DirectoryProviderFactory
#if NET_2_0
public List<IDirectoryProvider> providers = new List<IDirectoryProvider>();
#else
- public List providers = new ArrayList();
+ public IList providers = new ArrayList();
#endif
public IDirectoryProvider CreateDirectoryProvider(System.Type entity, Configuration cfg, SearchFactory searchFactory)
@@ -54,7 +59,7 @@ public IDirectoryProvider CreateDirectoryProvider(System.Type entity, Configurat
if (index != -1)
{
//share the same Directory provider for the same underlying store
- return providers[index];
+ return (IDirectoryProvider) providers[index];
}
else
{
@@ -99,7 +104,11 @@ private static String GetDirectoryProviderName(System.Type clazz, Configuration
IndexedAttribute indexAnn = AttributeUtil.GetIndexed(pc.MappedClass);
if (indexAnn != null)
{
+#if NET_2_0
if (string.IsNullOrEmpty(indexAnn.Index)==false)
+#else
+ if (indexAnn.Index != null && indexAnn.Index != string.Empty)
+#endif
{
return indexAnn.Index;
}
View
12 src/NHibernate.Search/Store/FSMasterDirectoryProvider.cs
@@ -36,7 +36,11 @@ public void Initialize(String directoryProviderName, IDictionary properties, Sea
log.Debug("Source directory: " + source);
DirectoryInfo indexDir = DirectoryProviderHelper.DetermineIndexDir(directoryProviderName, properties);
log.Debug("Index directory: " + indexDir);
+#if NET_2_0
String refreshPeriod = (string)(properties[Environment.Refresh] ?? "3600");
+#else
+ String refreshPeriod = (string) (properties[Environment.Refresh] != null ? properties[Environment.Refresh] : "3600");
+#endif
long period = int.Parse(refreshPeriod);
log.Debug("Refresh period " + period + " seconds");
period *= 1000; //per second
@@ -83,10 +87,14 @@ public void Initialize(String directoryProviderName, IDictionary properties, Sea
throw new HibernateException("Unable to initialize index: " + directoryProviderName, e);
}
searchFactory.RegisterDirectoryProviderForLocks(this);
+#if NET_2_0
timer = new Timer(
new CopyDirectory(this, indexName, source).Run
);
timer.Change(period, period);
+#else
+ timer = new Timer(new TimerCallback(new CopyDirectory(this, indexName, source).Run), null, period, period);
+#endif
this.searchFactory = searchFactory;
}
@@ -168,7 +176,11 @@ public void Run(object ignored)
}
try
{
+#if NET_2_0
File.Create(Path.Combine(destination, "current" + index)).Dispose();
+#else
+ File.Create(Path.Combine(destination, "current" + index));
+#endif
}
catch (IOException e)
{
View
21 src/NHibernate.Search/Store/FSSlaveDirectoryProvider.cs
@@ -43,7 +43,11 @@ public void Initialize(String directoryProviderName, IDictionary properties, Sea
log.Debug("Source directory: " + source);
DirectoryInfo indexDir = DirectoryProviderHelper.DetermineIndexDir(directoryProviderName, properties);
log.Debug("Index directory: " + indexDir.FullName);
- String refreshPeriod = (string)(properties[Environment.Refresh] ?? "3600");
+#if NET_2_0
+ string refreshPeriod = (string)(properties[Environment.Refresh] ?? "3600");
+#else
+ string refreshPeriod = (string)(properties[Environment.Refresh] != null ? properties[Environment.Refresh] : "3600");
+#endif
long period = long.Parse(refreshPeriod);
log.Debug("Refresh period " + period + " seconds");
period *= 1000; //per second
@@ -116,9 +120,14 @@ public void Initialize(String directoryProviderName, IDictionary properties, Sea
throw new HibernateException("Umable to synchonize directory: " + indexName, e);
}
}
+
try
{
+#if NET_2_0
File.Create(current1Master).Dispose();
+#else
+ File.Create(current1Master);
+#endif
}
catch (IOException e)
{
@@ -132,10 +141,14 @@ public void Initialize(String directoryProviderName, IDictionary properties, Sea
throw new HibernateException("Unable to initialize index: " + directoryProviderName, e);
}
searchFactory.RegisterDirectoryProviderForLocks(this);
+#if NET_2_0
timer = new Timer(
new CopyDirectory(this, source, indexName).Run
);
timer.Change(period, period);
+#else
+ timer = new Timer(new TimerCallback(new CopyDirectory(this, source, indexName).Run), null, period, period);
+#endif
}
public Directory Directory
@@ -232,6 +245,7 @@ public void Run(object ignoed)
inProgress = false;
return;
}
+
try
{
File.Delete(Path.Combine(parent.indexName, "current" + oldIndex));
@@ -240,9 +254,14 @@ public void Run(object ignoed)
{
log.Warn("Unable to remove previous marker file in " + parent.indexName, e);
}
+
try
{
+#if NET_2_0
File.Create(Path.Combine(parent.indexName, "current" + index)).Dispose();
+#else
+ File.Create(Path.Combine(parent.indexName, "current" + index));
+#endif
}
catch (IOException e)
{
View
12 src/NHibernate.Search/Store/FileHelper.cs
@@ -1,10 +1,16 @@
using System;
using System.IO;
+#if NET_2_0
+using System.Collections.Generic;
using Iesi.Collections.Generic;
+#else
+using System.Collections;
+using Iesi.Collections;
+#endif
namespace NHibernate.Search.Storage
{
- public static class FileHelper
+ public class FileHelper
{
private const int LastWriteTimePrecision = 2000;
@@ -15,7 +21,11 @@ public static void Synchronize(DirectoryInfo source, DirectoryInfo destination,
destination.Create();
}
FileInfo[] sources = source.GetFiles();
+#if NET_2_0
ISet<string> srcNames = new HashedSet<string>();
+#else
+ ISet srcNames = new HashedSet();
+#endif
foreach (FileInfo fileInfo in sources)
{
srcNames.Add(fileInfo.Name);
View
8 src/NHibernate.Test.Performance/NHibernate.Test.Performance-1.1.csproj
@@ -100,13 +100,13 @@
Package = "{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}"
/>
<Reference
- Name = "NHibernate.Test-1.1"
- Project = "{F6CDD71A-FDCA-43F1-A5FF-B2941224A66F}"
+ Name = "NHibernate.DomainModel-1.1"
+ Project = "{E3482030-5828-4112-9906-D4C5153DCE3F}"
Package = "{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}"
/>
<Reference
- Name = "NHibernate.DomainModel-1.1"
- Project = "{E3482030-5828-4112-9906-D4C5153DCE3F}"
+ Name = "NHibernate.Test-1.1"
+ Project = "{F6CDD71A-FDCA-43F1-A5FF-B2941224A66F}"
Package = "{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}"
/>
</References>

0 comments on commit 4220dda

Please sign in to comment.
Something went wrong with that request. Please try again.