LCOV - code coverage report
Current view: top level - backends/honey - honey_termlisttable.h (source / functions) Hit Total Coverage
Test: Test Coverage for xapian-core 4ba52dacf4fb Lines: 9 9 100.0 %
Date: 2019-05-20 14:58:19 Functions: 4 4 100.0 %
Branches: 2 4 50.0 %

           Branch data     Line data    Source code
       1                 :            : /** @file honey_termlisttable.h
       2                 :            :  * @brief Subclass of HoneyTable which holds termlists.
       3                 :            :  */
       4                 :            : /* Copyright (C) 2007,2008,2009,2010,2013,2014,2015,2016 Olly Betts
       5                 :            :  *
       6                 :            :  * This program is free software; you can redistribute it and/or modify
       7                 :            :  * it under the terms of the GNU General Public License as published by
       8                 :            :  * the Free Software Foundation; either version 2 of the License, or
       9                 :            :  * (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_HONEY_TERMLISTTABLE_H
      22                 :            : #define XAPIAN_INCLUDED_HONEY_TERMLISTTABLE_H
      23                 :            : 
      24                 :            : #include <xapian/constants.h>
      25                 :            : #include <xapian/types.h>
      26                 :            : 
      27                 :            : #include "honey_table.h"
      28                 :            : #include "pack.h"
      29                 :            : 
      30                 :            : #include <string>
      31                 :            : 
      32                 :            : namespace Xapian {
      33                 :            : class Document;
      34                 :            : }
      35                 :            : 
      36                 :        610 : class HoneyTermListTable : public HoneyTable {
      37                 :            :   public:
      38                 :        821 :     static std::string make_key(Xapian::docid did) {
      39                 :        821 :         std::string key;
      40         [ +  - ]:        821 :         pack_uint_preserving_sort(key, did);
      41                 :        821 :         return key;
      42                 :            :     }
      43                 :            : 
      44                 :            :     /** Create a new HoneyTermListTable object.
      45                 :            :      *
      46                 :            :      *  This method does not create or open the table on disk - you
      47                 :            :      *  must call the create() or open() methods respectively!
      48                 :            :      *
      49                 :            :      *  @param dbdir        The directory the honey database is stored in.
      50                 :            :      *  @param readonly     true if we're opening read-only, else false.
      51                 :            :      *  @param lazy_        Don't create a termlist if there isn't one.
      52                 :            :      */
      53                 :        304 :     HoneyTermListTable(const std::string & dbdir, bool readonly, bool lazy_)
      54         [ +  - ]:        304 :         : HoneyTable("termlist", dbdir + "/termlist.", readonly, lazy_) { }
      55                 :            : 
      56                 :          1 :     HoneyTermListTable(int fd, off_t offset_, bool readonly, bool lazy_)
      57                 :          1 :         : HoneyTable("termlist", fd, offset_, readonly, lazy_) { }
      58                 :            : 
      59                 :            :     /** Set the termlist data for document @a did.
      60                 :            :      *
      61                 :            :      *  Any existing data is replaced.
      62                 :            :      *
      63                 :            :      *  @param did      The docid to set the termlist data for.
      64                 :            :      *  @param doc      The Xapian::Document object to read term data from.
      65                 :            :      *  @param doclen   The document length.
      66                 :            :      */
      67                 :            :     void set_termlist(Xapian::docid did, const Xapian::Document & doc,
      68                 :            :                       Xapian::termcount doclen);
      69                 :            : 
      70                 :            :     /** Delete the termlist data for document @a did.
      71                 :            :      *
      72                 :            :      *  @param did  The docid to delete the termlist data for.
      73                 :            :      */
      74                 :            :     void delete_termlist(Xapian::docid did) { del(make_key(did)); }
      75                 :            : };
      76                 :            : 
      77                 :            : #endif // XAPIAN_INCLUDED_HONEY_TERMLISTTABLE_H

Generated by: LCOV version 1.11