Skip to content
Browse files

Remove .NET 1.1 conditional code

Additional attributes
Moved Index/Store to Attributes, possible breaking change.
Some more interfaces from Hibernate Search 

SVN: branches/1.2.x@3181
  • Loading branch information...
1 parent 4220dda commit fbcea31274674127b2b82d3d260787b9f4b11b7b @phatcher phatcher committed Dec 17, 2007
Showing with 2,110 additions and 2,478 deletions.
  1. +189 −204 src/NHibernate.Search.Tests/Bridge/Cloud.cs
  2. +0 −4 src/NHibernate.Search.Tests/DirectoryProvider/FSSlaveAndMasterDPTest.cs
  3. +1 −20 src/NHibernate.Search.Tests/DirectoryProvider/MultiplySessionFactoriesTestCase.cs
  4. +63 −67 src/NHibernate.Search.Tests/FileHleperTestCase.cs
  5. +0 −10 src/NHibernate.Search/AttributeUtil.cs
  6. +19 −0 src/NHibernate.Search/Attributes/ContainedInAttribute.cs
  7. +34 −0 src/NHibernate.Search/Attributes/Index.cs
  8. +1 −2 src/NHibernate.Search/Attributes/IndexedEmbedded.cs
  9. +12 −0 src/NHibernate.Search/Attributes/Store.cs
  10. +0 −11 src/NHibernate.Search/Backend/IBackendQueueProcessorFactory.cs
  11. +0 −18 src/NHibernate.Search/Backend/IQueueingProcessor.cs
  12. +0 −17 src/NHibernate.Search/Backend/Impl/BatchedQueueingProcessor.cs
  13. +0 −26 src/NHibernate.Search/Backend/Impl/Lucene/LuceneBackendQueueProcessor.cs
  14. +0 −10 src/NHibernate.Search/Backend/Impl/Lucene/LuceneBackendQueueProcessorFactory.cs
  15. +99 −0 src/NHibernate.Search/Backend/LuceneIndexingParameters.cs
  16. +149 −171 src/NHibernate.Search/Backend/Workspace.cs
  17. +0 −30 src/NHibernate.Search/Bridge/BridgeFactory.cs
  18. +0 −8 src/NHibernate.Search/Bridge/IFieldBridge.cs
  19. +0 −4 src/NHibernate.Search/Bridge/ITwoWayFieldBridge.cs
  20. +2 −16 src/NHibernate.Search/Bridge/String2FieldBridgeAdaptor.cs
  21. +0 −4 src/NHibernate.Search/Bridge/TwoWayString2FieldBridgeAdaptor.cs
  22. +105 −119 src/NHibernate.Search/DirectoryProviderHelper.cs
  23. +21 −180 src/NHibernate.Search/Engine/DocumentBuilder.cs
  24. +13 −0 src/NHibernate.Search/Engine/ISearchFactoryImplementor.cs
  25. +16 −48 src/NHibernate.Search/Engine/SearchFactory.cs
  26. +0 −6 src/NHibernate.Search/IFullTextSession.cs
  27. +39 −0 src/NHibernate.Search/ISearchFactory.cs
  28. +336 −350 src/NHibernate.Search/Impl/FullTextSessionImpl.cs
  29. +0 −24 src/NHibernate.Search/Impl/SearchInterceptor.cs
  30. +0 −10 src/NHibernate.Search/Index.cs
  31. +44 −53 src/NHibernate.Search/LuceneQueryExpression.cs
  32. +7 −3 src/NHibernate.Search/NHibernate.Search-2.0.csproj
  33. +213 −237 src/NHibernate.Search/Query/FullTextQueryImpl.cs
  34. +89 −120 src/NHibernate.Search/Query/FullTextSearchHelper.cs
  35. +10 −0 src/NHibernate.Search/Reader/IReaderProvider.cs
  36. +0 −9 src/NHibernate.Search/Store.cs
  37. +108 −118 src/NHibernate.Search/Store/DirectoryProviderFactory.cs
  38. +48 −49 src/NHibernate.Search/Store/FSDirectoryProvider.cs
  39. +160 −170 src/NHibernate.Search/Store/FSMasterDirectoryProvider.cs
  40. +235 −249 src/NHibernate.Search/Store/FSSlaveDirectoryProvider.cs
  41. +43 −54 src/NHibernate.Search/Store/FileHelper.cs
  42. +5 −6 src/NHibernate.Search/Store/IDirectoryProvider.cs
  43. +49 −51 src/NHibernate.Search/Store/RAMDirectoryProvider.cs
View
393 src/NHibernate.Search.Tests/Bridge/Cloud.cs
@@ -3,208 +3,193 @@
namespace NHibernate.Search.Tests.Bridge
{
- [Indexed]
- public class Cloud
- {
- private int id;
-#if NET_2_0
- private long? long1;
- private int? int1;
- private double? double1;
- 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;
- private DateTime? dateTimeDay;
- private DateTime? dateTimeHour;
- private DateTime? dateTimeMinute;
- private DateTime? dateTimeSecond;
- private DateTime? dateTimeMillisecond;
-#endif
- private String customFieldBridge;
- private String customStringBridge;
- private CloudType type;
- private bool storm;
-
- [Field(Index.Tokenized, Store = Store.Yes)]
- [FieldBridge(typeof (TruncateFieldBridge))]
- public virtual string CustomFieldBridge
- {
- get { return customFieldBridge; }
- set { this.customFieldBridge = value; }
- }
-
- [Field(Index.Tokenized, Store = Store.Yes)]
- [FieldBridge(typeof (TruncateStringBridge), 4)]
- public virtual string CustomStringBridge
- {
- get { return customStringBridge; }
- set { this.customStringBridge = value; }
- }
-
- [DocumentId]
- public virtual int Id
- {
- get { return id; }
- set { this.id = value; }
- }
-
-#if NET_2_0
- [Field(Index.UnTokenized, Store = Store.Yes)]
- public virtual long? Long1
- {
- get { return long1; }
- set { this.long1 = value; }
- }
-
- [Field(Index.UnTokenized, Store = Store.Yes)]
- public virtual int? Int1
- {
- get { return int1; }
- set { this.int1 = value; }
- }
-
- [Field(Index.UnTokenized, Store = Store.Yes)]
- public virtual double? Double1
- {
- get { return double1; }
- set { this.double1 = value; }
- }
-
- [Field(Index.UnTokenized, Store = Store.Yes)]
- public virtual float? Float1
- {
- get { return float1; }
- set { this.float1 = value; }
- }
-#endif
-
- [Field(Index.UnTokenized, Store = Store.Yes)]
- public virtual long Long2
- {
- get { return long2; }
- set { this.long2 = value; }
- }
-
- [Field(Index.UnTokenized, Store = Store.Yes)]
- public virtual int Int2
- {
- get { return int2; }
- set { this.int2 = value; }
- }
-
- [Field(Index.UnTokenized, Store = Store.Yes)]
- public virtual double Double2
- {
- get { return double2; }
- set { this.double2 = value; }
- }
-
- [Field(Index.UnTokenized, Store = Store.Yes)]
- public virtual float Float2
- {
- get { return float2; }
- set { this.float2 = value; }
- }
-
- [Field(Index.Tokenized, Store = Store.Yes)]
- public virtual string String1
- {
- get { return string1; }
- set { this.string1 = value; }
- }
-
-#if NET_2_0
- [Field(Index.UnTokenized, Store = Store.Yes)]
- public virtual DateTime? DateTime
- {
- get { return dateTime; }
- set { this.dateTime = value; }
- }
-
- [Field(Index.UnTokenized, Store = Store.Yes)]
- [DateBridge(Resolution.Year)]
- public virtual DateTime? DateTimeYear
- {
- get { return dateTimeYear; }
- set { this.dateTimeYear = value; }
- }
-
-
- [Field(Index.UnTokenized, Store = Store.Yes)]
- [DateBridge(Resolution.Month)]
- public virtual DateTime? DateTimeMonth
- {
- get { return dateTimeMonth; }
- set { this.dateTimeMonth = value; }
- }
-
-
- [Field(Index.UnTokenized, Store = Store.Yes)]
- [DateBridge(Resolution.Day)]
- public virtual DateTime? DateTimeDay
- {
- get { return dateTimeDay; }
- set { this.dateTimeDay = value; }
- }
-
-
- [Field(Index.UnTokenized, Store = Store.Yes)]
- [DateBridge(Resolution.Hour)]
- public virtual DateTime? DateTimeHour
- {
- get { return dateTimeHour; }
- set { this.dateTimeHour = value; }
- }
-
-
- [Field(Index.UnTokenized, Store = Store.Yes)]
- [DateBridge(Resolution.Minute)]
- public virtual DateTime? DateTimeMinute
- {
- get { return dateTimeMinute; }
- set { this.dateTimeMinute = value; }
- }
-
-
- [Field(Index.UnTokenized, Store = Store.Yes)]
- [DateBridge(Resolution.Second)]
- public virtual DateTime? DateTimeSecond
- {
- get { return dateTimeSecond; }
- set { this.dateTimeSecond = value; }
- }
-
-
- [Field(Index.UnTokenized, Store = Store.Yes)]
- [DateBridge(Resolution.Millisecond)]
- public virtual DateTime? DateTimeMillisecond
- {
- get { return dateTimeMillisecond; }
- set { this.dateTimeMillisecond = value; }
- }
-#endif
-
- [Field(Index.Tokenized)]
- public virtual CloudType Type
- {
- get { return type; }
- set { this.type = value; }
- }
-
-
- [Field(Index.Tokenized)]
- public virtual bool Storm
- {
- get { return storm; }
- set { this.storm = value; }
- }
- }
+ [Indexed]
+ public class Cloud
+ {
+ private int id;
+ private long? long1;
+ private int? int1;
+ private double? double1;
+ private float? float1;
+ private long long2;
+ private double double2;
+ private float float2;
+ private int int2;
+ private string string1;
+ private DateTime? dateTime;
+ private DateTime? dateTimeYear;
+ private DateTime? dateTimeMonth;
+ private DateTime? dateTimeDay;
+ private DateTime? dateTimeHour;
+ private DateTime? dateTimeMinute;
+ private DateTime? dateTimeSecond;
+ private DateTime? dateTimeMillisecond;
+ private String customFieldBridge;
+ private String customStringBridge;
+ private CloudType type;
+ private bool storm;
+
+ [Field(Index.Tokenized, Store = Store.Yes)]
+ [FieldBridge(typeof(TruncateFieldBridge))]
+ public virtual string CustomFieldBridge
+ {
+ get { return customFieldBridge; }
+ set { customFieldBridge = value; }
+ }
+
+ [Field(Index.Tokenized, Store = Store.Yes)]
+ [FieldBridge(typeof(TruncateStringBridge), 4)]
+ public virtual string CustomStringBridge
+ {
+ get { return customStringBridge; }
+ set { customStringBridge = value; }
+ }
+
+ [DocumentId]
+ public virtual int Id
+ {
+ get { return id; }
+ set { id = value; }
+ }
+
+ [Field(Index.UnTokenized, Store = Store.Yes)]
+ public virtual long? Long1
+ {
+ get { return long1; }
+ set { long1 = value; }
+ }
+
+ [Field(Index.UnTokenized, Store = Store.Yes)]
+ public virtual int? Int1
+ {
+ get { return int1; }
+ set { int1 = value; }
+ }
+
+ [Field(Index.UnTokenized, Store = Store.Yes)]
+ public virtual double? Double1
+ {
+ get { return double1; }
+ set { double1 = value; }
+ }
+
+ [Field(Index.UnTokenized, Store = Store.Yes)]
+ public virtual float? Float1
+ {
+ get { return float1; }
+ set { float1 = value; }
+ }
+
+ [Field(Index.UnTokenized, Store = Store.Yes)]
+ public virtual long Long2
+ {
+ get { return long2; }
+ set { long2 = value; }
+ }
+
+ [Field(Index.UnTokenized, Store = Store.Yes)]
+ public virtual int Int2
+ {
+ get { return int2; }
+ set { int2 = value; }
+ }
+
+ [Field(Index.UnTokenized, Store = Store.Yes)]
+ public virtual double Double2
+ {
+ get { return double2; }
+ set { double2 = value; }
+ }
+
+ [Field(Index.UnTokenized, Store = Store.Yes)]
+ public virtual float Float2
+ {
+ get { return float2; }
+ set { float2 = value; }
+ }
+
+ [Field(Index.Tokenized, Store = Store.Yes)]
+ public virtual string String1
+ {
+ get { return string1; }
+ set { string1 = value; }
+ }
+
+ [Field(Index.UnTokenized, Store = Store.Yes)]
+ public virtual DateTime? DateTime
+ {
+ get { return dateTime; }
+ set { dateTime = value; }
+ }
+
+ [Field(Index.UnTokenized, Store = Store.Yes)]
+ [DateBridge(Resolution.Year)]
+ public virtual DateTime? DateTimeYear
+ {
+ get { return dateTimeYear; }
+ set { dateTimeYear = value; }
+ }
+
+ [Field(Index.UnTokenized, Store = Store.Yes)]
+ [DateBridge(Resolution.Month)]
+ public virtual DateTime? DateTimeMonth
+ {
+ get { return dateTimeMonth; }
+ set { dateTimeMonth = value; }
+ }
+
+ [Field(Index.UnTokenized, Store = Store.Yes)]
+ [DateBridge(Resolution.Day)]
+ public virtual DateTime? DateTimeDay
+ {
+ get { return dateTimeDay; }
+ set { dateTimeDay = value; }
+ }
+
+ [Field(Index.UnTokenized, Store = Store.Yes)]
+ [DateBridge(Resolution.Hour)]
+ public virtual DateTime? DateTimeHour
+ {
+ get { return dateTimeHour; }
+ set { dateTimeHour = value; }
+ }
+
+ [Field(Index.UnTokenized, Store = Store.Yes)]
+ [DateBridge(Resolution.Minute)]
+ public virtual DateTime? DateTimeMinute
+ {
+ get { return dateTimeMinute; }
+ set { dateTimeMinute = value; }
+ }
+
+ [Field(Index.UnTokenized, Store = Store.Yes)]
+ [DateBridge(Resolution.Second)]
+ public virtual DateTime? DateTimeSecond
+ {
+ get { return dateTimeSecond; }
+ set { dateTimeSecond = value; }
+ }
+
+ [Field(Index.UnTokenized, Store = Store.Yes)]
+ [DateBridge(Resolution.Millisecond)]
+ public virtual DateTime? DateTimeMillisecond
+ {
+ get { return dateTimeMillisecond; }
+ set { dateTimeMillisecond = value; }
+ }
+
+ [Field(Index.Tokenized)]
+ public virtual CloudType Type
+ {
+ get { return type; }
+ set { type = value; }
+ }
+
+ [Field(Index.Tokenized)]
+ public virtual bool Storm
+ {
+ get { return storm; }
+ set { storm = value; }
+ }
+ }
}
View
4 src/NHibernate.Search.Tests/DirectoryProvider/FSSlaveAndMasterDPTest.cs
@@ -106,11 +106,7 @@ 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
21 src/NHibernate.Search.Tests/DirectoryProvider/MultiplySessionFactoriesTestCase.cs
@@ -1,7 +1,5 @@
using System.Collections;
-#if NET_2_0
using System.Collections.Generic;
-#endif
using System.Reflection;
using NHibernate.Cfg;
using NHibernate.Tool.hbm2ddl;
@@ -11,21 +9,12 @@ namespace NHibernate.Search.Tests.DirectoryProvider
{
public abstract class MultiplySessionFactoriesTestCase
{
-#if NET_2_0
- private List<ISessionFactory> sessionFactories = new List<ISessionFactory>();
+ private readonly 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; }
}
@@ -58,11 +47,7 @@ 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());
@@ -82,11 +67,7 @@ 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
130 src/NHibernate.Search.Tests/FileHleperTestCase.cs
@@ -1,82 +1,78 @@
using System;
-#if NET_2_0
-using System.Collections.Generic;
-#endif
using System.IO;
-using System.Text;
using System.Threading;
using NHibernate.Search.Storage;
using NUnit.Framework;
namespace NHibernate.Search.Tests
{
- [TestFixture]
- public class FileHleperTestCase
- {
- [SetUp]
- public void SetUp()
- {
- DirectoryInfo dir = new DirectoryInfo("./filehelpersrc");
- dir.Create();
- WriteFile(dir, "a");
- WriteFile(dir, "b");
- dir = new DirectoryInfo(Path.Combine(dir.FullName, "subdir"));
- dir.Create();
- WriteFile(dir, "c");
- }
+ [TestFixture]
+ public class FileHleperTestCase
+ {
+ [SetUp]
+ public void SetUp()
+ {
+ DirectoryInfo dir = new DirectoryInfo("./filehelpersrc");
+ dir.Create();
+ WriteFile(dir, "a");
+ WriteFile(dir, "b");
+ dir = new DirectoryInfo(Path.Combine(dir.FullName, "subdir"));
+ dir.Create();
+ WriteFile(dir, "c");
+ }
- private void WriteFile(DirectoryInfo dir, String name)
- {
- FileInfo a = new FileInfo(Path.Combine(dir.FullName, name));
- StreamWriter os = a.CreateText();
- os.WriteLine(1);
- os.WriteLine(2);
- os.WriteLine(3);
- os.Flush();
- os.Close();
- }
+ private static void WriteFile(DirectoryInfo dir, String name)
+ {
+ FileInfo a = new FileInfo(Path.Combine(dir.FullName, name));
+ StreamWriter os = a.CreateText();
+ os.WriteLine(1);
+ os.WriteLine(2);
+ os.WriteLine(3);
+ os.Flush();
+ os.Close();
+ }
- [TearDown]
- protected void TearDown()
- {
- DirectoryInfo dir = new DirectoryInfo("./filehelpersrc");
- dir.Delete(true);
- dir = new DirectoryInfo("./filehelperdest");
- dir.Delete(true);
- }
+ [TearDown]
+ protected void TearDown()
+ {
+ DirectoryInfo dir = new DirectoryInfo("./filehelpersrc");
+ dir.Delete(true);
+ dir = new DirectoryInfo("./filehelperdest");
+ dir.Delete(true);
+ }
- [Test]
- public void Synchronize()
- {
- DirectoryInfo src = new DirectoryInfo("./filehelpersrc");
- DirectoryInfo dest = new DirectoryInfo("./filehelperdest");
- FileHelper.Synchronize(src, dest, true);
- Assert.IsTrue(File.Exists(Path.Combine(dest.FullName, "b")));
+ [Test]
+ public void Synchronize()
+ {
+ DirectoryInfo src = new DirectoryInfo("./filehelpersrc");
+ DirectoryInfo dest = new DirectoryInfo("./filehelperdest");
+ FileHelper.Synchronize(src, dest, true);
+ Assert.IsTrue(File.Exists(Path.Combine(dest.FullName, "b")));
- string path = Path.Combine(dest.FullName, Path.Combine("subdir", "c"));
- Assert.IsTrue(File.Exists(path));
+ string path = Path.Combine(dest.FullName, Path.Combine("subdir", "c"));
+ Assert.IsTrue(File.Exists(path));
- //change
- Thread.Sleep(2*2000);
- StreamWriter os = File.CreateText(Path.Combine(src.FullName, "c"));
- os.WriteLine(1);
- os.WriteLine(2);
- os.WriteLine(3);
- os.Flush();
- os.Close();
- FileInfo test = new FileInfo(Path.Combine(src.FullName, "c"));
- FileInfo destTest = new FileInfo(Path.Combine(dest.FullName, "c"));
- Assert.AreNotSame(test.LastWriteTime, destTest.LastWriteTime);
- FileHelper.Synchronize(src, dest, true);
- destTest.Refresh();
- Assert.AreEqual(test.LastWriteTime, destTest.LastWriteTime);
- Assert.AreEqual(test.Length, destTest.Length);
+ //change
+ Thread.Sleep(2*2000);
+ StreamWriter os = File.CreateText(Path.Combine(src.FullName, "c"));
+ os.WriteLine(1);
+ os.WriteLine(2);
+ os.WriteLine(3);
+ os.Flush();
+ os.Close();
+ FileInfo test = new FileInfo(Path.Combine(src.FullName, "c"));
+ FileInfo destTest = new FileInfo(Path.Combine(dest.FullName, "c"));
+ Assert.AreNotSame(test.LastWriteTime, destTest.LastWriteTime);
+ FileHelper.Synchronize(src, dest, true);
+ destTest.Refresh();
+ Assert.AreEqual(test.LastWriteTime, destTest.LastWriteTime);
+ Assert.AreEqual(test.Length, destTest.Length);
- //delete file
- test.Delete();
- FileHelper.Synchronize(src, dest, true);
- destTest.Refresh();
- Assert.IsTrue(! destTest.Exists);
- }
- }
+ //delete file
+ test.Delete();
+ FileHelper.Synchronize(src, dest, true);
+ destTest.Refresh();
+ Assert.IsTrue(! destTest.Exists);
+ }
+ }
}
View
10 src/NHibernate.Search/AttributeUtil.cs
@@ -33,12 +33,7 @@ public static DocumentIdAttribute GetDocumentId(MemberInfo member)
if (objects.Length == 0)
return null;
DocumentIdAttribute documentIdAttribute = (DocumentIdAttribute) objects[0];
-#if NET_2_0
documentIdAttribute.Name = documentIdAttribute.Name ?? member.Name;
-#else
- if (documentIdAttribute.Name == null)
- documentIdAttribute.Name = member.Name;
-#endif
return documentIdAttribute;
}
@@ -48,12 +43,7 @@ public static FieldAttribute GetField(MemberInfo member)
if (objects.Length == 0)
return null;
FieldAttribute fieldAttribute = (FieldAttribute) objects[0];
-#if NET_2_0
fieldAttribute.Name = fieldAttribute.Name ?? member.Name;
-#else
- if (fieldAttribute.Name == null)
- fieldAttribute.Name = member.Name;
-#endif
return fieldAttribute;
}
View
19 src/NHibernate.Search/Attributes/ContainedInAttribute.cs
@@ -0,0 +1,19 @@
+using System;
+
+namespace NHibernate.Search.Attributes
+{
+ /// <summary>
+ /// Describe the owning entity as being part of the target entity's
+ /// index (to be more accurate, being part of the indexed object graph)
+ ///
+ /// Only necessary when an @Indexed class is used as a <see cref="IndexedEmbeddedAttribute" />
+ /// target class. ContainedIn must mark the property pointing back
+ /// to the IndexedEmbedded owning Entity
+ ///
+ /// Not necessary if the class is an Embeddable class.
+ /// </summary>
+ [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = false)]
+ public class ContainedInAttribute : Attribute
+ {
+ }
+}
View
34 src/NHibernate.Search/Attributes/Index.cs
@@ -0,0 +1,34 @@
+namespace NHibernate.Search.Attributes
+{
+ /// <summary>
+ /// The choices of how to index a field
+ /// </summary>
+ public enum Index
+ {
+ /// <summary>
+ /// Index the field's value without an Analyzer, and disable
+ /// the storing of norms. No norms means that index-time boosting
+ /// and field length normalization will be disabled. The benefit is
+ /// less memory usage as norms take up one byte per indexed field
+ /// for every document in the index.
+ /// </summary>
+ NoNormalization,
+ /// <summary>
+ /// Do not index the field value. This field can thus not be searched,
+ /// but one can still access its contents provided it is
+ /// </summary>
+ No,
+ /// <summary>
+ /// Index the field's value so it can be searched. An Analyzer will be used
+ /// to tokenize and possibly further normalize the text before its
+ /// terms will be stored in the index. This is useful for common text.
+ /// </summary>
+ Tokenized,
+ /// <summary>
+ /// Index the field's value without using an Analyzer, so it can be searched.
+ /// As no analyzer is used the value will be stored as a single term. This is
+ /// useful for unique Ids like product numbers.
+ /// </summary>
+ UnTokenized
+ }
+}
View
3 src/NHibernate.Search/Attributes/IndexedEmbedded.cs
@@ -1,5 +1,4 @@
using System;
-using System.Text;
namespace NHibernate.Search.Attributes
{
@@ -10,4 +9,4 @@ namespace NHibernate.Search.Attributes
public class IndexedEmbeddedAttribute : Attribute
{
}
-}
+}
View
12 src/NHibernate.Search/Attributes/Store.cs
@@ -0,0 +1,12 @@
+namespace NHibernate.Search.Attributes
+{
+ /// <summary>
+ /// Whether or not the value is stored in the document
+ /// </summary>
+ public enum Store
+ {
+ Yes,
+ No,
+ Compress
+ }
+}
View
11 src/NHibernate.Search/Backend/IBackendQueueProcessorFactory.cs
@@ -1,7 +1,5 @@
using System.Collections;
-#if NET_2_0
using System.Collections.Generic;
-#endif
using System.Threading;
namespace NHibernate.Search.Backend
@@ -15,20 +13,11 @@ 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,8 +1,4 @@
-#if NET_2_0
using System.Collections.Generic;
-#else
-using System.Collections;
-#endif
namespace NHibernate.Search.Backend
{
@@ -13,7 +9,6 @@ namespace NHibernate.Search.Backend
/// </summary>
public interface IQueueingProcessor
{
-#if NET_2_0
/// <summary>
/// Performs all the work in the queue
/// </summary>
@@ -25,18 +20,5 @@ 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
17 src/NHibernate.Search/Backend/Impl/BatchedQueueingProcessor.cs
@@ -1,8 +1,6 @@
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;
@@ -25,19 +23,12 @@ 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];
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();
}
@@ -60,11 +51,7 @@ 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)
@@ -77,11 +64,7 @@ public void PerformWork(IList luceneQueue)
}
}
-#if NET_2_0
public void CancelWork(List<LuceneWork> queue)
-#else
- public void CancelWork(IList queue)
-#endif
{
queue.Clear();
}
View
26 src/NHibernate.Search/Backend/Impl/Lucene/LuceneBackendQueueProcessor.cs
@@ -1,9 +1,5 @@
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
@@ -15,7 +11,6 @@ public class LuceneBackendQueueProcessor
{
private readonly SearchFactory searchFactory;
-#if NET_2_0
private readonly List<LuceneWork> queue;
public LuceneBackendQueueProcessor(List<LuceneWork> queue, SearchFactory searchFactory)
@@ -44,27 +39,6 @@ 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)
{
View
10 src/NHibernate.Search/Backend/Impl/Lucene/LuceneBackendQueueProcessorFactory.cs
@@ -1,7 +1,5 @@
using System.Collections;
-#if NET_2_0
using System.Collections.Generic;
-#endif
using System.Threading;
namespace NHibernate.Search.Backend.Impl.Lucene
@@ -15,17 +13,9 @@ 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
99 src/NHibernate.Search/Backend/LuceneIndexingParameters.cs
@@ -0,0 +1,99 @@
+namespace NHibernate.Search.Backend
+{
+ /// <summary>
+ /// Wrapper class around the Lucene indexing parameters <i>mergeFactor</i>, <i>maxMergeDocs</i> and
+ /// <i>maxBufferedDocs</i>.
+ /// <p>
+ /// There are two sets of these parameters. One is for regular indexing the other is for batch indexing
+ /// triggered by <code>FullTextSessoin.index(Object entity)</code>
+ /// </summary>
+ public class LuceneIndexingParameters
+ {
+ private int transactionMergeFactor = 10;
+ private int transactionMaxMergeDocs = int.MaxValue;
+ private int transactionMaxBufferedDocs = 10;
+ private int batchMergeFactor = 10;
+ private int batchMaxMergeDocs = int.MinValue;
+ private int batchMaxBufferedDocs = 10;
+
+ // the defaults settings
+ private const int DEFAULT_MERGE_FACTOR = 10;
+ private const int DEFAULT_MAX_MERGE_DOCS = int.MinValue;
+ private const int DEFAULT_MAX_BUFFERED_DOCS = 10;
+
+ #region Constructors
+
+ /// <summary>
+ /// Constructor which instantiates a new parameter object with the the default values.
+ /// </summary>
+ public LuceneIndexingParameters()
+ {
+ transactionMergeFactor = DEFAULT_MERGE_FACTOR;
+ batchMergeFactor = DEFAULT_MERGE_FACTOR;
+ transactionMaxMergeDocs = DEFAULT_MAX_MERGE_DOCS;
+ batchMaxMergeDocs = DEFAULT_MAX_MERGE_DOCS;
+ transactionMaxBufferedDocs = DEFAULT_MAX_BUFFERED_DOCS;
+ batchMaxBufferedDocs = DEFAULT_MAX_BUFFERED_DOCS;
+ }
+
+ #endregion
+
+ #region Property methods
+
+ /// <summary>
+ ///
+ /// </summary>
+ public int TransactionMaxMergeDocs
+ {
+ get { return transactionMaxMergeDocs; }
+ set { transactionMaxMergeDocs = value; }
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ public int TransactionMergeFactor
+ {
+ get { return transactionMergeFactor; }
+ set { transactionMergeFactor = value; }
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ public int BatchMaxMergeDocs
+ {
+ get { return batchMaxMergeDocs; }
+ set { batchMaxMergeDocs = value; }
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ public int BatchMergeFactor
+ {
+ get { return batchMergeFactor; }
+ set { batchMergeFactor = value; }
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ public int BatchMaxBufferedDocs
+ {
+ get { return batchMaxBufferedDocs; }
+ set { batchMaxBufferedDocs = value; }
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ public int TransactionMaxBufferedDocs
+ {
+ get { return transactionMaxBufferedDocs; }
+ set { transactionMaxBufferedDocs = value; }
+ }
+
+ #endregion
+ }
+}
View
320 src/NHibernate.Search/Backend/Workspace.cs
@@ -1,9 +1,5 @@
using System;
-#if NET_2_0
using System.Collections.Generic;
-#else
-using System.Collections;
-#endif
using System.IO;
using System.Threading;
using log4net;
@@ -14,179 +10,161 @@
namespace NHibernate.Search.Impl
{
//TODO introduce the notion of read only IndexReader? We cannot enforce it because Lucene use abstract classes, not interfaces
- /// <summary>
- /// Lucene workspace
- /// This is not intended to be used in a multithreaded environment
- /// <p/>
- /// One cannot execute modification through an IndexReader when an IndexWriter has been acquired on the same underlying directory
- /// One cannot get an IndexWriter when an IndexReader have been acquired and modificed on the same underlying directory
- /// The recommended approach is to execute all the modifications on the IndexReaders, {@link #Dispose()} }, and acquire the
- /// index writers
- /// </summary>
- 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;
+ /// <summary>
+ /// Lucene workspace
+ /// This is not intended to be used in a multithreaded environment
+ /// <p/>
+ /// One cannot execute modification through an IndexReader when an IndexWriter has been acquired on the same underlying directory
+ /// One cannot get an IndexWriter when an IndexReader have been acquired and modificed on the same underlying directory
+ /// The recommended approach is to execute all the modifications on the IndexReaders, {@link #Dispose()} }, and acquire the
+ /// index writers
+ /// </summary>
+ public class Workspace : IDisposable
+ {
+ private static readonly ILog log = LogManager.GetLogger(typeof(Workspace));
- public Workspace(SearchFactory searchFactory)
- {
- this.searchFactory = searchFactory;
- }
+ private readonly Dictionary<IDirectoryProvider, IndexReader> readers = new Dictionary<IDirectoryProvider, IndexReader>();
+ private readonly Dictionary<IDirectoryProvider, IndexWriter> writers = new Dictionary<IDirectoryProvider, IndexWriter>();
+ private readonly List<IDirectoryProvider> lockedProviders = new List<IDirectoryProvider>();
+ private readonly SearchFactory searchFactory;
+ public Workspace(SearchFactory searchFactory)
+ {
+ this.searchFactory = searchFactory;
+ }
- public DocumentBuilder GetDocumentBuilder(System.Type entity)
- {
- return searchFactory.GetDocumentBuilder(entity);
- }
+ public DocumentBuilder GetDocumentBuilder(System.Type entity)
+ {
+ return searchFactory.GetDocumentBuilder(entity);
+ }
- public IndexReader GetIndexReader(System.Type entity)
- {
- //TODO NPEs
- IDirectoryProvider provider = searchFactory.GetDirectoryProvider(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 = 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
- {
- reader = IndexReader.Open(provider.Directory);
- readers.Add(provider, reader);
- }
- catch (IOException e)
- {
- CleanUp(new SearchException("Unable to open IndexReader for " + entity, e));
- }
- return reader;
- }
+ public IndexReader GetIndexReader(System.Type entity)
+ {
+ //TODO NPEs
+ IDirectoryProvider provider = searchFactory.GetDirectoryProvider(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 = null;
+ readers.TryGetValue(provider, out reader);
- 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 = null;
-#if NET_2_0
- readers.TryGetValue(provider, out reader);
-#else
- if (readers.ContainsKey(provider))
- reader = (IndexReader) readers[provider];
-#endif
- if (reader != null)
- {
- try
- {
- reader.Close();
- }
- catch (IOException e)
- {
- throw new SearchException("Exception while closing IndexReader", e);
- }
- readers.Remove(provider);
- }
- 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
- {
- writer = new IndexWriter(
- provider.Directory, searchFactory.GetDocumentBuilder(entity).Analyzer, false
- ); //have been created at init time
- writers.Add(provider, writer);
- }
- catch (IOException e)
- {
- CleanUp(new SearchException("Unable to open IndexWriter for " + entity, e));
- }
- return writer;
- }
+ if (reader != null) return reader;
+ LockProvider(provider);
+ try
+ {
+ reader = IndexReader.Open(provider.Directory);
+ readers.Add(provider, reader);
+ }
+ catch (IOException e)
+ {
+ CleanUp(new SearchException("Unable to open IndexReader for " + entity, e));
+ }
+ return reader;
+ }
- private void LockProvider(IDirectoryProvider provider)
- {
- //make sure to use a semaphore
- object syncLock = searchFactory.GetLockObjForDirectoryProvider(provider);
- Monitor.Enter(syncLock);
- lockedProviders.Add(provider);
- }
+ 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 = null;
+ readers.TryGetValue(provider, out reader);
- private void CleanUp(SearchException originalException)
- {
- //release all readers and writers, then release locks
- SearchException raisedException = originalException;
- foreach (IndexReader reader in readers.Values)
- {
- try
- {
- reader.Close();
- }
- catch (IOException e)
- {
- if (raisedException != null)
- {
- log.Error("Subsequent Exception while closing IndexReader", e);
- }
- else
- {
- raisedException = new SearchException("Exception while closing IndexReader", e);
- }
- }
- }
- foreach (IndexWriter writer in writers.Values)
- {
- try
- {
- writer.Close();
- }
- catch (IOException e)
- {
- if (raisedException != null)
- {
- log.Error("Subsequent Exception while closing IndexWriter", e);
- }
- else
- {
- raisedException = new SearchException("Exception while closing IndexWriter", e);
- }
- }
- }
- foreach (IDirectoryProvider provider in lockedProviders)
- {
- object syncLock = searchFactory.GetLockObjForDirectoryProvider(provider);
- Monitor.Exit(syncLock);
- }
- readers.Clear();
- writers.Clear();
- lockedProviders.Clear();
- if (raisedException != null) throw raisedException;
- }
+ if (reader != null)
+ {
+ try
+ {
+ reader.Close();
+ }
+ catch (IOException e)
+ {
+ throw new SearchException("Exception while closing IndexReader", e);
+ }
+ readers.Remove(provider);
+ }
+ IndexWriter writer;
+ writers.TryGetValue(provider, out writer);
- /// <summary>
- /// release resources consumed in the workspace if any
- /// </summary>
- public void Dispose()
- {
- CleanUp(null);
- }
- }
+ if (writer != null) return writer;
+ LockProvider(provider);
+ try
+ {
+ writer = new IndexWriter(
+ provider.Directory, searchFactory.GetDocumentBuilder(entity).Analyzer, false
+ ); //have been created at init time
+ writers.Add(provider, writer);
+ }
+ catch (IOException e)
+ {
+ CleanUp(new SearchException("Unable to open IndexWriter for " + entity, e));
+ }
+ return writer;
+ }
+
+ private void LockProvider(IDirectoryProvider provider)
+ {
+ //make sure to use a semaphore
+ object syncLock = searchFactory.GetLockObjForDirectoryProvider(provider);
+ Monitor.Enter(syncLock);
+ lockedProviders.Add(provider);
+ }
+
+ private void CleanUp(SearchException originalException)
+ {
+ //release all readers and writers, then release locks
+ SearchException raisedException = originalException;
+ foreach (IndexReader reader in readers.Values)
+ {
+ try
+ {
+ reader.Close();
+ }
+ catch (IOException e)
+ {
+ if (raisedException != null)
+ {
+ log.Error("Subsequent Exception while closing IndexReader", e);
+ }
+ else
+ {
+ raisedException = new SearchException("Exception while closing IndexReader", e);
+ }
+ }
+ }
+ foreach (IndexWriter writer in writers.Values)
+ {
+ try
+ {
+ writer.Close();
+ }
+ catch (IOException e)
+ {
+ if (raisedException != null)
+ {
+ log.Error("Subsequent Exception while closing IndexWriter", e);
+ }
+ else
+ {
+ raisedException = new SearchException("Exception while closing IndexWriter", e);
+ }
+ }
+ }
+ foreach (IDirectoryProvider provider in lockedProviders)
+ {
+ object syncLock = searchFactory.GetLockObjForDirectoryProvider(provider);
+ Monitor.Exit(syncLock);
+ }
+ readers.Clear();
+ writers.Clear();
+ lockedProviders.Clear();
+ if (raisedException != null) throw raisedException;
+ }
+
+ /// <summary>
+ /// release resources consumed in the workspace if any
+ /// </summary>
+ public void Dispose()
+ {
+ CleanUp(null);
+ }
+ }
}
View
30 src/NHibernate.Search/Bridge/BridgeFactory.cs
@@ -1,47 +1,26 @@
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;
using NHibernate.Search.Bridge.Builtin;
namespace NHibernate.Search.Bridge
{
-#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>();
-#else
- private static readonly Hashtable builtInBridges = new Hashtable();
-#endif
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 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);
@@ -111,13 +90,9 @@ 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(
@@ -132,12 +107,7 @@ public static IFieldBridge GuessType(MemberInfo member)
private static bool IsNullable(System.Type returnType)
{
-#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
8 src/NHibernate.Search/Bridge/IFieldBridge.cs
@@ -7,16 +7,8 @@ namespace NHibernate.Search.Bridge
/// <summary>
/// Put an object inside the document.
/// </summary>
-#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);
-#else
- void Set(string idKeywordName, object id, Document doc, Field.Store store, Field.Index index, float boost);
-#endif
}
}
View
4 src/NHibernate.Search/Bridge/ITwoWayFieldBridge.cs
@@ -4,10 +4,6 @@
namespace NHibernate.Search.Bridge
{
-#if NET_2_0
-#else
- [CLSCompliant(false)]
-#endif
public interface ITwoWayFieldBridge : IFieldBridge
{
object Get(string value, Document document);
View
18 src/NHibernate.Search/Bridge/String2FieldBridgeAdaptor.cs
@@ -1,14 +1,9 @@
using System;
using Lucene.Net.Documents;
-using NHibernate.Search.Bridge;
using NHibernate.Util;
namespace NHibernate.Search.Bridge
{
-#if NET_2_0
-#else
- [CLSCompliant(false)]
-#endif
public class String2FieldBridgeAdaptor : IFieldBridge
{
private readonly IStringBridge stringBridge;
@@ -18,25 +13,16 @@ public String2FieldBridgeAdaptor(IStringBridge stringBridge)
this.stringBridge = stringBridge;
}
-#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
+ public void Set(String name, Object value, Document document, Field.Store store, Field.Index index, float? boost)
{
String indexedString = stringBridge.ObjectToString(value);
//Do not add fields on empty strings, seems a sensible default in most situations
if (StringHelper.IsNotEmpty(indexedString))
{
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
- document.Add(field);
+ document.Add(field);
}
}
}
View
4 src/NHibernate.Search/Bridge/TwoWayString2FieldBridgeAdaptor.cs
@@ -3,10 +3,6 @@
namespace NHibernate.Search.Bridge
{
-#if NET_2_0
-#else
- [CLSCompliant(false)]
-#endif
public class TwoWayString2FieldBridgeAdaptor : String2FieldBridgeAdaptor, ITwoWayFieldBridge
{
private readonly ITwoWayStringBridge stringBridge;
View
224 src/NHibernate.Search/DirectoryProviderHelper.cs
@@ -1,133 +1,119 @@
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;
namespace NHibernate.Search
{
- public class DirectoryProviderHelper
- {
- private static ILog log = LogManager.GetLogger(typeof (DirectoryProviderHelper));
-
- /// <summary>
- /// Build a directory name out of a root and relative path, guessing the significant part
- /// and checking for the file availability
- /// </summary>
- public static String GetSourceDirectory(
- String rootPropertyName, String relativePropertyName,
- String directoryProviderName, IDictionary properties)
- {
- //TODO check that it's a directory
- String root = (string) properties[rootPropertyName];
- String relative = (string) properties[relativePropertyName];
- if (log.IsDebugEnabled)
- {
- log.Debug(
- "Guess source directory from " + rootPropertyName + " " + root != null
- ? root : "<null>" + " and " + relativePropertyName + " " + (relative != null ? relative: "<null>")
- );
- }
- if (relative == null) relative = directoryProviderName;
- if (StringHelper.IsEmpty(root))
- {
- log.Debug("No root directory, go with relative " + relative);
- DirectoryInfo sourceFile = new DirectoryInfo(relative);
- if (! sourceFile.Exists)
- {
- throw new HibernateException("Unable to read source directory: " + relative);
- }
- //else keep source as it
- }
- else
- {
- DirectoryInfo rootDir = new DirectoryInfo(root);
- if (rootDir.Exists)
- {
- DirectoryInfo sourceFile = new DirectoryInfo(Path.Combine(root, relative));
- if (! sourceFile.Exists) sourceFile.Create();
- log.Debug("Get directory from root + relative");
- try
- {
- relative = sourceFile.FullName;
- }
- catch (IOException e)
- {
- throw new AssertionFailure("Unable to get canonical path: " + root + " + " + relative);
- }
- }
- else
- {
- throw new SearchException(rootPropertyName + " does not exist");
- }
- }
- return relative;
- }
+ public class DirectoryProviderHelper
+ {
+ private static readonly ILog log = LogManager.GetLogger(typeof(DirectoryProviderHelper));
- public static DirectoryInfo DetermineIndexDir(String directoryProviderName, IDictionary properties)
- {
- 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);
- DirectoryInfo indexDir = new DirectoryInfo(indexBase);
- if (!(indexDir.Exists))
- {
- if(!createIfMissing)
- throw new HibernateException(String.Format("Index directory does not exists: {0}", indexBase));
- indexDir.Create();
- }
+ /// <summary>
+ /// Build a directory name out of a root and relative path, guessing the significant part
+ /// and checking for the file availability
+ /// </summary>
+ public static String GetSourceDirectory(
+ String rootPropertyName, String relativePropertyName,
+ String directoryProviderName, IDictionary properties)
+ {
+ //TODO check that it's a directory
+ String root = (string) properties[rootPropertyName];
+ String relative = (string) properties[relativePropertyName];
+ if (log.IsDebugEnabled)
+ {
+ log.Debug(
+ "Guess source directory from " + rootPropertyName + " " + root != null
+ ? root
+ : "<null>" + " and " + relativePropertyName + " " + (relative != null ? relative : "<null>")
+ );
+ }
+ if (relative == null) relative = directoryProviderName;
+ if (StringHelper.IsEmpty(root))
+ {
+ log.Debug("No root directory, go with relative " + relative);
+ DirectoryInfo sourceFile = new DirectoryInfo(relative);
+ if (! sourceFile.Exists)
+ {
+ throw new HibernateException("Unable to read source directory: " + relative);
+ }
+ //else keep source as it
+ }
+ else
+ {
+ DirectoryInfo rootDir = new DirectoryInfo(root);
+ if (rootDir.Exists)
+ {
+ DirectoryInfo sourceFile = new DirectoryInfo(Path.Combine(root, relative));
+ if (! sourceFile.Exists) sourceFile.Create();
+ log.Debug("Get directory from root + relative");
+ try
+ {
+ relative = sourceFile.FullName;
+ }
+ catch (IOException e)
+ {
+ throw new AssertionFailure("Unable to get canonical path: " + root + " + " + relative);
+ }
+ }
+ else
+ {
+ throw new SearchException(rootPropertyName + " does not exist");
+ }
+ }
+ return relative;
+ }
- if (!HasWriteAccess(indexDir))
- {
- throw new HibernateException("Cannot write into index directory: " + indexBase);
- }
+ public static DirectoryInfo DetermineIndexDir(String directoryProviderName, IDictionary properties)
+ {
+ bool createIfMissing;
+ string indexBase = (string) properties["indexBase"] ?? ".";
+ string shouldCreate = (string) properties["indexBase.create"] ?? "false";
+ bool.TryParse(shouldCreate, out createIfMissing);
- indexDir = new DirectoryInfo(Path.Combine(indexDir.FullName, directoryProviderName));
- return indexDir;
- }
+ //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);
+ DirectoryInfo indexDir = new DirectoryInfo(indexBase);
+ if (!(indexDir.Exists))
+ {
+ if (!createIfMissing)
+ throw new HibernateException(String.Format("Index directory does not exists: {0}", indexBase));
+ indexDir.Create();
+ }
- private static bool HasWriteAccess(DirectoryInfo indexDir)
- {
- string tempFileName = Path.Combine(indexDir.FullName, Guid.NewGuid().ToString());
- //Yuck! but it is the simplest way
- try
- {
- File.CreateText(tempFileName).Close();
- }
- catch (UnauthorizedAccessException)
- {
- return false;
- }
- try
- {
- File.Delete(tempFileName);
- }
- catch (UnauthorizedAccessException)
- {
- //we may have permissions to create but not delete, ignoring
- }
- return true;
- }
- }
+ if (!HasWriteAccess(indexDir))
+ {
+ throw new HibernateException("Cannot write into index directory: " + indexBase);
+ }
+
+ indexDir = new DirectoryInfo(Path.Combine(indexDir.FullName, directoryProviderName));
+ return indexDir;
+ }
+
+ private static bool HasWriteAccess(DirectoryInfo indexDir)
+ {
+ string tempFileName = Path.Combine(indexDir.FullName, Guid.NewGuid().ToString());
+ //Yuck! but it is the simplest way
+ try
+ {
+ File.CreateText(tempFileName).Close();
+ }
+ catch (UnauthorizedAccessException)
+ {
+ return false;
+ }
+ try
+ {
+ File.Delete(tempFileName);
+ }
+ catch (UnauthorizedAccessException)
+ {
+ //we may have permissions to create but not delete, ignoring
+ }
+ return true;
+ }
+ }
}
View
201 src/NHibernate.Search/Engine/DocumentBuilder.cs
@@ -1,34 +1,24 @@
using System;
-using System.Reflection;
-#if NET_2_0
using System.Collections.Generic;
+using System.Reflection;
using Iesi.Collections.Generic;
-#else
-using System.Collections;
-using Iesi.Collections;
-#endif
using log4net;
using Lucene.Net.Analysis;
using Lucene.Net.Documents;
using Lucene.Net.Index;
-using NHibernate.Mapping;
using NHibernate.Search.Attributes;
using NHibernate.Search.Backend;
using NHibernate.Search.Bridge;
using NHibernate.Search.Impl;
using NHibernate.Search.Storage;
using NHibernate.Util;
-using FieldInfo = System.Reflection.FieldInfo;
+using FieldInfo=System.Reflection.FieldInfo;
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));
@@ -39,36 +29,24 @@ public class DocumentBuilder
private String idKeywordName;
private MemberInfo idGetter;
private readonly Analyzer analyzer;
-#if NET_2_0
private float? idBoost;
-#else
- private float idBoost;
-#endif
public const string CLASS_FIELDNAME = "_hibernate_class";
private ITwoWayFieldBridge idBridge;
-#if NET_2_0
private ISet<System.Type> mappedSubclasses = new HashedSet<System.Type>();
-#else
- private ISet mappedSubclasses = new HashedSet();
-#endif
private int level = 0;
private int maxLevel = int.MaxValue;
public DocumentBuilder(System.Type clazz, Analyzer analyzer, IDirectoryProvider directory)
{
- this.beanClass = clazz;
+ beanClass = clazz;
this.analyzer = analyzer;
- this.directoryProvider = directory;
+ directoryProvider = directory;
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
@@ -79,36 +57,26 @@ public DocumentBuilder(System.Type clazz, Analyzer analyzer, IDirectoryProvider
}
}
-#if NET_2_0
private void InitializeMembers(
System.Type clazz, PropertiesMetadata propertiesMetadata, bool isRoot, String prefix,
Set<System.Type> processedClasses)
-#else
- private void InitializeMembers(
- System.Type clazz, PropertiesMetadata propertiesMetadata, bool isRoot, String prefix,
- ISet processedClasses)
-#endif
{
PropertyInfo[] propertyInfos = clazz.GetProperties();
foreach (PropertyInfo propertyInfo in propertyInfos)
{
InitializeMember(propertyInfo, propertiesMetadata, isRoot, prefix, processedClasses);
}
- System.Reflection.FieldInfo[] fields = clazz.GetFields(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance);
- foreach (System.Reflection.FieldInfo fieldInfo in fields)
+ FieldInfo[] fields = clazz.GetFields(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance);
+ foreach (FieldInfo fieldInfo in fields)
{
InitializeMember(fieldInfo, propertiesMetadata, isRoot, prefix, processedClasses);
}
}
private void InitializeMember(
MemberInfo member, PropertiesMetadata propertiesMetadata, bool isRoot,
-#if NET_2_0
String prefix, ISet<System.Type> processedClasses)
-#else
- String prefix, ISet processedClasses)
-#endif
{
DocumentIdAttribute documentIdAnn = AttributeUtil.GetDocumentId(member);
if (isRoot && documentIdAnn != null)
@@ -123,7 +91,7 @@ public DocumentBuilder(System.Type clazz, Analyzer analyzer, IDirectoryProvider
IFieldBridge fieldBridge = BridgeFactory.GuessType(member);
if (fieldBridge is ITwoWayFieldBridge)
{
- idBridge = (ITwoWayFieldBridge)fieldBridge;
+ idBridge = (ITwoWayFieldBridge) fieldBridge;
}
else
{
@@ -179,7 +147,6 @@ private static Field.Index GetIndex(Index index)
}
}
-#if NET_2_0
private static float? GetBoost(MemberInfo element)
{
if (element == null) return null;
@@ -188,34 +155,21 @@ private static Field.Index GetIndex(Index index)
return null;
return boost.Value;
}
-#else
- private static float GetBoost(MemberInfo element)
- {
- if (element == null) return 0;
- BoostAttribute boost = AttributeUtil.GetBoost(element);
- if (boost == null)
- return 0;
- return boost.Value;
- }
-#endif
private static object GetMemberValue(Object instnace, MemberInfo getter)
{
PropertyInfo info = getter as PropertyInfo;
if (info != null)
return info.GetValue(instnace, null);
else
- return ((FieldInfo)getter).GetValue(instnace);
+ return ((FieldInfo) getter).GetValue(instnace);
}
/// <summary>
/// This add the new work to the queue, so it can be processed in a batch fashion later
/// </summary>
-#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, IList queue, SearchFactory searchFactory)
-#endif
+ public void AddToWorkQueue(object entity, object id, WorkType workType, List<LuceneWork> queue,
+ SearchFactory searchFactory)
{
System.Type entityClass = NHibernateUtil.GetClass(entity);
foreach (LuceneWork luceneWork in queue)
@@ -277,33 +231,26 @@ 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, IList queue, System.Type valueClass, DocumentBuilder builder, SearchFactory searchFactory)
-#endif
- {
- object id = DocumentBuilder.GetMemberValue(value, builder.idGetter);
- builder.AddToWorkQueue(value, id, WorkType.Update, queue, searchFactory);
- }
+ private void ProcessContainedInValue(object value, List<LuceneWork> queue, System.Type valueClass,
+ DocumentBuilder builder, SearchFactory searchFactory)
+ {
+ object id = GetMemberValue(value, builder.idGetter);
+ builder.AddToWorkQueue(value, id, WorkType.Update, queue, searchFactory);
+ }
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?
+ // TODO: Check if that should be an else?
{
Field classField =
- new Field(CLASS_FIELDNAME, instanceClass.AssemblyQualifiedName, Field.Store.YES, Field.Index.UN_TOKENIZED);
+ new Field(CLASS_FIELDNAME, instanceClass.AssemblyQualifiedName, Field.Store.YES,
+ Field.Index.UN_TOKENIZED);
doc.Add(classField);
idBridge.Set(idKeywordName, id, doc, Field.Store.YES, Field.Index.UN_TOKENIZED, idBoost);
}
@@ -315,7 +262,6 @@ 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];
@@ -360,63 +306,6 @@ 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)
@@ -466,8 +355,7 @@ public static object GetDocumentId(SearchFactory searchFactory, Document documen
return builder.IdBridge.Get(builder.getIdKeywordName(), document);
}
-#if NET_2_0
- public void PostInitialize(ISet<System.Type> indexedClasses)
+ public void PostInitialize(ISet<System.Type> indexedClasses)
{
//this method does not requires synchronization
System.Type plainClass = beanClass;
@@ -486,7 +374,7 @@ public ISet<System.Type> MappedSubclasses
get { return mappedSubclasses; }
}
-
+
private class PropertiesMetadata
{
public float? boost = null;
@@ -508,52 +396,5 @@ private class PropertiesMetadata
public readonly List<PropertiesMetadata> embeddedPropertiesMetadata = new List<PropertiesMetadata>();
public readonly List<MemberInfo> containedInGetters = new List<MemberInfo>();
}
-
-#else
- 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)
- {
- if (plainClass.IsAssignableFrom(currentClass))
- tempMappedSubclasses.Add(currentClass);
- }
- mappedSubclasses = tempMappedSubclasses;
- }
-
- public ISet MappedSubclasses
- {
- get { return mappedSubclasses; }
- }
-
- private class PropertiesMetadata
- {
- public float boost = 0;
- 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
13 src/NHibernate.Search/Engine/ISearchFactoryImplementor.cs
@@ -0,0 +1,13 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace NHibernate.Search.Engine
+{
+ /// <summary>
+ ///
+ /// </summary>
+ public interface ISearchFactoryImplementor : ISearchFactory
+ {
+ }
+}
View
64 src/NHibernate.Search/Engine/SearchFactory.cs
@@ -1,11 +1,6 @@
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.Analysis;
using Lucene.Net.Analysis.Standard;
using NHibernate.Cfg;
@@ -20,10 +15,6 @@
namespace NHibernate.Search
{
-#if NET_2_0
-#else
- [CLSCompliant(false)]
-#endif
public class SearchFactory
{
private static readonly WeakHashtable sessionFactory2SearchFactory = new WeakHashtable();
@@ -32,28 +23,23 @@ public class SearchFactory
/// <summary>
/// Note that we will lock on the values in this dictionary
/// </summary>
-#if NET_2_0
- private readonly Dictionary<IDirectoryProvider, object> lockableDirectoryProviders = new Dictionary<IDirectoryProvider, object>();
- private readonly Dictionary<System.Type, DocumentBuilder> documentBuilders = new Dictionary<System.Type, DocumentBuilder>();
-#else
- private readonly Hashtable lockableDirectoryProviders = new Hashtable();
- private readonly Hashtable documentBuilders = new Hashtable();
-#endif
+ private readonly Dictionary<IDirectoryProvider, object> lockableDirectoryProviders =
+ new Dictionary<IDirectoryProvider, object>();
+
+ private readonly Dictionary<System.Type, DocumentBuilder> documentBuilders =
+ new Dictionary<System.Type, DocumentBuilder>();
+
private readonly IQueueingProcessor queueingProcessor;
private IBackendQueueProcessorFactory backendQueueProcessorFactory;
-#if NET_2_0
public Dictionary<System.Type, DocumentBuilder> DocumentBuilders
-#else
- public Hashtable DocumentBuilders
-#endif
{
get { return documentBuilders; }
}
public static SearchFactory GetSearchFactory(ISession session)
{
- SearchFactory searchFactory = (SearchFactory)sessionFactory2SearchFactory[session.SessionFactory];
+ SearchFactory searchFactory = (SearchFactory) sessionFactory2SearchFactory[session.SessionFactory];
if (searchFactory == null)
{
throw new HibernateException(
@@ -65,7 +51,7 @@ public static SearchFactory GetSearchFactory(ISession session)
public static SearchFactory GetSearchFactory(ISessionFactory sessionFactory)