lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject svn commit: r888198 - in /incubator/lucene.net/trunk/C#/src: Lucene.Net/Search/FieldDoc.cs Lucene.Net/Search/Searcher.cs Test/TestSupportClass.cs
Date Tue, 08 Dec 2009 00:13:08 GMT
Author: digy
Date: Tue Dec  8 00:13:07 2009
New Revision: 888198

URL: http://svn.apache.org/viewvc?rev=888198&view=rev
Log:
A new test case for LUCENENET-100 + patches

Modified:
    incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/FieldDoc.cs
    incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/Searcher.cs
    incubator/lucene.net/trunk/C#/src/Test/TestSupportClass.cs

Modified: incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/FieldDoc.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Lucene.Net/Search/FieldDoc.cs?rev=888198&r1=888197&r2=888198&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/FieldDoc.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/FieldDoc.cs Tue Dec  8 00:13:07 2009
@@ -56,6 +56,7 @@
 		/// </seealso>
 		/// <seealso cref="Searcher.Search(Query,Filter,int,Sort)">
 		/// </seealso>
+        [NonSerialized]
 		public System.IComparable[] fields;
 		
 		/// <summary>Expert: Creates one of these objects with empty sort information. </summary>

Modified: incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/Searcher.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Lucene.Net/Search/Searcher.cs?rev=888198&r1=888197&r2=888198&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/Searcher.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/Searcher.cs Tue Dec  8 00:13:07 2009
@@ -31,7 +31,7 @@
 	/// Note that you can only access hits from a Searcher as long as it is not yet
 	/// closed, otherwise an IOException will be thrown.
 	/// </summary>
-	public abstract class Searcher : Searchable
+	public abstract class Searcher : System.MarshalByRefObject, Searchable
 	{
 		public Searcher()
 		{

Modified: incubator/lucene.net/trunk/C#/src/Test/TestSupportClass.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Test/TestSupportClass.cs?rev=888198&r1=888197&r2=888198&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Test/TestSupportClass.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Test/TestSupportClass.cs Tue Dec  8 00:13:07 2009
@@ -61,27 +61,27 @@
         }
     }
 
-/// <summary>
-/// </summary>
-	[TestFixture]
-	public class TestSupportClass
-	{
-		/// <summary></summary>
-		/// <throws></throws>
-		[Test]
-		public virtual void TestCRC32()
-		{
-			byte[] b = new byte[256];
-			for (int i = 0; i < b.Length; i++)
-				b[i] = (byte)i;
-
-			SupportClass.Checksum digest = new SupportClass.CRC32();
-			digest.Update(b, 0, b.Length);
-
-			Int64 expected = 688229491;
-			Assert.AreEqual(expected, digest.GetValue());
-		}
-	}
+    /// <summary>
+    /// </summary>
+    [TestFixture]
+    public class TestSupportClass
+    {
+        /// <summary></summary>
+        /// <throws></throws>
+        [Test]
+        public virtual void TestCRC32()
+        {
+            byte[] b = new byte[256];
+            for (int i = 0; i < b.Length; i++)
+                b[i] = (byte)i;
+
+            SupportClass.Checksum digest = new SupportClass.CRC32();
+            digest.Update(b, 0, b.Length);
+
+            Int64 expected = 688229491;
+            Assert.AreEqual(expected, digest.GetValue());
+        }
+    }
 
     [TestFixture]
     public class TestWeakHashTable
@@ -145,7 +145,7 @@
         [Test]
         public void B_TestOutOfMemory()
         {
-            IDictionary wht = TestWeakHashTableBehavior.CreateDictionary(); 
+            IDictionary wht = TestWeakHashTableBehavior.CreateDictionary();
             int OOMECount = 0;
 
             for (int i = 0; i < 1024 * 24 + 32; i++) // total requested Mem. > 24GB
@@ -153,7 +153,7 @@
                 try
                 {
                     wht.Add(new BigObject(i), i);
-                    if(i%1024==0) Console.WriteLine("Requested Mem: " + i.ToString() + "
MB");
+                    if (i % 1024 == 0) Console.WriteLine("Requested Mem: " + i.ToString()
+ " MB");
                     OOMECount = 0;
                 }
                 catch (OutOfMemoryException oom)
@@ -752,7 +752,7 @@
             Lucene.Net.Search.BooleanQuery queryPreSerialized = new Lucene.Net.Search.BooleanQuery();
             queryPreSerialized.Add(new Lucene.Net.Search.TermQuery(new Lucene.Net.Index.Term("country",
"Russia")), Lucene.Net.Search.BooleanClause.Occur.MUST);
             queryPreSerialized.Add(new Lucene.Net.Search.TermQuery(new Lucene.Net.Index.Term("country",
"France")), Lucene.Net.Search.BooleanClause.Occur.MUST);
-            
+
             //now serialize it 
             System.Runtime.Serialization.Formatters.Binary.BinaryFormatter serializer = new
System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
             System.IO.MemoryStream memoryStream = new System.IO.MemoryStream();
@@ -761,7 +761,7 @@
             //now deserialize 
             memoryStream.Seek(0, System.IO.SeekOrigin.Begin);
             Lucene.Net.Search.BooleanQuery queryPostSerialized = (Lucene.Net.Search.BooleanQuery)serializer.Deserialize(memoryStream);
-            
+
             memoryStream.Close();
 
             Assert.AreEqual(queryPreSerialized, queryPostSerialized, "See the issue: LUCENENET-170");
@@ -775,7 +775,7 @@
             Lucene.Net.Store.RAMDirectory ramDIR = new Lucene.Net.Store.RAMDirectory();
 
             //Index 1 Doc
-            Lucene.Net.Index.IndexWriter wr = new Lucene.Net.Index.IndexWriter(ramDIR, new
Lucene.Net.Analysis.WhitespaceAnalyzer(),true);
+            Lucene.Net.Index.IndexWriter wr = new Lucene.Net.Index.IndexWriter(ramDIR, new
Lucene.Net.Analysis.WhitespaceAnalyzer(), true);
             Lucene.Net.Documents.Document doc = new Lucene.Net.Documents.Document();
             doc.Add(new Lucene.Net.Documents.Field("field1", "value1 value11", Lucene.Net.Documents.Field.Store.YES,
Lucene.Net.Documents.Field.Index.TOKENIZED));
             wr.AddDocument(doc);
@@ -800,15 +800,15 @@
             doc.Add(new Lucene.Net.Documents.Field("field1", "value1 value11", Lucene.Net.Documents.Field.Store.YES,
Lucene.Net.Documents.Field.Index.TOKENIZED));
             wr.AddDocument(doc);
             wr.Close();
-            
+
             //Search
             Lucene.Net.Search.IndexSearcher s = new Lucene.Net.Search.IndexSearcher(ramDIR2);
             Lucene.Net.QueryParsers.QueryParser qp = new Lucene.Net.QueryParsers.QueryParser("field1",
new Lucene.Net.Analysis.Standard.StandardAnalyzer());
             Lucene.Net.Search.Query q = qp.Parse("value1");
-            Lucene.Net.Search.TopDocs topDocs = s.Search(q,100);
+            Lucene.Net.Search.TopDocs topDocs = s.Search(q, 100);
             s.Close();
 
-            Assert.AreEqual(topDocs.totalHits, 2,"See the issue: LUCENENET-174");
+            Assert.AreEqual(topDocs.totalHits, 2, "See the issue: LUCENENET-174");
         }
 
 
@@ -853,7 +853,88 @@
                 return char.IsLetterOrDigit(c);
             }
         }
+
+
+        //-------------------------------------------
+        [Test]
+        [Description("LUCENENET-100")]
+        public void Lucene_Net_Search_FieldDoc()
+        {
+            try
+            {
+                LUCENENET_100_CreateIndex();
+
+                System.Runtime.Remoting.Channels.ChannelServices.RegisterChannel(new System.Runtime.Remoting.Channels.Tcp.TcpChannel(38085));
+
+                Lucene.Net.Search.IndexSearcher indexSearcher = new Lucene.Net.Search.IndexSearcher(LUCENENET_100_Dir);
+                System.Runtime.Remoting.RemotingServices.Marshal(indexSearcher, "Searcher");
+
+                LUCENENET_100_ClientSearch();
+            }
+            catch (Exception ex)
+            {
+                Console.WriteLine(ex.Message);
+            }
+
+            //Wait Client to finish
+            while (LUCENENET_100_testFinished == false) System.Threading.Thread.Sleep(10);
+
+            if (LUCENENET_100_Exception != null) throw LUCENENET_100_Exception;
+
+        }
+
+        Lucene.Net.Store.RAMDirectory LUCENENET_100_Dir = new Lucene.Net.Store.RAMDirectory();
+        bool LUCENENET_100_testFinished = false;
+        Exception LUCENENET_100_Exception = null;
+
+
+        void LUCENENET_100_ClientSearch()
+        {
+            try
+            {
+                Lucene.Net.Search.Searchable s = (Lucene.Net.Search.Searchable)Activator.GetObject(typeof(Lucene.Net.Search.Searchable),
@"tcp://localhost:38085/Searcher");
+                Lucene.Net.Search.MultiSearcher searcher = new Lucene.Net.Search.MultiSearcher(new
Lucene.Net.Search.Searchable[] { s });
+
+                Lucene.Net.Search.Query q = new Lucene.Net.Search.TermQuery(new Lucene.Net.Index.Term("field1",
"moon"));
+
+                Lucene.Net.Search.Sort sort = new Lucene.Net.Search.Sort();
+                sort.SetSort(new Lucene.Net.Search.SortField("field2", Lucene.Net.Search.SortField.INT));
+
+                Lucene.Net.Search.Hits h = searcher.Search(q, sort);
+            }
+            catch (Exception ex)
+            {
+                LUCENENET_100_Exception = ex;
+            }
+            finally
+            {
+                LUCENENET_100_testFinished = true;
+            }
+        }
+
+        void LUCENENET_100_CreateIndex()
+        {
+            Lucene.Net.Index.IndexWriter w = new Lucene.Net.Index.IndexWriter(LUCENENET_100_Dir,
new Lucene.Net.Analysis.Standard.StandardAnalyzer(), true);
+
+            Lucene.Net.Documents.Field f1 = new Lucene.Net.Documents.Field("field1", "dark
side of the moon", Lucene.Net.Documents.Field.Store.YES, Lucene.Net.Documents.Field.Index.TOKENIZED);
+            Lucene.Net.Documents.Field f2 = new Lucene.Net.Documents.Field("field2", "123",
Lucene.Net.Documents.Field.Store.YES, Lucene.Net.Documents.Field.Index.UN_TOKENIZED);
+            Lucene.Net.Documents.Document d = new Lucene.Net.Documents.Document();
+            d.Add(f1);
+            d.Add(f2);
+            w.AddDocument(d);
+
+            f1 = new Lucene.Net.Documents.Field("field1", "Fly me to the moon", Lucene.Net.Documents.Field.Store.YES,
Lucene.Net.Documents.Field.Index.TOKENIZED);
+            f2 = new Lucene.Net.Documents.Field("field2", "456", Lucene.Net.Documents.Field.Store.YES,
Lucene.Net.Documents.Field.Index.UN_TOKENIZED);
+            d = new Lucene.Net.Documents.Document();
+            d.Add(f1);
+            d.Add(f2);
+            w.AddDocument(d);
+
+            w.Close();
+        }
+
         //-------------------------------------------
 
+
     }
 }
\ No newline at end of file



Mime
View raw message