Revision: 16358 http://gate.svn.sourceforge.net/gate/?rev=16358&view=rev Author: valyt Date: 2012-11-29 16:20:38 +0000 (Thu, 29 Nov 2012) Log Message: ----------- Support for using a QueryNode value instead of a query string.
Modified Paths: -------------- mimir/trunk/mimir-client/src/gate/mimir/search/RemoteQueryRunner.java Modified: mimir/trunk/mimir-client/src/gate/mimir/search/RemoteQueryRunner.java =================================================================== --- mimir/trunk/mimir-client/src/gate/mimir/search/RemoteQueryRunner.java 2012-11-29 15:03:33 UTC (rev 16357) +++ mimir/trunk/mimir-client/src/gate/mimir/search/RemoteQueryRunner.java 2012-11-29 16:20:38 UTC (rev 16358) @@ -17,6 +17,7 @@ import gate.mimir.index.IndexException; import gate.mimir.index.mg4j.zipcollection.DocumentData; import gate.mimir.search.query.Binding; +import gate.mimir.search.query.QueryNode; import gate.mimir.tool.WebUtils; import it.unimi.dsi.fastutil.doubles.DoubleArrayList; import it.unimi.dsi.fastutil.doubles.DoubleBigArrayBigList; @@ -196,17 +197,37 @@ this.closed = false; // submit the remote query try { - this.queryId = (String) webUtils.getObject( + init((String) webUtils.getObject( getActionBaseUrl(ACTION_POST_QUERY_BIN), "queryString", - URLEncoder.encode(queryString, "UTF-8")); + URLEncoder.encode(queryString, "UTF-8")), threadSource); } catch(ClassNotFoundException e) { //we were expecting a String but got some object of unknown class throw (IOException) new IOException( "Was expecting a String query ID value, but got " + "an unknown object type!").initCause(e); } - + } + + public RemoteQueryRunner(String remoteUrl, QueryNode query, + Executor threadSource, WebUtils webUtils) throws IOException { + this.remoteUrl = remoteUrl.endsWith("/") ? remoteUrl : (remoteUrl + "/"); + this.webUtils = webUtils; + this.closed = false; + // submit the remote query + try { + init((String) webUtils.rpcCall( + getActionBaseUrl(ACTION_POST_QUERY_BIN), + query), threadSource); + } catch(ClassNotFoundException e) { + //we were expecting a String but got some object of unknown class + throw (IOException) new IOException( + "Was expecting a String query ID value, but got " + + "an unknown object type!").initCause(e); + } + } + + protected void init(String queryId, Executor threadSource) { // init the caches this.documentIds = new LongBigArrayBigList(); this.documentScores = new DoubleBigArrayBigList(); @@ -221,7 +242,7 @@ } else { new Thread(docDataUpdater, DocumentDataUpdater.class.getCanonicalName()).start(); - } + } } protected String getActionBaseUrl(String action) throws IOException{ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ Keep yourself connected to Go Parallel: VERIFY Test and improve your parallel project with help from experts and peers. http://goparallel.sourceforge.net _______________________________________________ GATE-cvs mailing list GATE-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gate-cvs