Revision: 16331
http://gate.svn.sourceforge.net/gate/?rev=16331&view=rev
Author: valyt
Date: 2012-11-26 17:43:09 +0000 (Mon, 26 Nov 2012)
Log Message:
-----------
(Untested) support for remote TermsQuery posting.
Modified Paths:
--------------
mimir/trunk/mimir-web/grails-app/controllers/gate/mimir/web/SearchController.groovy
mimir/trunk/mimir-web/grails-app/domain/gate/mimir/web/Index.groovy
mimir/trunk/mimir-web/grails-app/domain/gate/mimir/web/LocalIndex.groovy
mimir/trunk/mimir-web/grails-app/domain/gate/mimir/web/RemoteIndex.groovy
Modified:
mimir/trunk/mimir-web/grails-app/controllers/gate/mimir/web/SearchController.groovy
===================================================================
---
mimir/trunk/mimir-web/grails-app/controllers/gate/mimir/web/SearchController.groovy
2012-11-26 17:41:50 UTC (rev 16330)
+++
mimir/trunk/mimir-web/grails-app/controllers/gate/mimir/web/SearchController.groovy
2012-11-26 17:43:09 UTC (rev 16331)
@@ -21,6 +21,8 @@
import gate.mimir.index.mg4j.zipcollection.DocumentData;
import gate.mimir.search.query.Binding;
import gate.mimir.search.query.parser.ParseException;
+import gate.mimir.search.terms.TermsQuery;
+import gate.mimir.search.terms.TermsResultSet;
import java.io.ObjectOutputStream;
import java.util.HashSet;
@@ -550,6 +552,39 @@
}
/**
+ * Binary version of post query
+ */
+ def postTermsQueryBin = {
+ def p = params["request"] ?: params
+ // read the serialized TermsQuery from the remote caller
+ TermsQuery theQuery = null
+ request.inputStream.withStream { stream ->
+ ObjectInputStream ois = new ObjectInputStream(stream)
+ theQuery = ois.readObject()
+ // drain input stream
+ byte[] buf = new byte[1024];
+ while(ois.read(buf) >= 0) {
+ // do nothing
+ }
+ ois.close()
+ }
+
+ try {
+ Index theIndex = request.theIndex
+ TermsResultSet trs = theIndex.postTermsQuery(theQuery)
+
+ new ObjectOutputStream (response.outputStream).withStream {stream ->
+ stream.writeObject(trs)
+ }
+ } catch(Exception e) {
+ log.error("Exception posting query", e)
+ response.sendError(HttpServletResponse.SC_BAD_REQUEST,
+ "Problem posting query: \"" + e.getMessage() + "\"")
+ }
+ }
+
+
+ /**
* Gets the number of result documents found so far. After the search
* completes, the result returned by this call is identical to that of
* {@link #documentsCountBin}. The result is returned as a binary
Modified: mimir/trunk/mimir-web/grails-app/domain/gate/mimir/web/Index.groovy
===================================================================
--- mimir/trunk/mimir-web/grails-app/domain/gate/mimir/web/Index.groovy
2012-11-26 17:41:50 UTC (rev 16330)
+++ mimir/trunk/mimir-web/grails-app/domain/gate/mimir/web/Index.groovy
2012-11-26 17:43:09 UTC (rev 16331)
@@ -14,6 +14,8 @@
import gate.mimir.search.QueryRunner
import gate.mimir.search.query.parser.ParseException
+import gate.mimir.search.terms.TermsQuery;
+import gate.mimir.search.terms.TermsResultSet;
import gate.mimir.index.mg4j.zipcollection.DocumentData
/**
@@ -102,6 +104,10 @@
throw new UnsupportedOperationException()
}
+ TermsResultSet postTermsQuery(TermsQuery query) {
+ throw new UnsupportedOperationException()
+ }
+
/**
* Gets the {@link DocumentData} value for a given document ID.
* @param documentID
Modified:
mimir/trunk/mimir-web/grails-app/domain/gate/mimir/web/LocalIndex.groovy
===================================================================
--- mimir/trunk/mimir-web/grails-app/domain/gate/mimir/web/LocalIndex.groovy
2012-11-26 17:41:50 UTC (rev 16330)
+++ mimir/trunk/mimir-web/grails-app/domain/gate/mimir/web/LocalIndex.groovy
2012-11-26 17:43:09 UTC (rev 16331)
@@ -18,6 +18,8 @@
import gate.mimir.index.mg4j.zipcollection.DocumentData
import gate.mimir.search.QueryRunner
import gate.mimir.search.query.parser.ParseException
+import gate.mimir.search.terms.TermsQuery;
+import gate.mimir.search.terms.TermsResultSet;
import gate.Document
import gate.Gate
import gate.creole.ResourceData
@@ -106,6 +108,15 @@
return localIndexService.getQueryRunner(this, queryString)
}
+
+ /* (non-Javadoc)
+ * @see
gate.mimir.web.Index#postTermsQuery(gate.mimir.search.terms.TermsQuery)
+ */
+ @Override
+ public TermsResultSet postTermsQuery(TermsQuery query) {
+ return query.execute(localIndexService.getQueryEngine(this))
+ }
+
/**
* Gets the {@link DocumentData} value for a given document ID.
* @param documentID
Modified:
mimir/trunk/mimir-web/grails-app/domain/gate/mimir/web/RemoteIndex.groovy
===================================================================
--- mimir/trunk/mimir-web/grails-app/domain/gate/mimir/web/RemoteIndex.groovy
2012-11-26 17:41:50 UTC (rev 16330)
+++ mimir/trunk/mimir-web/grails-app/domain/gate/mimir/web/RemoteIndex.groovy
2012-11-26 17:43:09 UTC (rev 16331)
@@ -18,6 +18,8 @@
import gate.mimir.search.QueryRunner
import gate.mimir.search.RemoteQueryRunner
import gate.mimir.search.query.parser.ParseException
+import gate.mimir.search.terms.TermsQuery;
+import gate.mimir.search.terms.TermsResultSet;
import gate.mimir.tool.WebUtils
import gate.mimir.util.WebUtilsManager
@@ -26,6 +28,8 @@
*/
class RemoteIndex extends Index {
+ protected static final String ACTION_POST_TERMS_QUERY_BIN =
"search/postTermsQueryBin";
+
static constraints = {
remoteUrl(blank:false, nullable:false)
remoteUsername(blank:true, nullable:true)
@@ -81,6 +85,19 @@
webUtilsManager.currentWebUtils(this))
}
+
+ /* (non-Javadoc)
+ * @see
gate.mimir.web.Index#postTermsQuery(gate.mimir.search.terms.TermsQuery)
+ */
+ @Override
+ public TermsResultSet postTermsQuery(TermsQuery query) {
+ String urlStr = (remoteUrl.endsWith("/") ? remoteUrl : (remoteUrl + "/")) +
+ ACTION_POST_TERMS_QUERY_BIN;
+
+ return webUtilsManager.currentWebUtils(this).rpcCall(urlStr, query)
+ }
+
+
/**
* Gets the {@link DocumentData} value for a given document ID.
* @param documentID
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Monitor your physical, virtual and cloud infrastructure from a single
web console. Get in-depth insight into apps, servers, databases, vmware,
SAP, cloud infrastructure, etc. Download 30-day Free Trial.
Pricing starts from $795 for 25 servers or applications!
http://p.sf.net/sfu/zoho_dev2dev_nov
_______________________________________________
GATE-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gate-cvs