[Mulgara-svn] r1452 - trunk/src/jar/resolver-lucene/java/org/mulgara/resolver/lucene

ronald at mulgara.org ronald at mulgara.org
Thu Jan 22 11:17:13 UTC 2009


Author: ronald
Date: 2009-01-22 03:17:12 -0800 (Thu, 22 Jan 2009)
New Revision: 1452

Modified:
   trunk/src/jar/resolver-lucene/java/org/mulgara/resolver/lucene/LuceneResolver.java
Log:
Effectively undoing most of r1446 (lazy-evaluation of the result). It turns
out that in some common cases running multiple higher constrained lucene
queries is far slower than running one less constrained one. If we could
figure out the best strategy to use at runtime that would be great, but I
don't see how without some global query planner.

Modified: trunk/src/jar/resolver-lucene/java/org/mulgara/resolver/lucene/LuceneResolver.java
===================================================================
--- trunk/src/jar/resolver-lucene/java/org/mulgara/resolver/lucene/LuceneResolver.java	2009-01-22 11:17:07 UTC (rev 1451)
+++ trunk/src/jar/resolver-lucene/java/org/mulgara/resolver/lucene/LuceneResolver.java	2009-01-22 11:17:12 UTC (rev 1452)
@@ -372,7 +372,19 @@
     // generate the tuples
     try {
       FullTextStringIndex stringIndex = getFullTextStringIndex(((LocalNode)modelElement).getValue());
-      return new FullTextStringIndexTuples(stringIndex, (LuceneConstraint)constraint, resolverSession);
+
+      /* run the query now and materialize the result; it is often much faster to run a large query
+       * and grab all resulting lucene documents than it is to run many smaller queries. Ideally we
+       * would try and figure out which approach is better on a query-by-query basis.
+       */
+      Tuples tmpTuples = new FullTextStringIndexTuples(stringIndex, (LuceneConstraint)constraint, resolverSession);
+      Tuples tuples = TuplesOperations.sort(tmpTuples);
+      tmpTuples.close();
+
+      return new TuplesWrapperResolution(tuples, constraint);
+    } catch (TuplesException te) {
+      throw new QueryException("Failed to sort tuples and close", te);
+
     } catch (IOException ioe) {
       throw new QueryException("Failed to open string index", ioe);
     } catch (FullTextStringIndexException ef) {




More information about the Mulgara-svn mailing list