Revision: 14567
          http://gate.svn.sourceforge.net/gate/?rev=14567&view=rev
Author:   valyt
Date:     2011-11-17 16:27:55 +0000 (Thu, 17 Nov 2011)
Log Message:
-----------
Started work on the new QueryRunner API.

Modified Paths:
--------------
    mimir/trunk/mimir-core/src/gate/mimir/search/RankingQueryRunnerImpl.java

Modified: 
mimir/trunk/mimir-core/src/gate/mimir/search/RankingQueryRunnerImpl.java
===================================================================
--- mimir/trunk/mimir-core/src/gate/mimir/search/RankingQueryRunnerImpl.java    
2011-11-17 14:15:57 UTC (rev 14566)
+++ mimir/trunk/mimir-core/src/gate/mimir/search/RankingQueryRunnerImpl.java    
2011-11-17 16:27:55 UTC (rev 14567)
@@ -43,7 +43,7 @@
 /**
  * A QueryRunner implementation that does ranking.
  */
-public class RankingQueryRunnerImpl implements QueryRunner, Runnable {
+public class RankingQueryRunnerImpl implements Runnable {
   
   /**
    * When doing ranking, this class is used to delegate the iteration of 
@@ -112,6 +112,7 @@
    * built, so some elements may be null. 
    */
   protected ObjectList<Binding[]> documentHits;
+  
 
   /**
    * The order the documents should be returned in (elements in this list are 
@@ -150,8 +151,7 @@
   /* (non-Javadoc)
    * @see gate.mimir.search.QueryRunner#getMoreHits()
    */
-  @Override
-  public synchronized void getMoreHits() throws IOException {
+  protected synchronized void getMoreHits() throws IOException {
     if(runningThread != null){
       //we're already running -> ignore
       return;
@@ -163,164 +163,46 @@
       new Thread(this, getClass().getName()).start();
     }
   }
-
-  /* (non-Javadoc)
-   * @see gate.mimir.search.QueryRunner#setStageMaxHits(int)
+  
+  
+  /**
+   * Gets the number of documents found to contain hits. If the search has not
+   * yet completed, then -1 is returned.
+   * @return
    */
-  @Override
-  public void setStageMaxHits(int maxHits) throws IOException {
-    // TODO Auto-generated method stub
+  public int getDocumentsCount() {
+    if(queryExecutor == null) return documentIds.size();
+    else return -1;
   }
 
-  /* (non-Javadoc)
-   * @see gate.mimir.search.QueryRunner#setStageTimeout(int)
+  /**
+   * Gets the number of documents found to contain hits so far. After the 
search
+   * completes, the result returned by this call is identical to that of 
+   * {@link #getDocumentsCount()}. 
+   * @return
    */
-  @Override
-  public void setStageTimeout(int timeout) throws IOException {
-    // TODO Auto-generated method stub
+  public int getCurrentDocumentsCount() {
+    return documentIds.size();
   }
-
-  /* (non-Javadoc)
-   * @see gate.mimir.search.QueryRunner#getHitsCount()
+  
+  /**
+   * Gets the ID of a document found to contain hits.
+   * @param index the index of the desired document in the list of documents. 
+   * This should be a value between 0 and {@link #getDocumentsCount()} -1.
+   *  
+   * @return an int value, representing the ID of the requested document.
+   * @throws IndexOutOfBoundsException is the index provided is less than 
zero, 
+   * or greater than {@link #getDocumentsCount()} -1.
    */
-  @Override
-  public int getHitsCount() {
-    // TODO Auto-generated method stub
-    return 0;
-  }
-
-  /* (non-Javadoc)
-   * @see gate.mimir.search.QueryRunner#getDocumentsCount()
-   */
-  @Override
-  public int getDocumentsCount() {
-    // TODO Auto-generated method stub
-    return 0;
-  }
-
-  /* (non-Javadoc)
-   * @see gate.mimir.search.QueryRunner#getDocumentID(int)
-   */
-  @Override
   public int getDocumentID(int index) throws IndexOutOfBoundsException {
-    // TODO Auto-generated method stub
-    return 0;
+    // TODO: check position index has been ranked yet
+    if(documentsOrder != null) {
+      return documentIds.getInt(documentsOrder.getInt(index));
+    } else {
+      return documentIds.getInt(index);  
+    }
   }
-
-  /* (non-Javadoc)
-   * @see gate.mimir.search.QueryRunner#getDocumentHitsCount(int)
-   */
-  @Override
-  public int getDocumentHitsCount(int index) throws IndexOutOfBoundsException {
-    // TODO Auto-generated method stub
-    return 0;
-  }
-
-  /* (non-Javadoc)
-   * @see gate.mimir.search.QueryRunner#getHits(int, int)
-   */
-  @Override
-  public List<Binding> getHits(int startIndex, int hitCount)
-    throws IndexOutOfBoundsException {
-    // TODO Auto-generated method stub
-    return null;
-  }
-
-  /* (non-Javadoc)
-   * @see gate.mimir.search.QueryRunner#getHitsForDocument(int)
-   */
-  @Override
-  public List<Binding> getHitsForDocument(int documentId)
-    throws IndexOutOfBoundsException {
-    // TODO Auto-generated method stub
-    return null;
-  }
-
-  /* (non-Javadoc)
-   * @see gate.mimir.search.QueryRunner#renderDocument(int, 
java.lang.Appendable)
-   */
-  @Override
-  public void renderDocument(int documentId, Appendable out)
-    throws IOException, IndexException {
-    // TODO Auto-generated method stub
-  }
-
-  /* (non-Javadoc)
-   * @see gate.mimir.search.QueryRunner#getDocumentURI(int)
-   */
-  @Override
-  public String getDocumentURI(int documentID) throws IndexException {
-    // TODO Auto-generated method stub
-    return null;
-  }
-
-  /* (non-Javadoc)
-   * @see gate.mimir.search.QueryRunner#getDocumentTitle(int)
-   */
-  @Override
-  public String getDocumentTitle(int documentID) throws IndexException {
-    // TODO Auto-generated method stub
-    return null;
-  }
-
-  /* (non-Javadoc)
-   * @see gate.mimir.search.QueryRunner#getDocumentMetadataField(int, 
java.lang.String)
-   */
-  @Override
-  public Serializable getDocumentMetadataField(int docID, String fieldName)
-    throws IndexException {
-    // TODO Auto-generated method stub
-    return null;
-  }
-
-  /* (non-Javadoc)
-   * @see gate.mimir.search.QueryRunner#getDocumentMetadataFields(int, 
java.util.Set)
-   */
-  @Override
-  public Map<String, Serializable> getDocumentMetadataFields(int docID,
-                                                             Set<String> 
fieldNames)
-    throws IndexException {
-    // TODO Auto-generated method stub
-    return null;
-  }
-
-  /* (non-Javadoc)
-   * @see gate.mimir.search.QueryRunner#getDocumentText(int, int, int)
-   */
-  @Override
-  public String[][] getDocumentText(int documentID, int termPosition, int 
length)
-    throws IndexException {
-    // TODO Auto-generated method stub
-    return null;
-  }
-
-  /* (non-Javadoc)
-   * @see gate.mimir.search.QueryRunner#isActive()
-   */
-  @Override
-  public boolean isActive() {
-    // TODO Auto-generated method stub
-    return false;
-  }
-
-  /* (non-Javadoc)
-   * @see gate.mimir.search.QueryRunner#isComplete()
-   */
-  @Override
-  public boolean isComplete() {
-    // TODO Auto-generated method stub
-    return false;
-  }
-
-  /* (non-Javadoc)
-   * @see gate.mimir.search.QueryRunner#close()
-   */
-  @Override
-  public void close() throws IOException {
-    // TODO Auto-generated method stub
-  }
   
-  
   /**
    * Creates an {@link IntIterator} used for enumerating the documents in the
    * correct order for returning to the user.

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure 
contains a definitive record of customers, application performance, 
security threats, fraudulent activity, and more. Splunk takes this 
data and makes sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-novd2d
_______________________________________________
GATE-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gate-cvs

Reply via email to