LCOV - code coverage report
Current view: top level - matcher - remotesubmatch.cc (source / functions) Hit Total Coverage
Test: Test Coverage for xapian-core r Lines: 17 17 100.0 %
Date: 2011-08-21 Functions: 4 5 80.0 %
Branches: 4 4 100.0 %

           Branch data     Line data    Source code
       1                 :            : /** @file remotesubmatch.cc
       2                 :            :  *  @brief SubMatch class for a remote database.
       3                 :            :  */
       4                 :            : /* Copyright (C) 2006,2007,2009,2010 Olly Betts
       5                 :            :  * Copyright (C) 2007,2008 Lemur Consulting Ltd
       6                 :            :  *
       7                 :            :  * This program is free software; you can redistribute it and/or modify
       8                 :            :  * it under the terms of the GNU General Public License as published by
       9                 :            :  * the Free Software Foundation; either version 2 of the License, or
      10                 :            :  * (at your option) any later version.
      11                 :            :  *
      12                 :            :  * This program is distributed in the hope that it will be useful,
      13                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      14                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      15                 :            :  * GNU General Public License for more details.
      16                 :            :  *
      17                 :            :  * You should have received a copy of the GNU General Public License
      18                 :            :  * along with this program; if not, write to the Free Software
      19                 :            :  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
      20                 :            :  */
      21                 :            : 
      22                 :            : #include <config.h>
      23                 :            : 
      24                 :            : #include "remotesubmatch.h"
      25                 :            : 
      26                 :            : #include "debuglog.h"
      27                 :            : #include "msetpostlist.h"
      28                 :            : #include "remote-database.h"
      29                 :            : #include "weightinternal.h"
      30                 :            : 
      31                 :       4404 : RemoteSubMatch::RemoteSubMatch(RemoteDatabase *db_,
      32                 :            :                                bool decreasing_relevance_,
      33                 :            :                                const vector<Xapian::MatchSpy *> & matchspies_)
      34                 :            :         : db(db_),
      35                 :            :           decreasing_relevance(decreasing_relevance_),
      36                 :       4404 :           matchspies(matchspies_)
      37                 :            : {
      38                 :            :     LOGCALL_CTOR(MATCH, "RemoteSubMatch", db_ | decreasing_relevance_ | matchspies_);
      39                 :       4404 : }
      40                 :            : 
      41                 :            : bool
      42                 :       4407 : RemoteSubMatch::prepare_match(bool nowait,
      43                 :            :                               Xapian::Weight::Internal & total_stats)
      44                 :            : {
      45                 :            :     LOGCALL(MATCH, bool, "RemoteSubMatch::prepare_match", nowait | total_stats);
      46                 :       4407 :     Xapian::Weight::Internal remote_stats;
      47         [ +  + ]:       4407 :     if (!db->get_remote_stats(nowait, remote_stats)) RETURN(false);
      48                 :       4404 :     total_stats += remote_stats;
      49                 :       4407 :     RETURN(true);
      50                 :            : }
      51                 :            : 
      52                 :            : void
      53                 :       4404 : RemoteSubMatch::start_match(Xapian::doccount first,
      54                 :            :                             Xapian::doccount maxitems,
      55                 :            :                             Xapian::doccount check_at_least,
      56                 :            :                             const Xapian::Weight::Internal & total_stats)
      57                 :            : {
      58                 :            :     LOGCALL_VOID(MATCH, "RemoteSubMatch::start_match", first | maxitems | check_at_least | total_stats);
      59                 :       4404 :     db->send_global_stats(first, maxitems, check_at_least, total_stats);
      60                 :       4404 : }
      61                 :            : 
      62                 :            : PostList *
      63                 :        156 : RemoteSubMatch::get_postlist_and_term_info(MultiMatch *,
      64                 :            :         map<string, Xapian::MSet::Internal::TermFreqAndWeight> * termfreqandwts,
      65                 :            :         Xapian::termcount * total_subqs_ptr)
      66                 :            : {
      67                 :            :     LOGCALL(MATCH, PostList *, "RemoteSubMatch::get_postlist_and_term_info", Literal("[matcher]") | termfreqandwts | total_subqs_ptr);
      68                 :        156 :     Xapian::MSet mset;
      69                 :        156 :     db->get_mset(mset, matchspies);
      70                 :        156 :     percent_factor = mset.internal->percent_factor;
      71         [ +  + ]:        156 :     if (termfreqandwts) *termfreqandwts = mset.internal->termfreqandwts;
      72                 :            :     // For remote databases we report percent_factor rather than counting the
      73                 :            :     // number of subqueries.
      74                 :            :     (void)total_subqs_ptr;
      75                 :        156 :     return new MSetPostList(mset, decreasing_relevance);
      76                 :            : }

Generated by: LCOV version 1.8