LCOV - code coverage report
Current view: top level - backends/glass - glass_changes.h (source / functions) Hit Total Coverage
Test: Test Coverage for xapian-core 954b5873a738 Lines: 10 10 100.0 %
Date: 2019-06-30 05:20:33 Functions: 4 4 100.0 %
Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : /** @file glass_changes.h
       2                 :            :  * @brief Glass changesets
       3                 :            :  */
       4                 :            : /* Copyright 2014 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
      19                 :            :  * USA
      20                 :            :  */
      21                 :            : 
      22                 :            : #ifndef XAPIAN_INCLUDED_GLASS_CHANGES_H
      23                 :            : #define XAPIAN_INCLUDED_GLASS_CHANGES_H
      24                 :            : 
      25                 :            : #include "glass_defs.h"
      26                 :            : #include <string>
      27                 :            : 
      28                 :            : class GlassChanges {
      29                 :            :     /// File descriptor to write changeset to (or -1 for none).
      30                 :            :     int changes_fd;
      31                 :            : 
      32                 :            :     std::string changes_stem;
      33                 :            : 
      34                 :            :     /** The maximum number of changesets to keep.
      35                 :            :      *
      36                 :            :      *  If a slave is more than this number of changesets behind, it will need
      37                 :            :      *  to be sent a full copy of the database (which can be more efficient if
      38                 :            :      *  a lot has changed).
      39                 :            :      */
      40                 :            :     glass_revision_number_t max_changesets;
      41                 :            : 
      42                 :            :     /** The oldest changeset which might exist on disk.
      43                 :            :      *
      44                 :            :      *  Used to optimise removal of old changesets by giving us a point to
      45                 :            :      *  start looking for ones to delete.
      46                 :            :      */
      47                 :            :     glass_revision_number_t oldest_changeset;
      48                 :            : 
      49                 :            :   public:
      50                 :       4128 :     explicit GlassChanges(const std::string & db_dir)
      51                 :            :         : changes_fd(-1),
      52                 :            :           changes_stem(db_dir + "/changes"),
      53                 :       4128 :           oldest_changeset(0) { }
      54                 :            : 
      55                 :            :     ~GlassChanges();
      56                 :            : 
      57                 :            :     GlassChanges * start(glass_revision_number_t old_rev,
      58                 :            :                          glass_revision_number_t rev,
      59                 :            :                          int flags);
      60                 :            : 
      61                 :            :     void write_block(const char * p, size_t len);
      62                 :            : 
      63                 :        128 :     void write_block(const std::string & s) {
      64                 :        128 :         write_block(s.data(), s.size());
      65                 :        128 :     }
      66                 :            : 
      67                 :        555 :     void set_oldest_changeset(glass_revision_number_t rev) {
      68                 :        555 :         oldest_changeset = rev;
      69                 :        555 :     }
      70                 :            : 
      71                 :       9050 :     glass_revision_number_t get_oldest_changeset() const {
      72                 :       9050 :         return oldest_changeset;
      73                 :            :     }
      74                 :            : 
      75                 :            :     void commit(glass_revision_number_t new_rev, int flags);
      76                 :            : 
      77                 :            :     static void check(const std::string & changes_file);
      78                 :            : };
      79                 :            : 
      80                 :            : #endif // XAPIAN_INCLUDED_GLASS_CHANGES_H

Generated by: LCOV version 1.11