LCOV - code coverage report
Current view: top level - backends/remote - net_postlist.h (source / functions) Hit Total Coverage
Test: Test Coverage for xapian-core 7028d852e609 Lines: 8 8 100.0 %
Date: 2019-02-17 14:59:59 Functions: 3 3 100.0 %
Branches: 4 6 66.7 %

           Branch data     Line data    Source code
       1                 :            : /** @file net_postlist.h
       2                 :            :  *  @brief Postlists for remote databases
       3                 :            :  */
       4                 :            : /* Copyright (C) 2007,2009 Lemur Consulting Ltd
       5                 :            :  * Copyright (C) 2007,2008,2009,2011 Olly Betts
       6                 :            :  *
       7                 :            :  * This program is free software; you can redistribute it and/or
       8                 :            :  * modify it under the terms of the GNU General Public License as
       9                 :            :  * published by the Free Software Foundation; either version 2 of the
      10                 :            :  * License, or (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
      20                 :            :  * USA
      21                 :            :  */
      22                 :            : 
      23                 :            : #ifndef XAPIAN_INCLUDED_NET_POSTLIST_H
      24                 :            : #define XAPIAN_INCLUDED_NET_POSTLIST_H
      25                 :            : 
      26                 :            : #include <string>
      27                 :            : 
      28                 :            : #include "api/leafpostlist.h"
      29                 :            : #include "omassert.h"
      30                 :            : #include "remote-database.h"
      31                 :            : 
      32                 :            : using namespace std;
      33                 :            : 
      34                 :            : /** A postlist in a remote database.
      35                 :            :  */
      36         [ -  + ]:       1048 : class NetworkPostList : public LeafPostList {
      37                 :            :     friend class RemoteDatabase;
      38                 :            : 
      39                 :            :     Xapian::Internal::intrusive_ptr<const RemoteDatabase> db;
      40                 :            : 
      41                 :            :     string postings;
      42                 :            :     bool started;
      43                 :            :     const char * pos;
      44                 :            :     const char * pos_end;
      45                 :            : 
      46                 :            :     Xapian::docid lastdocid;
      47                 :            :     Xapian::termcount lastwdf;
      48                 :            :     Xapian::Internal::intrusive_ptr<PositionList> lastposlist;
      49                 :            : 
      50                 :            :     Xapian::doccount termfreq;
      51                 :            : 
      52                 :            :     /// Append a posting to the end of the postlist.
      53                 :       6572 :     void append_posting(const string & serialised) {
      54                 :            :         Assert(pos == NULL);
      55                 :            :         Assert(!started);
      56                 :       6572 :         postings.append(serialised);
      57                 :       6572 :     }
      58                 :            : 
      59                 :            :   public:
      60                 :            :     /// Constructor.
      61                 :        266 :     NetworkPostList(Xapian::Internal::intrusive_ptr<const RemoteDatabase> db_,
      62                 :            :                     const string & term_)
      63                 :            :         : LeafPostList(term_),
      64                 :            :           db(db_), started(false), pos(NULL), pos_end(NULL),
      65         [ +  - ]:        270 :           lastdocid(0), lastwdf(0), termfreq(0)
      66                 :            :     {
      67         [ +  + ]:        266 :         termfreq = db->read_post_list(term, *this);
      68                 :        262 :     }
      69                 :            : 
      70                 :            :     /// Get number of documents indexed by this term.
      71                 :            :     Xapian::doccount get_termfreq() const;
      72                 :            : 
      73                 :            :     /// Get the current document ID.
      74                 :            :     Xapian::docid get_docid() const;
      75                 :            : 
      76                 :            :     /// Get the Within Document Frequency of the term in the current document.
      77                 :            :     Xapian::termcount get_wdf() const;
      78                 :            : 
      79                 :            :     /// Read the position list for the term in the current document and
      80                 :            :     /// return a pointer to it (owned by the PostList).
      81                 :            :     PositionList * read_position_list();
      82                 :            : 
      83                 :            :     /// Read the position list for the term in the current document and
      84                 :            :     /// return a pointer to it (not owned by the PostList).
      85                 :            :     PositionList * open_position_list() const;
      86                 :            : 
      87                 :            :     /// Move to the next document in the postlist (the weight parameter is
      88                 :            :     /// ignored).
      89                 :            :     PostList * next(double);
      90                 :            : 
      91                 :            :     /// Skip forward to the next document with document ID >= the supplied
      92                 :            :     /// document ID (the weight parameter is ignored).
      93                 :            :     PostList * skip_to(Xapian::docid did, double weight);
      94                 :            : 
      95                 :            :     /// Return true if and only if we've moved off the end of the list.
      96                 :            :     bool at_end() const;
      97                 :            : 
      98                 :            :     /// Get a description of the postlist.
      99                 :            :     string get_description() const;
     100                 :            : };
     101                 :            : 
     102                 :            : #endif /* XAPIAN_INCLUDED_NET_POSTLIST_H */

Generated by: LCOV version 1.11