LCOV - code coverage report
Current view: top level - backends/remote - net_postlist.h (source / functions) Hit Total Coverage
Test: Test Coverage for xapian-core 954b5873a738 Lines: 3 3 100.0 %
Date: 2019-06-30 05:20:33 Functions: 2 2 100.0 %
Branches: 1 2 50.0 %

           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,2019 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 = false;
      43                 :            :     const char* pos = NULL;
      44                 :            :     const char* pos_end = NULL;
      45                 :            : 
      46                 :            :     Xapian::docid lastdocid = 0;
      47                 :            :     Xapian::termcount lastwdf = 0;
      48                 :            :     Xapian::Internal::intrusive_ptr<PositionList> lastposlist;
      49                 :            : 
      50                 :            :     Xapian::doccount termfreq;
      51                 :            : 
      52                 :            :   public:
      53                 :            :     /// Constructor.
      54                 :        262 :     NetworkPostList(Xapian::Internal::intrusive_ptr<const RemoteDatabase> db_,
      55                 :            :                     const string& term_,
      56                 :            :                     Xapian::doccount termfreq_,
      57                 :            :                     string&& postings_)
      58                 :            :         : LeafPostList(term_),
      59                 :        262 :           db(db_), postings(std::move(postings_)), termfreq(termfreq_) { }
      60                 :            : 
      61                 :            :     /// Get number of documents indexed by this term.
      62                 :            :     Xapian::doccount get_termfreq() const;
      63                 :            : 
      64                 :            :     /// Get the current document ID.
      65                 :            :     Xapian::docid get_docid() const;
      66                 :            : 
      67                 :            :     /// Get the Within Document Frequency of the term in the current document.
      68                 :            :     Xapian::termcount get_wdf() const;
      69                 :            : 
      70                 :            :     /// Read the position list for the term in the current document and
      71                 :            :     /// return a pointer to it (owned by the PostList).
      72                 :            :     PositionList * read_position_list();
      73                 :            : 
      74                 :            :     /// Read the position list for the term in the current document and
      75                 :            :     /// return a pointer to it (not owned by the PostList).
      76                 :            :     PositionList * open_position_list() const;
      77                 :            : 
      78                 :            :     /// Move to the next document in the postlist (the weight parameter is
      79                 :            :     /// ignored).
      80                 :            :     PostList * next(double);
      81                 :            : 
      82                 :            :     /// Skip forward to the next document with document ID >= the supplied
      83                 :            :     /// document ID (the weight parameter is ignored).
      84                 :            :     PostList * skip_to(Xapian::docid did, double weight);
      85                 :            : 
      86                 :            :     /// Return true if and only if we've moved off the end of the list.
      87                 :            :     bool at_end() const;
      88                 :            : 
      89                 :            :     /// Get a description of the postlist.
      90                 :            :     string get_description() const;
      91                 :            : };
      92                 :            : 
      93                 :            : #endif /* XAPIAN_INCLUDED_NET_POSTLIST_H */

Generated by: LCOV version 1.11