xapian-core  1.4.25
glass_changes.h
Go to the documentation of this file.
1 
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 {
31 
32  std::string changes_stem;
33 
41 
48 
49  public:
50  explicit GlassChanges(const std::string & db_dir)
51  : changes_fd(-1),
52  changes_stem(db_dir + "/changes"),
53  oldest_changeset(0) { }
54 
55  ~GlassChanges();
56 
59  int flags);
60 
61  void write_block(const char * p, size_t len);
62 
63  void write_block(const std::string & s) {
64  write_block(s.data(), s.size());
65  }
66 
68  oldest_changeset = rev;
69  }
70 
72  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
XAPIAN_REVISION_TYPE rev
Revision number of a database.
Definition: types.h:133
uint4 glass_revision_number_t
The revision number of a glass database.
Definition: glass_defs.h:68
Definitions, types, etc for use inside glass.
static void check(const std::string &changes_file)
glass_revision_number_t get_oldest_changeset() const
Definition: glass_changes.h:71
void commit(glass_revision_number_t new_rev, int flags)
glass_revision_number_t oldest_changeset
The oldest changeset which might exist on disk.
Definition: glass_changes.h:47
void write_block(const std::string &s)
Definition: glass_changes.h:63
GlassChanges(const std::string &db_dir)
Definition: glass_changes.h:50
void set_oldest_changeset(glass_revision_number_t rev)
Definition: glass_changes.h:67
GlassChanges * start(glass_revision_number_t old_rev, glass_revision_number_t rev, int flags)
glass_revision_number_t max_changesets
The maximum number of changesets to keep.
Definition: glass_changes.h:40
int changes_fd
File descriptor to write changeset to (or -1 for none).
Definition: glass_changes.h:30
void write_block(const char *p, size_t len)
std::string changes_stem
Definition: glass_changes.h:32