29 #ifdef XAPIAN_HAS_GLASS_BACKEND 34 #ifdef XAPIAN_HAS_CHERT_BACKEND 52 #ifdef XAPIAN_HAS_GLASS_BACKEND 69 auto msg =
"Couldn't find Xapian database or table to check";
77 #if defined XAPIAN_HAS_CHERT_BACKEND || defined XAPIAN_HAS_GLASS_BACKEND 85 *out <<
"Cross-checking document lengths between the postlist and " 86 "termlist tables would use more than 1GB of memory, so " 87 "skipping that check" << endl;
91 doclens.reserve(last_docid + 1);
92 }
catch (
const std::bad_alloc &) {
95 *out <<
"Couldn't allocate enough memory for cross-checking document " 96 "lengths between the postlist and termlist tables, so " 97 "skipping that check" << endl;
98 }
catch (
const std::length_error &) {
101 *out <<
"Couldn't allocate enough elements for cross-checking document " 102 "lengths between the postlist and termlist tables, so " 103 "skipping that check" << endl;
112 if (stat((path +
"/iamchert").c_str(), &sb) == 0) {
113 #ifndef XAPIAN_HAS_CHERT_BACKEND 119 vector<Xapian::termcount> doclens;
139 *out <<
"Database couldn't be opened for reading: " 141 <<
"\nContinuing check anyway" << endl;
145 size_t pre_table_check_errors = errors;
153 static const struct {
char name[9]; } tables[] = {
161 for (
auto t : tables) {
162 const char *
name = t.name;
164 *out << name <<
":\n";
165 if (strcmp(name,
"record") != 0 && strcmp(name,
"postlist") != 0) {
173 if (strcmp(name,
"termlist") == 0) {
174 *out <<
"Not present.\n";
176 *out <<
"Lazily created, and not yet used.\n";
184 doccount, db_last_docid, out);
200 if (stat((path +
"/iamglass").c_str(), &sb) == 0) {
201 #ifndef XAPIAN_HAS_GLASS_BACKEND 207 vector<Xapian::termcount> doclens;
216 *out <<
"Database couldn't be opened for reading: " 218 <<
"\nContinuing check anyway" << endl;
225 string changes_file = path;
226 changes_file +=
"/changes";
227 changes_file +=
str(r);
234 if (db_last_docid < doccount) {
236 *out <<
"last_docid = " << db_last_docid <<
" < doccount = " 251 if (stat((path +
"/iamflint").c_str(), &sb) == 0) {
256 if (stat((path +
"/iambrass").c_str(), &sb) == 0) {
261 if (stat((path +
"/record_DB").c_str(), &sb) == 0) {
267 "Directory does not contain a Xapian database");
280 size_t p = filename.find_last_of(
DIR_SEPS);
286 string dir(filename, 0, p);
289 while (p != filename.size()) {
290 char ch = filename[p++];
291 if (ch ==
'.')
break;
295 #if defined XAPIAN_HAS_CHERT_BACKEND || defined XAPIAN_HAS_GLASS_BACKEND 296 vector<Xapian::termcount> doclens;
304 #ifndef XAPIAN_HAS_GLASS_BACKEND 305 auto msg =
"Glass database support isn't enabled";
326 if (stat((dir +
"/iamflint").c_str(), &sb) == 0) {
330 if (stat((dir +
"/iambrass").c_str(), &sb) == 0) {
334 #ifndef XAPIAN_HAS_CHERT_BACKEND 360 #ifdef XAPIAN_HAS_GLASS_BACKEND 367 if (db_last_docid < doccount) {
369 *out <<
"last_docid = " << db_last_docid <<
" < doccount = " 373 vector<Xapian::termcount> doclens;
379 version_file,
opts, doclens,
403 [&errors, opts, out](
const string& path) {
404 errors += Database::check(path, opts, out);
406 [&errors,
opts, out](
const string& path) {
408 errors += Database::check(path, opts, out);
410 [&errors,
opts, out](
const string& path) {
412 errors += Database::check(path, opts, out);
414 [](
const string&,
const string&) {
415 auto msg =
"Remote database checking not implemented";
418 [](
const string&, unsigned) {
419 auto msg =
"Remote database checking not implemented";
423 auto msg =
"InMemory database checking not implemented";
430 Database::check_(
const string * path_ptr,
int fd,
int opts, std::ostream *out)
438 if (path_ptr == NULL) {
442 const string & path = *path_ptr;
445 if (stat(path.c_str(), &sb) == 0) {
476 string filename = path;
478 filename.resize(filename.size() - 1);
482 if (stat((filename +
".DB").c_str(), &sb) == 0) {
Xapian::docid get_lastdocid() const
Virtual methods of Database::Internal.
The Xapian namespace contains public interfaces for the Xapian library.
bool endswith(const std::string &s, char sfx)
static size_t check_stub(const string &stub_path, int opts, std::ostream *out)
void read_and_check()
Read the version file and check it's a version we understand.
XAPIAN_REVISION_TYPE rev
Revision number of a database.
This class is used to access a database, or a group of databases.
DatabaseOpeningError indicates failure to open a database.
uint4 glass_revision_number_t
The revision number of a glass database.
Xapian::doccount get_doccount() const
Virtual methods of Database::Internal.
Constants in the Xapian namespace.
The GlassVersion class manages the revision files.
Helper functions for database handling.
chert_revision_number_t get_revision_number() const
Get an object holding the revision number which the tables are opened at.
static void reserve_doclens(vector< Xapian::termcount > &doclens, Xapian::docid last_docid, ostream *out)
static void check(const std::string &changes_file)
static size_t check_db_fd(int fd, int opts, std::ostream *out, int backend)
Check a single file DB from an fd.
Utility functions for testing files.
Types used by chert backend and the Btree manager.
size_t check_glass_table(const char *tablename, const string &db_dir, int fd, off_t offset_, const GlassVersion &version_file, int opts, vector< Xapian::termcount > &doclens, ostream *out)
unsigned int chert_revision_number_t
A type used to store a revision number for a table.
#define GLASS_TABLE_EXTENSION
Glass table extension.
Xapian::docid get_last_docid() const
int test_if_single_file_db(const struct stat &sb, const string &path, int *fd_ptr)
Probe if a path is a single-file database.
Hierarchy of classes which Xapian can throw as exceptions.
The ChertVersion class manages the "iamchert" file.
unsigned XAPIAN_TERMCOUNT_BASE_TYPE termcount
A counts of terms.
Indicates an attempt to use a feature which is unavailable.
API for working with Xapian databases.
string str(int value)
Convert int to std::string.
#define CHERT_MAX_DOCID
The largest docid value supported by chert.
void read_stub_file(const std::string &file, A1 action_auto, A2 action_chert, A3 action_glass, A4 action_remote_prog, A5 action_remote_tcp, A6 action_inmemory)
Open, read and process a stub database file.
const int DBCHECK_FIX
Fix problems.
void read()
Read the version file and check it's a version we understand.
C++ class definition for chert database.
std::string get_description() const
Return a string describing this object.
void create()
Create the version file.
static size_t check_db_table(const string &filename, int opts, std::ostream *out, int backend)
Check a database table.
size_t check_chert_table(const char *tablename, const string &dir, chert_revision_number_t *rev_ptr, int opts, vector< Xapian::termcount > &doclens, Xapian::doccount doccount, Xapian::docid db_last_docid, ostream *out)
static size_t check_db_dir(const string &path, int opts, std::ostream *out)
unsigned XAPIAN_DOCID_BASE_TYPE doccount
A count of documents.
static const struct @3 glass_tables[]
A backend designed for efficient indexing and retrieval, using compressed posting lists and a btree s...
All exceptions thrown by Xapian are subclasses of Xapian::Error.
Various handy helpers which std::string really should provide.
Various assertion macros.
static void throw_no_db_to_check()
unsigned XAPIAN_DOCID_BASE_TYPE docid
A unique identifier for a document.
DatabaseError indicates some sort of database related error.
glass_revision_number_t get_revision() const
bool file_exists(const char *path)
Test if a file exists.
UnimplementedError indicates an attempt to use an unimplemented feature.
Xapian::doccount get_doccount() const