LCOV - code coverage report
Current view: top level - backends/inmemory - inmemory_document.cc (source / functions) Hit Total Coverage
Test: Test Coverage for xapian-core 954b5873a738 Lines: 20 23 87.0 %
Date: 2019-06-30 05:20:33 Functions: 3 3 100.0 %
Branches: 13 22 59.1 %

           Branch data     Line data    Source code
       1                 :            : /** @file inmemory_document.cc
       2                 :            :  * @brief A document read from a InMemoryDatabase.
       3                 :            :  */
       4                 :            : /* Copyright (C) 2008,2009,2016 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                 :            : #include <config.h>
      22                 :            : 
      23                 :            : #include "inmemory_document.h"
      24                 :            : 
      25                 :            : #include "inmemory_database.h"
      26                 :            : 
      27                 :            : #include "debuglog.h"
      28                 :            : 
      29                 :            : string
      30                 :     244675 : InMemoryDocument::fetch_value(Xapian::valueno slot) const
      31                 :            : {
      32                 :            :     LOGCALL(DB, string, "InMemoryDocument::fetch_value", slot);
      33                 :            :     const InMemoryDatabase * db;
      34                 :     244675 :     db = static_cast<const InMemoryDatabase*>(database.get());
      35         [ -  + ]:     244675 :     if (rare(did > db->valuelists.size()))
      36         [ #  # ]:          0 :         RETURN(string());
      37         [ +  - ]:     244675 :     map<Xapian::valueno, string> values_ = db->valuelists[did - 1];
      38                 :     244675 :     map<Xapian::valueno, string>::const_iterator i;
      39         [ +  - ]:     244675 :     i = values_.find(slot);
      40         [ +  + ]:     244675 :     if (i == values_.end())
      41         [ +  - ]:       9282 :         RETURN(string());
      42         [ +  - ]:     244675 :     RETURN(i->second);
      43                 :            : }
      44                 :            : 
      45                 :            : void
      46                 :      12063 : InMemoryDocument::fetch_all_values(map<Xapian::valueno, string> &values_) const
      47                 :            : {
      48                 :            :     LOGCALL_VOID(DB, "InMemoryDocument::fetch_all_values", values_);
      49                 :            :     const InMemoryDatabase * db;
      50                 :      12063 :     db = static_cast<const InMemoryDatabase*>(database.get());
      51         [ -  + ]:      12063 :     if (db->closed) InMemoryDatabase::throw_database_closed();
      52         [ -  + ]:      12063 :     if (rare(did > db->valuelists.size())) {
      53                 :          0 :         values_.clear();
      54                 :          0 :         return;
      55                 :            :     }
      56                 :      12063 :     values_ = db->valuelists[did - 1];
      57                 :            : }
      58                 :            : 
      59                 :            : string
      60                 :       1316 : InMemoryDocument::fetch_data() const
      61                 :            : {
      62                 :            :     LOGCALL(DB, string, "InMemoryDocument::fetch_data", NO_ARGS);
      63                 :            :     const InMemoryDatabase * db;
      64                 :       1316 :     db = static_cast<const InMemoryDatabase*>(database.get());
      65         [ +  + ]:       1316 :     if (db->closed) InMemoryDatabase::throw_database_closed();
      66         [ +  + ]:       1315 :     if (rare(did > db->valuelists.size()))
      67                 :          1 :         RETURN(string());
      68                 :       1314 :     RETURN(db->doclists[did - 1]);
      69                 :            : }

Generated by: LCOV version 1.11