예제 #1
0
  /** {@inheritDoc} */
  public ResultSet match(String queryNumber, MatchingQueryTerms queryTerms) throws IOException {
    final long starttime = System.currentTimeMillis();
    initialise(queryTerms);

    plm = new PostingListManager(index, super.collectionStatistics, queryTerms);
    if (MATCH_EMPTY_QUERY && plm.size() == 0) {
      // Check whether we need to match an empty query. If so, then return the existing result set.
      resultSet = new CollectionResultSet(collectionStatistics.getNumberOfDocuments());
      resultSet.setExactResultSize(collectionStatistics.getNumberOfDocuments());
      resultSet.setResultSize(collectionStatistics.getNumberOfDocuments());
      return resultSet;
    }
    // DO NOT prepare the posting lists for TAAT retrieval
    plm.prepare(false);

    for (int i = 0; i < plm.size(); i++) {
      assignScores(i, (AccumulatorResultSet) resultSet, plm.getPosting(i));
    }

    resultSet.initialise();
    this.numberOfRetrievedDocuments = resultSet.getExactResultSize();
    finalise(queryTerms);
    if (logger.isDebugEnabled())
      logger.debug(
          "Time to match "
              + numberOfRetrievedDocuments
              + " results: "
              + (System.currentTimeMillis() - starttime)
              + "ms");
    return resultSet;
  }
예제 #2
0
  protected void assignScores(int i, AccumulatorResultSet rs, final IterablePosting postings)
      throws IOException {
    int docid;
    double score;

    short mask = 0;
    if (i < 16) mask = (short) (1 << i);

    while (postings.next() != IterablePosting.EOL) {
      score = plm.score(i);
      docid = postings.getId();
      // logger.info("Docid=" + docid + " score=" + score);
      if ((!rs.scoresMap.contains(docid)) && (score > 0.0d)) numberOfRetrievedDocuments++;
      else if ((rs.scoresMap.contains(docid)) && (score < 0.0d)) numberOfRetrievedDocuments--;

      rs.scoresMap.adjustOrPutValue(docid, score, score);
      rs.occurrencesMap.put(docid, (short) (rs.occurrencesMap.get(docid) | mask));
    }
  }