LCOV - code coverage report
Current view: top level - backends/chert - chert_termlisttable.h (source / functions) Hit Total Coverage
Test: Test Coverage for xapian-core r Lines: 10 11 90.9 %
Date: 2011-08-21 Functions: 5 5 100.0 %
Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : /** @file chert_termlisttable.h
       2                 :            :  * @brief Subclass of ChertTable which holds termlists.
       3                 :            :  */
       4                 :            : /* Copyright (C) 2007,2008,2009 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_CHERT_TERMLISTTABLE_H
      22                 :            : #define XAPIAN_INCLUDED_CHERT_TERMLISTTABLE_H
      23                 :            : 
      24                 :            : #include <xapian/types.h>
      25                 :            : 
      26                 :            : #include "chert_lazytable.h"
      27                 :            : #include "pack.h"
      28                 :            : 
      29                 :            : #include <string>
      30                 :            : 
      31                 :            : namespace Xapian {
      32                 :            : class Document;
      33                 :            : }
      34                 :            : 
      35                 :       2289 : class ChertTermListTable : public ChertLazyTable {
      36                 :            :   public:
      37                 :     141013 :     static std::string make_key(Xapian::docid did) {
      38                 :     141013 :         std::string key;
      39                 :     141013 :         pack_uint_preserving_sort(key, did);
      40                 :          0 :         return key;
      41                 :            :     }
      42                 :            : 
      43                 :            :     /** Create a new ChertTermListTable object.
      44                 :            :      *
      45                 :            :      *  This method does not create or open the table on disk - you
      46                 :            :      *  must call the create() or open() methods respectively!
      47                 :            :      *
      48                 :            :      *  @param dbdir        The directory the chert database is stored in.
      49                 :            :      *  @param readonly     true if we're opening read-only, else false.
      50                 :            :      */
      51                 :       2289 :     ChertTermListTable(const std::string & dbdir, bool readonly)
      52                 :            :         : ChertLazyTable("termlist", dbdir + "/termlist.", readonly,
      53                 :       2289 :                          Z_DEFAULT_STRATEGY) { }
      54                 :            : 
      55                 :            :     /** Set the termlist data for document @a did.
      56                 :            :      *
      57                 :            :      *  Any existing data is replaced.
      58                 :            :      *
      59                 :            :      *  @param did      The docid to set the termlist data for.
      60                 :            :      *  @param doc      The Xapian::Document object to read term data from.
      61                 :            :      *  @param doclen   The document length.
      62                 :            :      */
      63                 :            :     void set_termlist(Xapian::docid did, const Xapian::Document & doc,
      64                 :            :                       chert_doclen_t doclen);
      65                 :            : 
      66                 :            :     /** Delete the termlist data for document @a did.
      67                 :            :      *
      68                 :            :      *  @param did  The docid to delete the termlist data for.
      69                 :            :      */
      70                 :       9891 :     void delete_termlist(Xapian::docid did) { del(make_key(did)); }
      71                 :            : 
      72                 :            :     /** Non-lazy override of ChertLazyTable::create_and_open().
      73                 :            :      *
      74                 :            :      * Don't create lazily, but if the termlist is deleted, work without it.
      75                 :            :      *
      76                 :            :      *  This method isn't virtual, but we never call it such that it needs to
      77                 :            :      *  be.
      78                 :            :      */
      79                 :        334 :     void create_and_open(unsigned int blocksize) {
      80                 :        334 :         ChertTable::create_and_open(blocksize);
      81                 :        334 :     }
      82                 :            : };
      83                 :            : 
      84                 :            : #endif // XAPIAN_INCLUDED_CHERT_TERMLISTTABLE_H

Generated by: LCOV version 1.8