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

           Branch data     Line data    Source code
       1                 :            : /** @file result.h
       2                 :            :  * @brief A result in an MSet
       3                 :            :  */
       4                 :            : /* Copyright 2017,2019 Olly Betts
       5                 :            :  *
       6                 :            :  * This program is free software; you can redistribute it and/or
       7                 :            :  * modify it under the terms of the GNU General Public License as
       8                 :            :  * published by the Free Software Foundation; either version 2 of the
       9                 :            :  * License, or (at your option) any later version.
      10                 :            :  *
      11                 :            :  * This program is distributed in the hope that it will be useful,
      12                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      13                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      14                 :            :  * GNU General Public License for more details.
      15                 :            :  *
      16                 :            :  * You should have received a copy of the GNU General Public License
      17                 :            :  * along with this program; if not, write to the Free Software
      18                 :            :  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
      19                 :            :  */
      20                 :            : 
      21                 :            : #ifndef XAPIAN_INCLUDED_RESULT_H
      22                 :            : #define XAPIAN_INCLUDED_RESULT_H
      23                 :            : 
      24                 :            : #include "backends/multi.h"
      25                 :            : #include "xapian/types.h"
      26                 :            : 
      27                 :            : #include <string>
      28                 :            : 
      29                 :            : /** A result in an MSet. */
      30                 :  305409078 : class Result {
      31                 :            :     double weight;
      32                 :            : 
      33                 :            :     Xapian::docid did;
      34                 :            : 
      35                 :            :     Xapian::doccount collapse_count = 0;
      36                 :            : 
      37                 :            :     std::string collapse_key;
      38                 :            : 
      39                 :            :     std::string sort_key;
      40                 :            : 
      41                 :            :   public:
      42                 :            :     Result& operator=(const Result&) = delete;
      43                 :            : 
      44                 :            :     Result(const Result&) = delete;
      45                 :            : 
      46                 :            :     /// Move constructor.
      47                 :   80812938 :     Result(Result&&) = default;
      48                 :            : 
      49                 :            :     /// Move assignment.
      50                 :            :     Result& operator=(Result&&) = default;
      51                 :            : 
      52                 :            :     /// Constructor.
      53                 :   34352864 :     Result(double weight_, Xapian::docid did_)
      54         [ +  - ]:   34352864 :         : weight(weight_), did(did_) {}
      55                 :            : 
      56                 :            :     /// Constructor used by MSet::Internal::unserialise().
      57                 :     110262 :     Result(double weight_, Xapian::docid did_,
      58                 :            :            std::string&& collapse_key_,
      59                 :            :            Xapian::doccount collapse_count_,
      60                 :            :            std::string&& sort_key_)
      61                 :            :         : weight(weight_), did(did_),
      62                 :            :           collapse_count(collapse_count_),
      63                 :     110262 :           collapse_key(std::move(collapse_key_)),
      64                 :     110262 :           sort_key(std::move(sort_key_)) {}
      65                 :            : 
      66                 :            :     void swap(Result& o);
      67                 :            : 
      68                 :   87195916 :     Xapian::docid get_docid() const { return did; }
      69                 :            : 
      70                 : 2520242874 :     double get_weight() const { return weight; }
      71                 :            : 
      72                 :     220524 :     Xapian::doccount get_collapse_count() const { return collapse_count; }
      73                 :            : 
      74                 :     579838 :     const std::string& get_collapse_key() const { return collapse_key; }
      75                 :            : 
      76                 :     649052 :     const std::string& get_sort_key() const { return sort_key; }
      77                 :            : 
      78                 :      10361 :     void set_weight(double weight_) { weight = weight_; }
      79                 :            : 
      80                 :      50660 :     void set_collapse_count(Xapian::doccount c) { collapse_count = c; }
      81                 :            : 
      82                 :     122968 :     void set_collapse_key(const std::string& k) { collapse_key = k; }
      83                 :            : 
      84                 :      54838 :     void set_sort_key(const std::string& k) { sort_key = k; }
      85                 :            : 
      86                 :        102 :     void unshard_docid(Xapian::doccount shard, Xapian::doccount n_shards) {
      87                 :        102 :         did = unshard(did, shard, n_shards);
      88                 :        102 :     }
      89                 :            : 
      90                 :            :     std::string get_description() const;
      91                 :            : };
      92                 :            : 
      93                 :            : #endif // XAPIAN_INCLUDED_RESULT_H

Generated by: LCOV version 1.11