beagle r4491 - branches/beagle-rdf/beagled



Author: dbera
Date: Fri Feb 15 22:40:36 2008
New Revision: 4491
URL: http://svn.gnome.org/viewvc/beagle?rev=4491&view=rev

Log:
* Lucene TermEnum is always set at the first term when constructed, no need to call Next() like some other enumerators.
* Drop QueryPartHook for RDF queries. QueryPartHook is only for stupid creations known as human being.
* Use the right property type when property type is specified in the RDF query.


Modified:
   branches/beagle-rdf/beagled/LuceneCommon.cs
   branches/beagle-rdf/beagled/LuceneQueryable.cs
   branches/beagle-rdf/beagled/LuceneQueryingDriver.cs

Modified: branches/beagle-rdf/beagled/LuceneCommon.cs
==============================================================================
--- branches/beagle-rdf/beagled/LuceneCommon.cs	(original)
+++ branches/beagle-rdf/beagled/LuceneCommon.cs	Fri Feb 15 22:40:36 2008
@@ -1415,7 +1415,9 @@
 			// This gives a chance to modify create new queries based on
 			// backend specific properties
 
-			abstract_part = query_part_hook (abstract_part);
+			if (query_part_hook != null)
+				abstract_part = query_part_hook (abstract_part);
+
 			if (abstract_part == null)
 				return;
 

Modified: branches/beagle-rdf/beagled/LuceneQueryable.cs
==============================================================================
--- branches/beagle-rdf/beagled/LuceneQueryable.cs	(original)
+++ branches/beagle-rdf/beagled/LuceneQueryable.cs	Fri Feb 15 22:40:36 2008
@@ -282,7 +282,7 @@
 
 		public ICollection DoRDFQuery (Query query)
 		{
-			return Driver.DoRDFQuery (query, backend_query_part_hook);
+			return Driver.DoRDFQuery (query);
 		}
 
 		public void DoQuery (Query                query,

Modified: branches/beagle-rdf/beagled/LuceneQueryingDriver.cs
==============================================================================
--- branches/beagle-rdf/beagled/LuceneQueryingDriver.cs	(original)
+++ branches/beagle-rdf/beagled/LuceneQueryingDriver.cs	Fri Feb 15 22:40:36 2008
@@ -322,8 +322,8 @@
 		// HitFilter and UriFilter are ignored for now
 		// They will come into play in the final FetchDocument part
 		// FIXME: Should RDFQuery do any query mapping using backend_query_part_hook ?
-		// I think it should.
-		public ICollection DoRDFQuery (Query _query, QueryPartHook query_part_hook)
+		// I think it should not. QueryPart hooks are for human beings, RDF is for softwares.
+		public ICollection DoRDFQuery (Query _query)
 		{
 			RDFQuery query = (RDFQuery) _query;
 
@@ -350,7 +350,7 @@
 				part.Text = _object;
 				part.SearchFullText = false; // We only search properties in RDF query
 				query.AddPart (part);
-				return DoLowLevelRDFQuery (query, null, _object, query_part_hook);
+				return DoLowLevelRDFQuery (query, null, _object);
 			}
 
 			// Return uris for all documents with this property
@@ -361,12 +361,12 @@
 			// Property query
 			if (subject == String.Empty && predicate != String.Empty && _object != String.Empty) {
 				QueryPart_Property part = new QueryPart_Property ();
-				part.Type = PropertyType.Text; // FIXME
+				part.Type = pred_type;
 				part.Key = predicate;
 				part.Value = _object;
 				query.AddPart (part);
 				string field_name = PropertyToFieldName (pred_type, predicate);
-				return DoLowLevelRDFQuery (query, field_name, _object, query_part_hook);
+				return DoLowLevelRDFQuery (query, field_name, _object);
 			}
 
 			// Return if the URI exists
@@ -375,7 +375,7 @@
 				part.Uri = new Uri (subject); // better be URI!
 				query.AddPart (part);
 				// FIXME: Which properties to return in the hit? All or none ?
-				return DoLowLevelRDFQuery (query, null, null, query_part_hook);
+				return DoLowLevelRDFQuery (query, null, null);
 			}
 
 			// Normal query in the document with this URI
@@ -389,7 +389,7 @@
 				part.SearchFullText = false; // We only search properties in RDF query
 				query.AddPart (part);
 
-				return DoLowLevelRDFQuery (query, null, _object, query_part_hook);
+				return DoLowLevelRDFQuery (query, null, _object);
 			}
 
 			// Return URI if the document with this URI contains this property
@@ -413,13 +413,13 @@
 				query.AddPart (uri_part);
 
 				QueryPart_Property part = new QueryPart_Property ();
-				part.Type = PropertyType.Text; // FIXME
+				part.Type = pred_type;
 				part.Key = predicate;
 				part.Value = _object;
 				query.AddPart (part);
 
 				string field_name = PropertyToFieldName (pred_type, predicate);
-				return DoLowLevelRDFQuery (query, field_name, _object, query_part_hook);
+				return DoLowLevelRDFQuery (query, field_name, _object);
 			}
 
 			throw new Exception ("Never reaches");
@@ -452,11 +452,12 @@
 
 			TermDocs docs = primary_reader.TermDocs ();
 			string field_name = PropertyToFieldName (prop_type, propname);
+			Console.WriteLine (field_name);
 			TermEnum enumerator = primary_reader.Terms (new Term (field_name, String.Empty));
 			Term term;
 			bool field_present = false;
 
-			while (enumerator.Next ()) {
+			do {
 				// Find all terms with given field
 				term = enumerator.Term ();
 			
@@ -470,10 +471,12 @@
 				// Find all docs with that term
 				while (docs.Next ())
 					all_docs [docs.Doc ()] = true;
-			}
+			} while (enumerator.Next ());
+			Console.WriteLine (field_present);
 
 			enumerator.Close ();
 
+			// Maxdoc could be millions!
 			ArrayList hits = new ArrayList (primary_reader.MaxDoc ());
 
 			// If field_present is false, preempt
@@ -538,8 +541,7 @@
 
 		private ICollection DoLowLevelRDFQuery (Query query,
 							string field_name,
-							string field_value,
-							QueryPartHook query_part_hook)
+							string field_value)
 		{
 
 			Stopwatch total, a, b, c, d, e, f;
@@ -570,7 +572,7 @@
 			// Assemble all of the parts into a bunch of Lucene queries
 
 			term_list = AssembleQuery (query,
-				query_part_hook,
+				null,
 				null,
 				out primary_required_part_queries,
 				out secondary_required_part_queries,



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