xapian-core  2.0.0
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, see
18  * <https://www.gnu.org/licenses/>.
19  */
20 
21 #ifndef XAPIAN_INCLUDED_GLASS_CHANGES_H
22 #define XAPIAN_INCLUDED_GLASS_CHANGES_H
23 
24 #include "glass_defs.h"
25 #include <string>
26 
27 class GlassChanges {
30 
31  std::string changes_stem;
32 
40 
47 
48  public:
49  explicit GlassChanges(const std::string & db_dir)
50  : changes_fd(-1),
51  changes_stem(db_dir + "/changes"),
52  oldest_changeset(0) { }
53 
54  ~GlassChanges();
55 
58  int flags);
59 
60  void write_block(const char * p, size_t len);
61 
62  void write_block(const std::string & s) {
63  write_block(s.data(), s.size());
64  }
65 
68  }
69 
71  return oldest_changeset;
72  }
73 
74  void commit(glass_revision_number_t new_rev, int flags);
75 
76  static void check(const std::string & changes_file);
77 };
78 
79 #endif // XAPIAN_INCLUDED_GLASS_CHANGES_H
void write_block(const char *p, size_t len)
GlassChanges * start(glass_revision_number_t old_rev, glass_revision_number_t rev, int flags)
glass_revision_number_t oldest_changeset
The oldest changeset which might exist on disk.
Definition: glass_changes.h:46
glass_revision_number_t get_oldest_changeset() const
Definition: glass_changes.h:70
void write_block(const std::string &s)
Definition: glass_changes.h:62
glass_revision_number_t max_changesets
The maximum number of changesets to keep.
Definition: glass_changes.h:39
GlassChanges(const std::string &db_dir)
Definition: glass_changes.h:49
void set_oldest_changeset(glass_revision_number_t rev)
Definition: glass_changes.h:66
static void check(const std::string &changes_file)
int changes_fd
File descriptor to write changeset to (or -1 for none).
Definition: glass_changes.h:29
std::string changes_stem
Definition: glass_changes.h:31
void commit(glass_revision_number_t new_rev, int flags)
PositionList * p
Definitions, types, etc for use inside glass.
uint4 glass_revision_number_t
The revision number of a glass database.
Definition: glass_defs.h:68
XAPIAN_REVISION_TYPE rev
Revision number of a database.
Definition: types.h:108