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

           Branch data     Line data    Source code
       1                 :            : /* chert_alltermslist.h: A termlist containing all terms in a chert database.
       2                 :            :  *
       3                 :            :  * Copyright (C) 2005,2007,2008,2009,2010 Olly Betts
       4                 :            :  *
       5                 :            :  * This program is free software; you can redistribute it and/or
       6                 :            :  * modify it under the terms of the GNU General Public License as
       7                 :            :  * published by the Free Software Foundation; either version 2 of the
       8                 :            :  * License, or (at your option) any later version.
       9                 :            :  *
      10                 :            :  * This program is distributed in the hope that it will be useful,
      11                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      12                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      13                 :            :  * GNU General Public License for more details.
      14                 :            :  *
      15                 :            :  * You should have received a copy of the GNU General Public License
      16                 :            :  * along with this program; if not, write to the Free Software
      17                 :            :  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301
      18                 :            :  * USA
      19                 :            :  */
      20                 :            : 
      21                 :            : #ifndef XAPIAN_INCLUDED_CHERT_ALLTERMSLIST_H
      22                 :            : #define XAPIAN_INCLUDED_CHERT_ALLTERMSLIST_H
      23                 :            : 
      24                 :            : #include "alltermslist.h"
      25                 :            : #include "chert_database.h"
      26                 :            : #include "chert_postlist.h"
      27                 :            : 
      28                 :            : class ChertCursor;
      29                 :            : 
      30                 :            : class ChertAllTermsList : public AllTermsList {
      31                 :            :     /// Copying is not allowed.
      32                 :            :     ChertAllTermsList(const ChertAllTermsList &);
      33                 :            : 
      34                 :            :     /// Assignment is not allowed.
      35                 :            :     void operator=(const ChertAllTermsList &);
      36                 :            : 
      37                 :            :     /// Keep a reference to our database to stop it being deleted.
      38                 :            :     Xapian::Internal::RefCntPtr<const ChertDatabase> database;
      39                 :            : 
      40                 :            :     /** A cursor which runs through the postlist table reading termnames from
      41                 :            :      *  the keys.
      42                 :            :      */
      43                 :            :     ChertCursor * cursor;
      44                 :            : 
      45                 :            :     /// The termname at the current position.
      46                 :            :     std::string current_term;
      47                 :            : 
      48                 :            :     /// The prefix to restrict the terms to.
      49                 :            :     std::string prefix;
      50                 :            : 
      51                 :            :     /** The term frequency of the term at the current position.
      52                 :            :      *
      53                 :            :      *  If this value is zero, then we haven't read the term frequency or
      54                 :            :      *  collection frequency for the current term yet.  We need to call
      55                 :            :      *  read_termfreq_and_collfreq() to read these.
      56                 :            :      */
      57                 :            :     mutable Xapian::doccount termfreq;
      58                 :            : 
      59                 :            :     /// The collection frequency of the term at the current position.
      60                 :            :     mutable Xapian::termcount collfreq;
      61                 :            : 
      62                 :            :     /// Read and cache the term frequency and collection frequency.
      63                 :            :     void read_termfreq_and_collfreq() const;
      64                 :            : 
      65                 :            :   public:
      66                 :        238 :     ChertAllTermsList(Xapian::Internal::RefCntPtr<const ChertDatabase> database_,
      67                 :            :                       const std::string & prefix_)
      68                 :        238 :         : database(database_), cursor(NULL), prefix(prefix_), termfreq(0) { }
      69                 :            : 
      70                 :            :     /// Destructor.
      71                 :            :     ~ChertAllTermsList();
      72                 :            : 
      73                 :            :     /** Returns the current termname.
      74                 :            :      *
      75                 :            :      *  Either next() or skip_to() must have been called before this
      76                 :            :      *  method can be called.
      77                 :            :      */
      78                 :            :     std::string get_termname() const;
      79                 :            : 
      80                 :            :     /** Returns the term frequency of the current term.
      81                 :            :      *
      82                 :            :      *  Either next() or skip_to() must have been called before this
      83                 :            :      *  method can be called.
      84                 :            :      */
      85                 :            :     Xapian::doccount get_termfreq() const;
      86                 :            : 
      87                 :            :     /** Returns the collection frequency of the current term.
      88                 :            :      *
      89                 :            :      *  Either next() or skip_to() must have been called before this
      90                 :            :      *  method can be called.
      91                 :            :      */
      92                 :            :     Xapian::termcount get_collection_freq() const;
      93                 :            : 
      94                 :            :     /// Advance to the next term in the list.
      95                 :            :     TermList * next();
      96                 :            : 
      97                 :            :     /// Advance to the first term which is >= tname.
      98                 :            :     TermList * skip_to(const std::string &tname);
      99                 :            : 
     100                 :            :     /// True if we're off the end of the list
     101                 :            :     bool at_end() const;
     102                 :            : };
     103                 :            : 
     104                 :            : #endif /* XAPIAN_INCLUDED_CHERT_ALLTERMSLIST_H */

Generated by: LCOV version 1.8