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

           Branch data     Line data    Source code
       1                 :            : /** @file inmemory_positionlist.h
       2                 :            :  * @brief PositionList from an InMemory DB or a Document object
       3                 :            :  */
       4                 :            : /* Copyright 2017 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_INMEMORY_POSITIONLIST_H
      22                 :            : #define XAPIAN_INCLUDED_INMEMORY_POSITIONLIST_H
      23                 :            : 
      24                 :            : #include "api/smallvector.h"
      25                 :            : #include "backends/positionlist.h"
      26                 :            : 
      27                 :            : /// PositionList from an InMemory DB or a Document object.
      28         [ -  + ]:    6362134 : class InMemoryPositionList : public PositionList {
      29                 :            :     /// Sorted list of term positions.
      30                 :            :     Xapian::VecCOW<Xapian::termpos> positions;
      31                 :            : 
      32                 :            :     /** Current index into @a positions.
      33                 :            :      *
      34                 :            :      *  Or size_t(-1) if we've not yet started.
      35                 :            :      */
      36                 :            :     size_t index = size_t(-1);
      37                 :            : 
      38                 :            :     /// Don't allow assignment.
      39                 :            :     void operator=(const InMemoryPositionList&) = delete;
      40                 :            : 
      41                 :            :     /// Don't allow copying.
      42                 :            :     InMemoryPositionList(const InMemoryPositionList&) = delete;
      43                 :            : 
      44                 :            :   public:
      45                 :            :     /// Construct with an empty position list.
      46                 :     102836 :     InMemoryPositionList() {}
      47                 :            : 
      48                 :            :     /// Move construct with positional data.
      49                 :            :     explicit
      50                 :        667 :     InMemoryPositionList(Xapian::VecCOW<Xapian::termpos>&& positions_)
      51                 :        667 :         : positions(std::move(positions_)) {}
      52                 :            : 
      53                 :            :     /// Construct with copied positional data.
      54                 :            :     explicit
      55                 :    1564155 :     InMemoryPositionList(const Xapian::VecCOW<Xapian::termpos>& positions_)
      56 [ +  - ][ +  - ]:    1564155 :         : positions(positions_.copy()) {}
      57                 :            : 
      58                 :            :     /// Move assign positional data.
      59                 :        669 :     void assign(Xapian::VecCOW<Xapian::termpos>&& positions_) {
      60                 :        669 :         positions = std::move(positions_);
      61                 :        669 :         index = size_t(-1);
      62                 :        669 :     }
      63                 :            : 
      64                 :            :     /// Assign copied positional data.
      65                 :            :     void assign(const Xapian::VecCOW<Xapian::termpos>& positions_) {
      66                 :            :         positions = positions_.copy();
      67                 :            :         index = size_t(-1);
      68                 :            :     }
      69                 :            : 
      70                 :            :     Xapian::termcount get_approx_size() const;
      71                 :            : 
      72                 :            :     Xapian::termpos back() const;
      73                 :            : 
      74                 :            :     Xapian::termpos get_position() const;
      75                 :            : 
      76                 :            :     bool next();
      77                 :            : 
      78                 :            :     bool skip_to(Xapian::termpos termpos);
      79                 :            : };
      80                 :            : 
      81                 :            : #endif // XAPIAN_INCLUDED_INMEMORY_POSITIONLIST_H

Generated by: LCOV version 1.11