beagle r4400 - branches/beagle-rdf/beagled



Author: dbera
Date: Sat Jan 19 00:30:46 2008
New Revision: 4400
URL: http://svn.gnome.org/viewvc/beagle?rev=4400&view=rev

Log:
TermEnum.Next() should be called before TermEnum.Term(). Handle crash in DumpIndex if index is empty. Patches from Enrico Minack.


Modified:
   branches/beagle-rdf/beagled/DumpIndex.cs
   branches/beagle-rdf/beagled/LuceneQueryingDriver.cs

Modified: branches/beagle-rdf/beagled/DumpIndex.cs
==============================================================================
--- branches/beagle-rdf/beagled/DumpIndex.cs	(original)
+++ branches/beagle-rdf/beagled/DumpIndex.cs	Sat Jan 19 00:30:46 2008
@@ -225,8 +225,18 @@
 	// Dump the fields: we do this via direct Lucene access.
 	static void DumpOneIndex_Fields (string index_name)
 	{
+		Console.WriteLine ("Index: {0}", index_name);
+
 		LuceneQueryingDriver driver;
-		driver = new LuceneQueryingDriver (index_name, -1, true);
+		try
+		{
+			driver = new LuceneQueryingDriver (index_name, -1, true);
+		}
+		catch (InvalidOperationException e)
+		{
+			Console.Error.WriteLine("There is no Lucene index in the index folder '{0}':\n{1}", index_name, e.StackTrace);
+			return;
+		}
 		
 		IndexReader reader;
 		reader = IndexReader.Open (driver.PrimaryStore);
@@ -315,6 +325,7 @@
   --uris                   Dump all Uris (default)
   --properties             Dump all properties
   --term-frequencies       Dump term frequencies
+  --fields                 Dump all fields
 
   --show-counts            Show index count totals (default)
   --hide-counts            Hide index count totals

Modified: branches/beagle-rdf/beagled/LuceneQueryingDriver.cs
==============================================================================
--- branches/beagle-rdf/beagled/LuceneQueryingDriver.cs	(original)
+++ branches/beagle-rdf/beagled/LuceneQueryingDriver.cs	Sat Jan 19 00:30:46 2008
@@ -264,7 +264,7 @@
 			Term term;
 			bool field_present = false;
 
-			do {
+			while (enumerator.Next ()) {
 				// Find all terms with given field
 				term = enumerator.Term ();
 			
@@ -278,8 +278,7 @@
 				// Find all docs with that term
 				while (docs.Next ())
 					all_docs [docs.Doc ()] = true;
-
-			} while (enumerator.Next ());
+			}
 
 			enumerator.Close ();
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]